Skip to content

Commit

Permalink
Don't duplicate types from faims3-data-model
Browse files Browse the repository at this point in the history
Signed-off-by: Steve Cassidy <[email protected]>
  • Loading branch information
stevecassidy committed Feb 1, 2024
1 parent a156c41 commit 98ab0b3
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 102 deletions.
3 changes: 1 addition & 2 deletions src/couchdb/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ import {
COUCHDB_INTERNAL_URL,
LOCAL_COUCHDB_AUTH,
} from '../buildconfig';
import {ProjectID} from 'faims3-datamodel';
import {ProjectObject} from '../datamodel/database';
import {ProjectID, ProjectObject} from 'faims3-datamodel';
import {
initialiseDirectoryDB,
initialiseProjectsDB,
Expand Down
8 changes: 6 additions & 2 deletions src/couchdb/notebooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,17 +20,17 @@

import PouchDB from 'pouchdb';
import {getProjectsDB} from '.';
import {CLUSTER_ADMIN_GROUP_NAME} from '../buildconfig';
import {CLUSTER_ADMIN_GROUP_NAME, COUCHDB_PUBLIC_URL} from '../buildconfig';
import {
ProjectID,
getProjectDB,
ProjectObject,
resolve_project_id,
notebookRecordIterator,
addDesignDocsForNotebook,
} from 'faims3-datamodel';
import {
ProjectMetadata,
ProjectObject,
ProjectUIFields,
ProjectUIModel,
PROJECT_METADATA_PREFIX,
Expand Down Expand Up @@ -74,6 +74,10 @@ export const getProjects = async (
if (userHasPermission(user, e.id, 'read')) {
delete doc._rev;
const project = doc as unknown as ProjectObject;
// add database connection details
if (project.metadata_db)
project.metadata_db.base_url = COUCHDB_PUBLIC_URL;
if (project.data_db) project.data_db.base_url = COUCHDB_PUBLIC_URL;
projects.push(project);
}
}
Expand Down
99 changes: 1 addition & 98 deletions src/datamodel/database.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,7 @@
* TODO
*/

import {
NonUniqueProjectID,
RecordID,
RevisionID,
AttributeValuePairID,
ProjectID,
ListingID,
} from 'faims3-datamodel';
import {RecordID, RevisionID, AttributeValuePairID} from 'faims3-datamodel';

export const UI_SPECIFICATION_NAME = 'ui-specification';
export const PROJECT_SPECIFICATION_PREFIX = 'project-specification';
Expand All @@ -40,18 +33,6 @@ export interface PouchAttachments {
[key: string]: any; // any for now until we work out what we need
}

export interface ConnectionInfo {
proto: string;
host: string;
port: number;
lan?: boolean;
db_name: string;
auth?: {
username: string;
password: string;
};
}

/**
* User-facing description of an Authentication mechanism.
* The actual auth mechanisms are stored in authconfig.ts in the FAIMS3-conductor
Expand All @@ -63,89 +44,11 @@ export type AuthInfo = {
name: string;
};

export type PossibleConnectionInfo =
| undefined
| {
proto?: string | undefined;
host?: string | undefined;
port?: number | undefined;
lan?: boolean | undefined;
db_name?: string | undefined;
auth?: {
username: string;
password: string;
};
};

export type DirectoryEntry =
| undefined
| {
_id: string;
name: string;
description: string;
people_db?: PossibleConnectionInfo;
projects_db?: PossibleConnectionInfo;
auth_mechanisms: {[key: string]: AuthInfo};
};

export interface ListingsObject {
_id: string;
name: string;
description: string;
projects_db?: PossibleConnectionInfo;
auth_mechanisms: {[key: string]: AuthInfo};
}

export interface NonNullListingsObject extends ListingsObject {
projects_db: ConnectionInfo;
}

export interface ActiveDoc {
_id: ProjectID;
listing_id: string;
project_id: NonUniqueProjectID;
username: string | null;
password: string | null;
friendly_name?: string;
is_sync: boolean;
}

export interface LocalAuthDoc {
_id: string; //Corresponds to a listings ID
dc_token: string;
}

/**
* Describes a project, with connection, name, description, and schema
* Part of the Projects DB
* Do not use with UI code; sync code only
*/
export interface ProjectObject {
_id: string;
name: string;
description?: string;
data_db?: PossibleConnectionInfo;
metadata_db?: PossibleConnectionInfo;
last_updated?: string;
created?: string;
status?: string;
}

export type ProjectsList = {
[key: string]: ProjectObject;
};

export interface ProjectInformation {
project_id: ProjectID;
name: string;
description?: string;
last_updated?: string;
created?: string;
status?: string;
listing_id: ListingID;
non_unique_project_id: NonUniqueProjectID;
}

export interface EncodedProjectMetadata {
_id: string; // optional as we may want to include the raw json in places
_rev?: string; // optional as we may want to include the raw json in places
Expand Down

0 comments on commit 98ab0b3

Please sign in to comment.