diff --git a/src/couchdb/index.ts b/src/couchdb/index.ts index e16dae26..0d21cbb3 100644 --- a/src/couchdb/index.ts +++ b/src/couchdb/index.ts @@ -25,7 +25,7 @@ import { COUCHDB_INTERNAL_URL, LOCAL_COUCHDB_AUTH, } from '../buildconfig'; -import {ProjectID} from '../datamodel/core'; +import {ProjectID} from 'faims3-datamodel'; import {ProjectObject} from '../datamodel/database'; import { initialiseDirectoryDB, diff --git a/src/couchdb/notebooks.ts b/src/couchdb/notebooks.ts index 1439c027..433cbdf6 100644 --- a/src/couchdb/notebooks.ts +++ b/src/couchdb/notebooks.ts @@ -26,7 +26,7 @@ import { getProjectsDB, } from '.'; import {CLUSTER_ADMIN_GROUP_NAME} from '../buildconfig'; -import {ProjectID, resolve_project_id} from '../datamodel/core'; +import {ProjectID, resolve_project_id} from 'faims3-datamodel'; import { ProjectMetadata, ProjectObject, diff --git a/src/couchdb/users.ts b/src/couchdb/users.ts index a7a1a4d9..c38ce5e0 100644 --- a/src/couchdb/users.ts +++ b/src/couchdb/users.ts @@ -22,7 +22,7 @@ import {ProjectRole} from 'faims3-datamodel/build/src/types'; import {getUsersDB} from '.'; import {CLUSTER_ADMIN_GROUP_NAME} from '../buildconfig'; -import {NonUniqueProjectID, ProjectID} from '../datamodel/core'; +import {NonUniqueProjectID, ProjectID} from 'faims3-datamodel'; import { AllProjectRoles, ConductorRole, diff --git a/src/datamodel/core.ts b/src/datamodel/core.ts deleted file mode 100644 index 4e510ad6..00000000 --- a/src/datamodel/core.ts +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright 2021, 2022 Macquarie University - * - * Licensed under the Apache License Version 2.0 (the, "License"); - * you may not use, this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing software - * distributed under the License is distributed on an "AS IS" BASIS - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND either express or implied. - * See, the License, for the specific language governing permissions and - * limitations under the License. - * - * Filename: core.ts - * Description: - * TODO - */ - -// There are two internal IDs for projects, the former is unique to the system -// (i.e. includes the listing_id), the latter is unique only to the 'projects' -// database it came from, for a FAIMS listing -// (It is this way because the list of projects is decentralised and so we -// cannot enforce system-wide unique project IDs without a 'namespace' listing id) -export type ProjectID = string; -export type NonUniqueProjectID = string; -/** Listing identifier */ -export type ListingID = string; - -export function resolve_project_id( - listing_id: ListingID, - nonunique_id: NonUniqueProjectID -): ProjectID { - const cleaned_listing_id = listing_id.replace('||', '\\|\\|'); - return cleaned_listing_id + '||' + nonunique_id; -} - -// There are two internal ID for records, the former is unique to a -// project, the latter unique to the system (i.e. includes project_id) -export type RecordID = string; -export type FullyResolvedRecordID = string; -export interface SplitRecordID { - project_id: string; - record_id: RecordID; -} - -export function resolve_record_id( - split_id: SplitRecordID -): FullyResolvedRecordID { - const cleaned_project_id = split_id.project_id.replace('||', '\\|\\|'); - return cleaned_project_id + '||' + split_id.record_id; -} - -export function split_full_record_id( - full_proj_id: FullyResolvedRecordID -): SplitRecordID { - const splitid = full_proj_id.split('||'); - if ( - splitid.length !== 2 || - splitid[0].trim() === '' || - splitid[1].trim() === '' - ) { - throw Error('Not a valid full record id'); - } - const cleaned_project_id = splitid[0].replace('\\|\\|', '||'); - return { - project_id: cleaned_project_id, - record_id: splitid[1], - }; -} - -export type RevisionID = string; -export type AttributeValuePairID = string; diff --git a/src/datamodel/database.ts b/src/datamodel/database.ts index 02a6b915..f6ea86e9 100644 --- a/src/datamodel/database.ts +++ b/src/datamodel/database.ts @@ -25,7 +25,7 @@ import { AttributeValuePairID, ProjectID, ListingID, -} from './core'; +} from 'faims3-datamodel'; export const UI_SPECIFICATION_NAME = 'ui-specification'; export const PROJECT_SPECIFICATION_PREFIX = 'project-specification'; @@ -260,7 +260,3 @@ export interface ProjectUIModel { * discriminated by the prefix of the object's id */ export type ProjectDataObject = AttributeValuePair | Revision | EncodedRecord; - -export function isRecord(doc: ProjectDataObject): doc is EncodedRecord { - return (doc).record_format_version !== undefined; -} diff --git a/src/routes.ts b/src/routes.ts index cc38a5e6..4e652c99 100644 --- a/src/routes.ts +++ b/src/routes.ts @@ -22,7 +22,7 @@ import handlebars from 'handlebars'; import {body, validationResult} from 'express-validator'; import QRCode from 'qrcode'; import {app} from './core'; -import {NonUniqueProjectID} from './datamodel/core'; +import {NonUniqueProjectID} from 'faims3-datamodel'; import {AllProjectRoles} from './datamodel/users'; // BBS 20221101 Adding this as a proxy for the pouch db url diff --git a/src/types.ts b/src/types.ts index 07558d57..1c9f303c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -25,7 +25,7 @@ import type { OtherRoles, UserServiceProfiles, } from './datamodel/users'; -import type {NonUniqueProjectID} from './datamodel/core'; +import type {NonUniqueProjectID} from 'faims3-datamodel'; export type DoneFunction = (err?: Error | null, profile?: any) => void; export type UserProfileCallback = (