@nest-yalc-2/omnikernel-module 2.2.0 → 2.2.2
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/package.json +30 -17
- package/src/base/omni-base.entity.js +42 -0
- package/src/base/omni-base.entity.js.map +1 -0
- package/src/base/omni-external-ref.entity.js +61 -0
- package/src/base/omni-external-ref.entity.js.map +1 -0
- package/src/base/omni-named.entity.js +24 -0
- package/src/base/omni-named.entity.js.map +1 -0
- package/src/base/omni-record.entity.js +60 -0
- package/src/base/omni-record.entity.js.map +1 -0
- package/src/base/omni-relation.entity.js +80 -0
- package/src/base/omni-relation.entity.js.map +1 -0
- package/src/index.js +50 -0
- package/src/index.js.map +1 -0
- package/src/omni-collection-kind.enum.js +10 -0
- package/src/omni-collection-kind.enum.js.map +1 -0
- package/src/omni-collection.backend.js +11 -0
- package/src/omni-collection.backend.js.map +1 -0
- package/{dist/src → src}/omni-collection.dto.d.ts +1 -1
- package/src/omni-collection.dto.js +170 -0
- package/src/omni-collection.dto.js.map +1 -0
- package/{dist/src → src}/omni-collection.dto.ts +1 -1
- package/src/omni-collection.entity.js +30 -0
- package/src/omni-collection.entity.js.map +1 -0
- package/{dist/src → src}/omni-collection.service.js +4 -8
- package/src/omni-collection.service.js.map +1 -0
- package/src/omni-document-kind.enum.js +12 -0
- package/src/omni-document-kind.enum.js.map +1 -0
- package/src/omni-document.backend.js +11 -0
- package/src/omni-document.backend.js.map +1 -0
- package/{dist/src → src}/omni-document.dto.d.ts +1 -1
- package/src/omni-document.dto.js +199 -0
- package/src/omni-document.dto.js.map +1 -0
- package/{dist/src → src}/omni-document.dto.ts +1 -1
- package/src/omni-document.entity.js +42 -0
- package/src/omni-document.entity.js.map +1 -0
- package/{dist/src → src}/omni-document.service.js +4 -8
- package/src/omni-document.service.js.map +1 -0
- package/src/omni-dto.helpers.js +7 -0
- package/src/omni-dto.helpers.js.map +1 -0
- package/{dist/src → src}/omni-extension-projection.definition.js +24 -29
- package/src/omni-extension-projection.definition.js.map +1 -0
- package/{dist/src → src}/omni-extension-projection.resource.d.ts +1 -1
- package/src/omni-extension-projection.resource.js +124 -0
- package/src/omni-extension-projection.resource.js.map +1 -0
- package/{dist/src → src}/omni-extension-projection.resource.ts +1 -1
- package/{dist/src → src}/omni-extension-projection.service.js +15 -19
- package/src/omni-extension-projection.service.js.map +1 -0
- package/src/omni-external-ref-binding.validator.js +30 -0
- package/src/omni-external-ref-binding.validator.js.map +1 -0
- package/src/omni-external-ref-internal-type.enum.js +11 -0
- package/src/omni-external-ref-internal-type.enum.js.map +1 -0
- package/src/omni-external-ref.backend.js +15 -0
- package/src/omni-external-ref.backend.js.map +1 -0
- package/{dist/src → src}/omni-external-ref.dto.d.ts +1 -1
- package/src/omni-external-ref.dto.js +126 -0
- package/src/omni-external-ref.dto.js.map +1 -0
- package/{dist/src → src}/omni-external-ref.dto.ts +1 -1
- package/{dist/src → src}/omni-external-ref.service.js +11 -15
- package/src/omni-external-ref.service.js.map +1 -0
- package/{dist/src → src}/omni-migration.js +22 -27
- package/src/omni-migration.js.map +1 -0
- package/src/omni-named.backend.js +9 -0
- package/src/omni-named.backend.js.map +1 -0
- package/{dist/src → src}/omni-named.dto.d.ts +1 -1
- package/src/omni-named.dto.js +80 -0
- package/src/omni-named.dto.js.map +1 -0
- package/{dist/src → src}/omni-named.dto.ts +1 -1
- package/{dist/src → src}/omni-projection.catalog.js +18 -23
- package/src/omni-projection.catalog.js.map +1 -0
- package/src/omni-projection.lifecycle.js +2 -0
- package/src/omni-record-status.enum.js +11 -0
- package/src/omni-record-status.enum.js.map +1 -0
- package/src/omni-record.backend.js +9 -0
- package/src/omni-record.backend.js.map +1 -0
- package/{dist/src → src}/omni-record.dto.d.ts +1 -1
- package/src/omni-record.dto.js +155 -0
- package/src/omni-record.dto.js.map +1 -0
- package/{dist/src → src}/omni-record.dto.ts +1 -1
- package/{dist/src → src}/omni-record.service.js +6 -10
- package/src/omni-record.service.js.map +1 -0
- package/src/omni-relation-kind.contract.js +29 -0
- package/src/omni-relation-kind.contract.js.map +1 -0
- package/src/omni-relation-kind.enum.js +12 -0
- package/src/omni-relation-kind.enum.js.map +1 -0
- package/{dist/src → src}/omni-relation-projection.definition.js +7 -12
- package/src/omni-relation-projection.definition.js.map +1 -0
- package/{dist/src → src}/omni-relation-projection.resource.d.ts +1 -1
- package/src/omni-relation-projection.resource.js +196 -0
- package/src/omni-relation-projection.resource.js.map +1 -0
- package/{dist/src → src}/omni-relation-projection.resource.ts +2 -2
- package/{dist/src → src}/omni-relation-projection.service.js +44 -48
- package/src/omni-relation-projection.service.js.map +1 -0
- package/src/omni-relation-semantics.js +27 -0
- package/src/omni-relation-semantics.js.map +1 -0
- package/src/omni-relation-status.enum.js +11 -0
- package/src/omni-relation-status.enum.js.map +1 -0
- package/src/omni-relation.backend.js +13 -0
- package/src/omni-relation.backend.js.map +1 -0
- package/{dist/src → src}/omni-relation.dto.d.ts +1 -1
- package/src/omni-relation.dto.js +139 -0
- package/src/omni-relation.dto.js.map +1 -0
- package/{dist/src → src}/omni-relation.dto.ts +1 -1
- package/{dist/src → src}/omni-relation.service.js +14 -18
- package/src/omni-relation.service.js.map +1 -0
- package/{dist/src → src}/omni-scope.js +14 -18
- package/src/omni-scope.js.map +1 -0
- package/{dist/src → src}/omni-scoped.backend.d.ts +1 -1
- package/src/omni-scoped.backend.js +43 -0
- package/src/omni-scoped.backend.js.map +1 -0
- package/{dist/src → src}/omni-scoped.backend.ts +1 -1
- package/{dist/src → src}/omni-scoped.repository.js +1 -5
- package/src/omni-scoped.repository.js.map +1 -0
- package/{dist/src → src}/omni-scoped.service.js +17 -21
- package/src/omni-scoped.service.js.map +1 -0
- package/{dist/src → src}/omnikernel.diagnostics.js +1 -4
- package/src/omnikernel.diagnostics.js.map +1 -0
- package/src/omnikernel.module.js +79 -0
- package/src/omnikernel.module.js.map +1 -0
- package/src/omnikernel.query.service.js +80 -0
- package/src/omnikernel.query.service.js.map +1 -0
- package/dist/src/base/omni-base.entity.js +0 -45
- package/dist/src/base/omni-base.entity.js.map +0 -1
- package/dist/src/base/omni-external-ref.entity.js +0 -64
- package/dist/src/base/omni-external-ref.entity.js.map +0 -1
- package/dist/src/base/omni-named.entity.js +0 -27
- package/dist/src/base/omni-named.entity.js.map +0 -1
- package/dist/src/base/omni-record.entity.js +0 -63
- package/dist/src/base/omni-record.entity.js.map +0 -1
- package/dist/src/base/omni-relation.entity.js +0 -83
- package/dist/src/base/omni-relation.entity.js.map +0 -1
- package/dist/src/index.js +0 -53
- package/dist/src/index.js.map +0 -1
- package/dist/src/omni-collection-kind.enum.js +0 -13
- package/dist/src/omni-collection-kind.enum.js.map +0 -1
- package/dist/src/omni-collection.backend.js +0 -15
- package/dist/src/omni-collection.backend.js.map +0 -1
- package/dist/src/omni-collection.dto.js +0 -173
- package/dist/src/omni-collection.dto.js.map +0 -1
- package/dist/src/omni-collection.entity.js +0 -33
- package/dist/src/omni-collection.entity.js.map +0 -1
- package/dist/src/omni-collection.service.js.map +0 -1
- package/dist/src/omni-document-kind.enum.js +0 -15
- package/dist/src/omni-document-kind.enum.js.map +0 -1
- package/dist/src/omni-document.backend.js +0 -15
- package/dist/src/omni-document.backend.js.map +0 -1
- package/dist/src/omni-document.dto.js +0 -202
- package/dist/src/omni-document.dto.js.map +0 -1
- package/dist/src/omni-document.entity.js +0 -45
- package/dist/src/omni-document.entity.js.map +0 -1
- package/dist/src/omni-document.service.js.map +0 -1
- package/dist/src/omni-dto.helpers.js +0 -10
- package/dist/src/omni-dto.helpers.js.map +0 -1
- package/dist/src/omni-extension-projection.definition.js.map +0 -1
- package/dist/src/omni-extension-projection.resource.js +0 -127
- package/dist/src/omni-extension-projection.resource.js.map +0 -1
- package/dist/src/omni-extension-projection.service.js.map +0 -1
- package/dist/src/omni-external-ref-binding.validator.js +0 -34
- package/dist/src/omni-external-ref-binding.validator.js.map +0 -1
- package/dist/src/omni-external-ref-internal-type.enum.js +0 -14
- package/dist/src/omni-external-ref-internal-type.enum.js.map +0 -1
- package/dist/src/omni-external-ref.backend.js +0 -19
- package/dist/src/omni-external-ref.backend.js.map +0 -1
- package/dist/src/omni-external-ref.dto.js +0 -129
- package/dist/src/omni-external-ref.dto.js.map +0 -1
- package/dist/src/omni-external-ref.service.js.map +0 -1
- package/dist/src/omni-migration.js.map +0 -1
- package/dist/src/omni-named.backend.js +0 -13
- package/dist/src/omni-named.backend.js.map +0 -1
- package/dist/src/omni-named.dto.js +0 -83
- package/dist/src/omni-named.dto.js.map +0 -1
- package/dist/src/omni-projection.catalog.js.map +0 -1
- package/dist/src/omni-projection.lifecycle.js +0 -3
- package/dist/src/omni-record-status.enum.js +0 -14
- package/dist/src/omni-record-status.enum.js.map +0 -1
- package/dist/src/omni-record.backend.js +0 -13
- package/dist/src/omni-record.backend.js.map +0 -1
- package/dist/src/omni-record.dto.js +0 -158
- package/dist/src/omni-record.dto.js.map +0 -1
- package/dist/src/omni-record.service.js.map +0 -1
- package/dist/src/omni-relation-kind.contract.js +0 -33
- package/dist/src/omni-relation-kind.contract.js.map +0 -1
- package/dist/src/omni-relation-kind.enum.js +0 -15
- package/dist/src/omni-relation-kind.enum.js.map +0 -1
- package/dist/src/omni-relation-projection.definition.js.map +0 -1
- package/dist/src/omni-relation-projection.resource.js +0 -201
- package/dist/src/omni-relation-projection.resource.js.map +0 -1
- package/dist/src/omni-relation-projection.service.js.map +0 -1
- package/dist/src/omni-relation-semantics.js +0 -34
- package/dist/src/omni-relation-semantics.js.map +0 -1
- package/dist/src/omni-relation-status.enum.js +0 -14
- package/dist/src/omni-relation-status.enum.js.map +0 -1
- package/dist/src/omni-relation.backend.js +0 -17
- package/dist/src/omni-relation.backend.js.map +0 -1
- package/dist/src/omni-relation.dto.js +0 -142
- package/dist/src/omni-relation.dto.js.map +0 -1
- package/dist/src/omni-relation.service.js.map +0 -1
- package/dist/src/omni-scope.js.map +0 -1
- package/dist/src/omni-scoped.backend.js +0 -47
- package/dist/src/omni-scoped.backend.js.map +0 -1
- package/dist/src/omni-scoped.repository.js.map +0 -1
- package/dist/src/omni-scoped.service.js.map +0 -1
- package/dist/src/omnikernel.diagnostics.js.map +0 -1
- package/dist/src/omnikernel.module.js +0 -82
- package/dist/src/omnikernel.module.js.map +0 -1
- package/dist/src/omnikernel.query.service.js +0 -85
- package/dist/src/omnikernel.query.service.js.map +0 -1
- /package/{dist/src → src}/__tests__/omni-collection.entity.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-collection.service.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-document.entity.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-document.service.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-extension-projection-constraints.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-extension-projection.registration.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-extension-projection.service.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-external-ref.entity.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-external-ref.service.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-named.entity.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-record.entity.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-record.service.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-relation-semantics.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-relation.entity.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-scope-substrate.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-scoped.backend.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omni-scoped.service.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omnikernel.diagnostics.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omnikernel.module.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omnikernel.persistence.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omnikernel.public-api.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/omnikernel.query.service.spec.ts +0 -0
- /package/{dist/src → src}/__tests__/tsconfig.json +0 -0
- /package/{dist/src → src}/base/omni-base.entity.d.ts +0 -0
- /package/{dist/src → src}/base/omni-base.entity.ts +0 -0
- /package/{dist/src → src}/base/omni-external-ref.entity.d.ts +0 -0
- /package/{dist/src → src}/base/omni-external-ref.entity.ts +0 -0
- /package/{dist/src → src}/base/omni-named.entity.d.ts +0 -0
- /package/{dist/src → src}/base/omni-named.entity.ts +0 -0
- /package/{dist/src → src}/base/omni-record.entity.d.ts +0 -0
- /package/{dist/src → src}/base/omni-record.entity.ts +0 -0
- /package/{dist/src → src}/base/omni-relation.entity.d.ts +0 -0
- /package/{dist/src → src}/base/omni-relation.entity.ts +0 -0
- /package/{dist/src → src}/index.d.ts +0 -0
- /package/{dist/src → src}/index.ts +0 -0
- /package/{dist/src → src}/omni-collection-kind.enum.d.ts +0 -0
- /package/{dist/src → src}/omni-collection-kind.enum.ts +0 -0
- /package/{dist/src → src}/omni-collection.backend.d.ts +0 -0
- /package/{dist/src → src}/omni-collection.backend.ts +0 -0
- /package/{dist/src → src}/omni-collection.entity.d.ts +0 -0
- /package/{dist/src → src}/omni-collection.entity.ts +0 -0
- /package/{dist/src → src}/omni-collection.service.d.ts +0 -0
- /package/{dist/src → src}/omni-collection.service.ts +0 -0
- /package/{dist/src → src}/omni-document-kind.enum.d.ts +0 -0
- /package/{dist/src → src}/omni-document-kind.enum.ts +0 -0
- /package/{dist/src → src}/omni-document.backend.d.ts +0 -0
- /package/{dist/src → src}/omni-document.backend.ts +0 -0
- /package/{dist/src → src}/omni-document.entity.d.ts +0 -0
- /package/{dist/src → src}/omni-document.entity.ts +0 -0
- /package/{dist/src → src}/omni-document.service.d.ts +0 -0
- /package/{dist/src → src}/omni-document.service.ts +0 -0
- /package/{dist/src → src}/omni-dto.helpers.d.ts +0 -0
- /package/{dist/src → src}/omni-dto.helpers.ts +0 -0
- /package/{dist/src → src}/omni-extension-projection.definition.d.ts +0 -0
- /package/{dist/src → src}/omni-extension-projection.definition.ts +0 -0
- /package/{dist/src → src}/omni-extension-projection.service.d.ts +0 -0
- /package/{dist/src → src}/omni-extension-projection.service.ts +0 -0
- /package/{dist/src → src}/omni-external-ref-binding.validator.d.ts +0 -0
- /package/{dist/src → src}/omni-external-ref-binding.validator.ts +0 -0
- /package/{dist/src → src}/omni-external-ref-internal-type.enum.d.ts +0 -0
- /package/{dist/src → src}/omni-external-ref-internal-type.enum.ts +0 -0
- /package/{dist/src → src}/omni-external-ref.backend.d.ts +0 -0
- /package/{dist/src → src}/omni-external-ref.backend.ts +0 -0
- /package/{dist/src → src}/omni-external-ref.service.d.ts +0 -0
- /package/{dist/src → src}/omni-external-ref.service.ts +0 -0
- /package/{dist/src → src}/omni-migration.d.ts +0 -0
- /package/{dist/src → src}/omni-migration.ts +0 -0
- /package/{dist/src → src}/omni-named.backend.d.ts +0 -0
- /package/{dist/src → src}/omni-named.backend.ts +0 -0
- /package/{dist/src → src}/omni-projection.catalog.d.ts +0 -0
- /package/{dist/src → src}/omni-projection.catalog.ts +0 -0
- /package/{dist/src → src}/omni-projection.lifecycle.d.ts +0 -0
- /package/{dist/src → src}/omni-projection.lifecycle.js.map +0 -0
- /package/{dist/src → src}/omni-projection.lifecycle.ts +0 -0
- /package/{dist/src → src}/omni-record-status.enum.d.ts +0 -0
- /package/{dist/src → src}/omni-record-status.enum.ts +0 -0
- /package/{dist/src → src}/omni-record.backend.d.ts +0 -0
- /package/{dist/src → src}/omni-record.backend.ts +0 -0
- /package/{dist/src → src}/omni-record.service.d.ts +0 -0
- /package/{dist/src → src}/omni-record.service.ts +0 -0
- /package/{dist/src → src}/omni-relation-kind.contract.d.ts +0 -0
- /package/{dist/src → src}/omni-relation-kind.contract.ts +0 -0
- /package/{dist/src → src}/omni-relation-kind.enum.d.ts +0 -0
- /package/{dist/src → src}/omni-relation-kind.enum.ts +0 -0
- /package/{dist/src → src}/omni-relation-projection.definition.d.ts +0 -0
- /package/{dist/src → src}/omni-relation-projection.definition.ts +0 -0
- /package/{dist/src → src}/omni-relation-projection.service.d.ts +0 -0
- /package/{dist/src → src}/omni-relation-projection.service.ts +0 -0
- /package/{dist/src → src}/omni-relation-semantics.d.ts +0 -0
- /package/{dist/src → src}/omni-relation-semantics.ts +0 -0
- /package/{dist/src → src}/omni-relation-status.enum.d.ts +0 -0
- /package/{dist/src → src}/omni-relation-status.enum.ts +0 -0
- /package/{dist/src → src}/omni-relation.backend.d.ts +0 -0
- /package/{dist/src → src}/omni-relation.backend.ts +0 -0
- /package/{dist/src → src}/omni-relation.service.d.ts +0 -0
- /package/{dist/src → src}/omni-relation.service.ts +0 -0
- /package/{dist/src → src}/omni-scope.d.ts +0 -0
- /package/{dist/src → src}/omni-scope.ts +0 -0
- /package/{dist/src → src}/omni-scoped.repository.d.ts +0 -0
- /package/{dist/src → src}/omni-scoped.repository.ts +0 -0
- /package/{dist/src → src}/omni-scoped.service.d.ts +0 -0
- /package/{dist/src → src}/omni-scoped.service.ts +0 -0
- /package/{dist/src → src}/omnikernel.diagnostics.d.ts +0 -0
- /package/{dist/src → src}/omnikernel.diagnostics.ts +0 -0
- /package/{dist/src → src}/omnikernel.module.d.ts +0 -0
- /package/{dist/src → src}/omnikernel.module.ts +0 -0
- /package/{dist/src → src}/omnikernel.query.service.d.ts +0 -0
- /package/{dist/src → src}/omnikernel.query.service.ts +0 -0
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { OmniRelationKind } from './omni-relation-kind.enum.js';
|
|
2
|
+
export const omniRelationKindPattern = /^[a-z][a-z0-9_]{0,63}$/;
|
|
3
|
+
export const canonicalOmniRelationKinds = Object.freeze([
|
|
4
|
+
OmniRelationKind.Contains,
|
|
5
|
+
OmniRelationKind.References,
|
|
6
|
+
OmniRelationKind.RelatedTo,
|
|
7
|
+
OmniRelationKind.DerivedFrom,
|
|
8
|
+
]);
|
|
9
|
+
export function createOmniRelationKindContract(additionalKinds = []) {
|
|
10
|
+
const kinds = new Set(canonicalOmniRelationKinds);
|
|
11
|
+
for (const kind of additionalKinds) {
|
|
12
|
+
if (typeof kind !== 'string' || !omniRelationKindPattern.test(kind)) {
|
|
13
|
+
throw new TypeError('Omni relation kinds must use lowercase letters, digits, and underscores.');
|
|
14
|
+
}
|
|
15
|
+
kinds.add(kind);
|
|
16
|
+
}
|
|
17
|
+
return Object.freeze({
|
|
18
|
+
kinds,
|
|
19
|
+
assert(kind) {
|
|
20
|
+
if (typeof kind !== 'string' || !kinds.has(kind)) {
|
|
21
|
+
throw new TypeError('Omni relation kind is not registered for this module.');
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
has(kind) {
|
|
25
|
+
return kinds.has(kind);
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=omni-relation-kind.contract.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-relation-kind.contract.js","sourceRoot":"","sources":["omni-relation-kind.contract.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAC;AAEhE,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAEhE,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC;IACtD,gBAAgB,CAAC,QAAQ;IACzB,gBAAgB,CAAC,UAAU;IAC3B,gBAAgB,CAAC,SAAS;IAC1B,gBAAgB,CAAC,WAAW;CACpB,CAAC,CAAC;AAaZ,MAAM,UAAU,8BAA8B,CAC5C,kBAAqC,EAAE;IAEvC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS,0BAA0B,CAAC,CAAC;IAC1D,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;QACnC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,uBAAuB,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;YACpE,MAAM,IAAI,SAAS,CACjB,0EAA0E,CAC3E,CAAC;QACJ,CAAC;QACD,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;IAClB,CAAC;IAED,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,KAAK;QACL,MAAM,CAAC,IAAa;YAClB,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjD,MAAM,IAAI,SAAS,CACjB,uDAAuD,CACxD,CAAC;YACJ,CAAC;QACH,CAAC;QACD,GAAG,CAAC,IAAY;YACd,OAAO,KAAK,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;KACF,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { registerEnumType } from '@nestjs/graphql';
|
|
2
|
+
export var OmniRelationKind;
|
|
3
|
+
(function (OmniRelationKind) {
|
|
4
|
+
OmniRelationKind["Contains"] = "contains";
|
|
5
|
+
OmniRelationKind["References"] = "references";
|
|
6
|
+
OmniRelationKind["RelatedTo"] = "related_to";
|
|
7
|
+
OmniRelationKind["DerivedFrom"] = "derived_from";
|
|
8
|
+
})(OmniRelationKind || (OmniRelationKind = {}));
|
|
9
|
+
registerEnumType(OmniRelationKind, {
|
|
10
|
+
name: 'OmniRelationKind',
|
|
11
|
+
});
|
|
12
|
+
//# sourceMappingURL=omni-relation-kind.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-relation-kind.enum.js","sourceRoot":"","sources":["omni-relation-kind.enum.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AAEnD,MAAM,CAAN,IAAY,gBAKX;AALD,WAAY,gBAAgB;IAC1B,yCAAqB,CAAA;IACrB,6CAAyB,CAAA;IACzB,4CAAwB,CAAA;IACxB,gDAA4B,CAAA;AAC9B,CAAC,EALW,gBAAgB,KAAhB,gBAAgB,QAK3B;AAED,gBAAgB,CAAC,gBAAgB,EAAE;IACjC,IAAI,EAAE,kBAAkB;CACzB,CAAC,CAAC"}
|
|
@@ -1,10 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
exports.getOmniRelationProjectionAllowedKinds = getOmniRelationProjectionAllowedKinds;
|
|
4
|
-
exports.getOmniRelationProjectionAliases = getOmniRelationProjectionAliases;
|
|
5
|
-
exports.defineOmniRelationProjection = defineOmniRelationProjection;
|
|
6
|
-
const omni_relation_status_enum_js_1 = require("./omni-relation-status.enum.js");
|
|
7
|
-
const omni_relation_kind_contract_js_1 = require("./omni-relation-kind.contract.js");
|
|
1
|
+
import { OmniRelationStatus } from './omni-relation-status.enum.js';
|
|
2
|
+
import { omniRelationKindPattern } from './omni-relation-kind.contract.js';
|
|
8
3
|
const publicFieldPattern = /^[_A-Za-z][_0-9A-Za-z]*$/;
|
|
9
4
|
function assertFixedValue(value, label, max) {
|
|
10
5
|
if (typeof value !== 'string' ||
|
|
@@ -23,10 +18,10 @@ function freeze(definition) {
|
|
|
23
18
|
}
|
|
24
19
|
return definition;
|
|
25
20
|
}
|
|
26
|
-
function getOmniRelationProjectionAllowedKinds(definition) {
|
|
21
|
+
export function getOmniRelationProjectionAllowedKinds(definition) {
|
|
27
22
|
return definition.relation.allowedKinds ?? [definition.relation.kind];
|
|
28
23
|
}
|
|
29
|
-
function getOmniRelationProjectionAliases(definition) {
|
|
24
|
+
export function getOmniRelationProjectionAliases(definition) {
|
|
30
25
|
return {
|
|
31
26
|
kind: definition.aliases?.kind ?? 'kind',
|
|
32
27
|
source: definition.aliases?.source ?? 'sourceRecordId',
|
|
@@ -34,7 +29,7 @@ function getOmniRelationProjectionAliases(definition) {
|
|
|
34
29
|
payload: definition.aliases?.payload ?? 'payload',
|
|
35
30
|
};
|
|
36
31
|
}
|
|
37
|
-
function defineOmniRelationProjection(definition) {
|
|
32
|
+
export function defineOmniRelationProjection(definition) {
|
|
38
33
|
assertFixedValue(definition.id, 'Omni relation projection id', 128);
|
|
39
34
|
const relation = definition.relation;
|
|
40
35
|
if (!relation || typeof relation !== 'object') {
|
|
@@ -51,14 +46,14 @@ function defineOmniRelationProjection(definition) {
|
|
|
51
46
|
}
|
|
52
47
|
for (const kind of allowedKinds) {
|
|
53
48
|
assertFixedValue(kind, 'Omni relation projection kind', 64);
|
|
54
|
-
if (!
|
|
49
|
+
if (!omniRelationKindPattern.test(kind)) {
|
|
55
50
|
throw new TypeError('Omni relation projection kind must use lowercase letters, digits, and underscores.');
|
|
56
51
|
}
|
|
57
52
|
}
|
|
58
53
|
assertFixedValue(relation.sourceKind, 'Omni relation projection source kind', 64);
|
|
59
54
|
assertFixedValue(relation.targetKind, 'Omni relation projection target kind', 64);
|
|
60
55
|
if (relation.status !== undefined &&
|
|
61
|
-
!Object.values(
|
|
56
|
+
!Object.values(OmniRelationStatus).includes(relation.status)) {
|
|
62
57
|
throw new TypeError('Omni relation projection status must be an Omni relation status.');
|
|
63
58
|
}
|
|
64
59
|
if (relation.schema) {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-relation-projection.definition.js","sourceRoot":"","sources":["omni-relation-projection.definition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAC;AACpE,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAmC3E,MAAM,kBAAkB,GAAG,0BAA0B,CAAC;AAEtD,SAAS,gBAAgB,CACvB,KAAc,EACd,KAAa,EACb,GAAW;IAEX,IACE,OAAO,KAAK,KAAK,QAAQ;QACzB,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC;QACzB,KAAK,CAAC,MAAM,GAAG,GAAG,EAClB,CAAC;QACD,MAAM,IAAI,SAAS,CACjB,GAAG,KAAK,qCAAqC,GAAG,cAAc,CAC/D,CAAC;IACJ,CAAC;AACH,CAAC;AAED,SAAS,MAAM,CAAI,UAAa;IAC9B,IAAI,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,CAAC,OAAO,GAAG,aAAa,EACvC,CAAC;YACD,MAAM,IAAI,SAAS,CACjB,mFAAmF,CACpF,CAAC;QACJ,CAAC;IACH,CAAC;IACD,MAAM,OAAO,GAAG,gCAAgC,CAAC,UAAU,CAAC,CAAC;IAC7D,IAAI,IAAI,GAAG,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,MAAM,EAAE,CAAC;QACzE,MAAM,IAAI,SAAS,CAAC,kDAAkD,CAAC,CAAC;IAC1E,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACpD,IAAI,CAAC,kBAAkB,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACpC,MAAM,IAAI,SAAS,CACjB,4BAA4B,IAAI,2CAA2C,CAC5E,CAAC;QACJ,CAAC;IACH,CAAC;IACD,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC;AAC5B,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { type InjectionToken, type Provider } from '@nestjs/common';
|
|
2
2
|
import { type ICrudGenResourceFactoryResult } from '@nest-yalc-2/crud-gen';
|
|
3
|
-
import type { ClassType } from '@node-yalc/types/globals';
|
|
3
|
+
import type { ClassType } from '@node-yalc/types/globals.js';
|
|
4
4
|
import type { ObjectLiteral } from 'typeorm';
|
|
5
5
|
import { OmniRelationEntity } from './base/omni-relation.entity.js';
|
|
6
6
|
import type { OmniProjectionReaderCatalogProvider, OmniRelationProjectionReaderRegistration } from './omni-projection.catalog.js';
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
import { Scope } from '@nestjs/common';
|
|
2
|
+
import { InputType, Int, ObjectType } from '@nestjs/graphql';
|
|
3
|
+
import { getDataSourceToken } from '@nestjs/typeorm';
|
|
4
|
+
import { CrudGenResourceFactory, FilterOptionType, ModelField, ModelObject, getServiceToken, } from '@nest-yalc-2/crud-gen';
|
|
5
|
+
import { GQLDataLoader, getDataloaderToken, getFn, } from '@nest-yalc-2/data-loader';
|
|
6
|
+
import { UUIDScalar } from '@nest-yalc-2/graphql/scalars/uuid.scalar.js';
|
|
7
|
+
import returnValue from '@node-yalc/utils/returnValue.js';
|
|
8
|
+
import { Exclude, Expose } from 'class-transformer';
|
|
9
|
+
import { GraphQLJSON } from 'graphql-type-json';
|
|
10
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
11
|
+
import { OmniRelationEntity } from './base/omni-relation.entity.js';
|
|
12
|
+
import { getOmniRelationProjectionAliases, getOmniRelationProjectionAllowedKinds, } from './omni-relation-projection.definition.js';
|
|
13
|
+
import { OmniRelationProjectionService } from './omni-relation-projection.service.js';
|
|
14
|
+
import { createOmniRelationKindContract } from './omni-relation-kind.contract.js';
|
|
15
|
+
import { OMNI_KERNEL_OPTIONS, OmniScopeContext } from './omni-scope.js';
|
|
16
|
+
function namedClass(name, outputFields) {
|
|
17
|
+
return {
|
|
18
|
+
[name]: class {
|
|
19
|
+
constructor(data) {
|
|
20
|
+
if (!outputFields) {
|
|
21
|
+
Object.assign(this, data);
|
|
22
|
+
return;
|
|
23
|
+
}
|
|
24
|
+
for (const [publicName, destination] of outputFields) {
|
|
25
|
+
if (data && Object.prototype.hasOwnProperty.call(data, destination)) {
|
|
26
|
+
this[publicName] = data[destination];
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
}[name];
|
|
32
|
+
}
|
|
33
|
+
function addField(target, name, destination, type, nullable) {
|
|
34
|
+
ModelField({
|
|
35
|
+
dst: destination,
|
|
36
|
+
gqlType: returnValue(type),
|
|
37
|
+
gqlOptions: { nullable },
|
|
38
|
+
})(target.prototype, name);
|
|
39
|
+
Expose()(target.prototype, name);
|
|
40
|
+
}
|
|
41
|
+
function defaultGraphqlNames(apiModel) {
|
|
42
|
+
return {
|
|
43
|
+
object: apiModel.name,
|
|
44
|
+
create: `${apiModel.name}CreateInput`,
|
|
45
|
+
patch: `${apiModel.name}UpdateInput`,
|
|
46
|
+
conditions: `${apiModel.name}Condition`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
export function createOmniRelationProjectionGraphqlTypes(definition, names) {
|
|
50
|
+
const aliases = getOmniRelationProjectionAliases(definition);
|
|
51
|
+
const multipleKinds = getOmniRelationProjectionAllowedKinds(definition).length > 1;
|
|
52
|
+
const objectFields = [
|
|
53
|
+
['guid', 'guid'],
|
|
54
|
+
[aliases.source, 'sourceRecordId'],
|
|
55
|
+
[aliases.target, 'targetRecordId'],
|
|
56
|
+
['revision', 'revision'],
|
|
57
|
+
[aliases.payload, 'payload'],
|
|
58
|
+
];
|
|
59
|
+
if (multipleKinds)
|
|
60
|
+
objectFields.splice(1, 0, [aliases.kind, 'kind']);
|
|
61
|
+
const object = namedClass(names.object, objectFields);
|
|
62
|
+
ObjectType(names.object)(object);
|
|
63
|
+
ModelObject({
|
|
64
|
+
filters: { type: FilterOptionType.INCLUDE, fields: ['guid'] },
|
|
65
|
+
})(object);
|
|
66
|
+
Exclude()(object);
|
|
67
|
+
addField(object, 'guid', 'guid', UUIDScalar, false);
|
|
68
|
+
if (multipleKinds) {
|
|
69
|
+
addField(object, aliases.kind, 'kind', String, false);
|
|
70
|
+
}
|
|
71
|
+
addField(object, aliases.source, 'sourceRecordId', UUIDScalar, false);
|
|
72
|
+
addField(object, aliases.target, 'targetRecordId', UUIDScalar, false);
|
|
73
|
+
addField(object, 'revision', 'revision', Int, false);
|
|
74
|
+
addField(object, aliases.payload, 'payload', GraphQLJSON, true);
|
|
75
|
+
const create = namedClass(names.create);
|
|
76
|
+
InputType(names.create)(create);
|
|
77
|
+
ModelObject()(create);
|
|
78
|
+
addField(create, 'guid', 'guid', UUIDScalar, false);
|
|
79
|
+
if (multipleKinds) {
|
|
80
|
+
addField(create, aliases.kind, 'kind', String, false);
|
|
81
|
+
}
|
|
82
|
+
addField(create, aliases.source, 'sourceRecordId', UUIDScalar, false);
|
|
83
|
+
addField(create, aliases.target, 'targetRecordId', UUIDScalar, false);
|
|
84
|
+
addField(create, aliases.payload, 'payload', GraphQLJSON, true);
|
|
85
|
+
const patch = namedClass(names.patch);
|
|
86
|
+
InputType(names.patch)(patch);
|
|
87
|
+
ModelObject()(patch);
|
|
88
|
+
addField(patch, aliases.payload, 'payload', GraphQLJSON, true);
|
|
89
|
+
addField(patch, 'expectedRevision', 'expectedRevision', Int, false);
|
|
90
|
+
const conditions = namedClass(names.conditions);
|
|
91
|
+
InputType(names.conditions)(conditions);
|
|
92
|
+
ModelObject()(conditions);
|
|
93
|
+
addField(conditions, 'guid', 'guid', UUIDScalar, false);
|
|
94
|
+
return { object, create, patch, conditions };
|
|
95
|
+
}
|
|
96
|
+
export function createOmniRelationProjectionRegistration(options) {
|
|
97
|
+
const graphqlTypes = createOmniRelationProjectionGraphqlTypes(options.definition, options.graphql?.names ?? defaultGraphqlNames(options.apiModel));
|
|
98
|
+
const serviceToken = getServiceToken(options.apiModel);
|
|
99
|
+
const dataLoaderToken = getDataloaderToken(options.apiModel);
|
|
100
|
+
const resource = CrudGenResourceFactory({
|
|
101
|
+
entityModel: options.apiModel,
|
|
102
|
+
backend: false,
|
|
103
|
+
graphql: {
|
|
104
|
+
resolver: {
|
|
105
|
+
dto: graphqlTypes.object,
|
|
106
|
+
input: {
|
|
107
|
+
create: graphqlTypes.create,
|
|
108
|
+
update: graphqlTypes.patch,
|
|
109
|
+
conditions: graphqlTypes.conditions,
|
|
110
|
+
},
|
|
111
|
+
...(options.graphql?.prefix ? { prefix: options.graphql.prefix } : {}),
|
|
112
|
+
...(options.moduleRefToken !== undefined
|
|
113
|
+
? { moduleRefToken: options.moduleRefToken }
|
|
114
|
+
: {}),
|
|
115
|
+
queries: { getResource: { idName: 'guid' } },
|
|
116
|
+
},
|
|
117
|
+
serviceToken,
|
|
118
|
+
dataLoaderToken,
|
|
119
|
+
},
|
|
120
|
+
rest: {
|
|
121
|
+
dto: graphqlTypes.object,
|
|
122
|
+
serialize: true,
|
|
123
|
+
...(options.rest?.path ? { path: options.rest.path } : {}),
|
|
124
|
+
idField: 'guid',
|
|
125
|
+
serviceToken,
|
|
126
|
+
},
|
|
127
|
+
});
|
|
128
|
+
const relationKinds = Object.freeze([
|
|
129
|
+
...getOmniRelationProjectionAllowedKinds(options.definition),
|
|
130
|
+
]);
|
|
131
|
+
const reader = Object.freeze({
|
|
132
|
+
type: 'relation',
|
|
133
|
+
id: options.definition.id,
|
|
134
|
+
definition: options.definition,
|
|
135
|
+
});
|
|
136
|
+
const serviceProvider = options.lifecycle && options.catalog
|
|
137
|
+
? {
|
|
138
|
+
provide: serviceToken,
|
|
139
|
+
scope: Scope.REQUEST,
|
|
140
|
+
useFactory: (dataSource, scope, omniOptions, lifecycle, catalog) => new OmniRelationProjectionService(dataSource.getRepository(OmniRelationEntity), scope, omniOptions.deletion.relation, dataSource.getRepository(OmniRecordEntity), createOmniRelationKindContract(relationKinds), options.definition, dataSource, lifecycle, catalog),
|
|
141
|
+
inject: [
|
|
142
|
+
getDataSourceToken(options.dbConnection),
|
|
143
|
+
OmniScopeContext,
|
|
144
|
+
OMNI_KERNEL_OPTIONS,
|
|
145
|
+
options.lifecycle.token,
|
|
146
|
+
options.catalog.token,
|
|
147
|
+
],
|
|
148
|
+
}
|
|
149
|
+
: options.lifecycle
|
|
150
|
+
? {
|
|
151
|
+
provide: serviceToken,
|
|
152
|
+
scope: Scope.REQUEST,
|
|
153
|
+
useFactory: (dataSource, scope, omniOptions, lifecycle) => new OmniRelationProjectionService(dataSource.getRepository(OmniRelationEntity), scope, omniOptions.deletion.relation, dataSource.getRepository(OmniRecordEntity), createOmniRelationKindContract(relationKinds), options.definition, dataSource, lifecycle),
|
|
154
|
+
inject: [
|
|
155
|
+
getDataSourceToken(options.dbConnection),
|
|
156
|
+
OmniScopeContext,
|
|
157
|
+
OMNI_KERNEL_OPTIONS,
|
|
158
|
+
options.lifecycle.token,
|
|
159
|
+
],
|
|
160
|
+
}
|
|
161
|
+
: {
|
|
162
|
+
provide: serviceToken,
|
|
163
|
+
scope: Scope.REQUEST,
|
|
164
|
+
useFactory: (dataSource, scope, omniOptions) => new OmniRelationProjectionService(dataSource.getRepository(OmniRelationEntity), scope, omniOptions.deletion.relation, dataSource.getRepository(OmniRecordEntity), createOmniRelationKindContract(relationKinds), options.definition, dataSource, undefined),
|
|
165
|
+
inject: [
|
|
166
|
+
getDataSourceToken(options.dbConnection),
|
|
167
|
+
OmniScopeContext,
|
|
168
|
+
OMNI_KERNEL_OPTIONS,
|
|
169
|
+
],
|
|
170
|
+
};
|
|
171
|
+
const providers = [
|
|
172
|
+
serviceProvider,
|
|
173
|
+
{
|
|
174
|
+
provide: dataLoaderToken,
|
|
175
|
+
scope: Scope.REQUEST,
|
|
176
|
+
useFactory: (service, scope) => new GQLDataLoader(getFn(service), 'guid', undefined, {
|
|
177
|
+
cacheKeyFn: (key) => scope.cacheKey(key),
|
|
178
|
+
}),
|
|
179
|
+
inject: [serviceToken, OmniScopeContext],
|
|
180
|
+
},
|
|
181
|
+
...resource.providers,
|
|
182
|
+
];
|
|
183
|
+
return Object.freeze({
|
|
184
|
+
entities: Object.freeze([]),
|
|
185
|
+
relationKinds,
|
|
186
|
+
definition: options.definition,
|
|
187
|
+
reader,
|
|
188
|
+
graphqlTypes: Object.freeze(graphqlTypes),
|
|
189
|
+
resource,
|
|
190
|
+
controllers: Object.freeze([...resource.controllers]),
|
|
191
|
+
providers: Object.freeze(providers),
|
|
192
|
+
serviceToken,
|
|
193
|
+
dataLoaderToken,
|
|
194
|
+
});
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=omni-relation-projection.resource.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-relation-projection.resource.js","sourceRoot":"","sources":["omni-relation-projection.resource.ts"],"names":[],"mappings":"AAAA,O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EAAE;gBAC5D,UAAU,EAAE,CAAC,GAAG,EAAE,EAAE,CAAC,KAAK,CAAC,QAAQ,CAAC,GAAG,CAAC;aACzC,CAAC;YACJ,MAAM,EAAE,CAAC,YAAY,EAAE,gBAAgB,CAAC;SACzC;QACD,GAAG,QAAQ,CAAC,SAAS;KACtB,CAAC;IAEF,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,EAAE,CAAgB;QAC1C,aAAa;QACb,UAAU,EAAE,OAAO,CAAC,UAAU;QAC9B,MAAM;QACN,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,YAAY,CAAC;QACzC,QAAQ;QACR,WAAW,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,GAAG,QAAQ,CAAC,WAAW,CAAC,CAAC;QACrD,SAAS,EAAE,MAAM,CAAC,MAAM,CAAC,SAAS,CAAC;QACnC,YAAY;QACZ,eAAe;KAChB,CAAC,CAAC;AACL,CAAC"}
|
|
@@ -15,8 +15,8 @@ import {
|
|
|
15
15
|
getFn,
|
|
16
16
|
} from '@nest-yalc-2/data-loader';
|
|
17
17
|
import { UUIDScalar } from '@nest-yalc-2/graphql/scalars/uuid.scalar.js';
|
|
18
|
-
import type { ClassType } from '@node-yalc/types/globals';
|
|
19
|
-
import returnValue from '@node-yalc/utils/returnValue';
|
|
18
|
+
import type { ClassType } from '@node-yalc/types/globals.js';
|
|
19
|
+
import returnValue from '@node-yalc/utils/returnValue.js';
|
|
20
20
|
import { Exclude, Expose } from 'class-transformer';
|
|
21
21
|
import { GraphQLJSON } from 'graphql-type-json';
|
|
22
22
|
import type { DataSource, ObjectLiteral } from 'typeorm';
|
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
const omni_relation_projection_definition_js_1 = require("./omni-relation-projection.definition.js");
|
|
11
|
-
const omni_relation_service_js_1 = require("./omni-relation.service.js");
|
|
12
|
-
const omni_relation_status_enum_js_1 = require("./omni-relation-status.enum.js");
|
|
1
|
+
import { BadRequestException, ConflictException } from '@nestjs/common';
|
|
2
|
+
import { Operators, PROJECTION_INTEGER_MAX, } from '@nest-yalc-2/crud-gen';
|
|
3
|
+
import { In, IsNull, } from 'typeorm';
|
|
4
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
5
|
+
import { OmniRelationEntity } from './base/omni-relation.entity.js';
|
|
6
|
+
import { createOmniProjectionReaderCatalog, } from './omni-projection.catalog.js';
|
|
7
|
+
import { getOmniRelationProjectionAliases, getOmniRelationProjectionAllowedKinds, } from './omni-relation-projection.definition.js';
|
|
8
|
+
import { OmniRelationService } from './omni-relation.service.js';
|
|
9
|
+
import { OmniRelationStatus } from './omni-relation-status.enum.js';
|
|
13
10
|
function hasOwn(input, key) {
|
|
14
11
|
return Object.prototype.hasOwnProperty.call(input, key);
|
|
15
12
|
}
|
|
@@ -20,7 +17,7 @@ function isRetryableTransactionError(error) {
|
|
|
20
17
|
code === 'SQLITE_BUSY' ||
|
|
21
18
|
code === 'SQLITE_BUSY_SNAPSHOT');
|
|
22
19
|
}
|
|
23
|
-
class OmniRelationProjectionService extends
|
|
20
|
+
export class OmniRelationProjectionService extends OmniRelationService {
|
|
24
21
|
constructor(repository, scope, relationDeletion, recordRepository, kinds, definition, dataSource, lifecycle, readerCatalog) {
|
|
25
22
|
super(repository, scope, relationDeletion, recordRepository, kinds);
|
|
26
23
|
this.relationDeletion = relationDeletion;
|
|
@@ -28,7 +25,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
28
25
|
this.dataSource = dataSource;
|
|
29
26
|
this.lifecycle = lifecycle;
|
|
30
27
|
this.readerCatalog = readerCatalog;
|
|
31
|
-
for (const kind of
|
|
28
|
+
for (const kind of getOmniRelationProjectionAllowedKinds(definition)) {
|
|
32
29
|
try {
|
|
33
30
|
kinds.assert(kind);
|
|
34
31
|
}
|
|
@@ -49,7 +46,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
49
46
|
return typeof result === 'boolean' ? result : this.publicEntity(result);
|
|
50
47
|
}
|
|
51
48
|
const result = await this.mutate(async (manager) => {
|
|
52
|
-
await this.assertRelation(created, manager.getRepository(
|
|
49
|
+
await this.assertRelation(created, manager.getRepository(OmniRecordEntity));
|
|
53
50
|
await this.lifecycle.beforeCreate?.({
|
|
54
51
|
definition: this.definition,
|
|
55
52
|
scope: this.scope,
|
|
@@ -57,7 +54,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
57
54
|
readers: this.readers(manager),
|
|
58
55
|
input: this.publicInput(normalized),
|
|
59
56
|
});
|
|
60
|
-
const repository = manager.getRepository(
|
|
57
|
+
const repository = manager.getRepository(OmniRelationEntity);
|
|
61
58
|
const entity = {
|
|
62
59
|
...created,
|
|
63
60
|
scopeId: this.scopeId,
|
|
@@ -83,7 +80,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
83
80
|
async getEntityListExtended(findOptions = {}, withCount = false, relations, databaseName) {
|
|
84
81
|
this.rejectFixedFilters(findOptions.where);
|
|
85
82
|
const where = {
|
|
86
|
-
operator:
|
|
83
|
+
operator: Operators.AND,
|
|
87
84
|
filters: this.definitionFilters(),
|
|
88
85
|
...(findOptions.where ? { childExpressions: [findOptions.where] } : {}),
|
|
89
86
|
};
|
|
@@ -103,23 +100,23 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
103
100
|
if (typeof expectedRevision !== 'number' ||
|
|
104
101
|
!Number.isInteger(expectedRevision) ||
|
|
105
102
|
expectedRevision < 1 ||
|
|
106
|
-
expectedRevision >=
|
|
107
|
-
throw new
|
|
103
|
+
expectedRevision >= PROJECTION_INTEGER_MAX) {
|
|
104
|
+
throw new BadRequestException(`expectedRevision must be an integer between 1 and ${PROJECTION_INTEGER_MAX - 1}.`);
|
|
108
105
|
}
|
|
109
106
|
const fixedConditions = this.withDefinitionConditions(this.normalizeConditions(conditions));
|
|
110
107
|
const { expectedRevision: _expectedRevision, ...changes } = normalized;
|
|
111
108
|
if (Object.keys(changes).length === 0) {
|
|
112
|
-
throw new
|
|
109
|
+
throw new BadRequestException('Omni relation update requires metadata.');
|
|
113
110
|
}
|
|
114
111
|
const result = await this.mutate(async (manager) => {
|
|
115
|
-
const repository = manager.getRepository(
|
|
112
|
+
const repository = manager.getRepository(OmniRelationEntity);
|
|
116
113
|
const current = await repository.findOne({ where: fixedConditions });
|
|
117
114
|
if (!current)
|
|
118
115
|
this.notFound();
|
|
119
116
|
if (current.revision !== expectedRevision) {
|
|
120
|
-
throw new
|
|
117
|
+
throw new ConflictException('Omni relation revision conflict.');
|
|
121
118
|
}
|
|
122
|
-
await this.assertRelation({ ...current, ...changes }, manager.getRepository(
|
|
119
|
+
await this.assertRelation({ ...current, ...changes }, manager.getRepository(OmniRecordEntity));
|
|
123
120
|
await this.lifecycle?.beforeUpdate?.({
|
|
124
121
|
definition: this.definition,
|
|
125
122
|
scope: this.scope,
|
|
@@ -136,10 +133,10 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
136
133
|
.andWhere('"guid" = :guid', { guid: current.guid })
|
|
137
134
|
.andWhere('"revision" = :expectedRevision', { expectedRevision })
|
|
138
135
|
.andWhere('"kind" IN (:...kinds)', {
|
|
139
|
-
kinds: [...
|
|
136
|
+
kinds: [...getOmniRelationProjectionAllowedKinds(this.definition)],
|
|
140
137
|
})
|
|
141
138
|
.andWhere('"status" = :status', {
|
|
142
|
-
status: this.definition.relation.status ??
|
|
139
|
+
status: this.definition.relation.status ?? OmniRelationStatus.Active,
|
|
143
140
|
})
|
|
144
141
|
.andWhere(this.definition.relation.schema
|
|
145
142
|
? '"payloadSchemaId" = :schemaId AND "payloadSchemaVersion" = :schemaVersion'
|
|
@@ -154,7 +151,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
154
151
|
const existing = await repository.findOne({ where: fixedConditions });
|
|
155
152
|
if (!existing)
|
|
156
153
|
this.notFound();
|
|
157
|
-
throw new
|
|
154
|
+
throw new ConflictException('Omni relation revision conflict.');
|
|
158
155
|
}
|
|
159
156
|
if (!returnEntity)
|
|
160
157
|
return true;
|
|
@@ -167,7 +164,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
167
164
|
if (!this.lifecycle)
|
|
168
165
|
return super.deleteEntity(fixedConditions);
|
|
169
166
|
return this.mutate(async (manager) => {
|
|
170
|
-
const repository = manager.getRepository(
|
|
167
|
+
const repository = manager.getRepository(OmniRelationEntity);
|
|
171
168
|
const current = await repository.findOne({ where: fixedConditions });
|
|
172
169
|
if (!current)
|
|
173
170
|
this.notFound();
|
|
@@ -190,14 +187,14 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
190
187
|
assertEndpointKinds(source, target) {
|
|
191
188
|
if (source.kind !== this.definition.relation.sourceKind ||
|
|
192
189
|
target.kind !== this.definition.relation.targetKind) {
|
|
193
|
-
throw new
|
|
190
|
+
throw new BadRequestException('Omni relation endpoints do not match the registered resource kinds.');
|
|
194
191
|
}
|
|
195
192
|
}
|
|
196
193
|
createValues(input) {
|
|
197
194
|
return {
|
|
198
195
|
...input,
|
|
199
196
|
kind: input.kind,
|
|
200
|
-
status: this.definition.relation.status ??
|
|
197
|
+
status: this.definition.relation.status ?? OmniRelationStatus.Active,
|
|
201
198
|
...(this.definition.relation.schema
|
|
202
199
|
? {
|
|
203
200
|
payloadSchemaId: this.definition.relation.schema.id,
|
|
@@ -207,7 +204,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
207
204
|
};
|
|
208
205
|
}
|
|
209
206
|
publicEntity(entity) {
|
|
210
|
-
const aliases =
|
|
207
|
+
const aliases = getOmniRelationProjectionAliases(this.definition);
|
|
211
208
|
return {
|
|
212
209
|
...entity,
|
|
213
210
|
...(aliases.kind === 'kind' ? {} : { [aliases.kind]: entity.kind }),
|
|
@@ -223,7 +220,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
223
220
|
};
|
|
224
221
|
}
|
|
225
222
|
publicInput(input) {
|
|
226
|
-
const aliases =
|
|
223
|
+
const aliases = getOmniRelationProjectionAliases(this.definition);
|
|
227
224
|
const output = { ...input };
|
|
228
225
|
for (const [field, alias] of [
|
|
229
226
|
['kind', aliases.kind],
|
|
@@ -239,21 +236,21 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
239
236
|
return output;
|
|
240
237
|
}
|
|
241
238
|
selectCreateKind(input) {
|
|
242
|
-
const allowed =
|
|
239
|
+
const allowed = getOmniRelationProjectionAllowedKinds(this.definition);
|
|
243
240
|
if (allowed.length === 1) {
|
|
244
241
|
if (input.kind !== undefined) {
|
|
245
|
-
throw new
|
|
242
|
+
throw new BadRequestException('Omni relation kind is server-owned.');
|
|
246
243
|
}
|
|
247
244
|
input.kind = allowed[0];
|
|
248
245
|
return;
|
|
249
246
|
}
|
|
250
247
|
if (typeof input.kind !== 'string' || !allowed.includes(input.kind)) {
|
|
251
|
-
throw new
|
|
248
|
+
throw new BadRequestException('Omni relation kind is not allowed by this resource.');
|
|
252
249
|
}
|
|
253
250
|
}
|
|
254
251
|
normalizeInput(input) {
|
|
255
252
|
const normalized = { ...input };
|
|
256
|
-
const aliases =
|
|
253
|
+
const aliases = getOmniRelationProjectionAliases(this.definition);
|
|
257
254
|
for (const [alias, field] of [
|
|
258
255
|
[aliases.kind, 'kind'],
|
|
259
256
|
[aliases.source, 'sourceRecordId'],
|
|
@@ -265,7 +262,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
265
262
|
if (!hasOwn(normalized, alias))
|
|
266
263
|
continue;
|
|
267
264
|
if (hasOwn(normalized, field)) {
|
|
268
|
-
throw new
|
|
265
|
+
throw new BadRequestException(`Omni relation ${alias} conflicts with ${field}.`);
|
|
269
266
|
}
|
|
270
267
|
normalized[field] = normalized[alias];
|
|
271
268
|
delete normalized[alias];
|
|
@@ -283,14 +280,14 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
283
280
|
'payloadSchemaVersion',
|
|
284
281
|
]) {
|
|
285
282
|
if (hasOwn(input, field)) {
|
|
286
|
-
throw new
|
|
283
|
+
throw new BadRequestException(`Omni relation ${field} is server-owned.`);
|
|
287
284
|
}
|
|
288
285
|
}
|
|
289
286
|
}
|
|
290
287
|
rejectImmutableEndpoints(input) {
|
|
291
288
|
for (const field of ['guid', 'sourceRecordId', 'targetRecordId']) {
|
|
292
289
|
if (hasOwn(input, field)) {
|
|
293
|
-
throw new
|
|
290
|
+
throw new BadRequestException(`Omni relation ${field} is immutable.`);
|
|
294
291
|
}
|
|
295
292
|
}
|
|
296
293
|
}
|
|
@@ -298,7 +295,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
298
295
|
if (hasOwn(input, 'payload') &&
|
|
299
296
|
input.payload !== null &&
|
|
300
297
|
(typeof input.payload !== 'object' || Array.isArray(input.payload))) {
|
|
301
|
-
throw new
|
|
298
|
+
throw new BadRequestException('payload must be a JSON object or null.');
|
|
302
299
|
}
|
|
303
300
|
}
|
|
304
301
|
withDefinitionConditions(conditions) {
|
|
@@ -314,23 +311,23 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
314
311
|
definitionFilters() {
|
|
315
312
|
const relation = this.definition.relation;
|
|
316
313
|
return {
|
|
317
|
-
kind:
|
|
318
|
-
status: relation.status ??
|
|
314
|
+
kind: In([...getOmniRelationProjectionAllowedKinds(this.definition)]),
|
|
315
|
+
status: relation.status ?? OmniRelationStatus.Active,
|
|
319
316
|
...(relation.schema
|
|
320
317
|
? {
|
|
321
318
|
payloadSchemaId: relation.schema.id,
|
|
322
319
|
payloadSchemaVersion: relation.schema.version,
|
|
323
320
|
}
|
|
324
321
|
: {
|
|
325
|
-
payloadSchemaId:
|
|
326
|
-
payloadSchemaVersion:
|
|
322
|
+
payloadSchemaId: IsNull(),
|
|
323
|
+
payloadSchemaVersion: IsNull(),
|
|
327
324
|
}),
|
|
328
325
|
};
|
|
329
326
|
}
|
|
330
327
|
assertFixedConditions(conditions) {
|
|
331
328
|
for (const field of Object.keys(this.definitionFilters())) {
|
|
332
329
|
if (hasOwn(conditions, field)) {
|
|
333
|
-
throw new
|
|
330
|
+
throw new BadRequestException(`Omni relation ${field} is server-owned.`);
|
|
334
331
|
}
|
|
335
332
|
}
|
|
336
333
|
}
|
|
@@ -344,7 +341,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
344
341
|
const candidate = where;
|
|
345
342
|
for (const field of Object.keys(this.definitionFilters())) {
|
|
346
343
|
if (hasOwn(candidate, field)) {
|
|
347
|
-
throw new
|
|
344
|
+
throw new BadRequestException(`Omni relation ${field} is server-owned.`);
|
|
348
345
|
}
|
|
349
346
|
}
|
|
350
347
|
if (candidate.filters && typeof candidate.filters === 'object') {
|
|
@@ -356,7 +353,7 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
356
353
|
}
|
|
357
354
|
readers(manager) {
|
|
358
355
|
return (this.readerCatalog ??
|
|
359
|
-
|
|
356
|
+
createOmniProjectionReaderCatalog([
|
|
360
357
|
{
|
|
361
358
|
type: 'relation',
|
|
362
359
|
id: this.definition.id,
|
|
@@ -375,11 +372,10 @@ class OmniRelationProjectionService extends omni_relation_service_js_1.OmniRelat
|
|
|
375
372
|
}
|
|
376
373
|
catch (error) {
|
|
377
374
|
if (isRetryableTransactionError(error)) {
|
|
378
|
-
throw new
|
|
375
|
+
throw new ConflictException('Omni projection concurrent write conflict; retry the mutation.');
|
|
379
376
|
}
|
|
380
377
|
throw error;
|
|
381
378
|
}
|
|
382
379
|
}
|
|
383
380
|
}
|
|
384
|
-
exports.OmniRelationProjectionService = OmniRelationProjectionService;
|
|
385
381
|
//# sourceMappingURL=omni-relation-projection.service.js.map
|