@apollo-annotation/common 0.3.12 → 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@apollo-annotation/common",
3
- "version": "0.3.12",
3
+ "version": "1.0.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/GMOD/Apollo3.git",
@@ -13,13 +13,13 @@
13
13
  "build": "tsc --build"
14
14
  },
15
15
  "dependencies": {
16
- "@apollo-annotation/schemas": "^0.3.12",
16
+ "@apollo-annotation/schemas": "^1.0.0",
17
17
  "@jbrowse/core": "^4.1.1",
18
18
  "bson-objectid": "^2.0.4",
19
19
  "tslib": "^2.3.1"
20
20
  },
21
21
  "devDependencies": {
22
- "@apollo-annotation/mst": "^0.3.12",
22
+ "@apollo-annotation/mst": "^1.0.0",
23
23
  "@gmod/gff": "^2.1.0",
24
24
  "@nestjs/common": "^10.1.0",
25
25
  "@nestjs/core": "^10.1.0",
package/src/Change.ts CHANGED
@@ -1,57 +1,31 @@
1
1
  /* eslint-disable @typescript-eslint/no-unnecessary-condition */
2
- /* eslint-disable @typescript-eslint/restrict-template-expressions */
3
- import type {
4
- AnnotationFeature,
5
- AnnotationFeatureSnapshot,
6
- ApolloAssemblyI,
7
- BackendDriverType,
8
- CheckResultI,
9
- CheckResultSnapshot,
10
- } from '@apollo-annotation/mst'
11
- import type { AppRootModel, Region } from '@jbrowse/core/util'
2
+ import type { LoggerService } from '@nestjs/common'
12
3
 
13
4
  import { changeRegistry } from './ChangeTypeRegistry.js'
14
- import {
15
- type BackendDataStore,
16
- Operation,
17
- type OperationOptions,
18
- type SerializedOperation,
19
- } from './Operation.js'
20
5
 
21
- export interface ClientDataStore {
22
- typeName: 'Client'
23
- assemblies: Map<string | number, ApolloAssemblyI>
24
- checkResults: Map<string | number, CheckResultI>
25
- internetAccounts: AppRootModel['internetAccounts']
26
- getInternetAccount(
27
- assemblyName?: string,
28
- internetAccountId?: string,
29
- ): AppRootModel['internetAccounts'][0]
30
- loadFeatures(regions: Region[]): Promise<void>
31
- loadRefSeq(regions: Region[]): void
32
- getFeature(featureId: string): AnnotationFeature | undefined
33
- addFeature(assemblyId: string, feature: AnnotationFeatureSnapshot): void
34
- deleteFeature(featureId: string): void
35
- deleteAssembly(assemblyId: string): void
36
- addCheckResults(checkResults: CheckResultSnapshot[]): void
37
- addAssembly(
38
- assemblyId: string,
39
- backendDriverType?: BackendDriverType,
40
- ): ApolloAssemblyI
41
- clearCheckResults(): void
6
+ export interface SerializedChange {
7
+ typeName: string
42
8
  }
43
9
 
44
- export type SerializedChange = SerializedOperation
45
- export type ChangeOptions = OperationOptions
46
-
47
- export type DataStore = BackendDataStore | ClientDataStore
10
+ export interface ChangeOptions {
11
+ logger: LoggerService
12
+ }
48
13
 
49
14
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
50
15
  export function isChange(thing: any): thing is Change {
51
- return (thing as Change).executeOnClient !== undefined
16
+ return (thing as Change).getInverse !== undefined
52
17
  }
53
18
 
54
- export abstract class Change extends Operation {
19
+ export abstract class Change {
20
+ protected logger: LoggerService
21
+ abstract typeName: string
22
+
23
+ constructor(json: SerializedChange, options?: ChangeOptions) {
24
+ this.logger = options?.logger ?? console
25
+ }
26
+
27
+ abstract toJSON(): SerializedChange
28
+
55
29
  /**
56
30
  * If a non-empty string, a snackbar will display in JBrowse with this message
57
31
  * when a successful response is received from the server.
@@ -61,25 +35,10 @@ export abstract class Change extends Operation {
61
35
  return ''
62
36
  }
63
37
 
64
- static fromJSON(json: SerializedOperation, options?: ChangeOptions): Change {
38
+ static fromJSON(json: SerializedChange, options?: ChangeOptions): Change {
65
39
  const ChangeType = changeRegistry.getChangeType(json.typeName)
66
40
  return new ChangeType(json, options?.logger && { logger: options.logger })
67
41
  }
68
42
 
69
- async execute(backend: DataStore): Promise<unknown> {
70
- const backendType = backend.typeName
71
- if (backendType === 'LocalGFF3' || backendType === 'Server') {
72
- return super.execute(backend)
73
- }
74
- if (backendType === 'Client') {
75
- return this.executeOnClient(backend)
76
- }
77
- throw new Error(
78
- `no change implementation for backend type '${backendType}'`,
79
- )
80
- }
81
-
82
- abstract executeOnClient(backend: ClientDataStore): Promise<void>
83
-
84
43
  abstract getInverse(): Change
85
44
  }
package/src/Validation.ts CHANGED
@@ -4,7 +4,7 @@ import type { ExecutionContext } from '@nestjs/common'
4
4
  import type { Reflector } from '@nestjs/core'
5
5
  import type { ClientSession, Model } from 'mongoose'
6
6
 
7
- import type { Change, ClientDataStore } from './Change.js'
7
+ import type { Change } from './Change.js'
8
8
 
9
9
  export interface Context {
10
10
  context: ExecutionContext
@@ -26,10 +26,7 @@ export abstract class Validation {
26
26
  return { validationName: this.name }
27
27
  }
28
28
 
29
- async frontendPostValidate(
30
- _change: Change,
31
- _dataStore: ClientDataStore,
32
- ): Promise<ValidationResult> {
29
+ async frontendPostValidate(_change: Change): Promise<ValidationResult> {
33
30
  return { validationName: this.name }
34
31
  }
35
32
 
package/src/index.ts CHANGED
@@ -5,6 +5,4 @@ export * from './ChangeTypeRegistry.js'
5
5
  export * from './Check.js'
6
6
  export * from './CheckRegistry.js'
7
7
  export * from './FeatureChange.js'
8
- export * from './Operation.js'
9
- export * from './OperationTypeRegistry.js'
10
8
  export * from './Validation.js'
@@ -1,64 +0,0 @@
1
- import type { FileHandle } from 'node:fs/promises';
2
- import type { AssemblyDocument, CheckDocument, FeatureDocument, FileDocument, JBrowseConfigDocument, RefSeqChunkDocument, RefSeqDocument, UserDocument } from '@apollo-annotation/schemas';
3
- import type { GFF3Feature } from '@gmod/gff';
4
- import type { LoggerService } from '@nestjs/common';
5
- import type { GenericFilehandle } from 'generic-filehandle2';
6
- import type { ClientSession, Model } from 'mongoose';
7
- export interface LocalGFF3DataStore {
8
- typeName: 'LocalGFF3';
9
- gff3Handle: FileHandle;
10
- }
11
- interface CreateFileDto {
12
- readonly _id: string;
13
- readonly basename: string;
14
- readonly checksum: string;
15
- readonly type: 'text/x-gff3' | 'text/x-fasta';
16
- readonly user: string;
17
- }
18
- export interface ServerDataStore {
19
- typeName: 'Server';
20
- featureModel: Model<FeatureDocument>;
21
- assemblyModel: Model<AssemblyDocument>;
22
- refSeqModel: Model<RefSeqDocument>;
23
- refSeqChunkModel: Model<RefSeqChunkDocument>;
24
- checkModel: Model<CheckDocument>;
25
- fileModel: Model<FileDocument>;
26
- userModel: Model<UserDocument>;
27
- jbrowseConfigModel: Model<JBrowseConfigDocument>;
28
- session: ClientSession;
29
- filesService: {
30
- getFileStream(file: FileDocument): ReadableStream<Uint8Array>;
31
- getFileHandle(file: FileDocument): GenericFilehandle;
32
- parseGFF3(stream: ReadableStream<Uint8Array>, parseOptions?: {
33
- bufferSize?: number;
34
- errorCallback?(errorMessage: string): void;
35
- }): ReadableStream<GFF3Feature>;
36
- create(createFileDto: CreateFileDto): void;
37
- remove(id: string): void;
38
- };
39
- pluginsService: {
40
- evaluateExtensionPoint(extensionPointName: string, extendee: unknown, props?: Record<string, unknown>): void;
41
- };
42
- counterService: {
43
- getNextSequenceValue(sequenceName: string): Promise<number>;
44
- };
45
- user: string;
46
- }
47
- export interface SerializedOperation {
48
- typeName: string;
49
- }
50
- export type BackendDataStore = ServerDataStore | LocalGFF3DataStore;
51
- export interface OperationOptions {
52
- logger: LoggerService;
53
- }
54
- export declare abstract class Operation implements SerializedOperation {
55
- protected logger: LoggerService;
56
- abstract typeName: string;
57
- constructor(json: SerializedOperation, options?: OperationOptions);
58
- abstract toJSON(): SerializedOperation;
59
- execute(backend: BackendDataStore): Promise<unknown>;
60
- abstract executeOnServer(backend: ServerDataStore): Promise<unknown>;
61
- abstract executeOnLocalGFF3(backend: LocalGFF3DataStore): Promise<unknown>;
62
- }
63
- export {};
64
- //# sourceMappingURL=Operation.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Operation.d.ts","sourceRoot":"","sources":["../src/Operation.ts"],"names":[],"mappings":"AAGA,OAAO,KA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IAEhC,OAAO,CAAC,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,OAAO,CAAC;IAkB1D,QAAQ,CAAC,eAAe,CAAC,OAAO,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC;IACpE,QAAQ,CAAC,kBAAkB,CAAC,OAAO,EAAE,kBAAkB,GAAG,OAAO,CAAC,OAAO,CAAC;CAC3E"}
package/dist/Operation.js DELETED
@@ -1,18 +0,0 @@
1
- export class Operation {
2
- logger;
3
- constructor(json, options) {
4
- this.logger = options?.logger ?? console;
5
- }
6
- async execute(backend) {
7
- const backendType = backend.typeName;
8
- if (backendType === 'Server') {
9
- const initialResult = this.executeOnServer(backend);
10
- return backend.pluginsService.evaluateExtensionPoint(`${this.typeName}-transformResults`, initialResult, { operation: this, backend });
11
- }
12
- if (backendType === 'LocalGFF3') {
13
- return this.executeOnLocalGFF3(backend);
14
- }
15
- throw new Error(`no operation implementation for backend type '${backendType}'`);
16
- }
17
- }
18
- //# sourceMappingURL=Operation.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"Operation.js","sourceRoot":"","sources":["../src/Operation.ts"],"names":[],"mappings":"AA+EA,MAAM,OAAgB,SAAS;IACnB,MAAM,CAAe;IAG/B,YAAY,IAAyB,EAAE,OAA0B;QAC/D,IAAI,CAAC,MAAM,GAAG,OAAO,EAAE,MAAM,IAAI,OAAO,CAAA;IAC1C,CAAC;IAID,KAAK,CAAC,OAAO,CAAC,OAAyB;QACrC,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAA;QACpC,IAAI,WAAW,KAAK,QAAQ,EAAE,CAAC;YAC7B,MAAM,aAAa,GAAG,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;YACnD,OAAO,OAAO,CAAC,cAAc,CAAC,sBAAsB,CAClD,GAAG,IAAI,CAAC,QAAQ,mBAAmB,EACnC,aAAa,EACb,EAAE,SAAS,EAAE,IAAI,EAAE,OAAO,EAAE,CAC7B,CAAA;QACH,CAAC;QACD,IAAI,WAAW,KAAK,WAAW,EAAE,CAAC;YAChC,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAA;QACzC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,iDAAiD,WAAW,GAAG,CAChE,CAAA;IACH,CAAC;CAIF"}
@@ -1,11 +0,0 @@
1
- import type { Operation } from './Operation.js';
2
- type OperationType = new (...args: any[]) => Operation;
3
- declare class OperationTypeRegistry {
4
- operations: Map<string, OperationType>;
5
- registerOperation(name: string, operationType: OperationType): void;
6
- getOperationType(name: string): OperationType;
7
- }
8
- /** global singleton of all known types of operations */
9
- export declare const operationRegistry: OperationTypeRegistry;
10
- export {};
11
- //# sourceMappingURL=OperationTypeRegistry.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OperationTypeRegistry.d.ts","sourceRoot":"","sources":["../src/OperationTypeRegistry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAA;AAG/C,KAAK,aAAa,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,SAAS,CAAA;AAEtD,cAAM,qBAAqB;IACzB,UAAU,6BAAmC;IAE7C,iBAAiB,CAAC,IAAI,EAAE,MAAM,EAAE,aAAa,EAAE,aAAa,GAAG,IAAI;IAOnE,gBAAgB,CAAC,IAAI,EAAE,MAAM,GAAG,aAAa;CAO9C;AAED,wDAAwD;AACxD,eAAO,MAAM,iBAAiB,uBAA8B,CAAA"}
@@ -1,19 +0,0 @@
1
- class OperationTypeRegistry {
2
- operations = new Map();
3
- registerOperation(name, operationType) {
4
- if (this.operations.has(name)) {
5
- throw new Error(`operation type "${name}" has already been registered`);
6
- }
7
- this.operations.set(name, operationType);
8
- }
9
- getOperationType(name) {
10
- const RegisteredOperationType = this.operations.get(name);
11
- if (!RegisteredOperationType) {
12
- throw new Error(`No operation constructor registered for "${name}"`);
13
- }
14
- return RegisteredOperationType;
15
- }
16
- }
17
- /** global singleton of all known types of operations */
18
- export const operationRegistry = new OperationTypeRegistry();
19
- //# sourceMappingURL=OperationTypeRegistry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"OperationTypeRegistry.js","sourceRoot":"","sources":["../src/OperationTypeRegistry.ts"],"names":[],"mappings":"AAKA,MAAM,qBAAqB;IACzB,UAAU,GAAG,IAAI,GAAG,EAAyB,CAAA;IAE7C,iBAAiB,CAAC,IAAY,EAAE,aAA4B;QAC1D,IAAI,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC9B,MAAM,IAAI,KAAK,CAAC,mBAAmB,IAAI,+BAA+B,CAAC,CAAA;QACzE,CAAC;QACD,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,EAAE,aAAa,CAAC,CAAA;IAC1C,CAAC;IAED,gBAAgB,CAAC,IAAY;QAC3B,MAAM,uBAAuB,GAAG,IAAI,CAAC,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACzD,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC7B,MAAM,IAAI,KAAK,CAAC,4CAA4C,IAAI,GAAG,CAAC,CAAA;QACtE,CAAC;QACD,OAAO,uBAAuB,CAAA;IAChC,CAAC;CACF;AAED,wDAAwD;AACxD,MAAM,CAAC,MAAM,iBAAiB,GAAG,IAAI,qBAAqB,EAAE,CAAA"}
package/src/Operation.ts DELETED
@@ -1,110 +0,0 @@
1
- /* eslint-disable @typescript-eslint/no-confusing-void-expression */
2
- /* eslint-disable @typescript-eslint/no-unnecessary-condition */
3
- /* eslint-disable @typescript-eslint/restrict-template-expressions */
4
- import type { FileHandle } from 'node:fs/promises'
5
-
6
- import type {
7
- AssemblyDocument,
8
- CheckDocument,
9
- FeatureDocument,
10
- FileDocument,
11
- JBrowseConfigDocument,
12
- RefSeqChunkDocument,
13
- RefSeqDocument,
14
- UserDocument,
15
- } from '@apollo-annotation/schemas'
16
- import type { GFF3Feature } from '@gmod/gff'
17
- import type { LoggerService } from '@nestjs/common'
18
- import type { GenericFilehandle } from 'generic-filehandle2'
19
- import type { ClientSession, Model } from 'mongoose'
20
-
21
- export interface LocalGFF3DataStore {
22
- typeName: 'LocalGFF3'
23
- gff3Handle: FileHandle
24
- }
25
-
26
- interface CreateFileDto {
27
- readonly _id: string
28
- readonly basename: string
29
- readonly checksum: string
30
- readonly type: 'text/x-gff3' | 'text/x-fasta'
31
- readonly user: string
32
- }
33
-
34
- export interface ServerDataStore {
35
- typeName: 'Server'
36
- featureModel: Model<FeatureDocument>
37
- assemblyModel: Model<AssemblyDocument>
38
- refSeqModel: Model<RefSeqDocument>
39
- refSeqChunkModel: Model<RefSeqChunkDocument>
40
- checkModel: Model<CheckDocument>
41
- fileModel: Model<FileDocument>
42
- userModel: Model<UserDocument>
43
- jbrowseConfigModel: Model<JBrowseConfigDocument>
44
- session: ClientSession
45
- filesService: {
46
- getFileStream(file: FileDocument): ReadableStream<Uint8Array>
47
- getFileHandle(file: FileDocument): GenericFilehandle
48
- parseGFF3(
49
- stream: ReadableStream<Uint8Array>,
50
- parseOptions?: {
51
- bufferSize?: number
52
- errorCallback?(errorMessage: string): void
53
- },
54
- ): ReadableStream<GFF3Feature>
55
- create(createFileDto: CreateFileDto): void
56
- remove(id: string): void
57
- }
58
- pluginsService: {
59
- evaluateExtensionPoint(
60
- extensionPointName: string,
61
- extendee: unknown,
62
- props?: Record<string, unknown>,
63
- ): void
64
- }
65
- counterService: {
66
- getNextSequenceValue(sequenceName: string): Promise<number>
67
- }
68
- user: string
69
- }
70
- export interface SerializedOperation {
71
- typeName: string
72
- }
73
-
74
- export type BackendDataStore = ServerDataStore | LocalGFF3DataStore
75
-
76
- export interface OperationOptions {
77
- logger: LoggerService
78
- }
79
-
80
- export abstract class Operation implements SerializedOperation {
81
- protected logger: LoggerService
82
- abstract typeName: string
83
-
84
- constructor(json: SerializedOperation, options?: OperationOptions) {
85
- this.logger = options?.logger ?? console
86
- }
87
-
88
- abstract toJSON(): SerializedOperation
89
-
90
- async execute(backend: BackendDataStore): Promise<unknown> {
91
- const backendType = backend.typeName
92
- if (backendType === 'Server') {
93
- const initialResult = this.executeOnServer(backend)
94
- return backend.pluginsService.evaluateExtensionPoint(
95
- `${this.typeName}-transformResults`,
96
- initialResult,
97
- { operation: this, backend },
98
- )
99
- }
100
- if (backendType === 'LocalGFF3') {
101
- return this.executeOnLocalGFF3(backend)
102
- }
103
- throw new Error(
104
- `no operation implementation for backend type '${backendType}'`,
105
- )
106
- }
107
-
108
- abstract executeOnServer(backend: ServerDataStore): Promise<unknown>
109
- abstract executeOnLocalGFF3(backend: LocalGFF3DataStore): Promise<unknown>
110
- }
@@ -1,26 +0,0 @@
1
- import type { Operation } from './Operation.js'
2
-
3
- // eslint-disable-next-line @typescript-eslint/no-explicit-any
4
- type OperationType = new (...args: any[]) => Operation
5
-
6
- class OperationTypeRegistry {
7
- operations = new Map<string, OperationType>()
8
-
9
- registerOperation(name: string, operationType: OperationType): void {
10
- if (this.operations.has(name)) {
11
- throw new Error(`operation type "${name}" has already been registered`)
12
- }
13
- this.operations.set(name, operationType)
14
- }
15
-
16
- getOperationType(name: string): OperationType {
17
- const RegisteredOperationType = this.operations.get(name)
18
- if (!RegisteredOperationType) {
19
- throw new Error(`No operation constructor registered for "${name}"`)
20
- }
21
- return RegisteredOperationType
22
- }
23
- }
24
-
25
- /** global singleton of all known types of operations */
26
- export const operationRegistry = new OperationTypeRegistry()