@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,19 @@
|
|
|
1
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
2
|
+
import { omniScopedBackendProvidersFactory } from './omni-scoped.backend.js';
|
|
3
|
+
import { OmniRecordService } from './omni-record.service.js';
|
|
4
|
+
|
|
5
|
+
export const omniRecordBackendProvidersFactory = (
|
|
6
|
+
dbConnection: string,
|
|
7
|
+
reservedRecordKinds: readonly string[] = [],
|
|
8
|
+
) =>
|
|
9
|
+
omniScopedBackendProvidersFactory<OmniRecordEntity>({
|
|
10
|
+
entityModel: OmniRecordEntity,
|
|
11
|
+
dbConnection,
|
|
12
|
+
createService: (repository, scope, options) =>
|
|
13
|
+
new OmniRecordService(
|
|
14
|
+
repository,
|
|
15
|
+
scope,
|
|
16
|
+
options.deletion.record,
|
|
17
|
+
reservedRecordKinds,
|
|
18
|
+
),
|
|
19
|
+
});
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import type { Relation } from 'typeorm';
|
|
2
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
3
|
+
import { OmniRelationType } from './omni-relation.dto.js';
|
|
4
|
+
import { OmniRecordStatus } from './omni-record-status.enum.js';
|
|
5
|
+
export declare class OmniRecordType extends OmniRecordEntity {
|
|
6
|
+
constructor(data?: Partial<OmniRecordType>);
|
|
7
|
+
guid: string;
|
|
8
|
+
revision: number;
|
|
9
|
+
externalId?: string | null;
|
|
10
|
+
title: string;
|
|
11
|
+
slug?: string | null;
|
|
12
|
+
kind: string;
|
|
13
|
+
status: OmniRecordStatus;
|
|
14
|
+
payload?: Record<string, unknown> | null;
|
|
15
|
+
payloadSchemaId?: string | null;
|
|
16
|
+
payloadSchemaVersion?: number | null;
|
|
17
|
+
outgoingRelations?: Relation<OmniRelationType[]>;
|
|
18
|
+
incomingRelations?: Relation<OmniRelationType[]>;
|
|
19
|
+
}
|
|
20
|
+
declare const OmniRecordCreateInput_base: import("@nestjs/common").Type<Omit<OmniRecordType, "revision" | "createdAt" | "updatedAt" | "outgoingRelations" | "incomingRelations">>;
|
|
21
|
+
export declare class OmniRecordCreateInput extends OmniRecordCreateInput_base {
|
|
22
|
+
}
|
|
23
|
+
declare const OmniRecordCondition_base: import("@nestjs/common").Type<Partial<OmniRecordCreateInput>>;
|
|
24
|
+
export declare class OmniRecordCondition extends OmniRecordCondition_base {
|
|
25
|
+
}
|
|
26
|
+
declare const OmniRecordUpdateInput_base: import("@nestjs/common").Type<Partial<OmniRecordCreateInput>>;
|
|
27
|
+
export declare class OmniRecordUpdateInput extends OmniRecordUpdateInput_base {
|
|
28
|
+
}
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,169 @@
|
|
|
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.OmniRecordUpdateInput = exports.OmniRecordCondition = exports.OmniRecordCreateInput = exports.OmniRecordType = 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_relation_dto_js_1 = require("./omni-relation.dto.js");
|
|
26
|
+
const omni_record_status_enum_js_1 = require("./omni-record-status.enum.js");
|
|
27
|
+
let OmniRecordType = class OmniRecordType extends omni_record_entity_js_1.OmniRecordEntity {
|
|
28
|
+
constructor(data) {
|
|
29
|
+
super();
|
|
30
|
+
if (data) {
|
|
31
|
+
(0, omni_dto_helpers_js_1.assignOmniPublicDto)(this, data);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
exports.OmniRecordType = OmniRecordType;
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(uuid_scalar_js_1.UUIDScalar), isRequired: true }),
|
|
38
|
+
(0, class_validator_1.IsUUID)(),
|
|
39
|
+
__metadata("design:type", String)
|
|
40
|
+
], OmniRecordType.prototype, "guid", void 0);
|
|
41
|
+
__decorate([
|
|
42
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(graphql_1.Int) }),
|
|
43
|
+
(0, class_validator_1.IsInt)(),
|
|
44
|
+
__metadata("design:type", Number)
|
|
45
|
+
], OmniRecordType.prototype, "revision", void 0);
|
|
46
|
+
__decorate([
|
|
47
|
+
(0, object_decorator_js_1.ModelField)({
|
|
48
|
+
gqlType: (0, returnValue_js_1.default)(String),
|
|
49
|
+
gqlOptions: { nullable: true },
|
|
50
|
+
}),
|
|
51
|
+
(0, class_validator_1.IsOptional)(),
|
|
52
|
+
(0, class_validator_1.IsString)(),
|
|
53
|
+
(0, class_validator_1.MaxLength)(128),
|
|
54
|
+
__metadata("design:type", Object)
|
|
55
|
+
], OmniRecordType.prototype, "externalId", void 0);
|
|
56
|
+
__decorate([
|
|
57
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(String) }),
|
|
58
|
+
(0, class_validator_1.IsString)(),
|
|
59
|
+
(0, class_validator_1.MaxLength)(255),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], OmniRecordType.prototype, "title", void 0);
|
|
62
|
+
__decorate([
|
|
63
|
+
(0, object_decorator_js_1.ModelField)({
|
|
64
|
+
gqlType: (0, returnValue_js_1.default)(String),
|
|
65
|
+
gqlOptions: { nullable: true },
|
|
66
|
+
}),
|
|
67
|
+
(0, class_validator_1.IsOptional)(),
|
|
68
|
+
(0, class_validator_1.IsString)(),
|
|
69
|
+
(0, class_validator_1.MaxLength)(255),
|
|
70
|
+
__metadata("design:type", Object)
|
|
71
|
+
], OmniRecordType.prototype, "slug", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(String) }),
|
|
74
|
+
(0, class_validator_1.IsString)(),
|
|
75
|
+
(0, class_validator_1.MaxLength)(64),
|
|
76
|
+
__metadata("design:type", String)
|
|
77
|
+
], OmniRecordType.prototype, "kind", void 0);
|
|
78
|
+
__decorate([
|
|
79
|
+
(0, object_decorator_js_1.ModelField)({ gqlType: (0, returnValue_js_1.default)(omni_record_status_enum_js_1.OmniRecordStatus) }),
|
|
80
|
+
(0, class_validator_1.IsEnum)(omni_record_status_enum_js_1.OmniRecordStatus),
|
|
81
|
+
__metadata("design:type", String)
|
|
82
|
+
], OmniRecordType.prototype, "status", void 0);
|
|
83
|
+
__decorate([
|
|
84
|
+
(0, object_decorator_js_1.ModelField)({
|
|
85
|
+
gqlType: (0, returnValue_js_1.default)(graphql_type_json_1.GraphQLJSONObject),
|
|
86
|
+
gqlOptions: { nullable: true },
|
|
87
|
+
}),
|
|
88
|
+
(0, class_validator_1.IsOptional)(),
|
|
89
|
+
(0, class_validator_1.IsObject)(),
|
|
90
|
+
__metadata("design:type", Object)
|
|
91
|
+
], OmniRecordType.prototype, "payload", void 0);
|
|
92
|
+
__decorate([
|
|
93
|
+
(0, object_decorator_js_1.ModelField)({
|
|
94
|
+
gqlType: (0, returnValue_js_1.default)(String),
|
|
95
|
+
gqlOptions: { nullable: true },
|
|
96
|
+
}),
|
|
97
|
+
(0, class_validator_1.IsOptional)(),
|
|
98
|
+
(0, class_validator_1.IsString)(),
|
|
99
|
+
(0, class_validator_1.MaxLength)(128),
|
|
100
|
+
__metadata("design:type", Object)
|
|
101
|
+
], OmniRecordType.prototype, "payloadSchemaId", void 0);
|
|
102
|
+
__decorate([
|
|
103
|
+
(0, object_decorator_js_1.ModelField)({
|
|
104
|
+
gqlType: (0, returnValue_js_1.default)(graphql_1.Int),
|
|
105
|
+
gqlOptions: { nullable: true },
|
|
106
|
+
}),
|
|
107
|
+
(0, class_validator_1.IsOptional)(),
|
|
108
|
+
(0, class_validator_1.IsInt)(),
|
|
109
|
+
__metadata("design:type", Object)
|
|
110
|
+
], OmniRecordType.prototype, "payloadSchemaVersion", void 0);
|
|
111
|
+
__decorate([
|
|
112
|
+
(0, object_decorator_js_1.ModelField)({
|
|
113
|
+
gqlType: () => [omni_relation_dto_js_1.OmniRelationType],
|
|
114
|
+
gqlOptions: { nullable: true },
|
|
115
|
+
relation: {
|
|
116
|
+
relationType: 'one-to-many',
|
|
117
|
+
sourceKey: { dst: 'guid', alias: 'guid' },
|
|
118
|
+
targetKey: { dst: 'sourceRecordId', alias: 'sourceRecordId' },
|
|
119
|
+
type: () => omni_relation_entity_js_1.OmniRelationEntity,
|
|
120
|
+
},
|
|
121
|
+
}),
|
|
122
|
+
__metadata("design:type", Object)
|
|
123
|
+
], OmniRecordType.prototype, "outgoingRelations", void 0);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, object_decorator_js_1.ModelField)({
|
|
126
|
+
gqlType: () => [omni_relation_dto_js_1.OmniRelationType],
|
|
127
|
+
gqlOptions: { nullable: true },
|
|
128
|
+
relation: {
|
|
129
|
+
relationType: 'one-to-many',
|
|
130
|
+
sourceKey: { dst: 'guid', alias: 'guid' },
|
|
131
|
+
targetKey: { dst: 'targetRecordId', alias: 'targetRecordId' },
|
|
132
|
+
type: () => omni_relation_entity_js_1.OmniRelationEntity,
|
|
133
|
+
},
|
|
134
|
+
}),
|
|
135
|
+
__metadata("design:type", Object)
|
|
136
|
+
], OmniRecordType.prototype, "incomingRelations", void 0);
|
|
137
|
+
exports.OmniRecordType = OmniRecordType = __decorate([
|
|
138
|
+
(0, graphql_1.ObjectType)(),
|
|
139
|
+
(0, object_decorator_js_1.ModelObject)(),
|
|
140
|
+
__metadata("design:paramtypes", [Object])
|
|
141
|
+
], OmniRecordType);
|
|
142
|
+
let OmniRecordCreateInput = class OmniRecordCreateInput extends (0, graphql_1.OmitType)(OmniRecordType, [
|
|
143
|
+
'createdAt',
|
|
144
|
+
'updatedAt',
|
|
145
|
+
'revision',
|
|
146
|
+
'outgoingRelations',
|
|
147
|
+
'incomingRelations',
|
|
148
|
+
], graphql_1.InputType) {
|
|
149
|
+
};
|
|
150
|
+
exports.OmniRecordCreateInput = OmniRecordCreateInput;
|
|
151
|
+
exports.OmniRecordCreateInput = OmniRecordCreateInput = __decorate([
|
|
152
|
+
(0, graphql_1.InputType)(),
|
|
153
|
+
(0, object_decorator_js_1.ModelObject)()
|
|
154
|
+
], OmniRecordCreateInput);
|
|
155
|
+
let OmniRecordCondition = class OmniRecordCondition extends (0, graphql_1.PartialType)(OmniRecordCreateInput, graphql_1.InputType) {
|
|
156
|
+
};
|
|
157
|
+
exports.OmniRecordCondition = OmniRecordCondition;
|
|
158
|
+
exports.OmniRecordCondition = OmniRecordCondition = __decorate([
|
|
159
|
+
(0, graphql_1.InputType)(),
|
|
160
|
+
(0, object_decorator_js_1.ModelObject)({ copyFrom: OmniRecordType })
|
|
161
|
+
], OmniRecordCondition);
|
|
162
|
+
let OmniRecordUpdateInput = class OmniRecordUpdateInput extends (0, graphql_1.PartialType)(OmniRecordCreateInput, graphql_1.InputType) {
|
|
163
|
+
};
|
|
164
|
+
exports.OmniRecordUpdateInput = OmniRecordUpdateInput;
|
|
165
|
+
exports.OmniRecordUpdateInput = OmniRecordUpdateInput = __decorate([
|
|
166
|
+
(0, graphql_1.InputType)(),
|
|
167
|
+
(0, object_decorator_js_1.ModelObject)({ copyFrom: OmniRecordType })
|
|
168
|
+
], OmniRecordUpdateInput);
|
|
169
|
+
//# sourceMappingURL=omni-record.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-record.dto.js","sourceRoot":"","sources":["omni-record.dto.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,6CAMyB;AACzB,mFAGmD;AACnD,gFAAyE;AACzE,uFAA4D;AAC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ACrB,mBAAS,CACV;CAAG,CAAA;AAHS,sDAAqB;gCAArB,qBAAqB;IAFjC,IAAA,mBAAS,GAAE;IACX,IAAA,iCAAW,EAAC,EAAE,QAAQ,EAAE,cAAc,EAAE,CAAC;GAC7B,qBAAqB,CAG9B"}
|
|
@@ -0,0 +1,157 @@
|
|
|
1
|
+
import {
|
|
2
|
+
InputType,
|
|
3
|
+
Int,
|
|
4
|
+
ObjectType,
|
|
5
|
+
OmitType,
|
|
6
|
+
PartialType,
|
|
7
|
+
} from '@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
|
+
MaxLength,
|
|
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 { OmniRelationType } from './omni-relation.dto.js';
|
|
29
|
+
import { OmniRecordStatus } from './omni-record-status.enum.js';
|
|
30
|
+
|
|
31
|
+
@ObjectType()
|
|
32
|
+
@ModelObject()
|
|
33
|
+
export class OmniRecordType extends OmniRecordEntity {
|
|
34
|
+
constructor(data?: Partial<OmniRecordType>) {
|
|
35
|
+
super();
|
|
36
|
+
if (data) {
|
|
37
|
+
assignOmniPublicDto(this, data);
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
@ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
|
|
42
|
+
@IsUUID()
|
|
43
|
+
guid!: string;
|
|
44
|
+
|
|
45
|
+
@ModelField({ gqlType: returnValue(Int) })
|
|
46
|
+
@IsInt()
|
|
47
|
+
revision!: number;
|
|
48
|
+
|
|
49
|
+
@ModelField({
|
|
50
|
+
gqlType: returnValue(String),
|
|
51
|
+
gqlOptions: { nullable: true },
|
|
52
|
+
})
|
|
53
|
+
@IsOptional()
|
|
54
|
+
@IsString()
|
|
55
|
+
@MaxLength(128)
|
|
56
|
+
externalId?: string | null;
|
|
57
|
+
|
|
58
|
+
@ModelField({ gqlType: returnValue(String) })
|
|
59
|
+
@IsString()
|
|
60
|
+
@MaxLength(255)
|
|
61
|
+
title!: string;
|
|
62
|
+
|
|
63
|
+
@ModelField({
|
|
64
|
+
gqlType: returnValue(String),
|
|
65
|
+
gqlOptions: { nullable: true },
|
|
66
|
+
})
|
|
67
|
+
@IsOptional()
|
|
68
|
+
@IsString()
|
|
69
|
+
@MaxLength(255)
|
|
70
|
+
slug?: string | null;
|
|
71
|
+
|
|
72
|
+
@ModelField({ gqlType: returnValue(String) })
|
|
73
|
+
@IsString()
|
|
74
|
+
@MaxLength(64)
|
|
75
|
+
kind!: string;
|
|
76
|
+
|
|
77
|
+
@ModelField({ gqlType: returnValue(OmniRecordStatus) })
|
|
78
|
+
@IsEnum(OmniRecordStatus)
|
|
79
|
+
status!: OmniRecordStatus;
|
|
80
|
+
|
|
81
|
+
@ModelField({
|
|
82
|
+
gqlType: returnValue(GraphQLJSONObject),
|
|
83
|
+
gqlOptions: { nullable: true },
|
|
84
|
+
})
|
|
85
|
+
@IsOptional()
|
|
86
|
+
@IsObject()
|
|
87
|
+
payload?: Record<string, unknown> | null;
|
|
88
|
+
|
|
89
|
+
@ModelField({
|
|
90
|
+
gqlType: returnValue(String),
|
|
91
|
+
gqlOptions: { nullable: true },
|
|
92
|
+
})
|
|
93
|
+
@IsOptional()
|
|
94
|
+
@IsString()
|
|
95
|
+
@MaxLength(128)
|
|
96
|
+
payloadSchemaId?: string | null;
|
|
97
|
+
|
|
98
|
+
@ModelField({
|
|
99
|
+
gqlType: returnValue(Int),
|
|
100
|
+
gqlOptions: { nullable: true },
|
|
101
|
+
})
|
|
102
|
+
@IsOptional()
|
|
103
|
+
@IsInt()
|
|
104
|
+
payloadSchemaVersion?: number | null;
|
|
105
|
+
|
|
106
|
+
@ModelField({
|
|
107
|
+
gqlType: () => [OmniRelationType],
|
|
108
|
+
gqlOptions: { nullable: true },
|
|
109
|
+
relation: {
|
|
110
|
+
relationType: 'one-to-many',
|
|
111
|
+
sourceKey: { dst: 'guid', alias: 'guid' },
|
|
112
|
+
targetKey: { dst: 'sourceRecordId', alias: 'sourceRecordId' },
|
|
113
|
+
type: () => OmniRelationEntity,
|
|
114
|
+
},
|
|
115
|
+
})
|
|
116
|
+
outgoingRelations?: Relation<OmniRelationType[]>;
|
|
117
|
+
|
|
118
|
+
@ModelField({
|
|
119
|
+
gqlType: () => [OmniRelationType],
|
|
120
|
+
gqlOptions: { nullable: true },
|
|
121
|
+
relation: {
|
|
122
|
+
relationType: 'one-to-many',
|
|
123
|
+
sourceKey: { dst: 'guid', alias: 'guid' },
|
|
124
|
+
targetKey: { dst: 'targetRecordId', alias: 'targetRecordId' },
|
|
125
|
+
type: () => OmniRelationEntity,
|
|
126
|
+
},
|
|
127
|
+
})
|
|
128
|
+
incomingRelations?: Relation<OmniRelationType[]>;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
@InputType()
|
|
132
|
+
@ModelObject()
|
|
133
|
+
export class OmniRecordCreateInput extends OmitType(
|
|
134
|
+
OmniRecordType,
|
|
135
|
+
[
|
|
136
|
+
'createdAt',
|
|
137
|
+
'updatedAt',
|
|
138
|
+
'revision',
|
|
139
|
+
'outgoingRelations',
|
|
140
|
+
'incomingRelations',
|
|
141
|
+
] as const,
|
|
142
|
+
InputType,
|
|
143
|
+
) {}
|
|
144
|
+
|
|
145
|
+
@InputType()
|
|
146
|
+
@ModelObject({ copyFrom: OmniRecordType })
|
|
147
|
+
export class OmniRecordCondition extends PartialType(
|
|
148
|
+
OmniRecordCreateInput,
|
|
149
|
+
InputType,
|
|
150
|
+
) {}
|
|
151
|
+
|
|
152
|
+
@InputType()
|
|
153
|
+
@ModelObject({ copyFrom: OmniRecordType })
|
|
154
|
+
export class OmniRecordUpdateInput extends PartialType(
|
|
155
|
+
OmniRecordCreateInput,
|
|
156
|
+
InputType,
|
|
157
|
+
) {}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { CrudGenFindManyOptions } from '@nest-yalc-2/crud-gen/api-graphql/crud-gen-gql.interface.js';
|
|
2
|
+
import type { GenericTypeORMRepository } from '@nest-yalc-2/crud-gen/typeorm/generic.repository.js';
|
|
3
|
+
import { type DeepPartial, type FindOptionsWhere } from 'typeorm';
|
|
4
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
5
|
+
import type { OmniDeletePolicy, OmniScope } from './omni-scope.js';
|
|
6
|
+
import { OmniScopedService } from './omni-scoped.service.js';
|
|
7
|
+
export declare class OmniRecordService extends OmniScopedService<OmniRecordEntity> {
|
|
8
|
+
private readonly reservedKinds;
|
|
9
|
+
constructor(repository: GenericTypeORMRepository<OmniRecordEntity>, scopeOrRepositoryWrite?: OmniScope | GenericTypeORMRepository<OmniRecordEntity>, deletion?: OmniDeletePolicy, reservedRecordKinds?: readonly string[]);
|
|
10
|
+
createEntity(input: DeepPartial<OmniRecordEntity>, findOptions?: CrudGenFindManyOptions<OmniRecordEntity>, returnEntity?: true): Promise<OmniRecordEntity>;
|
|
11
|
+
createEntity(input: DeepPartial<OmniRecordEntity>, findOptions?: CrudGenFindManyOptions<OmniRecordEntity>, returnEntity?: boolean): Promise<OmniRecordEntity | boolean>;
|
|
12
|
+
updateEntity(conditions: FindOptionsWhere<OmniRecordEntity>, input: DeepPartial<OmniRecordEntity>, findOptions?: CrudGenFindManyOptions<OmniRecordEntity>, returnEntity?: true): Promise<OmniRecordEntity>;
|
|
13
|
+
updateEntity(conditions: FindOptionsWhere<OmniRecordEntity>, input: DeepPartial<OmniRecordEntity>, findOptions?: CrudGenFindManyOptions<OmniRecordEntity>, returnEntity?: boolean): Promise<OmniRecordEntity | boolean>;
|
|
14
|
+
deleteEntity(conditions: FindOptionsWhere<OmniRecordEntity>): Promise<boolean>;
|
|
15
|
+
private assertExistingRecordIsNotReserved;
|
|
16
|
+
private nonReservedConditions;
|
|
17
|
+
private rejectReservedKind;
|
|
18
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmniRecordService = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const omni_scoped_service_js_1 = require("./omni-scoped.service.js");
|
|
7
|
+
class OmniRecordService extends omni_scoped_service_js_1.OmniScopedService {
|
|
8
|
+
constructor(repository, scopeOrRepositoryWrite, deletion = 'tombstone', reservedRecordKinds = []) {
|
|
9
|
+
super(repository, scopeOrRepositoryWrite, deletion);
|
|
10
|
+
this.reservedKinds = new Set(reservedRecordKinds);
|
|
11
|
+
}
|
|
12
|
+
async createEntity(input, findOptions, returnEntity = true) {
|
|
13
|
+
this.rejectReservedKind(input.kind);
|
|
14
|
+
return super.createEntity(input, findOptions, returnEntity);
|
|
15
|
+
}
|
|
16
|
+
async updateEntity(conditions, input, findOptions, returnEntity = true) {
|
|
17
|
+
this.rejectReservedKind(input.kind);
|
|
18
|
+
await this.assertExistingRecordIsNotReserved(conditions);
|
|
19
|
+
return super.updateEntity(this.nonReservedConditions(conditions), input, findOptions, returnEntity);
|
|
20
|
+
}
|
|
21
|
+
async deleteEntity(conditions) {
|
|
22
|
+
await this.assertExistingRecordIsNotReserved(conditions);
|
|
23
|
+
return super.deleteEntity(this.nonReservedConditions(conditions));
|
|
24
|
+
}
|
|
25
|
+
async assertExistingRecordIsNotReserved(conditions) {
|
|
26
|
+
const record = await super.getEntity(conditions, undefined, undefined, undefined, { failOnNull: false });
|
|
27
|
+
if (record)
|
|
28
|
+
this.rejectReservedKind(record.kind);
|
|
29
|
+
}
|
|
30
|
+
nonReservedConditions(conditions) {
|
|
31
|
+
if (this.reservedKinds.size === 0)
|
|
32
|
+
return conditions;
|
|
33
|
+
return {
|
|
34
|
+
...conditions,
|
|
35
|
+
kind: (0, typeorm_1.Not)((0, typeorm_1.In)([...this.reservedKinds])),
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
rejectReservedKind(kind) {
|
|
39
|
+
if (typeof kind === 'string' && this.reservedKinds.has(kind)) {
|
|
40
|
+
throw new common_1.BadRequestException('This record kind is owned by a registered extension projection.');
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
exports.OmniRecordService = OmniRecordService;
|
|
45
|
+
//# sourceMappingURL=omni-record.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-record.service.js","sourceRoot":"","sources":["omni-record.service.ts"],"names":[],"mappings":";;;AAAA,2CAAqD;AAGrD,qCAA2E;AAG3E,qEAA6D;AAQ7D,MAAa,iBAAkB,SAAQ,0CAAmC;IAGxE,YACE,UAAsD,EACtD,sBACwD,EACxD,WAA6B,WAAW,EACxC,sBAAyC,EAAE;QAE3C,KAAK,CAAC,UAAU,EAAE,sBAAsB,EAAE,QAAQ,CAAC,CAAC;QACpD,IAAI,CAAC,aAAa,GAAG,IAAI,GAAG,CAAC,mBAAmB,CAAC,CAAC;IACpD,CAAC;IAYQ,KAAK,CAAC,YAAY,CACzB,KAAoC,EACpC,WAAsD,EACtD,YAAY,GAAG,IAAI;QAEnB,IAAI,CAAC,kBAAkB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACpC,OAAO,KAAK,CAAC,YAAY,CAAC,K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IAAI,CAAC,EAAE,CAAC;YAC7D,MAAM,IAAI,4BAAmB,CAC3B,iEAAiE,CAClE,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AAlGD,8CAkGC"}
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
import { BadRequestException } from '@nestjs/common';
|
|
2
|
+
import type { CrudGenFindManyOptions } from '@nest-yalc-2/crud-gen/api-graphql/crud-gen-gql.interface.js';
|
|
3
|
+
import type { GenericTypeORMRepository } from '@nest-yalc-2/crud-gen/typeorm/generic.repository.js';
|
|
4
|
+
import { In, Not, type DeepPartial, type FindOptionsWhere } from 'typeorm';
|
|
5
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
6
|
+
import type { OmniDeletePolicy, OmniScope } from './omni-scope.js';
|
|
7
|
+
import { OmniScopedService } from './omni-scoped.service.js';
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Raw Omni record CRUD with a mechanical boundary around extension-owned
|
|
11
|
+
* kinds. A registered extension is the only writer for its owner lifecycle;
|
|
12
|
+
* mounting a generic record transport cannot turn another record into that
|
|
13
|
+
* kind or mutate/delete an existing owner.
|
|
14
|
+
*/
|
|
15
|
+
export class OmniRecordService extends OmniScopedService<OmniRecordEntity> {
|
|
16
|
+
private readonly reservedKinds: ReadonlySet<string>;
|
|
17
|
+
|
|
18
|
+
constructor(
|
|
19
|
+
repository: GenericTypeORMRepository<OmniRecordEntity>,
|
|
20
|
+
scopeOrRepositoryWrite?:
|
|
21
|
+
OmniScope | GenericTypeORMRepository<OmniRecordEntity>,
|
|
22
|
+
deletion: OmniDeletePolicy = 'tombstone',
|
|
23
|
+
reservedRecordKinds: readonly string[] = [],
|
|
24
|
+
) {
|
|
25
|
+
super(repository, scopeOrRepositoryWrite, deletion);
|
|
26
|
+
this.reservedKinds = new Set(reservedRecordKinds);
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
override async createEntity(
|
|
30
|
+
input: DeepPartial<OmniRecordEntity>,
|
|
31
|
+
findOptions?: CrudGenFindManyOptions<OmniRecordEntity>,
|
|
32
|
+
returnEntity?: true,
|
|
33
|
+
): Promise<OmniRecordEntity>;
|
|
34
|
+
override async createEntity(
|
|
35
|
+
input: DeepPartial<OmniRecordEntity>,
|
|
36
|
+
findOptions?: CrudGenFindManyOptions<OmniRecordEntity>,
|
|
37
|
+
returnEntity?: boolean,
|
|
38
|
+
): Promise<OmniRecordEntity | boolean>;
|
|
39
|
+
override async createEntity(
|
|
40
|
+
input: DeepPartial<OmniRecordEntity>,
|
|
41
|
+
findOptions?: CrudGenFindManyOptions<OmniRecordEntity>,
|
|
42
|
+
returnEntity = true,
|
|
43
|
+
): Promise<OmniRecordEntity | boolean> {
|
|
44
|
+
this.rejectReservedKind(input.kind);
|
|
45
|
+
return super.createEntity(input, findOptions, returnEntity);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
override async updateEntity(
|
|
49
|
+
conditions: FindOptionsWhere<OmniRecordEntity>,
|
|
50
|
+
input: DeepPartial<OmniRecordEntity>,
|
|
51
|
+
findOptions?: CrudGenFindManyOptions<OmniRecordEntity>,
|
|
52
|
+
returnEntity?: true,
|
|
53
|
+
): Promise<OmniRecordEntity>;
|
|
54
|
+
override async updateEntity(
|
|
55
|
+
conditions: FindOptionsWhere<OmniRecordEntity>,
|
|
56
|
+
input: DeepPartial<OmniRecordEntity>,
|
|
57
|
+
findOptions?: CrudGenFindManyOptions<OmniRecordEntity>,
|
|
58
|
+
returnEntity?: boolean,
|
|
59
|
+
): Promise<OmniRecordEntity | boolean>;
|
|
60
|
+
override async updateEntity(
|
|
61
|
+
conditions: FindOptionsWhere<OmniRecordEntity>,
|
|
62
|
+
input: DeepPartial<OmniRecordEntity>,
|
|
63
|
+
findOptions?: CrudGenFindManyOptions<OmniRecordEntity>,
|
|
64
|
+
returnEntity = true,
|
|
65
|
+
): Promise<OmniRecordEntity | boolean> {
|
|
66
|
+
this.rejectReservedKind(input.kind);
|
|
67
|
+
await this.assertExistingRecordIsNotReserved(conditions);
|
|
68
|
+
return super.updateEntity(
|
|
69
|
+
this.nonReservedConditions(conditions),
|
|
70
|
+
input,
|
|
71
|
+
findOptions,
|
|
72
|
+
returnEntity,
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
override async deleteEntity(
|
|
77
|
+
conditions: FindOptionsWhere<OmniRecordEntity>,
|
|
78
|
+
): Promise<boolean> {
|
|
79
|
+
await this.assertExistingRecordIsNotReserved(conditions);
|
|
80
|
+
return super.deleteEntity(this.nonReservedConditions(conditions));
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private async assertExistingRecordIsNotReserved(
|
|
84
|
+
conditions: FindOptionsWhere<OmniRecordEntity>,
|
|
85
|
+
): Promise<void> {
|
|
86
|
+
const record = await super.getEntity(
|
|
87
|
+
conditions,
|
|
88
|
+
undefined,
|
|
89
|
+
undefined,
|
|
90
|
+
undefined,
|
|
91
|
+
{ failOnNull: false },
|
|
92
|
+
);
|
|
93
|
+
if (record) this.rejectReservedKind(record.kind);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
private nonReservedConditions(
|
|
97
|
+
conditions: FindOptionsWhere<OmniRecordEntity>,
|
|
98
|
+
): FindOptionsWhere<OmniRecordEntity> {
|
|
99
|
+
if (this.reservedKinds.size === 0) return conditions;
|
|
100
|
+
return {
|
|
101
|
+
...conditions,
|
|
102
|
+
kind: Not(In([...this.reservedKinds])),
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
private rejectReservedKind(kind: unknown): void {
|
|
107
|
+
if (typeof kind === 'string' && this.reservedKinds.has(kind)) {
|
|
108
|
+
throw new BadRequestException(
|
|
109
|
+
'This record kind is owned by a registered extension projection.',
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { OmniRelationKind } from './omni-relation-kind.enum.js';
|
|
2
|
+
export declare const omniRelationKindPattern: RegExp;
|
|
3
|
+
export declare const canonicalOmniRelationKinds: readonly [OmniRelationKind.Contains, OmniRelationKind.References, OmniRelationKind.RelatedTo, OmniRelationKind.DerivedFrom];
|
|
4
|
+
export interface OmniRelationKindContract {
|
|
5
|
+
readonly kinds: ReadonlySet<string>;
|
|
6
|
+
assert(kind: unknown): asserts kind is string;
|
|
7
|
+
has(kind: string): boolean;
|
|
8
|
+
}
|
|
9
|
+
export declare function createOmniRelationKindContract(additionalKinds?: readonly string[]): OmniRelationKindContract;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.canonicalOmniRelationKinds = exports.omniRelationKindPattern = void 0;
|
|
4
|
+
exports.createOmniRelationKindContract = createOmniRelationKindContract;
|
|
5
|
+
const omni_relation_kind_enum_js_1 = require("./omni-relation-kind.enum.js");
|
|
6
|
+
exports.omniRelationKindPattern = /^[a-z][a-z0-9_]{0,63}$/;
|
|
7
|
+
exports.canonicalOmniRelationKinds = Object.freeze([
|
|
8
|
+
omni_relation_kind_enum_js_1.OmniRelationKind.Contains,
|
|
9
|
+
omni_relation_kind_enum_js_1.OmniRelationKind.References,
|
|
10
|
+
omni_relation_kind_enum_js_1.OmniRelationKind.RelatedTo,
|
|
11
|
+
omni_relation_kind_enum_js_1.OmniRelationKind.DerivedFrom,
|
|
12
|
+
]);
|
|
13
|
+
function createOmniRelationKindContract(additionalKinds = []) {
|
|
14
|
+
const kinds = new Set(exports.canonicalOmniRelationKinds);
|
|
15
|
+
for (const kind of additionalKinds) {
|
|
16
|
+
if (typeof kind !== 'string' || !exports.omniRelationKindPattern.test(kind)) {
|
|
17
|
+
throw new TypeError('Omni relation kinds must use lowercase letters, digits, and underscores.');
|
|
18
|
+
}
|
|
19
|
+
kinds.add(kind);
|
|
20
|
+
}
|
|
21
|
+
return Object.freeze({
|
|
22
|
+
kinds,
|
|
23
|
+
assert(kind) {
|
|
24
|
+
if (typeof kind !== 'string' || !kinds.has(kind)) {
|
|
25
|
+
throw new TypeError('Omni relation kind is not registered for this module.');
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
has(kind) {
|
|
29
|
+
return kinds.has(kind);
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
//# 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":";;;AAsBA,wEA0BC;AAhDD,6EAAgE;AAEnD,QAAA,uBAAuB,GAAG,wBAAwB,CAAC;AAEnD,QAAA,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC;IACtD,6CAAgB,CAAC,QAAQ;IACzB,6CAAgB,CAAC,UAAU;IAC3B,6CAAgB,CAAC,SAAS;IAC1B,6CAAgB,CAAC,WAAW;CACpB,CAAC,CAAC;AAaZ,SAAgB,8BAA8B,CAC5C,kBAAqC,EAAE;IAEvC,MAAM,KAAK,GAAG,IAAI,GAAG,CAAS,kCAA0B,CAAC,CAAC;IAC1D,KAAK,MAAM,IAAI,IAAI,eAAe,EAAE,CAAC;QACnC,IAAI,OAAO,IAAI,KAAK,QAAQ,IAAI,CAAC,+BAAuB,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,49 @@
|
|
|
1
|
+
import { OmniRelationKind } from './omni-relation-kind.enum.js';
|
|
2
|
+
|
|
3
|
+
export const omniRelationKindPattern = /^[a-z][a-z0-9_]{0,63}$/;
|
|
4
|
+
|
|
5
|
+
export const canonicalOmniRelationKinds = Object.freeze([
|
|
6
|
+
OmniRelationKind.Contains,
|
|
7
|
+
OmniRelationKind.References,
|
|
8
|
+
OmniRelationKind.RelatedTo,
|
|
9
|
+
OmniRelationKind.DerivedFrom,
|
|
10
|
+
] as const);
|
|
11
|
+
|
|
12
|
+
export interface OmniRelationKindContract {
|
|
13
|
+
readonly kinds: ReadonlySet<string>;
|
|
14
|
+
assert(kind: unknown): asserts kind is string;
|
|
15
|
+
has(kind: string): boolean;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
/**
|
|
19
|
+
* Canonical kinds are stable exports. Applications may register additional
|
|
20
|
+
* syntactically portable kinds at module composition time without changing
|
|
21
|
+
* OmniKernel or turning arbitrary strings into valid graph semantics.
|
|
22
|
+
*/
|
|
23
|
+
export function createOmniRelationKindContract(
|
|
24
|
+
additionalKinds: readonly string[] = [],
|
|
25
|
+
): OmniRelationKindContract {
|
|
26
|
+
const kinds = new Set<string>(canonicalOmniRelationKinds);
|
|
27
|
+
for (const kind of additionalKinds) {
|
|
28
|
+
if (typeof kind !== 'string' || !omniRelationKindPattern.test(kind)) {
|
|
29
|
+
throw new TypeError(
|
|
30
|
+
'Omni relation kinds must use lowercase letters, digits, and underscores.',
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
kinds.add(kind);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
return Object.freeze({
|
|
37
|
+
kinds,
|
|
38
|
+
assert(kind: unknown): asserts kind is string {
|
|
39
|
+
if (typeof kind !== 'string' || !kinds.has(kind)) {
|
|
40
|
+
throw new TypeError(
|
|
41
|
+
'Omni relation kind is not registered for this module.',
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
has(kind: string): boolean {
|
|
46
|
+
return kinds.has(kind);
|
|
47
|
+
},
|
|
48
|
+
});
|
|
49
|
+
}
|