@apollo-annotation/common 0.1.18 → 0.1.20

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.
@@ -0,0 +1,9 @@
1
+ import Plugin from '@jbrowse/core/Plugin';
2
+ import PluginManager from '@jbrowse/core/PluginManager';
3
+ export type ApolloPluginConstructor = new (...args: unknown[]) => ApolloPlugin;
4
+ export interface ApolloPluginManager {
5
+ addToExtensionPoint: PluginManager['addToExtensionPoint'];
6
+ }
7
+ export declare abstract class ApolloPlugin extends Plugin {
8
+ apolloInstall(_pluginManager: ApolloPluginManager): void;
9
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ApolloPlugin = void 0;
4
+ const tslib_1 = require("tslib");
5
+ const Plugin_1 = tslib_1.__importDefault(require("@jbrowse/core/Plugin"));
6
+ class ApolloPlugin extends Plugin_1.default {
7
+ // eslint-disable-next-line @typescript-eslint/no-empty-function
8
+ apolloInstall(_pluginManager) { }
9
+ }
10
+ exports.ApolloPlugin = ApolloPlugin;
11
+ //# sourceMappingURL=ApolloPlugin.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ApolloPlugin.js","sourceRoot":"","sources":["../src/ApolloPlugin.ts"],"names":[],"mappings":";;;;AAAA,0EAAyC;AASzC,MAAsB,YAAa,SAAQ,gBAAM;IAC/C,gEAAgE;IAChE,aAAa,CAAC,cAAmC,IAAS,CAAC;CAC5D;AAHD,oCAGC"}
@@ -0,0 +1,9 @@
1
+ import { Change, ChangeOptions, SerializedChange } from './Change';
2
+ export interface SerializedAssemblySpecificChange extends SerializedChange {
3
+ assembly: string;
4
+ }
5
+ export declare function isAssemblySpecificChange(thing: any): thing is AssemblySpecificChange;
6
+ export declare abstract class AssemblySpecificChange extends Change {
7
+ assembly: string;
8
+ constructor(json: SerializedAssemblySpecificChange, options?: ChangeOptions);
9
+ }
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.AssemblySpecificChange = void 0;
4
+ exports.isAssemblySpecificChange = isAssemblySpecificChange;
5
+ /* eslint-disable @typescript-eslint/no-unnecessary-condition */
6
+ const Change_1 = require("./Change");
7
+ function isAssemblySpecificChange(
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ thing) {
10
+ return ((0, Change_1.isChange)(thing) && thing.assembly !== undefined);
11
+ }
12
+ class AssemblySpecificChange extends Change_1.Change {
13
+ constructor(json, options) {
14
+ super(json, options);
15
+ this.assembly = json.assembly;
16
+ }
17
+ }
18
+ exports.AssemblySpecificChange = AssemblySpecificChange;
19
+ //# sourceMappingURL=AssemblySpecificChange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AssemblySpecificChange.js","sourceRoot":"","sources":["../src/AssemblySpecificChange.ts"],"names":[],"mappings":";;;AAOA,4DAOC;AAdD,gEAAgE;AAChE,qCAA4E;AAM5E,SAAgB,wBAAwB;AACtC,8DAA8D;AAC9D,KAAU;IAEV,OAAO,CACL,IAAA,iBAAQ,EAAC,KAAK,CAAC,IAAK,KAAgC,CAAC,QAAQ,KAAK,SAAS,CAC5E,CAAA;AACH,CAAC;AAED,MAAsB,sBAAuB,SAAQ,eAAM;IAGzD,YAAY,IAAsC,EAAE,OAAuB;QACzE,KAAK,CAAC,IAAI,EAAE,OAAO,CAAC,CAAA;QACpB,IAAI,CAAC,QAAQ,GAAG,IAAI,CAAC,QAAQ,CAAA;IAC/B,CAAC;CACF;AAPD,wDAOC"}
@@ -0,0 +1,33 @@
1
+ import { AnnotationFeature, AnnotationFeatureSnapshot, ApolloAssemblyI, BackendDriverType, CheckResultI, CheckResultSnapshot } from '@apollo-annotation/mst';
2
+ import { AppRootModel, Region } from '@jbrowse/core/util';
3
+ import { BackendDataStore, Operation, OperationOptions, SerializedOperation } from './Operation';
4
+ export interface ClientDataStore {
5
+ typeName: 'Client';
6
+ assemblies: Map<string, ApolloAssemblyI>;
7
+ checkResults: Map<string, CheckResultI>;
8
+ internetAccounts: AppRootModel['internetAccounts'];
9
+ getInternetAccount(assemblyName?: string, internetAccountId?: string): AppRootModel['internetAccounts'][0];
10
+ loadFeatures(regions: Region[]): void;
11
+ loadRefSeq(regions: Region[]): void;
12
+ getFeature(featureId: string): AnnotationFeature | undefined;
13
+ addFeature(assemblyId: string, feature: AnnotationFeatureSnapshot): void;
14
+ deleteFeature(featureId: string): void;
15
+ deleteAssembly(assemblyId: string): void;
16
+ addCheckResults(checkResults: CheckResultSnapshot[]): void;
17
+ addAssembly(assemblyId: string, backendDriverType?: BackendDriverType): ApolloAssemblyI;
18
+ }
19
+ export type SerializedChange = SerializedOperation;
20
+ export type ChangeOptions = OperationOptions;
21
+ export type DataStore = BackendDataStore | ClientDataStore;
22
+ export declare function isChange(thing: any): thing is Change;
23
+ export declare abstract class Change extends Operation {
24
+ /**
25
+ * If a non-empty string, a snackbar will display in JBrowse with this message
26
+ * when a successful response is received from the server.
27
+ */
28
+ get notification(): string;
29
+ static fromJSON(json: SerializedOperation, options?: ChangeOptions): Change;
30
+ execute(backend: DataStore): Promise<unknown>;
31
+ abstract executeOnClient(backend: ClientDataStore): Promise<void>;
32
+ abstract getInverse(): Change;
33
+ }
package/dist/Change.js ADDED
@@ -0,0 +1,36 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Change = void 0;
4
+ exports.isChange = isChange;
5
+ const ChangeTypeRegistry_1 = require("./ChangeTypeRegistry");
6
+ const Operation_1 = require("./Operation");
7
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
8
+ function isChange(thing) {
9
+ return thing.executeOnClient !== undefined;
10
+ }
11
+ class Change extends Operation_1.Operation {
12
+ /**
13
+ * If a non-empty string, a snackbar will display in JBrowse with this message
14
+ * when a successful response is received from the server.
15
+ */
16
+ // eslint-disable-next-line @typescript-eslint/class-literal-property-style
17
+ get notification() {
18
+ return '';
19
+ }
20
+ static fromJSON(json, options) {
21
+ const ChangeType = ChangeTypeRegistry_1.changeRegistry.getChangeType(json.typeName);
22
+ return new ChangeType(json, (options === null || options === void 0 ? void 0 : options.logger) && { logger: options.logger });
23
+ }
24
+ async execute(backend) {
25
+ const backendType = backend.typeName;
26
+ if (backendType === 'LocalGFF3' || backendType === 'Server') {
27
+ return super.execute(backend);
28
+ }
29
+ if (backendType === 'Client') {
30
+ return this.executeOnClient(backend);
31
+ }
32
+ throw new Error(`no change implementation for backend type '${backendType}'`);
33
+ }
34
+ }
35
+ exports.Change = Change;
36
+ //# sourceMappingURL=Change.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Change.js","sourceRoot":"","sources":["../src/Change.ts"],"names":[],"mappings":";;;AAgDA,4BAEC;AAtCD,6DAAqD;AACrD,2CAKoB;AA6BpB,8DAA8D;AAC9D,SAAgB,QAAQ,CAAC,KAAU;IACjC,OAAQ,KAAgB,CAAC,eAAe,KAAK,SAAS,CAAA;AACxD,CAAC;AAED,MAAsB,MAAO,SAAQ,qBAAS;IAC5C;;;OAGG;IACH,2EAA2E;IAC3E,IAAI,YAAY;QACd,OAAO,EAAE,CAAA;IACX,CAAC;IAED,MAAM,CAAC,QAAQ,CAAC,IAAyB,EAAE,OAAuB;QAChE,MAAM,UAAU,GAAG,mCAAc,CAAC,aAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAA;QAC9D,OAAO,IAAI,UAAU,CAAC,IAAI,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,KAAI,EAAE,MAAM,EAAE,OAAO,CAAC,MAAM,EAAE,CAAC,CAAA;IAC5E,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,OAAkB;QAC9B,MAAM,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAA;QACpC,IAAI,WAAW,KAAK,WAAW,IAAI,WAAW,KAAK,QAAQ,EAAE,CAAC;YAC5D,OAAO,KAAK,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;QAC/B,CAAC;QACD,IAAI,WAAW,KAAK,QAAQ,EAAE,CAAC;YAC7B,OAAO,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,CAAA;QACtC,CAAC;QACD,MAAM,IAAI,KAAK,CACb,8CAA8C,WAAW,GAAG,CAC7D,CAAA;IACH,CAAC;CAKF;AA/BD,wBA+BC"}
@@ -0,0 +1,10 @@
1
+ import { Change } from './Change';
2
+ type ChangeType = new (...args: any[]) => Change;
3
+ declare class ChangeTypeRegistry {
4
+ changes: Map<string, ChangeType>;
5
+ registerChange(name: string, changeType: ChangeType): void;
6
+ getChangeType(name: string): ChangeType;
7
+ }
8
+ /** global singleton of all known types of changes */
9
+ export declare const changeRegistry: ChangeTypeRegistry;
10
+ export {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.changeRegistry = void 0;
4
+ class ChangeTypeRegistry {
5
+ constructor() {
6
+ this.changes = new Map();
7
+ }
8
+ registerChange(name, changeType) {
9
+ if (this.changes.has(name)) {
10
+ throw new Error(`change type "${name}" has already been registered`);
11
+ }
12
+ this.changes.set(name, changeType);
13
+ }
14
+ getChangeType(name) {
15
+ const RegisteredChangeType = this.changes.get(name);
16
+ if (!RegisteredChangeType) {
17
+ throw new Error(`No change constructor registered for "${name}"`);
18
+ }
19
+ return RegisteredChangeType;
20
+ }
21
+ }
22
+ /** global singleton of all known types of changes */
23
+ exports.changeRegistry = new ChangeTypeRegistry();
24
+ //# sourceMappingURL=ChangeTypeRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ChangeTypeRegistry.js","sourceRoot":"","sources":["../src/ChangeTypeRegistry.ts"],"names":[],"mappings":";;;AAKA,MAAM,kBAAkB;IAAxB;QACE,YAAO,GAAG,IAAI,GAAG,EAAsB,CAAA;IAgBzC,CAAC;IAdC,cAAc,CAAC,IAAY,EAAE,UAAsB;QACjD,IAAI,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,gBAAgB,IAAI,+BAA+B,CAAC,CAAA;QACtE,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,EAAE,UAAU,CAAC,CAAA;IACpC,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,MAAM,oBAAoB,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QACnD,IAAI,CAAC,oBAAoB,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,yCAAyC,IAAI,GAAG,CAAC,CAAA;QACnE,CAAC;QACD,OAAO,oBAAoB,CAAA;IAC7B,CAAC;CACF;AAED,qDAAqD;AACxC,QAAA,cAAc,GAAG,IAAI,kBAAkB,EAAE,CAAA"}
@@ -0,0 +1,6 @@
1
+ import { AnnotationFeatureSnapshot, CheckResultSnapshot } from '@apollo-annotation/mst';
2
+ export declare abstract class Check {
3
+ abstract name: string;
4
+ abstract version: number;
5
+ abstract checkFeature(feature: AnnotationFeatureSnapshot, getSequence: (start: number, end: number) => Promise<string>): Promise<CheckResultSnapshot[]>;
6
+ }
package/dist/Check.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Check = void 0;
4
+ class Check {
5
+ }
6
+ exports.Check = Check;
7
+ //# sourceMappingURL=Check.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Check.js","sourceRoot":"","sources":["../src/Check.ts"],"names":[],"mappings":";;;AAKA,MAAsB,KAAK;CAQ1B;AARD,sBAQC"}
@@ -0,0 +1,10 @@
1
+ import { Check } from './Check';
2
+ declare class CheckRegistry {
3
+ checks: Map<string, Check>;
4
+ registerCheck(name: string, check: Check): void;
5
+ getCheck(name: string): Check;
6
+ getChecks(): Map<string, Check>;
7
+ }
8
+ /** global singleton of all known checks */
9
+ export declare const checkRegistry: CheckRegistry;
10
+ export {};
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.checkRegistry = void 0;
4
+ class CheckRegistry {
5
+ constructor() {
6
+ this.checks = new Map();
7
+ }
8
+ registerCheck(name, check) {
9
+ if (this.checks.has(name)) {
10
+ throw new Error(`check "${name}" has already been registered`);
11
+ }
12
+ this.checks.set(name, check);
13
+ }
14
+ getCheck(name) {
15
+ const registeredCheck = this.checks.get(name);
16
+ if (!registeredCheck) {
17
+ throw new Error(`No check constructor registered for "${name}"`);
18
+ }
19
+ return registeredCheck;
20
+ }
21
+ getChecks() {
22
+ return this.checks;
23
+ }
24
+ }
25
+ /** global singleton of all known checks */
26
+ exports.checkRegistry = new CheckRegistry();
27
+ //# sourceMappingURL=CheckRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CheckRegistry.js","sourceRoot":"","sources":["../src/CheckRegistry.ts"],"names":[],"mappings":";;;AAEA,MAAM,aAAa;IAAnB;QACE,WAAM,GAAG,IAAI,GAAG,EAAiB,CAAA;IAoBnC,CAAC;IAlBC,aAAa,CAAC,IAAY,EAAE,KAAY;QACtC,IAAI,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;YAC1B,MAAM,IAAI,KAAK,CAAC,UAAU,IAAI,+BAA+B,CAAC,CAAA;QAChE,CAAC;QACD,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;IAC9B,CAAC;IAED,QAAQ,CAAC,IAAY;QACnB,MAAM,eAAe,GAAG,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAA;QAC7C,IAAI,CAAC,eAAe,EAAE,CAAC;YACrB,MAAM,IAAI,KAAK,CAAC,wCAAwC,IAAI,GAAG,CAAC,CAAA;QAClE,CAAC;QACD,OAAO,eAAe,CAAA;IACxB,CAAC;IAED,SAAS;QACP,OAAO,IAAI,CAAC,MAAM,CAAA;IACpB,CAAC;CACF;AAED,2CAA2C;AAC9B,QAAA,aAAa,GAAG,IAAI,aAAa,EAAE,CAAA"}
@@ -0,0 +1,32 @@
1
+ import type { AnnotationFeatureSnapshot } from '@apollo-annotation/mst';
2
+ import { Feature } from '@apollo-annotation/schemas';
3
+ import { AssemblySpecificChange, SerializedAssemblySpecificChange } from './AssemblySpecificChange';
4
+ import { ChangeOptions } from './Change';
5
+ export interface SerializedFeatureChange extends SerializedAssemblySpecificChange {
6
+ /** The IDs of features that were changed in this operation */
7
+ changedIds: string[];
8
+ }
9
+ export declare function isFeatureChange(thing: any): thing is FeatureChange;
10
+ export declare abstract class FeatureChange extends AssemblySpecificChange {
11
+ changedIds: string[];
12
+ constructor(json: SerializedFeatureChange, options?: ChangeOptions);
13
+ /**
14
+ * Get single feature by featureId
15
+ * @param feature -
16
+ * @param featureId -
17
+ * @returns
18
+ */
19
+ getFeatureFromId(feature: Feature, featureId: string): Feature | null;
20
+ /**
21
+ * Get children's feature ids
22
+ * @param feature - parent feature
23
+ * @returns
24
+ */
25
+ getChildFeatureIds(feature: Feature | AnnotationFeatureSnapshot): string[];
26
+ /**
27
+ * Recursively assign new IDs to a feature
28
+ * @param feature - Parent feature
29
+ * @param featureIds -
30
+ */
31
+ generateNewIds(feature: Feature | AnnotationFeatureSnapshot, featureIds: string[]): AnnotationFeatureSnapshot;
32
+ }
@@ -0,0 +1,88 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.FeatureChange = void 0;
4
+ exports.isFeatureChange = isFeatureChange;
5
+ const tslib_1 = require("tslib");
6
+ const bson_objectid_1 = tslib_1.__importDefault(require("bson-objectid"));
7
+ const AssemblySpecificChange_1 = require("./AssemblySpecificChange");
8
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
9
+ function isFeatureChange(thing) {
10
+ return ((0, AssemblySpecificChange_1.isAssemblySpecificChange)(thing) &&
11
+ thing.changedIds !== undefined);
12
+ }
13
+ class FeatureChange extends AssemblySpecificChange_1.AssemblySpecificChange {
14
+ constructor(json, options) {
15
+ super(json, options);
16
+ this.changedIds = json.changedIds;
17
+ }
18
+ /**
19
+ * Get single feature by featureId
20
+ * @param feature -
21
+ * @param featureId -
22
+ * @returns
23
+ */
24
+ getFeatureFromId(feature, featureId) {
25
+ var _a, _b, _c, _d;
26
+ const { logger } = this;
27
+ (_a = logger.verbose) === null || _a === void 0 ? void 0 : _a.call(logger, `Entry=${JSON.stringify(feature)}`);
28
+ if (feature._id.equals(featureId)) {
29
+ (_b = logger.debug) === null || _b === void 0 ? void 0 : _b.call(logger, `Top level featureId matches in the object ${JSON.stringify(feature)}`);
30
+ return feature;
31
+ }
32
+ // Check if there is also childFeatures in parent feature and it's not empty
33
+ // Let's get featureId from recursive method
34
+ (_c = logger.debug) === null || _c === void 0 ? void 0 : _c.call(logger, 'FeatureId was not found on top level so lets make recursive call...');
35
+ for (const [, childFeature] of (_d = feature.children) !== null && _d !== void 0 ? _d : new Map()) {
36
+ const subFeature = this.getFeatureFromId(childFeature, featureId);
37
+ if (subFeature) {
38
+ return subFeature;
39
+ }
40
+ }
41
+ return null;
42
+ }
43
+ /**
44
+ * Get children's feature ids
45
+ * @param feature - parent feature
46
+ * @returns
47
+ */
48
+ getChildFeatureIds(feature) {
49
+ if (!feature.children) {
50
+ return [];
51
+ }
52
+ const featureIds = [];
53
+ const children = feature.children instanceof Map
54
+ ? feature.children
55
+ : new Map(Object.entries(feature.children));
56
+ for (const [childFeatureId, childFeature] of children || new Map()) {
57
+ featureIds.push(childFeatureId, ...this.getChildFeatureIds(childFeature));
58
+ }
59
+ return featureIds;
60
+ }
61
+ /**
62
+ * Recursively assign new IDs to a feature
63
+ * @param feature - Parent feature
64
+ * @param featureIds -
65
+ */
66
+ generateNewIds(feature, featureIds) {
67
+ const newId = new bson_objectid_1.default().toHexString();
68
+ featureIds.push(newId);
69
+ const children = {};
70
+ if (feature.children) {
71
+ for (const child of Object.values(feature.children)) {
72
+ const newChild = this.generateNewIds(child, featureIds);
73
+ children[newChild._id] = newChild;
74
+ }
75
+ }
76
+ const refSeq = typeof feature.refSeq === 'string'
77
+ ? feature.refSeq
78
+ : feature.refSeq.toHexString();
79
+ return {
80
+ ...feature,
81
+ refSeq,
82
+ children: feature.children && children,
83
+ _id: newId,
84
+ };
85
+ }
86
+ }
87
+ exports.FeatureChange = FeatureChange;
88
+ //# sourceMappingURL=FeatureChange.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"FeatureChange.js","sourceRoot":"","sources":["../src/FeatureChange.ts"],"names":[],"mappings":"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"}
@@ -0,0 +1,59 @@
1
+ import type { ReadStream } from 'node:fs';
2
+ import type { FileHandle } from 'node:fs/promises';
3
+ import { AssemblyDocument, FeatureDocument, FileDocument, RefSeqChunkDocument, RefSeqDocument, JBrowseConfigDocument, UserDocument } from '@apollo-annotation/schemas';
4
+ import type { LoggerService } from '@nestjs/common';
5
+ import type { ClientSession, Model } from 'mongoose';
6
+ import { GenericFilehandle } from 'generic-filehandle';
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
+ fileModel: Model<FileDocument>;
25
+ userModel: Model<UserDocument>;
26
+ jbrowseConfigModel: Model<JBrowseConfigDocument>;
27
+ session: ClientSession;
28
+ filesService: {
29
+ getFileStream(file: FileDocument): ReadStream;
30
+ getFileHandle(file: FileDocument): GenericFilehandle;
31
+ parseGFF3(stream: ReadStream): ReadStream;
32
+ create(createFileDto: CreateFileDto): void;
33
+ remove(id: string): void;
34
+ };
35
+ pluginsService: {
36
+ evaluateExtensionPoint(extensionPointName: string, extendee: unknown, props?: Record<string, unknown>): void;
37
+ };
38
+ counterService: {
39
+ getNextSequenceValue(sequenceName: string): Promise<number>;
40
+ };
41
+ user: string;
42
+ }
43
+ export interface SerializedOperation {
44
+ typeName: string;
45
+ }
46
+ export type BackendDataStore = ServerDataStore | LocalGFF3DataStore;
47
+ export interface OperationOptions {
48
+ logger: LoggerService;
49
+ }
50
+ export declare abstract class Operation implements SerializedOperation {
51
+ protected logger: LoggerService;
52
+ abstract typeName: string;
53
+ constructor(json: SerializedOperation, options?: OperationOptions);
54
+ abstract toJSON(): SerializedOperation;
55
+ execute(backend: BackendDataStore): Promise<unknown>;
56
+ abstract executeOnServer(backend: ServerDataStore): Promise<unknown>;
57
+ abstract executeOnLocalGFF3(backend: LocalGFF3DataStore): Promise<unknown>;
58
+ }
59
+ export {};
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Operation = void 0;
4
+ class Operation {
5
+ constructor(json, options) {
6
+ var _a;
7
+ this.logger = (_a = options === null || options === void 0 ? void 0 : options.logger) !== null && _a !== void 0 ? _a : console;
8
+ }
9
+ async execute(backend) {
10
+ const backendType = backend.typeName;
11
+ if (backendType === 'Server') {
12
+ const initialResult = this.executeOnServer(backend);
13
+ return backend.pluginsService.evaluateExtensionPoint(`${this.typeName}-transformResults`, initialResult, { operation: this, backend });
14
+ }
15
+ if (backendType === 'LocalGFF3') {
16
+ return this.executeOnLocalGFF3(backend);
17
+ }
18
+ throw new Error(`no operation implementation for backend type '${backendType}'`);
19
+ }
20
+ }
21
+ exports.Operation = Operation;
22
+ //# sourceMappingURL=Operation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Operation.js","sourceRoot":"","sources":["../src/Operation.ts"],"names":[],"mappings":";;;AAuEA,MAAsB,SAAS;IAI7B,YAAY,IAAyB,EAAE,OAA0B;;QAC/D,IAAI,CAAC,MAAM,GAAG,MAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,mCAAI,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;AA9BD,8BA8BC"}
@@ -0,0 +1,10 @@
1
+ import { Operation } from './Operation';
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 {};
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.operationRegistry = void 0;
4
+ class OperationTypeRegistry {
5
+ constructor() {
6
+ this.operations = new Map();
7
+ }
8
+ registerOperation(name, operationType) {
9
+ if (this.operations.has(name)) {
10
+ throw new Error(`operation type "${name}" has already been registered`);
11
+ }
12
+ this.operations.set(name, operationType);
13
+ }
14
+ getOperationType(name) {
15
+ const RegisteredOperationType = this.operations.get(name);
16
+ if (!RegisteredOperationType) {
17
+ throw new Error(`No operation constructor registered for "${name}"`);
18
+ }
19
+ return RegisteredOperationType;
20
+ }
21
+ }
22
+ /** global singleton of all known types of operations */
23
+ exports.operationRegistry = new OperationTypeRegistry();
24
+ //# sourceMappingURL=OperationTypeRegistry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OperationTypeRegistry.js","sourceRoot":"","sources":["../src/OperationTypeRegistry.ts"],"names":[],"mappings":";;;AAKA,MAAM,qBAAqB;IAA3B;QACE,eAAU,GAAG,IAAI,GAAG,EAAyB,CAAA;IAgB/C,CAAC;IAdC,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;AAC3C,QAAA,iBAAiB,GAAG,IAAI,qBAAqB,EAAE,CAAA"}
@@ -0,0 +1,27 @@
1
+ import { FeatureDocument } from '@apollo-annotation/schemas';
2
+ import type { ExecutionContext } from '@nestjs/common';
3
+ import type { Reflector } from '@nestjs/core';
4
+ import { ClientSession, Model } from 'mongoose';
5
+ import { Change, ClientDataStore } from './Change';
6
+ export interface Context {
7
+ context: ExecutionContext;
8
+ reflector: Reflector;
9
+ }
10
+ export declare function isContext(thing: Change | Context): thing is Context;
11
+ export interface ValidationResult {
12
+ validationName: string;
13
+ error?: {
14
+ message: string;
15
+ };
16
+ }
17
+ export declare abstract class Validation {
18
+ abstract name: string;
19
+ frontendPreValidate(_change: Change): Promise<ValidationResult>;
20
+ frontendPostValidate(_change: Change, _dataStore: ClientDataStore): Promise<ValidationResult>;
21
+ backendPreValidate(_changeOrContext: Change | Context): Promise<ValidationResult>;
22
+ backendPostValidate(_change: Change, _context: {
23
+ session: ClientSession;
24
+ featureModel: Model<FeatureDocument>;
25
+ }): Promise<ValidationResult>;
26
+ possibleValues(_key: string): Promise<unknown[] | undefined>;
27
+ }
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.Validation = void 0;
4
+ exports.isContext = isContext;
5
+ function isContext(thing) {
6
+ return 'context' in thing && 'reflector' in thing;
7
+ }
8
+ class Validation {
9
+ async frontendPreValidate(_change) {
10
+ return { validationName: this.name };
11
+ }
12
+ async frontendPostValidate(_change, _dataStore) {
13
+ return { validationName: this.name };
14
+ }
15
+ async backendPreValidate(_changeOrContext) {
16
+ return { validationName: this.name };
17
+ }
18
+ async backendPostValidate(_change, _context) {
19
+ return { validationName: this.name };
20
+ }
21
+ async possibleValues(_key) {
22
+ return undefined;
23
+ }
24
+ }
25
+ exports.Validation = Validation;
26
+ //# sourceMappingURL=Validation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Validation.js","sourceRoot":"","sources":["../src/Validation.ts"],"names":[],"mappings":";;;AAaA,8BAEC;AAFD,SAAgB,SAAS,CAAC,KAAuB;IAC/C,OAAO,SAAS,IAAI,KAAK,IAAI,WAAW,IAAI,KAAK,CAAA;AACnD,CAAC;AAOD,MAAsB,UAAU;IAE9B,KAAK,CAAC,mBAAmB,CAAC,OAAe;QACvC,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IACtC,CAAC;IAED,KAAK,CAAC,oBAAoB,CACxB,OAAe,EACf,UAA2B;QAE3B,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IACtC,CAAC;IAED,KAAK,CAAC,kBAAkB,CACtB,gBAAkC;QAElC,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IACtC,CAAC;IAED,KAAK,CAAC,mBAAmB,CACvB,OAAe,EACf,QAA0E;QAE1E,OAAO,EAAE,cAAc,EAAE,IAAI,CAAC,IAAI,EAAE,CAAA;IACtC,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,IAAY;QAC/B,OAAO,SAAS,CAAA;IAClB,CAAC;CACF;AA7BD,gCA6BC"}
@@ -0,0 +1,10 @@
1
+ export * from './ApolloPlugin';
2
+ export * from './AssemblySpecificChange';
3
+ export * from './Change';
4
+ export * from './ChangeTypeRegistry';
5
+ export * from './Check';
6
+ export * from './CheckRegistry';
7
+ export * from './FeatureChange';
8
+ export * from './Operation';
9
+ export * from './OperationTypeRegistry';
10
+ export * from './Validation';
package/dist/index.js ADDED
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const tslib_1 = require("tslib");
4
+ tslib_1.__exportStar(require("./ApolloPlugin"), exports);
5
+ tslib_1.__exportStar(require("./AssemblySpecificChange"), exports);
6
+ tslib_1.__exportStar(require("./Change"), exports);
7
+ tslib_1.__exportStar(require("./ChangeTypeRegistry"), exports);
8
+ tslib_1.__exportStar(require("./Check"), exports);
9
+ tslib_1.__exportStar(require("./CheckRegistry"), exports);
10
+ tslib_1.__exportStar(require("./FeatureChange"), exports);
11
+ tslib_1.__exportStar(require("./Operation"), exports);
12
+ tslib_1.__exportStar(require("./OperationTypeRegistry"), exports);
13
+ tslib_1.__exportStar(require("./Validation"), exports);
14
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,yDAA8B;AAC9B,mEAAwC;AACxC,mDAAwB;AACxB,+DAAoC;AACpC,kDAAuB;AACvB,0DAA+B;AAC/B,0DAA+B;AAC/B,sDAA2B;AAC3B,kEAAuC;AACvC,uDAA4B"}