@nest-yalc-2/omnikernel-module 1.1.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/LICENSE +661 -0
- package/README.md +193 -0
- package/package.json +52 -0
- package/src/__tests__/omni-collection.entity.spec.ts +49 -0
- package/src/__tests__/omni-collection.service.spec.ts +83 -0
- package/src/__tests__/omni-document.entity.spec.ts +55 -0
- package/src/__tests__/omni-document.service.spec.ts +83 -0
- package/src/__tests__/omni-extension-projection-constraints.spec.ts +518 -0
- package/src/__tests__/omni-extension-projection.registration.spec.ts +946 -0
- package/src/__tests__/omni-extension-projection.service.spec.ts +806 -0
- package/src/__tests__/omni-external-ref.entity.spec.ts +36 -0
- package/src/__tests__/omni-external-ref.service.spec.ts +252 -0
- package/src/__tests__/omni-named.entity.spec.ts +33 -0
- package/src/__tests__/omni-record.entity.spec.ts +32 -0
- package/src/__tests__/omni-record.service.spec.ts +107 -0
- package/src/__tests__/omni-relation-semantics.spec.ts +102 -0
- package/src/__tests__/omni-relation.entity.spec.ts +38 -0
- package/src/__tests__/omni-scope-substrate.spec.ts +81 -0
- package/src/__tests__/omni-scoped.backend.spec.ts +115 -0
- package/src/__tests__/omni-scoped.service.spec.ts +354 -0
- package/src/__tests__/omnikernel.diagnostics.spec.ts +94 -0
- package/src/__tests__/omnikernel.module.spec.ts +40 -0
- package/src/__tests__/omnikernel.persistence.spec.ts +154 -0
- package/src/__tests__/omnikernel.public-api.spec.ts +238 -0
- package/src/__tests__/omnikernel.query.service.spec.ts +155 -0
- package/src/__tests__/tsconfig.json +6 -0
- package/src/base/omni-base.entity.d.ts +9 -0
- package/src/base/omni-base.entity.js +53 -0
- package/src/base/omni-base.entity.js.map +1 -0
- package/src/base/omni-base.entity.ts +41 -0
- package/src/base/omni-external-ref.entity.d.ts +13 -0
- package/src/base/omni-external-ref.entity.js +72 -0
- package/src/base/omni-external-ref.entity.js.map +1 -0
- package/src/base/omni-external-ref.entity.ts +53 -0
- package/src/base/omni-named.entity.d.ts +6 -0
- package/src/base/omni-named.entity.js +35 -0
- package/src/base/omni-named.entity.js.map +1 -0
- package/src/base/omni-named.entity.ts +16 -0
- package/src/base/omni-record.entity.d.ts +13 -0
- package/src/base/omni-record.entity.js +71 -0
- package/src/base/omni-record.entity.js.map +1 -0
- package/src/base/omni-record.entity.ts +51 -0
- package/src/base/omni-relation.entity.d.ts +15 -0
- package/src/base/omni-relation.entity.js +91 -0
- package/src/base/omni-relation.entity.js.map +1 -0
- package/src/base/omni-relation.entity.ts +72 -0
- package/src/index.d.ts +49 -0
- package/src/index.js +66 -0
- package/src/index.js.map +1 -0
- package/src/index.ts +49 -0
- package/src/omni-collection-kind.enum.d.ts +4 -0
- package/src/omni-collection-kind.enum.js +13 -0
- package/src/omni-collection-kind.enum.js.map +1 -0
- package/src/omni-collection-kind.enum.ts +10 -0
- package/src/omni-collection.backend.d.ts +2 -0
- package/src/omni-collection.backend.js +15 -0
- package/src/omni-collection.backend.js.map +1 -0
- package/src/omni-collection.backend.ts +16 -0
- package/src/omni-collection.dto.d.ts +32 -0
- package/src/omni-collection.dto.js +184 -0
- package/src/omni-collection.dto.js.map +1 -0
- package/src/omni-collection.dto.ts +170 -0
- package/src/omni-collection.entity.d.ts +7 -0
- package/src/omni-collection.entity.js +41 -0
- package/src/omni-collection.entity.js.map +1 -0
- package/src/omni-collection.entity.ts +21 -0
- package/src/omni-collection.service.d.ts +14 -0
- package/src/omni-collection.service.js +24 -0
- package/src/omni-collection.service.js.map +1 -0
- package/src/omni-collection.service.ts +75 -0
- package/src/omni-document-kind.enum.d.ts +6 -0
- package/src/omni-document-kind.enum.js +15 -0
- package/src/omni-document-kind.enum.js.map +1 -0
- package/src/omni-document-kind.enum.ts +12 -0
- package/src/omni-document.backend.d.ts +2 -0
- package/src/omni-document.backend.js +15 -0
- package/src/omni-document.backend.js.map +1 -0
- package/src/omni-document.backend.ts +16 -0
- package/src/omni-document.dto.d.ts +35 -0
- package/src/omni-document.dto.js +213 -0
- package/src/omni-document.dto.js.map +1 -0
- package/src/omni-document.dto.ts +198 -0
- package/src/omni-document.entity.d.ts +10 -0
- package/src/omni-document.entity.js +53 -0
- package/src/omni-document.entity.js.map +1 -0
- package/src/omni-document.entity.ts +30 -0
- package/src/omni-document.service.d.ts +14 -0
- package/src/omni-document.service.js +24 -0
- package/src/omni-document.service.js.map +1 -0
- package/src/omni-document.service.ts +75 -0
- package/src/omni-dto.helpers.d.ts +1 -0
- package/src/omni-dto.helpers.js +10 -0
- package/src/omni-dto.helpers.js.map +1 -0
- package/src/omni-dto.helpers.ts +21 -0
- package/src/omni-extension-projection.definition.d.ts +17 -0
- package/src/omni-extension-projection.definition.js +160 -0
- package/src/omni-extension-projection.definition.js.map +1 -0
- package/src/omni-extension-projection.definition.ts +294 -0
- package/src/omni-extension-projection.resource.d.ts +42 -0
- package/src/omni-extension-projection.resource.js +127 -0
- package/src/omni-extension-projection.resource.js.map +1 -0
- package/src/omni-extension-projection.resource.ts +274 -0
- package/src/omni-extension-projection.service.d.ts +33 -0
- package/src/omni-extension-projection.service.js +332 -0
- package/src/omni-extension-projection.service.js.map +1 -0
- package/src/omni-extension-projection.service.ts +452 -0
- package/src/omni-external-ref-binding.validator.d.ts +14 -0
- package/src/omni-external-ref-binding.validator.js +34 -0
- package/src/omni-external-ref-binding.validator.js.map +1 -0
- package/src/omni-external-ref-binding.validator.ts +53 -0
- package/src/omni-external-ref-internal-type.enum.d.ts +5 -0
- package/src/omni-external-ref-internal-type.enum.js +14 -0
- package/src/omni-external-ref-internal-type.enum.js.map +1 -0
- package/src/omni-external-ref-internal-type.enum.ts +11 -0
- package/src/omni-external-ref.backend.d.ts +2 -0
- package/src/omni-external-ref.backend.js +19 -0
- package/src/omni-external-ref.backend.js.map +1 -0
- package/src/omni-external-ref.backend.ts +25 -0
- package/src/omni-external-ref.dto.d.ts +26 -0
- package/src/omni-external-ref.dto.js +140 -0
- package/src/omni-external-ref.dto.js.map +1 -0
- package/src/omni-external-ref.dto.ts +128 -0
- package/src/omni-external-ref.service.d.ts +33 -0
- package/src/omni-external-ref.service.js +133 -0
- package/src/omni-external-ref.service.js.map +1 -0
- package/src/omni-external-ref.service.ts +255 -0
- package/src/omni-migration.d.ts +28 -0
- package/src/omni-migration.js +239 -0
- package/src/omni-migration.js.map +1 -0
- package/src/omni-migration.ts +365 -0
- package/src/omni-named.backend.d.ts +2 -0
- package/src/omni-named.backend.js +13 -0
- package/src/omni-named.backend.js.map +1 -0
- package/src/omni-named.backend.ts +11 -0
- package/src/omni-named.dto.d.ts +19 -0
- package/src/omni-named.dto.js +94 -0
- package/src/omni-named.dto.js.map +1 -0
- package/src/omni-named.dto.ts +86 -0
- package/src/omni-projection.catalog.d.ts +49 -0
- package/src/omni-projection.catalog.js +177 -0
- package/src/omni-projection.catalog.js.map +1 -0
- package/src/omni-projection.catalog.ts +345 -0
- package/src/omni-projection.lifecycle.d.ts +20 -0
- package/src/omni-projection.lifecycle.js +3 -0
- package/src/omni-projection.lifecycle.js.map +1 -0
- package/src/omni-projection.lifecycle.ts +53 -0
- package/src/omni-record-status.enum.d.ts +5 -0
- package/src/omni-record-status.enum.js +14 -0
- package/src/omni-record-status.enum.js.map +1 -0
- package/src/omni-record-status.enum.ts +11 -0
- package/src/omni-record.backend.d.ts +2 -0
- package/src/omni-record.backend.js +13 -0
- package/src/omni-record.backend.js.map +1 -0
- package/src/omni-record.backend.ts +19 -0
- package/src/omni-record.dto.d.ts +29 -0
- package/src/omni-record.dto.js +169 -0
- package/src/omni-record.dto.js.map +1 -0
- package/src/omni-record.dto.ts +157 -0
- package/src/omni-record.service.d.ts +18 -0
- package/src/omni-record.service.js +45 -0
- package/src/omni-record.service.js.map +1 -0
- package/src/omni-record.service.ts +113 -0
- package/src/omni-relation-kind.contract.d.ts +9 -0
- package/src/omni-relation-kind.contract.js +33 -0
- package/src/omni-relation-kind.contract.js.map +1 -0
- package/src/omni-relation-kind.contract.ts +49 -0
- package/src/omni-relation-kind.enum.d.ts +6 -0
- package/src/omni-relation-kind.enum.js +15 -0
- package/src/omni-relation-kind.enum.js.map +1 -0
- package/src/omni-relation-kind.enum.ts +12 -0
- package/src/omni-relation-projection.definition.d.ts +25 -0
- package/src/omni-relation-projection.definition.js +83 -0
- package/src/omni-relation-projection.definition.js.map +1 -0
- package/src/omni-relation-projection.definition.ts +166 -0
- package/src/omni-relation-projection.resource.d.ts +51 -0
- package/src/omni-relation-projection.resource.js +203 -0
- package/src/omni-relation-projection.resource.js.map +1 -0
- package/src/omni-relation-projection.resource.ts +360 -0
- package/src/omni-relation-projection.service.d.ts +47 -0
- package/src/omni-relation-projection.service.js +385 -0
- package/src/omni-relation-projection.service.js.map +1 -0
- package/src/omni-relation-projection.service.ts +610 -0
- package/src/omni-relation-semantics.d.ts +11 -0
- package/src/omni-relation-semantics.js +34 -0
- package/src/omni-relation-semantics.js.map +1 -0
- package/src/omni-relation-semantics.ts +52 -0
- package/src/omni-relation-status.enum.d.ts +5 -0
- package/src/omni-relation-status.enum.js +14 -0
- package/src/omni-relation-status.enum.js.map +1 -0
- package/src/omni-relation-status.enum.ts +11 -0
- package/src/omni-relation.backend.d.ts +2 -0
- package/src/omni-relation.backend.js +17 -0
- package/src/omni-relation.backend.js.map +1 -0
- package/src/omni-relation.backend.ts +21 -0
- package/src/omni-relation.dto.d.ts +28 -0
- package/src/omni-relation.dto.js +153 -0
- package/src/omni-relation.dto.js.map +1 -0
- package/src/omni-relation.dto.ts +142 -0
- package/src/omni-relation.service.d.ts +19 -0
- package/src/omni-relation.service.js +76 -0
- package/src/omni-relation.service.js.map +1 -0
- package/src/omni-relation.service.ts +159 -0
- package/src/omni-scope.d.ts +33 -0
- package/src/omni-scope.js +91 -0
- package/src/omni-scope.js.map +1 -0
- package/src/omni-scope.ts +161 -0
- package/src/omni-scoped.backend.d.ts +21 -0
- package/src/omni-scoped.backend.js +47 -0
- package/src/omni-scoped.backend.js.map +1 -0
- package/src/omni-scoped.backend.ts +110 -0
- package/src/omni-scoped.repository.d.ts +10 -0
- package/src/omni-scoped.repository.js +26 -0
- package/src/omni-scoped.repository.js.map +1 -0
- package/src/omni-scoped.repository.ts +34 -0
- package/src/omni-scoped.service.d.ts +36 -0
- package/src/omni-scoped.service.js +171 -0
- package/src/omni-scoped.service.js.map +1 -0
- package/src/omni-scoped.service.ts +338 -0
- package/src/omnikernel.diagnostics.d.ts +16 -0
- package/src/omnikernel.diagnostics.js +50 -0
- package/src/omnikernel.diagnostics.js.map +1 -0
- package/src/omnikernel.diagnostics.ts +83 -0
- package/src/omnikernel.module.d.ts +5 -0
- package/src/omnikernel.module.js +87 -0
- package/src/omnikernel.module.js.map +1 -0
- package/src/omnikernel.module.ts +97 -0
- package/src/omnikernel.query.service.d.ts +17 -0
- package/src/omnikernel.query.service.js +85 -0
- package/src/omnikernel.query.service.js.map +1 -0
- package/src/omnikernel.query.service.ts +108 -0
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
import { OmniCollectionKind } from './omni-collection-kind.enum.js';
|
|
2
|
+
import { OmniDocumentKind } from './omni-document-kind.enum.js';
|
|
3
|
+
import { OmniRelationKind } from './omni-relation-kind.enum.js';
|
|
4
|
+
|
|
5
|
+
export interface OmniRelationSemanticsInput {
|
|
6
|
+
sourceKind: string;
|
|
7
|
+
targetKind: string;
|
|
8
|
+
relationKind: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export const OMNI_COLLECTION_MEMBERSHIP_RELATION_KIND =
|
|
12
|
+
OmniRelationKind.Contains;
|
|
13
|
+
|
|
14
|
+
const hasKind = (kind: string): boolean => kind.trim().length > 0;
|
|
15
|
+
|
|
16
|
+
export const isOmniCollectionRecordKind = (kind: string): boolean =>
|
|
17
|
+
kind === OmniCollectionKind.Collection;
|
|
18
|
+
|
|
19
|
+
export const isOmniDocumentRecordKind = (kind: string): boolean =>
|
|
20
|
+
kind === OmniDocumentKind.Document;
|
|
21
|
+
|
|
22
|
+
export const isCanonicalCollectionMembershipRelation = ({
|
|
23
|
+
sourceKind,
|
|
24
|
+
relationKind,
|
|
25
|
+
}: Pick<OmniRelationSemanticsInput, 'sourceKind' | 'relationKind'>): boolean =>
|
|
26
|
+
relationKind === OMNI_COLLECTION_MEMBERSHIP_RELATION_KIND &&
|
|
27
|
+
isOmniCollectionRecordKind(sourceKind);
|
|
28
|
+
|
|
29
|
+
export const isAllowedOmniRelation = ({
|
|
30
|
+
sourceKind,
|
|
31
|
+
targetKind,
|
|
32
|
+
relationKind,
|
|
33
|
+
}: OmniRelationSemanticsInput): boolean => {
|
|
34
|
+
if (!hasKind(sourceKind) || !hasKind(targetKind)) {
|
|
35
|
+
return false;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
switch (relationKind) {
|
|
39
|
+
case OmniRelationKind.Contains:
|
|
40
|
+
return isOmniCollectionRecordKind(sourceKind);
|
|
41
|
+
case OmniRelationKind.DerivedFrom:
|
|
42
|
+
return (
|
|
43
|
+
isOmniDocumentRecordKind(sourceKind) &&
|
|
44
|
+
isOmniDocumentRecordKind(targetKind)
|
|
45
|
+
);
|
|
46
|
+
case OmniRelationKind.References:
|
|
47
|
+
case OmniRelationKind.RelatedTo:
|
|
48
|
+
return true;
|
|
49
|
+
default:
|
|
50
|
+
return false;
|
|
51
|
+
}
|
|
52
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmniRelationStatus = void 0;
|
|
4
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
5
|
+
var OmniRelationStatus;
|
|
6
|
+
(function (OmniRelationStatus) {
|
|
7
|
+
OmniRelationStatus["Active"] = "active";
|
|
8
|
+
OmniRelationStatus["Inactive"] = "inactive";
|
|
9
|
+
OmniRelationStatus["Archived"] = "archived";
|
|
10
|
+
})(OmniRelationStatus || (exports.OmniRelationStatus = OmniRelationStatus = {}));
|
|
11
|
+
(0, graphql_1.registerEnumType)(OmniRelationStatus, {
|
|
12
|
+
name: 'OmniRelationStatus',
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=omni-relation-status.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-relation-status.enum.js","sourceRoot":"","sources":["omni-relation-status.enum.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AAEnD,IAAY,kBAIX;AAJD,WAAY,kBAAkB;IAC5B,uCAAiB,CAAA;IACjB,2CAAqB,CAAA;IACrB,2CAAqB,CAAA;AACvB,CAAC,EAJW,kBAAkB,kCAAlB,kBAAkB,QAI7B;AAED,IAAA,0BAAgB,EAAC,kBAAkB,EAAE;IACnC,IAAI,EAAE,oBAAoB;CAC3B,CAAC,CAAC"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.omniRelationBackendProvidersFactory = void 0;
|
|
4
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
5
|
+
const omni_relation_entity_js_1 = require("./base/omni-relation.entity.js");
|
|
6
|
+
const omni_record_entity_js_1 = require("./base/omni-record.entity.js");
|
|
7
|
+
const omni_relation_kind_contract_js_1 = require("./omni-relation-kind.contract.js");
|
|
8
|
+
const omni_relation_service_js_1 = require("./omni-relation.service.js");
|
|
9
|
+
const omni_scoped_backend_js_1 = require("./omni-scoped.backend.js");
|
|
10
|
+
const omniRelationBackendProvidersFactory = (dbConnection) => (0, omni_scoped_backend_js_1.omniScopedBackendProvidersFactory)({
|
|
11
|
+
entityModel: omni_relation_entity_js_1.OmniRelationEntity,
|
|
12
|
+
dbConnection,
|
|
13
|
+
additionalInject: [(0, typeorm_1.getRepositoryToken)(omni_record_entity_js_1.OmniRecordEntity, dbConnection)],
|
|
14
|
+
createService: (repository, scope, options, recordRepository) => new omni_relation_service_js_1.OmniRelationService(repository, scope, options.deletion.relation, recordRepository, (0, omni_relation_kind_contract_js_1.createOmniRelationKindContract)(options.relationKinds)),
|
|
15
|
+
});
|
|
16
|
+
exports.omniRelationBackendProvidersFactory = omniRelationBackendProvidersFactory;
|
|
17
|
+
//# sourceMappingURL=omni-relation.backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-relation.backend.js","sourceRoot":"","sources":["omni-relation.backend.ts"],"names":[],"mappings":";;;AAAA,6CAAqD;AACrD,4EAAoE;AACpE,wEAAgE;AAChE,qFAAkF;AAClF,yEAAiE;AACjE,qEAA6E;AAEtE,MAAM,mCAAmC,GAAG,CAAC,YAAoB,EAAE,EAAE,CAC1E,IAAA,0DAAiC,EAAqB;IACpD,WAAW,EAAE,4CAAkB;IAC/B,YAAY;IACZ,gBAAgB,EAAE,CAAC,IAAA,4BAAkB,EAAC,wCAAgB,EAAE,YAAY,CAAC,CAAC;IACtE,aAAa,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAC9D,IAAI,8CAAmB,CACrB,UAAU,EACV,KAAK,EACL,OAAO,CAAC,QAAQ,CAAC,QAAQ,EACzB,gBAAyB,EACzB,IAAA,+DAA8B,EAAC,OAAO,CAAC,aAAa,CAAC,CACtD;CACJ,CAAC,CAAC;AAbQ,QAAA,mCAAmC,uCAa3C"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { getRepositoryToken } from '@nestjs/typeorm';
|
|
2
|
+
import { OmniRelationEntity } from './base/omni-relation.entity.js';
|
|
3
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
4
|
+
import { createOmniRelationKindContract } from './omni-relation-kind.contract.js';
|
|
5
|
+
import { OmniRelationService } from './omni-relation.service.js';
|
|
6
|
+
import { omniScopedBackendProvidersFactory } from './omni-scoped.backend.js';
|
|
7
|
+
|
|
8
|
+
export const omniRelationBackendProvidersFactory = (dbConnection: string) =>
|
|
9
|
+
omniScopedBackendProvidersFactory<OmniRelationEntity>({
|
|
10
|
+
entityModel: OmniRelationEntity,
|
|
11
|
+
dbConnection,
|
|
12
|
+
additionalInject: [getRepositoryToken(OmniRecordEntity, dbConnection)],
|
|
13
|
+
createService: (repository, scope, options, recordRepository) =>
|
|
14
|
+
new OmniRelationService(
|
|
15
|
+
repository,
|
|
16
|
+
scope,
|
|
17
|
+
options.deletion.relation,
|
|
18
|
+
recordRepository as never,
|
|
19
|
+
createOmniRelationKindContract(options.relationKinds),
|
|
20
|
+
),
|
|
21
|
+
});
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import type { Relation } from 'typeorm';
|
|
2
|
+
import { OmniRelationEntity } from './base/omni-relation.entity.js';
|
|
3
|
+
import { OmniRecordType } from './omni-record.dto.js';
|
|
4
|
+
import { OmniRelationStatus } from './omni-relation-status.enum.js';
|
|
5
|
+
export declare class OmniRelationType extends OmniRelationEntity {
|
|
6
|
+
constructor(data?: Partial<OmniRelationType>);
|
|
7
|
+
guid: string;
|
|
8
|
+
revision: number;
|
|
9
|
+
sourceRecordId: string;
|
|
10
|
+
sourceRecord: Relation<OmniRecordType>;
|
|
11
|
+
targetRecordId: string;
|
|
12
|
+
targetRecord: Relation<OmniRecordType>;
|
|
13
|
+
kind: string;
|
|
14
|
+
status: OmniRelationStatus;
|
|
15
|
+
payload?: Record<string, unknown> | null;
|
|
16
|
+
payloadSchemaId?: string | null;
|
|
17
|
+
payloadSchemaVersion?: number | null;
|
|
18
|
+
}
|
|
19
|
+
declare const OmniRelationCreateInput_base: import("@nestjs/common").Type<Omit<OmniRelationType, "revision" | "createdAt" | "updatedAt" | "sourceRecord" | "targetRecord">>;
|
|
20
|
+
export declare class OmniRelationCreateInput extends OmniRelationCreateInput_base {
|
|
21
|
+
}
|
|
22
|
+
declare const OmniRelationCondition_base: import("@nestjs/common").Type<Partial<OmniRelationCreateInput>>;
|
|
23
|
+
export declare class OmniRelationCondition extends OmniRelationCondition_base {
|
|
24
|
+
}
|
|
25
|
+
declare const OmniRelationUpdateInput_base: import("@nestjs/common").Type<Partial<OmniRelationCreateInput>>;
|
|
26
|
+
export declare class OmniRelationUpdateInput extends OmniRelationUpdateInput_base {
|
|
27
|
+
}
|
|
28
|
+
export {};
|
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OmniRelationUpdateInput = exports.OmniRelationCondition = exports.OmniRelationCreateInput = exports.OmniRelationType = void 0;
|
|
16
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
17
|
+
const object_decorator_js_1 = require("@nest-yalc-2/crud-gen/object.decorator.js");
|
|
18
|
+
const uuid_scalar_js_1 = require("@nest-yalc-2/graphql/scalars/uuid.scalar.js");
|
|
19
|
+
const returnValue_js_1 = __importDefault(require("@nest-yalc-2/utils/returnValue.js"));
|
|
20
|
+
const class_validator_1 = require("class-validator");
|
|
21
|
+
const graphql_type_json_1 = require("graphql-type-json");
|
|
22
|
+
const omni_record_entity_js_1 = require("./base/omni-record.entity.js");
|
|
23
|
+
const omni_relation_entity_js_1 = require("./base/omni-relation.entity.js");
|
|
24
|
+
const omni_dto_helpers_js_1 = require("./omni-dto.helpers.js");
|
|
25
|
+
const omni_record_dto_js_1 = require("./omni-record.dto.js");
|
|
26
|
+
const omni_relation_kind_contract_js_1 = require("./omni-relation-kind.contract.js");
|
|
27
|
+
const omni_relation_status_enum_js_1 = require("./omni-relation-status.enum.js");
|
|
28
|
+
let OmniRelationType = class OmniRelationType extends omni_relation_entity_js_1.OmniRelationEntity {
|
|
29
|
+
constructor(data) {
|
|
30
|
+
super();
|
|
31
|
+
if (data) {
|
|
32
|
+
(0, omni_dto_helpers_js_1.assignOmniPublicDto)(this, data);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
exports.OmniRelationType = OmniRelationType;
|
|
37
|
+
__decorate([
|
|
38
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(uuid_scalar_js_1.UUIDScalar), isRequired: true }),
|
|
39
|
+
(0, class_validator_1.IsUUID)(),
|
|
40
|
+
__metadata("design:type", String)
|
|
41
|
+
], OmniRelationType.prototype, "guid", void 0);
|
|
42
|
+
__decorate([
|
|
43
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(graphql_1.Int) }),
|
|
44
|
+
(0, class_validator_1.IsInt)(),
|
|
45
|
+
__metadata("design:type", Number)
|
|
46
|
+
], OmniRelationType.prototype, "revision", void 0);
|
|
47
|
+
__decorate([
|
|
48
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(uuid_scalar_js_1.UUIDScalar), isRequired: true }),
|
|
49
|
+
(0, class_validator_1.IsUUID)(),
|
|
50
|
+
__metadata("design:type", String)
|
|
51
|
+
], OmniRelationType.prototype, "sourceRecordId", void 0);
|
|
52
|
+
__decorate([
|
|
53
|
+
(0, object_decorator_js_1.ModelField)({
|
|
54
|
+
gqlType: () => omni_record_dto_js_1.OmniRecordType,
|
|
55
|
+
gqlOptions: { nullable: false },
|
|
56
|
+
relation: {
|
|
57
|
+
relationType: 'many-to-one',
|
|
58
|
+
sourceKey: { dst: 'sourceRecordId', alias: 'sourceRecordId' },
|
|
59
|
+
targetKey: { dst: 'guid', alias: 'guid' },
|
|
60
|
+
type: () => omni_record_entity_js_1.OmniRecordEntity,
|
|
61
|
+
},
|
|
62
|
+
}),
|
|
63
|
+
__metadata("design:type", Object)
|
|
64
|
+
], OmniRelationType.prototype, "sourceRecord", void 0);
|
|
65
|
+
__decorate([
|
|
66
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(uuid_scalar_js_1.UUIDScalar), isRequired: true }),
|
|
67
|
+
(0, class_validator_1.IsUUID)(),
|
|
68
|
+
__metadata("design:type", String)
|
|
69
|
+
], OmniRelationType.prototype, "targetRecordId", void 0);
|
|
70
|
+
__decorate([
|
|
71
|
+
(0, object_decorator_js_1.ModelField)({
|
|
72
|
+
gqlType: () => omni_record_dto_js_1.OmniRecordType,
|
|
73
|
+
gqlOptions: { nullable: false },
|
|
74
|
+
relation: {
|
|
75
|
+
relationType: 'many-to-one',
|
|
76
|
+
sourceKey: { dst: 'targetRecordId', alias: 'targetRecordId' },
|
|
77
|
+
targetKey: { dst: 'guid', alias: 'guid' },
|
|
78
|
+
type: () => omni_record_entity_js_1.OmniRecordEntity,
|
|
79
|
+
},
|
|
80
|
+
}),
|
|
81
|
+
__metadata("design:type", Object)
|
|
82
|
+
], OmniRelationType.prototype, "targetRecord", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(String) }),
|
|
85
|
+
(0, class_validator_1.IsString)(),
|
|
86
|
+
(0, class_validator_1.Matches)(omni_relation_kind_contract_js_1.omniRelationKindPattern),
|
|
87
|
+
__metadata("design:type", String)
|
|
88
|
+
], OmniRelationType.prototype, "kind", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(omni_relation_status_enum_js_1.OmniRelationStatus) }),
|
|
91
|
+
(0, class_validator_1.IsEnum)(omni_relation_status_enum_js_1.OmniRelationStatus),
|
|
92
|
+
__metadata("design:type", String)
|
|
93
|
+
], OmniRelationType.prototype, "status", void 0);
|
|
94
|
+
__decorate([
|
|
95
|
+
(0, object_decorator_js_1.ModelField)({
|
|
96
|
+
gqlType: (0, returnValue_js_1.default)(graphql_type_json_1.GraphQLJSONObject),
|
|
97
|
+
gqlOptions: { nullable: true },
|
|
98
|
+
}),
|
|
99
|
+
(0, class_validator_1.IsOptional)(),
|
|
100
|
+
(0, class_validator_1.IsObject)(),
|
|
101
|
+
__metadata("design:type", Object)
|
|
102
|
+
], OmniRelationType.prototype, "payload", void 0);
|
|
103
|
+
__decorate([
|
|
104
|
+
(0, object_decorator_js_1.ModelField)({
|
|
105
|
+
gqlType: (0, returnValue_js_1.default)(String),
|
|
106
|
+
gqlOptions: { nullable: true },
|
|
107
|
+
}),
|
|
108
|
+
(0, class_validator_1.IsOptional)(),
|
|
109
|
+
(0, class_validator_1.IsString)(),
|
|
110
|
+
__metadata("design:type", Object)
|
|
111
|
+
], OmniRelationType.prototype, "payloadSchemaId", void 0);
|
|
112
|
+
__decorate([
|
|
113
|
+
(0, object_decorator_js_1.ModelField)({
|
|
114
|
+
gqlType: (0, returnValue_js_1.default)(graphql_1.Int),
|
|
115
|
+
gqlOptions: { nullable: true },
|
|
116
|
+
}),
|
|
117
|
+
(0, class_validator_1.IsOptional)(),
|
|
118
|
+
(0, class_validator_1.IsInt)(),
|
|
119
|
+
__metadata("design:type", Object)
|
|
120
|
+
], OmniRelationType.prototype, "payloadSchemaVersion", void 0);
|
|
121
|
+
exports.OmniRelationType = OmniRelationType = __decorate([
|
|
122
|
+
(0, graphql_1.ObjectType)(),
|
|
123
|
+
(0, object_decorator_js_1.ModelObject)(),
|
|
124
|
+
__metadata("design:paramtypes", [Object])
|
|
125
|
+
], OmniRelationType);
|
|
126
|
+
let OmniRelationCreateInput = class OmniRelationCreateInput extends (0, graphql_1.OmitType)(OmniRelationType, [
|
|
127
|
+
'createdAt',
|
|
128
|
+
'updatedAt',
|
|
129
|
+
'revision',
|
|
130
|
+
'sourceRecord',
|
|
131
|
+
'targetRecord',
|
|
132
|
+
], graphql_1.InputType) {
|
|
133
|
+
};
|
|
134
|
+
exports.OmniRelationCreateInput = OmniRelationCreateInput;
|
|
135
|
+
exports.OmniRelationCreateInput = OmniRelationCreateInput = __decorate([
|
|
136
|
+
(0, graphql_1.InputType)(),
|
|
137
|
+
(0, object_decorator_js_1.ModelObject)()
|
|
138
|
+
], OmniRelationCreateInput);
|
|
139
|
+
let OmniRelationCondition = class OmniRelationCondition extends (0, graphql_1.PartialType)(OmniRelationCreateInput, graphql_1.InputType) {
|
|
140
|
+
};
|
|
141
|
+
exports.OmniRelationCondition = OmniRelationCondition;
|
|
142
|
+
exports.OmniRelationCondition = OmniRelationCondition = __decorate([
|
|
143
|
+
(0, graphql_1.InputType)(),
|
|
144
|
+
(0, object_decorator_js_1.ModelObject)({ copyFrom: OmniRelationType })
|
|
145
|
+
], OmniRelationCondition);
|
|
146
|
+
let OmniRelationUpdateInput = class OmniRelationUpdateInput extends (0, graphql_1.PartialType)(OmniRelationCreateInput, graphql_1.InputType) {
|
|
147
|
+
};
|
|
148
|
+
exports.OmniRelationUpdateInput = OmniRelationUpdateInput;
|
|
149
|
+
exports.OmniRelationUpdateInput = OmniRelationUpdateInput = __decorate([
|
|
150
|
+
(0, graphql_1.InputType)(),
|
|
151
|
+
(0, object_decorator_js_1.ModelObject)({ copyFrom: OmniRelationType })
|
|
152
|
+
], OmniRelationUpdateInput);
|
|
153
|
+
//# sourceMappingURL=omni-relation.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-relation.dto.js","sourceRoot":"","sources":["omni-relation.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAMyB;AACzB,mFA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nestjs/graphql';
|
|
8
|
+
import {
|
|
9
|
+
ModelField,
|
|
10
|
+
ModelObject,
|
|
11
|
+
} from '@nest-yalc-2/crud-gen/object.decorator.js';
|
|
12
|
+
import { UUIDScalar } from '@nest-yalc-2/graphql/scalars/uuid.scalar.js';
|
|
13
|
+
import returnValue from '@nest-yalc-2/utils/returnValue.js';
|
|
14
|
+
import {
|
|
15
|
+
IsEnum,
|
|
16
|
+
IsInt,
|
|
17
|
+
IsObject,
|
|
18
|
+
IsOptional,
|
|
19
|
+
IsString,
|
|
20
|
+
IsUUID,
|
|
21
|
+
Matches,
|
|
22
|
+
} from 'class-validator';
|
|
23
|
+
import { GraphQLJSONObject } from 'graphql-type-json';
|
|
24
|
+
import type { Relation } from 'typeorm';
|
|
25
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
26
|
+
import { OmniRelationEntity } from './base/omni-relation.entity.js';
|
|
27
|
+
import { assignOmniPublicDto } from './omni-dto.helpers.js';
|
|
28
|
+
import { OmniRecordType } from './omni-record.dto.js';
|
|
29
|
+
import { omniRelationKindPattern } from './omni-relation-kind.contract.js';
|
|
30
|
+
import { OmniRelationStatus } from './omni-relation-status.enum.js';
|
|
31
|
+
|
|
32
|
+
@ObjectType()
|
|
33
|
+
@ModelObject()
|
|
34
|
+
export class OmniRelationType extends OmniRelationEntity {
|
|
35
|
+
constructor(data?: Partial<OmniRelationType>) {
|
|
36
|
+
super();
|
|
37
|
+
if (data) {
|
|
38
|
+
assignOmniPublicDto(this, data);
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
@ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
|
|
43
|
+
@IsUUID()
|
|
44
|
+
guid!: string;
|
|
45
|
+
|
|
46
|
+
@ModelField({ gqlType: returnValue(Int) })
|
|
47
|
+
@IsInt()
|
|
48
|
+
revision!: number;
|
|
49
|
+
|
|
50
|
+
@ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
|
|
51
|
+
@IsUUID()
|
|
52
|
+
sourceRecordId!: string;
|
|
53
|
+
|
|
54
|
+
@ModelField({
|
|
55
|
+
gqlType: () => OmniRecordType,
|
|
56
|
+
gqlOptions: { nullable: false },
|
|
57
|
+
relation: {
|
|
58
|
+
relationType: 'many-to-one',
|
|
59
|
+
sourceKey: { dst: 'sourceRecordId', alias: 'sourceRecordId' },
|
|
60
|
+
targetKey: { dst: 'guid', alias: 'guid' },
|
|
61
|
+
type: () => OmniRecordEntity,
|
|
62
|
+
},
|
|
63
|
+
})
|
|
64
|
+
sourceRecord!: Relation<OmniRecordType>;
|
|
65
|
+
|
|
66
|
+
@ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
|
|
67
|
+
@IsUUID()
|
|
68
|
+
targetRecordId!: string;
|
|
69
|
+
|
|
70
|
+
@ModelField({
|
|
71
|
+
gqlType: () => OmniRecordType,
|
|
72
|
+
gqlOptions: { nullable: false },
|
|
73
|
+
relation: {
|
|
74
|
+
relationType: 'many-to-one',
|
|
75
|
+
sourceKey: { dst: 'targetRecordId', alias: 'targetRecordId' },
|
|
76
|
+
targetKey: { dst: 'guid', alias: 'guid' },
|
|
77
|
+
type: () => OmniRecordEntity,
|
|
78
|
+
},
|
|
79
|
+
})
|
|
80
|
+
targetRecord!: Relation<OmniRecordType>;
|
|
81
|
+
|
|
82
|
+
@ModelField({ gqlType: returnValue(String) })
|
|
83
|
+
@IsString()
|
|
84
|
+
@Matches(omniRelationKindPattern)
|
|
85
|
+
kind!: string;
|
|
86
|
+
|
|
87
|
+
@ModelField({ gqlType: returnValue(OmniRelationStatus) })
|
|
88
|
+
@IsEnum(OmniRelationStatus)
|
|
89
|
+
status!: OmniRelationStatus;
|
|
90
|
+
|
|
91
|
+
@ModelField({
|
|
92
|
+
gqlType: returnValue(GraphQLJSONObject),
|
|
93
|
+
gqlOptions: { nullable: true },
|
|
94
|
+
})
|
|
95
|
+
@IsOptional()
|
|
96
|
+
@IsObject()
|
|
97
|
+
payload?: Record<string, unknown> | null;
|
|
98
|
+
|
|
99
|
+
@ModelField({
|
|
100
|
+
gqlType: returnValue(String),
|
|
101
|
+
gqlOptions: { nullable: true },
|
|
102
|
+
})
|
|
103
|
+
@IsOptional()
|
|
104
|
+
@IsString()
|
|
105
|
+
payloadSchemaId?: string | null;
|
|
106
|
+
|
|
107
|
+
@ModelField({
|
|
108
|
+
gqlType: returnValue(Int),
|
|
109
|
+
gqlOptions: { nullable: true },
|
|
110
|
+
})
|
|
111
|
+
@IsOptional()
|
|
112
|
+
@IsInt()
|
|
113
|
+
payloadSchemaVersion?: number | null;
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
@InputType()
|
|
117
|
+
@ModelObject()
|
|
118
|
+
export class OmniRelationCreateInput extends OmitType(
|
|
119
|
+
OmniRelationType,
|
|
120
|
+
[
|
|
121
|
+
'createdAt',
|
|
122
|
+
'updatedAt',
|
|
123
|
+
'revision',
|
|
124
|
+
'sourceRecord',
|
|
125
|
+
'targetRecord',
|
|
126
|
+
] as const,
|
|
127
|
+
InputType,
|
|
128
|
+
) {}
|
|
129
|
+
|
|
130
|
+
@InputType()
|
|
131
|
+
@ModelObject({ copyFrom: OmniRelationType })
|
|
132
|
+
export class OmniRelationCondition extends PartialType(
|
|
133
|
+
OmniRelationCreateInput,
|
|
134
|
+
InputType,
|
|
135
|
+
) {}
|
|
136
|
+
|
|
137
|
+
@InputType()
|
|
138
|
+
@ModelObject({ copyFrom: OmniRelationType })
|
|
139
|
+
export class OmniRelationUpdateInput extends PartialType(
|
|
140
|
+
OmniRelationCreateInput,
|
|
141
|
+
InputType,
|
|
142
|
+
) {}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { CrudGenFindManyOptions } from '@nest-yalc-2/crud-gen/api-graphql/crud-gen-gql.interface.js';
|
|
2
|
+
import { type DeepPartial, type FindOptionsWhere, type Repository } from 'typeorm';
|
|
3
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
4
|
+
import { OmniRelationEntity } from './base/omni-relation.entity.js';
|
|
5
|
+
import { type OmniRelationKindContract } from './omni-relation-kind.contract.js';
|
|
6
|
+
import type { OmniDeletePolicy, OmniScope } from './omni-scope.js';
|
|
7
|
+
import { OmniScopedService } from './omni-scoped.service.js';
|
|
8
|
+
export declare class OmniRelationService extends OmniScopedService<OmniRelationEntity> {
|
|
9
|
+
protected readonly recordRepository: Repository<OmniRecordEntity>;
|
|
10
|
+
protected readonly kinds: OmniRelationKindContract;
|
|
11
|
+
constructor(repository: any, scope: OmniScope, deletion: OmniDeletePolicy, recordRepository: Repository<OmniRecordEntity>, kinds: OmniRelationKindContract);
|
|
12
|
+
createEntity(input: DeepPartial<OmniRelationEntity>, findOptions?: CrudGenFindManyOptions<OmniRelationEntity>, returnEntity?: true): Promise<OmniRelationEntity>;
|
|
13
|
+
createEntity(input: DeepPartial<OmniRelationEntity>, findOptions?: CrudGenFindManyOptions<OmniRelationEntity>, returnEntity?: boolean): Promise<OmniRelationEntity | boolean>;
|
|
14
|
+
updateEntity(conditions: FindOptionsWhere<OmniRelationEntity>, input: DeepPartial<OmniRelationEntity>, findOptions?: CrudGenFindManyOptions<OmniRelationEntity>, returnEntity?: true): Promise<OmniRelationEntity>;
|
|
15
|
+
updateEntity(conditions: FindOptionsWhere<OmniRelationEntity>, input: DeepPartial<OmniRelationEntity>, findOptions?: CrudGenFindManyOptions<OmniRelationEntity>, returnEntity?: boolean): Promise<OmniRelationEntity | boolean>;
|
|
16
|
+
protected assertRelation(input: DeepPartial<OmniRelationEntity>, recordRepository?: Repository<OmniRecordEntity>): Promise<void>;
|
|
17
|
+
protected assertEndpointKinds(_source: OmniRecordEntity, _target: OmniRecordEntity): void;
|
|
18
|
+
protected requiredIdentifier(value: unknown, field: string): string;
|
|
19
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmniRelationService = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const omni_relation_kind_contract_js_1 = require("./omni-relation-kind.contract.js");
|
|
7
|
+
const omni_relation_semantics_js_1 = require("./omni-relation-semantics.js");
|
|
8
|
+
const omni_scoped_service_js_1 = require("./omni-scoped.service.js");
|
|
9
|
+
class OmniRelationService extends omni_scoped_service_js_1.OmniScopedService {
|
|
10
|
+
constructor(repository, scope, deletion, recordRepository, kinds) {
|
|
11
|
+
super(repository, scope, deletion);
|
|
12
|
+
this.recordRepository = recordRepository;
|
|
13
|
+
this.kinds = kinds;
|
|
14
|
+
}
|
|
15
|
+
async createEntity(input, findOptions, returnEntity = true) {
|
|
16
|
+
this.rejectServerFields(input);
|
|
17
|
+
await this.assertRelation(input);
|
|
18
|
+
return super.createEntity(input, findOptions, returnEntity);
|
|
19
|
+
}
|
|
20
|
+
async updateEntity(conditions, input, findOptions, returnEntity = true) {
|
|
21
|
+
for (const field of ['guid', 'sourceRecordId', 'targetRecordId']) {
|
|
22
|
+
if (Object.prototype.hasOwnProperty.call(input, field)) {
|
|
23
|
+
throw new common_1.BadRequestException(`Omni relation ${field} is immutable.`);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
const current = await super.getEntity(conditions, undefined, undefined, undefined, {
|
|
27
|
+
failOnNull: true,
|
|
28
|
+
});
|
|
29
|
+
if (!current)
|
|
30
|
+
this.notFound();
|
|
31
|
+
await this.assertRelation({ ...current, ...input });
|
|
32
|
+
return super.updateEntity(conditions, input, findOptions, returnEntity);
|
|
33
|
+
}
|
|
34
|
+
async assertRelation(input, recordRepository = this.recordRepository) {
|
|
35
|
+
const sourceRecordId = this.requiredIdentifier(input.sourceRecordId, 'sourceRecordId');
|
|
36
|
+
const targetRecordId = this.requiredIdentifier(input.targetRecordId, 'targetRecordId');
|
|
37
|
+
const kind = this.requiredIdentifier(input.kind, 'kind');
|
|
38
|
+
try {
|
|
39
|
+
this.kinds.assert(kind);
|
|
40
|
+
}
|
|
41
|
+
catch (error) {
|
|
42
|
+
throw new common_1.BadRequestException(error instanceof Error
|
|
43
|
+
? error.message
|
|
44
|
+
: 'Omni relation kind is invalid.');
|
|
45
|
+
}
|
|
46
|
+
const records = await recordRepository.find({
|
|
47
|
+
where: [
|
|
48
|
+
{ scopeId: this.scopeId, guid: sourceRecordId, deletedAt: (0, typeorm_1.IsNull)() },
|
|
49
|
+
{ scopeId: this.scopeId, guid: targetRecordId, deletedAt: (0, typeorm_1.IsNull)() },
|
|
50
|
+
],
|
|
51
|
+
});
|
|
52
|
+
const source = records.find((record) => record.guid === sourceRecordId);
|
|
53
|
+
const target = records.find((record) => record.guid === targetRecordId);
|
|
54
|
+
if (!source || !target)
|
|
55
|
+
this.notFound();
|
|
56
|
+
this.assertEndpointKinds(source, target);
|
|
57
|
+
const isCanonical = omni_relation_kind_contract_js_1.canonicalOmniRelationKinds.includes(kind);
|
|
58
|
+
if (isCanonical &&
|
|
59
|
+
!(0, omni_relation_semantics_js_1.isAllowedOmniRelation)({
|
|
60
|
+
sourceKind: source.kind,
|
|
61
|
+
targetKind: target.kind,
|
|
62
|
+
relationKind: kind,
|
|
63
|
+
})) {
|
|
64
|
+
throw new common_1.BadRequestException('Omni relation kind is not valid for these endpoint kinds.');
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
assertEndpointKinds(_source, _target) { }
|
|
68
|
+
requiredIdentifier(value, field) {
|
|
69
|
+
if (typeof value !== 'string' || value.trim().length === 0) {
|
|
70
|
+
throw new common_1.BadRequestException(`Omni relation ${field} must be a non-empty string.`);
|
|
71
|
+
}
|
|
72
|
+
return value;
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
exports.OmniRelationService = OmniRelationService;
|
|
76
|
+
//# sourceMappingURL=omni-relation.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-relation.service.js","sourceRoot":"","sources":["omni-relation.service.ts"],"names":[],"mappings":";;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