@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,452 @@
|
|
|
1
|
+
import type { CrudGenFindManyOptions } from '@nest-yalc-2/crud-gen';
|
|
2
|
+
import {
|
|
3
|
+
PROJECTION_INTEGER_MAX,
|
|
4
|
+
ProjectionResourceService,
|
|
5
|
+
type ProjectionDialect,
|
|
6
|
+
type ProjectionValuePatch,
|
|
7
|
+
} from '@nest-yalc-2/crud-gen';
|
|
8
|
+
import { YalcEventService } from '@nest-yalc-2/event-manager';
|
|
9
|
+
import {
|
|
10
|
+
In,
|
|
11
|
+
IsNull,
|
|
12
|
+
type DataSource,
|
|
13
|
+
type EntityManager,
|
|
14
|
+
type ObjectLiteral,
|
|
15
|
+
type Repository,
|
|
16
|
+
} from 'typeorm';
|
|
17
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
18
|
+
import {
|
|
19
|
+
createOmniProjectionReaderCatalog,
|
|
20
|
+
type OmniProjectionReaderCatalog,
|
|
21
|
+
} from './omni-projection.catalog.js';
|
|
22
|
+
import type { OmniExtensionProjectionDefinition } from './omni-extension-projection.definition.js';
|
|
23
|
+
import type { OmniProjectionLifecycle } from './omni-projection.lifecycle.js';
|
|
24
|
+
import type { OmniScope } from './omni-scope.js';
|
|
25
|
+
|
|
26
|
+
function hasOwn(input: Record<string, unknown>, field: string): boolean {
|
|
27
|
+
return Object.prototype.hasOwnProperty.call(input, field);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
function isUniqueConstraint(error: unknown): boolean {
|
|
31
|
+
const candidate = error as { driverError?: { code?: unknown } } | undefined;
|
|
32
|
+
const code = candidate?.driverError?.code;
|
|
33
|
+
return code === 'SQLITE_CONSTRAINT' || code === '23505';
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function isRetryableTransactionError(error: unknown): boolean {
|
|
37
|
+
const candidate = error as {
|
|
38
|
+
code?: unknown;
|
|
39
|
+
driverError?: { code?: unknown };
|
|
40
|
+
};
|
|
41
|
+
const code = candidate?.driverError?.code ?? candidate?.code;
|
|
42
|
+
return (
|
|
43
|
+
code === '40001' ||
|
|
44
|
+
code === 'SQLITE_BUSY' ||
|
|
45
|
+
code === 'SQLITE_BUSY_SNAPSHOT'
|
|
46
|
+
);
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
/**
|
|
50
|
+
* Generated-CRUD compatible store for a dedicated extension table. It keeps
|
|
51
|
+
* the Omni record as the only root identity and revision owner, while the
|
|
52
|
+
* extension table owns projected columns and its native JSON payload.
|
|
53
|
+
*/
|
|
54
|
+
export class OmniExtensionProjectionService<
|
|
55
|
+
Extension extends ObjectLiteral,
|
|
56
|
+
> extends ProjectionResourceService<Extension> {
|
|
57
|
+
constructor(
|
|
58
|
+
extensionRepository: Repository<Extension>,
|
|
59
|
+
private readonly ownerRepository: Repository<OmniRecordEntity>,
|
|
60
|
+
private readonly dataSource: DataSource,
|
|
61
|
+
scope: OmniScope,
|
|
62
|
+
dialect: ProjectionDialect,
|
|
63
|
+
events: YalcEventService,
|
|
64
|
+
private readonly omniDefinition: OmniExtensionProjectionDefinition,
|
|
65
|
+
private readonly lifecycle?: OmniProjectionLifecycle<
|
|
66
|
+
OmniExtensionProjectionDefinition,
|
|
67
|
+
Extension
|
|
68
|
+
>,
|
|
69
|
+
private readonly readerCatalog?: OmniProjectionReaderCatalog,
|
|
70
|
+
) {
|
|
71
|
+
super(extensionRepository, scope, dialect, events, omniDefinition);
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
override async getEntity(
|
|
75
|
+
conditions: Record<string, unknown>,
|
|
76
|
+
_fields?: string[],
|
|
77
|
+
_relations?: string[],
|
|
78
|
+
_databaseName?: string,
|
|
79
|
+
options?: { failOnNull?: boolean },
|
|
80
|
+
): Promise<Extension | null> {
|
|
81
|
+
const guid = this.guidFromConditions(conditions);
|
|
82
|
+
const entity = await this.readOne(guid);
|
|
83
|
+
if (!entity && options?.failOnNull) this.notFound();
|
|
84
|
+
return entity;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
override async getEntityListExtended(
|
|
88
|
+
findOptions: CrudGenFindManyOptions<Extension> = {},
|
|
89
|
+
withCount = false,
|
|
90
|
+
): Promise<Extension[] | [Extension[], number]> {
|
|
91
|
+
const [extensions, count] = await this.dialect.findMany(
|
|
92
|
+
this.repository,
|
|
93
|
+
this.definition,
|
|
94
|
+
this.scope.scopeId,
|
|
95
|
+
this.filtersFromFindOptions(findOptions),
|
|
96
|
+
this.sortingFromFindOptions(findOptions),
|
|
97
|
+
this.pageFromFindOptions(findOptions),
|
|
98
|
+
);
|
|
99
|
+
const guidColumn = this.definition.identity.column;
|
|
100
|
+
const guids = extensions.map(
|
|
101
|
+
(extension) =>
|
|
102
|
+
(extension as Record<string, unknown>)[guidColumn] as string,
|
|
103
|
+
);
|
|
104
|
+
if (guids.length === 0) return withCount ? [[], count] : [];
|
|
105
|
+
|
|
106
|
+
const owners = await this.ownerRepository.find({
|
|
107
|
+
where: {
|
|
108
|
+
scopeId: this.scope.scopeId,
|
|
109
|
+
guid: In(guids),
|
|
110
|
+
kind: this.omniDefinition.owner.kind,
|
|
111
|
+
payloadSchemaId: this.omniDefinition.owner.schema.id,
|
|
112
|
+
payloadSchemaVersion: this.omniDefinition.owner.schema.version,
|
|
113
|
+
deletedAt: IsNull(),
|
|
114
|
+
},
|
|
115
|
+
});
|
|
116
|
+
const ownersByGuid = new Map(owners.map((owner) => [owner.guid, owner]));
|
|
117
|
+
if (ownersByGuid.size !== extensions.length) {
|
|
118
|
+
throw new Error(
|
|
119
|
+
'Omni extension projection invariant failed: an extension owner is unavailable.',
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
const projected = extensions.map((extension) =>
|
|
123
|
+
this.merge(extension, ownersByGuid.get((extension as any)[guidColumn])!),
|
|
124
|
+
);
|
|
125
|
+
return withCount ? [projected, count] : projected;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
override async createEntity(
|
|
129
|
+
input: Record<string, unknown>,
|
|
130
|
+
): Promise<Extension> {
|
|
131
|
+
this.rejectUnknownInput(input, true);
|
|
132
|
+
const extension = this.createExtension(input);
|
|
133
|
+
const guid = extension[this.definition.identity.column] as string;
|
|
134
|
+
const owner = this.ownerRepository.create({
|
|
135
|
+
scopeId: this.scope.scopeId,
|
|
136
|
+
guid,
|
|
137
|
+
title: this.omniDefinition.owner.title,
|
|
138
|
+
kind: this.omniDefinition.owner.kind,
|
|
139
|
+
status: this.omniDefinition.owner.status,
|
|
140
|
+
payload: null,
|
|
141
|
+
payloadSchemaId: this.omniDefinition.owner.schema.id,
|
|
142
|
+
payloadSchemaVersion: this.omniDefinition.owner.schema.version,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
try {
|
|
146
|
+
return await this.mutate(async (manager) => {
|
|
147
|
+
await this.lifecycle?.beforeCreate?.({
|
|
148
|
+
definition: this.omniDefinition,
|
|
149
|
+
scope: this.scope,
|
|
150
|
+
manager,
|
|
151
|
+
readers: this.readers(manager),
|
|
152
|
+
input,
|
|
153
|
+
});
|
|
154
|
+
await manager.getRepository(OmniRecordEntity).save(owner);
|
|
155
|
+
const saved = await manager
|
|
156
|
+
.getRepository(this.repository.target)
|
|
157
|
+
.save(extension as Extension);
|
|
158
|
+
return this.merge(saved, owner);
|
|
159
|
+
});
|
|
160
|
+
} catch (error) {
|
|
161
|
+
if (isUniqueConstraint(error)) this.identityConflict();
|
|
162
|
+
throw error;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
override async updateEntity(
|
|
167
|
+
conditions: Record<string, unknown>,
|
|
168
|
+
input: Record<string, unknown>,
|
|
169
|
+
): Promise<Extension> {
|
|
170
|
+
this.rejectUnknownInput(input, false);
|
|
171
|
+
const guid = this.guidFromConditions(conditions);
|
|
172
|
+
const expectedRevision = input.expectedRevision;
|
|
173
|
+
if (
|
|
174
|
+
typeof expectedRevision !== 'number' ||
|
|
175
|
+
!Number.isInteger(expectedRevision) ||
|
|
176
|
+
expectedRevision < 1 ||
|
|
177
|
+
expectedRevision >= PROJECTION_INTEGER_MAX
|
|
178
|
+
) {
|
|
179
|
+
this.invalid(
|
|
180
|
+
`expectedRevision must be an integer between 1 and ${PROJECTION_INTEGER_MAX - 1}.`,
|
|
181
|
+
);
|
|
182
|
+
}
|
|
183
|
+
const patch = this.createValuePatch(guid, input);
|
|
184
|
+
|
|
185
|
+
return this.mutate(async (manager) => {
|
|
186
|
+
const owners = manager.getRepository(OmniRecordEntity);
|
|
187
|
+
const extensions = manager.getRepository(this.repository.target);
|
|
188
|
+
const currentOwner = await this.findOwner(guid, manager);
|
|
189
|
+
const currentExtension = await extensions.findOne({
|
|
190
|
+
where: {
|
|
191
|
+
[this.definition.scope.column]: this.scope.scopeId,
|
|
192
|
+
[this.definition.identity.column]: guid,
|
|
193
|
+
} as any,
|
|
194
|
+
});
|
|
195
|
+
if (!currentOwner) this.notFound();
|
|
196
|
+
if (currentOwner.revision !== expectedRevision) {
|
|
197
|
+
await this.throwUpdateMiss(guid, manager);
|
|
198
|
+
}
|
|
199
|
+
if (!currentExtension) {
|
|
200
|
+
throw new Error(
|
|
201
|
+
'Omni extension projection invariant failed: extension row is unavailable.',
|
|
202
|
+
);
|
|
203
|
+
}
|
|
204
|
+
await this.lifecycle?.beforeUpdate?.({
|
|
205
|
+
definition: this.omniDefinition,
|
|
206
|
+
scope: this.scope,
|
|
207
|
+
manager,
|
|
208
|
+
readers: this.readers(manager),
|
|
209
|
+
input,
|
|
210
|
+
current: this.merge(currentExtension, currentOwner),
|
|
211
|
+
});
|
|
212
|
+
const result = await owners
|
|
213
|
+
.createQueryBuilder()
|
|
214
|
+
.update()
|
|
215
|
+
.set({ revision: () => '"revision" + 1' })
|
|
216
|
+
.where(
|
|
217
|
+
'"scopeId" = :scopeId AND "guid" = :guid AND "revision" = :expectedRevision AND "kind" = :kind AND "payloadSchemaId" = :schemaId AND "payloadSchemaVersion" = :schemaVersion AND "deletedAt" IS NULL',
|
|
218
|
+
{
|
|
219
|
+
scopeId: this.scope.scopeId,
|
|
220
|
+
guid,
|
|
221
|
+
expectedRevision,
|
|
222
|
+
kind: this.omniDefinition.owner.kind,
|
|
223
|
+
schemaId: this.omniDefinition.owner.schema.id,
|
|
224
|
+
schemaVersion: this.omniDefinition.owner.schema.version,
|
|
225
|
+
},
|
|
226
|
+
)
|
|
227
|
+
.execute();
|
|
228
|
+
if (!result.affected) await this.throwUpdateMiss(guid, manager);
|
|
229
|
+
|
|
230
|
+
const patched = await this.dialect.patchValues(
|
|
231
|
+
extensions,
|
|
232
|
+
this.definition,
|
|
233
|
+
patch,
|
|
234
|
+
);
|
|
235
|
+
if (patched !== 1) {
|
|
236
|
+
throw new Error(
|
|
237
|
+
'Omni extension projection invariant failed: extension row is unavailable.',
|
|
238
|
+
);
|
|
239
|
+
}
|
|
240
|
+
const extension = await extensions.findOneOrFail({
|
|
241
|
+
where: {
|
|
242
|
+
[this.definition.scope.column]: this.scope.scopeId,
|
|
243
|
+
[this.definition.identity.column]: guid,
|
|
244
|
+
} as any,
|
|
245
|
+
});
|
|
246
|
+
const owner = await owners.findOneOrFail({
|
|
247
|
+
where: { scopeId: this.scope.scopeId, guid },
|
|
248
|
+
});
|
|
249
|
+
return this.merge(extension, owner);
|
|
250
|
+
});
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
override async deleteEntity(
|
|
254
|
+
conditions: Record<string, unknown>,
|
|
255
|
+
): Promise<boolean> {
|
|
256
|
+
const guid = this.guidFromConditions(conditions);
|
|
257
|
+
await this.mutate(async (manager) => {
|
|
258
|
+
const owner = await this.findOwner(guid, manager);
|
|
259
|
+
if (!owner) this.notFound();
|
|
260
|
+
const extension = await manager
|
|
261
|
+
.getRepository(this.repository.target)
|
|
262
|
+
.findOne({
|
|
263
|
+
where: {
|
|
264
|
+
[this.definition.scope.column]: this.scope.scopeId,
|
|
265
|
+
[this.definition.identity.column]: guid,
|
|
266
|
+
} as any,
|
|
267
|
+
});
|
|
268
|
+
if (!extension) {
|
|
269
|
+
throw new Error(
|
|
270
|
+
'Omni extension projection invariant failed: extension row is unavailable.',
|
|
271
|
+
);
|
|
272
|
+
}
|
|
273
|
+
await this.lifecycle?.beforeDelete?.({
|
|
274
|
+
definition: this.omniDefinition,
|
|
275
|
+
scope: this.scope,
|
|
276
|
+
manager,
|
|
277
|
+
readers: this.readers(manager),
|
|
278
|
+
input: {},
|
|
279
|
+
current: this.merge(extension, owner),
|
|
280
|
+
});
|
|
281
|
+
const result = await manager.getRepository(OmniRecordEntity).delete({
|
|
282
|
+
scopeId: this.scope.scopeId,
|
|
283
|
+
guid,
|
|
284
|
+
kind: this.omniDefinition.owner.kind,
|
|
285
|
+
payloadSchemaId: this.omniDefinition.owner.schema.id,
|
|
286
|
+
payloadSchemaVersion: this.omniDefinition.owner.schema.version,
|
|
287
|
+
});
|
|
288
|
+
if (!result.affected) this.notFound();
|
|
289
|
+
});
|
|
290
|
+
return true;
|
|
291
|
+
}
|
|
292
|
+
|
|
293
|
+
private createExtension(
|
|
294
|
+
input: Record<string, unknown>,
|
|
295
|
+
): Record<string, unknown> {
|
|
296
|
+
const extension: Record<string, unknown> = {
|
|
297
|
+
[this.definition.scope.column]: this.scope.scopeId,
|
|
298
|
+
[this.definition.payload.column]: this.createPayload(input),
|
|
299
|
+
};
|
|
300
|
+
for (const field of this.definition.fields) {
|
|
301
|
+
const value = input[field.name];
|
|
302
|
+
if (field.requiredOnCreate && (value === undefined || value === null)) {
|
|
303
|
+
this.invalid(`Projection field ${field.name} is required on create.`);
|
|
304
|
+
}
|
|
305
|
+
if (value === null && !field.nullable) {
|
|
306
|
+
this.invalid(`Projection field ${field.name} cannot be null.`);
|
|
307
|
+
}
|
|
308
|
+
if (value !== undefined && field.storage === 'column') {
|
|
309
|
+
extension[field.column ?? field.name] = this.normalizeValue(
|
|
310
|
+
field,
|
|
311
|
+
value,
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
return extension;
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
private readers(manager: EntityManager) {
|
|
319
|
+
return (
|
|
320
|
+
this.readerCatalog ??
|
|
321
|
+
createOmniProjectionReaderCatalog([
|
|
322
|
+
{
|
|
323
|
+
type: 'extension',
|
|
324
|
+
id: this.omniDefinition.id,
|
|
325
|
+
entity: this.repository.target,
|
|
326
|
+
definition: this.omniDefinition,
|
|
327
|
+
},
|
|
328
|
+
])
|
|
329
|
+
).bind(manager, this.scope);
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
private async mutate<T>(
|
|
333
|
+
work: (manager: EntityManager) => Promise<T>,
|
|
334
|
+
): Promise<T> {
|
|
335
|
+
try {
|
|
336
|
+
if (this.lifecycle) {
|
|
337
|
+
return await this.dataSource.transaction('SERIALIZABLE', work);
|
|
338
|
+
}
|
|
339
|
+
return await this.dataSource.transaction(work);
|
|
340
|
+
} catch (error) {
|
|
341
|
+
if (isRetryableTransactionError(error)) {
|
|
342
|
+
throw this.events.errorConflict(
|
|
343
|
+
'projection.concurrent.write.conflict',
|
|
344
|
+
{
|
|
345
|
+
response: {
|
|
346
|
+
message:
|
|
347
|
+
'Omni projection concurrent write conflict; retry the mutation.',
|
|
348
|
+
},
|
|
349
|
+
},
|
|
350
|
+
);
|
|
351
|
+
}
|
|
352
|
+
throw error;
|
|
353
|
+
}
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
private createValuePatch(
|
|
357
|
+
guid: string,
|
|
358
|
+
input: Record<string, unknown>,
|
|
359
|
+
): ProjectionValuePatch {
|
|
360
|
+
const patch: ProjectionValuePatch = {
|
|
361
|
+
scopeId: this.scope.scopeId,
|
|
362
|
+
guid,
|
|
363
|
+
columnValues: {},
|
|
364
|
+
jsonValues: [],
|
|
365
|
+
};
|
|
366
|
+
for (const field of this.definition.fields) {
|
|
367
|
+
if (
|
|
368
|
+
field.name === this.definition.identity.column ||
|
|
369
|
+
!hasOwn(input, field.name)
|
|
370
|
+
) {
|
|
371
|
+
continue;
|
|
372
|
+
}
|
|
373
|
+
const value = input[field.name];
|
|
374
|
+
if (value === null && !field.nullable) {
|
|
375
|
+
this.invalid(`Projection field ${field.name} cannot be null.`);
|
|
376
|
+
}
|
|
377
|
+
const normalized = this.normalizeValue(field, value);
|
|
378
|
+
if (field.storage === 'column') {
|
|
379
|
+
patch.columnValues[field.column ?? field.name] = normalized;
|
|
380
|
+
} else {
|
|
381
|
+
patch.jsonValues.push({ field, value: normalized });
|
|
382
|
+
}
|
|
383
|
+
}
|
|
384
|
+
if (
|
|
385
|
+
Object.keys(patch.columnValues).length === 0 &&
|
|
386
|
+
patch.jsonValues.length === 0
|
|
387
|
+
) {
|
|
388
|
+
this.invalid('Projection update requires at least one writable field.');
|
|
389
|
+
}
|
|
390
|
+
return patch;
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
private async readOne(guid: string): Promise<Extension | null> {
|
|
394
|
+
const extension = await this.repository.findOne({
|
|
395
|
+
where: {
|
|
396
|
+
[this.definition.scope.column]: this.scope.scopeId,
|
|
397
|
+
[this.definition.identity.column]: guid,
|
|
398
|
+
} as any,
|
|
399
|
+
});
|
|
400
|
+
if (!extension) return null;
|
|
401
|
+
const owner = await this.findOwner(guid);
|
|
402
|
+
return owner ? this.merge(extension, owner) : null;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
private async findOwner(
|
|
406
|
+
guid: string,
|
|
407
|
+
manager?: EntityManager,
|
|
408
|
+
): Promise<OmniRecordEntity | null> {
|
|
409
|
+
return (
|
|
410
|
+
manager?.getRepository(OmniRecordEntity) ?? this.ownerRepository
|
|
411
|
+
).findOne({
|
|
412
|
+
where: {
|
|
413
|
+
scopeId: this.scope.scopeId,
|
|
414
|
+
guid,
|
|
415
|
+
kind: this.omniDefinition.owner.kind,
|
|
416
|
+
payloadSchemaId: this.omniDefinition.owner.schema.id,
|
|
417
|
+
payloadSchemaVersion: this.omniDefinition.owner.schema.version,
|
|
418
|
+
deletedAt: IsNull(),
|
|
419
|
+
},
|
|
420
|
+
});
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
private merge(extension: Extension, owner: OmniRecordEntity): Extension {
|
|
424
|
+
return {
|
|
425
|
+
...(this.project(extension) as Record<string, unknown>),
|
|
426
|
+
scopeId: owner.scopeId,
|
|
427
|
+
guid: owner.guid,
|
|
428
|
+
[this.definition.revision.column]: owner.revision,
|
|
429
|
+
createdAt: owner.createdAt,
|
|
430
|
+
updatedAt: owner.updatedAt,
|
|
431
|
+
deletedAt: owner.deletedAt,
|
|
432
|
+
} as unknown as Extension;
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
private async throwUpdateMiss(
|
|
436
|
+
guid: string,
|
|
437
|
+
manager: EntityManager,
|
|
438
|
+
): Promise<never> {
|
|
439
|
+
if (!(await this.findOwner(guid, manager))) this.notFound();
|
|
440
|
+
throw this.events.errorConflict('projection.revision.conflict', {
|
|
441
|
+
response: { message: 'Projection resource revision is stale.' },
|
|
442
|
+
});
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
private identityConflict(): never {
|
|
446
|
+
throw this.events.errorConflict('projection.identity.conflict', {
|
|
447
|
+
response: {
|
|
448
|
+
message: 'Projection identity already exists in this scope.',
|
|
449
|
+
},
|
|
450
|
+
});
|
|
451
|
+
}
|
|
452
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { type Repository } from 'typeorm';
|
|
2
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
3
|
+
import { OmniExternalRefInternalType } from './omni-external-ref-internal-type.enum.js';
|
|
4
|
+
import type { OmniScope } from './omni-scope.js';
|
|
5
|
+
export interface OmniExternalRefBinding {
|
|
6
|
+
internalId: string;
|
|
7
|
+
internalType: OmniExternalRefInternalType;
|
|
8
|
+
}
|
|
9
|
+
export declare class OmniExternalRefBindingValidator {
|
|
10
|
+
private readonly recordRepository;
|
|
11
|
+
private readonly scope;
|
|
12
|
+
constructor(recordRepository: Repository<OmniRecordEntity>, scope: OmniScope);
|
|
13
|
+
assertTarget(binding: OmniExternalRefBinding): Promise<OmniRecordEntity>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmniExternalRefBindingValidator = void 0;
|
|
4
|
+
const common_1 = require("@nestjs/common");
|
|
5
|
+
const typeorm_1 = require("typeorm");
|
|
6
|
+
const omni_external_ref_internal_type_enum_js_1 = require("./omni-external-ref-internal-type.enum.js");
|
|
7
|
+
class OmniExternalRefBindingValidator {
|
|
8
|
+
constructor(recordRepository, scope) {
|
|
9
|
+
this.recordRepository = recordRepository;
|
|
10
|
+
this.scope = scope;
|
|
11
|
+
}
|
|
12
|
+
async assertTarget(binding) {
|
|
13
|
+
if (binding.internalType !== omni_external_ref_internal_type_enum_js_1.OmniExternalRefInternalType.Record) {
|
|
14
|
+
throw new common_1.BadRequestException('Omni external record binding must declare internalType record.');
|
|
15
|
+
}
|
|
16
|
+
if (typeof binding.internalId !== 'string' ||
|
|
17
|
+
binding.internalId.trim().length === 0) {
|
|
18
|
+
throw new common_1.BadRequestException('Omni external reference internalId must be a non-empty record identity.');
|
|
19
|
+
}
|
|
20
|
+
const record = await this.recordRepository.findOne({
|
|
21
|
+
where: {
|
|
22
|
+
scopeId: this.scope.scopeId,
|
|
23
|
+
guid: binding.internalId,
|
|
24
|
+
deletedAt: (0, typeorm_1.IsNull)(),
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
if (!record) {
|
|
28
|
+
throw new common_1.NotFoundException('Omni external reference target was not found in this scope.');
|
|
29
|
+
}
|
|
30
|
+
return record;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
exports.OmniExternalRefBindingValidator = OmniExternalRefBindingValidator;
|
|
34
|
+
//# sourceMappingURL=omni-external-ref-binding.validator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-external-ref-binding.validator.js","sourceRoot":"","sources":["omni-external-ref-binding.validator.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,qCAAkD;AAElD,uGAAwF;AAaxF,MAAa,+BAA+B;IAC1C,YACmB,gBAA8C,EAC9C,KAAgB;QADhB,qBAAgB,GAAhB,gBAAgB,CAA8B;QAC9C,UAAK,GAAL,KAAK,CAAW;IAChC,CAAC;IAEJ,KAAK,CAAC,YAAY,CAChB,OAA+B;QAE/B,IAAI,OAAO,CAAC,YAAY,KAAK,qEAA2B,CAAC,MAAM,EAAE,CAAC;YAChE,MAAM,IAAI,4BAAmB,CAC3B,gEAAgE,CACjE,CAAC;QACJ,CAAC;QACD,IACE,OAAO,OAAO,CAAC,UAAU,KAAK,QAAQ;YACtC,OAAO,CAAC,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EACtC,CAAC;YACD,MAAM,IAAI,4BAAmB,CAC3B,yEAAyE,CAC1E,CAAC;QACJ,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;YACjD,KAAK,EAAE;gBACL,OAAO,EAAE,IAAI,CAAC,KAAK,CAAC,OAAO;gBAC3B,IAAI,EAAE,OAAO,CAAC,UAAU;gBACxB,SAAS,EAAE,IAAA,gBAAM,GAAE;aACpB;SACF,CAAC,CAAC;QACH,IAAI,CAAC,MAAM,EAAE,CAAC;YACZ,MAAM,IAAI,0BAAiB,CACzB,6DAA6D,CAC9D,CAAC;QACJ,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AApCD,0EAoCC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { BadRequestException, NotFoundException } from '@nestjs/common';
|
|
2
|
+
import { IsNull, type Repository } from 'typeorm';
|
|
3
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
4
|
+
import { OmniExternalRefInternalType } from './omni-external-ref-internal-type.enum.js';
|
|
5
|
+
import type { OmniScope } from './omni-scope.js';
|
|
6
|
+
|
|
7
|
+
export interface OmniExternalRefBinding {
|
|
8
|
+
internalId: string;
|
|
9
|
+
internalType: OmniExternalRefInternalType;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Reusable validation for an external reference whose declared target is an
|
|
14
|
+
* Omni record identity. Other internal types remain legacy application-owned
|
|
15
|
+
* identities and are intentionally not passed to this validator.
|
|
16
|
+
*/
|
|
17
|
+
export class OmniExternalRefBindingValidator {
|
|
18
|
+
constructor(
|
|
19
|
+
private readonly recordRepository: Repository<OmniRecordEntity>,
|
|
20
|
+
private readonly scope: OmniScope,
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
async assertTarget(
|
|
24
|
+
binding: OmniExternalRefBinding,
|
|
25
|
+
): Promise<OmniRecordEntity> {
|
|
26
|
+
if (binding.internalType !== OmniExternalRefInternalType.Record) {
|
|
27
|
+
throw new BadRequestException(
|
|
28
|
+
'Omni external record binding must declare internalType record.',
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
if (
|
|
32
|
+
typeof binding.internalId !== 'string' ||
|
|
33
|
+
binding.internalId.trim().length === 0
|
|
34
|
+
) {
|
|
35
|
+
throw new BadRequestException(
|
|
36
|
+
'Omni external reference internalId must be a non-empty record identity.',
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
const record = await this.recordRepository.findOne({
|
|
40
|
+
where: {
|
|
41
|
+
scopeId: this.scope.scopeId,
|
|
42
|
+
guid: binding.internalId,
|
|
43
|
+
deletedAt: IsNull(),
|
|
44
|
+
},
|
|
45
|
+
});
|
|
46
|
+
if (!record) {
|
|
47
|
+
throw new NotFoundException(
|
|
48
|
+
'Omni external reference target was not found in this scope.',
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
return record;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OmniExternalRefInternalType = void 0;
|
|
4
|
+
const graphql_1 = require("@nestjs/graphql");
|
|
5
|
+
var OmniExternalRefInternalType;
|
|
6
|
+
(function (OmniExternalRefInternalType) {
|
|
7
|
+
OmniExternalRefInternalType["Record"] = "record";
|
|
8
|
+
OmniExternalRefInternalType["Document"] = "document";
|
|
9
|
+
OmniExternalRefInternalType["Collection"] = "collection";
|
|
10
|
+
})(OmniExternalRefInternalType || (exports.OmniExternalRefInternalType = OmniExternalRefInternalType = {}));
|
|
11
|
+
(0, graphql_1.registerEnumType)(OmniExternalRefInternalType, {
|
|
12
|
+
name: 'OmniExternalRefInternalType',
|
|
13
|
+
});
|
|
14
|
+
//# sourceMappingURL=omni-external-ref-internal-type.enum.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-external-ref-internal-type.enum.js","sourceRoot":"","sources":["omni-external-ref-internal-type.enum.ts"],"names":[],"mappings":";;;AAAA,6CAAmD;AAEnD,IAAY,2BAIX;AAJD,WAAY,2BAA2B;IACrC,gDAAiB,CAAA;IACjB,oDAAqB,CAAA;IACrB,wDAAyB,CAAA;AAC3B,CAAC,EAJW,2BAA2B,2CAA3B,2BAA2B,QAItC;AAED,IAAA,0BAAgB,EAAC,2BAA2B,EAAE;IAC5C,IAAI,EAAE,6BAA6B;CACpC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { registerEnumType } from '@nestjs/graphql';
|
|
2
|
+
|
|
3
|
+
export enum OmniExternalRefInternalType {
|
|
4
|
+
Record = 'record',
|
|
5
|
+
Document = 'document',
|
|
6
|
+
Collection = 'collection',
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
registerEnumType(OmniExternalRefInternalType, {
|
|
10
|
+
name: 'OmniExternalRefInternalType',
|
|
11
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.omniExternalRefBackendProvidersFactory = void 0;
|
|
4
|
+
const typeorm_1 = require("@nestjs/typeorm");
|
|
5
|
+
const omni_record_entity_js_1 = require("./base/omni-record.entity.js");
|
|
6
|
+
const omni_external_ref_entity_js_1 = require("./base/omni-external-ref.entity.js");
|
|
7
|
+
const omni_external_ref_binding_validator_js_1 = require("./omni-external-ref-binding.validator.js");
|
|
8
|
+
const omni_external_ref_service_js_1 = require("./omni-external-ref.service.js");
|
|
9
|
+
const omni_scoped_backend_js_1 = require("./omni-scoped.backend.js");
|
|
10
|
+
const omniExternalRefBackendProvidersFactory = (dbConnection) => (0, omni_scoped_backend_js_1.omniScopedBackendProvidersFactory)({
|
|
11
|
+
entityModel: omni_external_ref_entity_js_1.OmniExternalRefEntity,
|
|
12
|
+
dbConnection,
|
|
13
|
+
serviceToken: (0, omni_scoped_backend_js_1.omniBackendServiceToken)(omni_external_ref_service_js_1.OmniExternalRefService),
|
|
14
|
+
serviceProvider: omni_external_ref_service_js_1.OmniExternalRefService,
|
|
15
|
+
additionalInject: [(0, typeorm_1.getRepositoryToken)(omni_record_entity_js_1.OmniRecordEntity, dbConnection)],
|
|
16
|
+
createService: (repository, scope, options, recordRepository) => new omni_external_ref_service_js_1.OmniExternalRefService(repository, scope, options.deletion.externalRef, new omni_external_ref_binding_validator_js_1.OmniExternalRefBindingValidator(recordRepository, scope)),
|
|
17
|
+
});
|
|
18
|
+
exports.omniExternalRefBackendProvidersFactory = omniExternalRefBackendProvidersFactory;
|
|
19
|
+
//# sourceMappingURL=omni-external-ref.backend.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"omni-external-ref.backend.js","sourceRoot":"","sources":["omni-external-ref.backend.ts"],"names":[],"mappings":";;;AAAA,6CAAqD;AACrD,wEAAgE;AAChE,oFAA2E;AAC3E,qGAA2F;AAC3F,iFAAwE;AACxE,qEAGkC;AAE3B,MAAM,sCAAsC,GAAG,CAAC,YAAoB,EAAE,EAAE,CAC7E,IAAA,0DAAiC,EAAwB;IACvD,WAAW,EAAE,mDAAqB;IAClC,YAAY;IACZ,YAAY,EAAE,IAAA,gDAAuB,EAAC,qDAAsB,CAAC;IAC7D,eAAe,EAAE,qDAAsB;IACvC,gBAAgB,EAAE,CAAC,IAAA,4BAAkB,EAAC,wCAAgB,EAAE,YAAY,CAAC,CAAC;IACtE,aAAa,EAAE,CAAC,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,gBAAgB,EAAE,EAAE,CAC9D,IAAI,qDAAsB,CACxB,UAAU,EACV,KAAK,EACL,OAAO,CAAC,QAAQ,CAAC,WAAW,EAC5B,IAAI,wEAA+B,CAAC,gBAAyB,EAAE,KAAK,CAAC,CACtE;CACJ,CAAC,CAAC;AAdQ,QAAA,sCAAsC,0CAc9C"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { getRepositoryToken } from '@nestjs/typeorm';
|
|
2
|
+
import { OmniRecordEntity } from './base/omni-record.entity.js';
|
|
3
|
+
import { OmniExternalRefEntity } from './base/omni-external-ref.entity.js';
|
|
4
|
+
import { OmniExternalRefBindingValidator } from './omni-external-ref-binding.validator.js';
|
|
5
|
+
import { OmniExternalRefService } from './omni-external-ref.service.js';
|
|
6
|
+
import {
|
|
7
|
+
omniBackendServiceToken,
|
|
8
|
+
omniScopedBackendProvidersFactory,
|
|
9
|
+
} from './omni-scoped.backend.js';
|
|
10
|
+
|
|
11
|
+
export const omniExternalRefBackendProvidersFactory = (dbConnection: string) =>
|
|
12
|
+
omniScopedBackendProvidersFactory<OmniExternalRefEntity>({
|
|
13
|
+
entityModel: OmniExternalRefEntity,
|
|
14
|
+
dbConnection,
|
|
15
|
+
serviceToken: omniBackendServiceToken(OmniExternalRefService),
|
|
16
|
+
serviceProvider: OmniExternalRefService,
|
|
17
|
+
additionalInject: [getRepositoryToken(OmniRecordEntity, dbConnection)],
|
|
18
|
+
createService: (repository, scope, options, recordRepository) =>
|
|
19
|
+
new OmniExternalRefService(
|
|
20
|
+
repository,
|
|
21
|
+
scope,
|
|
22
|
+
options.deletion.externalRef,
|
|
23
|
+
new OmniExternalRefBindingValidator(recordRepository as never, scope),
|
|
24
|
+
),
|
|
25
|
+
});
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import { OmniExternalRefEntity } from './base/omni-external-ref.entity.js';
|
|
2
|
+
import { OmniExternalRefInternalType } from './omni-external-ref-internal-type.enum.js';
|
|
3
|
+
export declare class OmniExternalRefType extends OmniExternalRefEntity {
|
|
4
|
+
constructor(data?: Partial<OmniExternalRefType>);
|
|
5
|
+
guid: string;
|
|
6
|
+
revision: number;
|
|
7
|
+
internalType: OmniExternalRefInternalType;
|
|
8
|
+
internalId: string;
|
|
9
|
+
provider: string;
|
|
10
|
+
account?: string | null;
|
|
11
|
+
container?: string | null;
|
|
12
|
+
externalId: string;
|
|
13
|
+
payload?: Record<string, unknown> | null;
|
|
14
|
+
payloadSchemaId?: string | null;
|
|
15
|
+
payloadSchemaVersion?: number | null;
|
|
16
|
+
}
|
|
17
|
+
declare const OmniExternalRefCreateInput_base: import("@nestjs/common").Type<Omit<OmniExternalRefType, "revision" | "createdAt" | "updatedAt">>;
|
|
18
|
+
export declare class OmniExternalRefCreateInput extends OmniExternalRefCreateInput_base {
|
|
19
|
+
}
|
|
20
|
+
declare const OmniExternalRefCondition_base: import("@nestjs/common").Type<Partial<OmniExternalRefCreateInput>>;
|
|
21
|
+
export declare class OmniExternalRefCondition extends OmniExternalRefCondition_base {
|
|
22
|
+
}
|
|
23
|
+
declare const OmniExternalRefUpdateInput_base: import("@nestjs/common").Type<Partial<OmniExternalRefCreateInput>>;
|
|
24
|
+
export declare class OmniExternalRefUpdateInput extends OmniExternalRefUpdateInput_base {
|
|
25
|
+
}
|
|
26
|
+
export {};
|