@nest-yalc-2/omnikernel-module 2.2.2 → 2.2.4

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.
Files changed (74) hide show
  1. package/package.json +17 -15
  2. package/src/__tests__/omni-collection.entity.spec.ts +49 -49
  3. package/src/__tests__/omni-collection.service.spec.ts +83 -83
  4. package/src/__tests__/omni-document.entity.spec.ts +55 -55
  5. package/src/__tests__/omni-document.service.spec.ts +83 -83
  6. package/src/__tests__/omni-extension-projection-constraints.spec.ts +518 -518
  7. package/src/__tests__/omni-extension-projection.registration.spec.ts +947 -946
  8. package/src/__tests__/omni-extension-projection.service.spec.ts +806 -806
  9. package/src/__tests__/omni-external-ref.entity.spec.ts +36 -36
  10. package/src/__tests__/omni-external-ref.service.spec.ts +252 -252
  11. package/src/__tests__/omni-named.entity.spec.ts +33 -33
  12. package/src/__tests__/omni-record.entity.spec.ts +32 -32
  13. package/src/__tests__/omni-record.service.spec.ts +107 -107
  14. package/src/__tests__/omni-relation-semantics.spec.ts +102 -102
  15. package/src/__tests__/omni-relation.entity.spec.ts +38 -38
  16. package/src/__tests__/omni-scope-substrate.spec.ts +81 -81
  17. package/src/__tests__/omni-scoped.backend.spec.ts +115 -115
  18. package/src/__tests__/omni-scoped.service.spec.ts +354 -354
  19. package/src/__tests__/omnikernel.diagnostics.spec.ts +94 -94
  20. package/src/__tests__/omnikernel.module.spec.ts +38 -40
  21. package/src/__tests__/omnikernel.persistence.spec.ts +154 -154
  22. package/src/__tests__/omnikernel.public-api.spec.ts +238 -238
  23. package/src/__tests__/omnikernel.query.service.spec.ts +155 -155
  24. package/src/base/omni-base.entity.ts +41 -41
  25. package/src/base/omni-external-ref.entity.ts +53 -53
  26. package/src/base/omni-named.entity.ts +16 -16
  27. package/src/base/omni-record.entity.ts +51 -51
  28. package/src/base/omni-relation.entity.ts +72 -72
  29. package/src/index.ts +49 -49
  30. package/src/omni-collection-kind.enum.ts +10 -10
  31. package/src/omni-collection.backend.ts +16 -16
  32. package/src/omni-collection.dto.ts +170 -170
  33. package/src/omni-collection.entity.ts +21 -21
  34. package/src/omni-collection.service.ts +75 -75
  35. package/src/omni-document-kind.enum.ts +12 -12
  36. package/src/omni-document.backend.ts +16 -16
  37. package/src/omni-document.dto.ts +198 -198
  38. package/src/omni-document.entity.ts +30 -30
  39. package/src/omni-document.service.ts +75 -75
  40. package/src/omni-dto.helpers.ts +21 -21
  41. package/src/omni-extension-projection.definition.ts +294 -294
  42. package/src/omni-extension-projection.resource.ts +274 -274
  43. package/src/omni-extension-projection.service.ts +452 -452
  44. package/src/omni-external-ref-binding.validator.ts +53 -53
  45. package/src/omni-external-ref-internal-type.enum.ts +11 -11
  46. package/src/omni-external-ref.backend.ts +25 -25
  47. package/src/omni-external-ref.dto.ts +128 -128
  48. package/src/omni-external-ref.service.ts +255 -255
  49. package/src/omni-migration.ts +365 -365
  50. package/src/omni-named.backend.ts +11 -11
  51. package/src/omni-named.dto.ts +86 -86
  52. package/src/omni-projection.catalog.ts +345 -345
  53. package/src/omni-projection.lifecycle.ts +53 -53
  54. package/src/omni-record-status.enum.ts +11 -11
  55. package/src/omni-record.backend.ts +19 -19
  56. package/src/omni-record.dto.ts +157 -157
  57. package/src/omni-record.service.ts +113 -113
  58. package/src/omni-relation-kind.contract.ts +49 -49
  59. package/src/omni-relation-kind.enum.ts +12 -12
  60. package/src/omni-relation-projection.definition.ts +166 -166
  61. package/src/omni-relation-projection.resource.ts +360 -360
  62. package/src/omni-relation-projection.service.ts +610 -610
  63. package/src/omni-relation-semantics.ts +52 -52
  64. package/src/omni-relation-status.enum.ts +11 -11
  65. package/src/omni-relation.backend.ts +21 -21
  66. package/src/omni-relation.dto.ts +142 -142
  67. package/src/omni-relation.service.ts +159 -159
  68. package/src/omni-scope.ts +161 -161
  69. package/src/omni-scoped.backend.ts +110 -110
  70. package/src/omni-scoped.repository.ts +34 -34
  71. package/src/omni-scoped.service.ts +338 -338
  72. package/src/omnikernel.diagnostics.ts +83 -83
  73. package/src/omnikernel.module.ts +97 -97
  74. package/src/omnikernel.query.service.ts +108 -108
@@ -1,166 +1,166 @@
1
- import { OmniRelationStatus } from './omni-relation-status.enum.js';
2
- import { omniRelationKindPattern } from './omni-relation-kind.contract.js';
3
-
4
- export interface OmniRelationProjectionAliases {
5
- /** Public field that maps to OmniRelationEntity.kind. */
6
- kind?: string;
7
- /** Public field that maps to OmniRelationEntity.sourceRecordId. */
8
- source?: string;
9
- /** Public field that maps to OmniRelationEntity.targetRecordId. */
10
- target?: string;
11
- /** Public field that maps to OmniRelationEntity.payload. */
12
- payload?: string;
13
- }
14
-
15
- export interface OmniRelationProjectionDefinition {
16
- id: string;
17
- relation: {
18
- /**
19
- * Legacy single-kind shorthand. New multi-kind resources use
20
- * allowedKinds instead.
21
- */
22
- kind?: string;
23
- /** The non-empty registered kinds this one generated resource permits. */
24
- allowedKinds?: readonly string[];
25
- sourceKind: string;
26
- targetKind: string;
27
- status?: OmniRelationStatus;
28
- schema?: {
29
- id: string;
30
- version: number;
31
- };
32
- };
33
- /** Names exposed by generated REST and GraphQL transports. */
34
- aliases?: OmniRelationProjectionAliases;
35
- }
36
-
37
- const publicFieldPattern = /^[_A-Za-z][_0-9A-Za-z]*$/;
38
-
39
- function assertFixedValue(
40
- value: unknown,
41
- label: string,
42
- max: number,
43
- ): asserts value is string {
44
- if (
45
- typeof value !== 'string' ||
46
- value.trim().length === 0 ||
47
- value.length > max
48
- ) {
49
- throw new TypeError(
50
- `${label} must be a non-empty string up to ${max} characters.`,
51
- );
52
- }
53
- }
54
-
55
- function freeze<T>(definition: T): Readonly<T> {
56
- if (definition && typeof definition === 'object') {
57
- Object.values(definition as Record<string, unknown>).forEach((value) => {
58
- if (value && typeof value === 'object') freeze(value);
59
- });
60
- Object.freeze(definition);
61
- }
62
- return definition;
63
- }
64
-
65
- /** Resolves legacy kind syntax into the canonical immutable allowed-kind set. */
66
- export function getOmniRelationProjectionAllowedKinds(
67
- definition: OmniRelationProjectionDefinition,
68
- ): readonly string[] {
69
- return definition.relation.allowedKinds ?? [definition.relation.kind!];
70
- }
71
-
72
- /** Resolves omitted aliases to the native OmniRelationEntity field names. */
73
- export function getOmniRelationProjectionAliases(
74
- definition: OmniRelationProjectionDefinition,
75
- ): Required<OmniRelationProjectionAliases> {
76
- return {
77
- kind: definition.aliases?.kind ?? 'kind',
78
- source: definition.aliases?.source ?? 'sourceRecordId',
79
- target: definition.aliases?.target ?? 'targetRecordId',
80
- payload: definition.aliases?.payload ?? 'payload',
81
- };
82
- }
83
-
84
- /**
85
- * Defines one generated relation resource over omni-relation. A resource can
86
- * expose one or more registered relation kinds, while status, schema, and
87
- * endpoint kinds remain server-owned.
88
- */
89
- export function defineOmniRelationProjection<
90
- TDefinition extends OmniRelationProjectionDefinition,
91
- >(definition: TDefinition): Readonly<TDefinition> {
92
- assertFixedValue(definition.id, 'Omni relation projection id', 128);
93
- const relation = definition.relation;
94
- if (!relation || typeof relation !== 'object') {
95
- throw new TypeError('Omni relation projection relation must be an object.');
96
- }
97
- if (relation.kind !== undefined && relation.allowedKinds !== undefined) {
98
- throw new TypeError(
99
- 'Omni relation projection accepts either kind or allowedKinds, not both.',
100
- );
101
- }
102
- const allowedKinds = getOmniRelationProjectionAllowedKinds(definition);
103
- if (
104
- !Array.isArray(allowedKinds) ||
105
- allowedKinds.length === 0 ||
106
- new Set(allowedKinds).size !== allowedKinds.length
107
- ) {
108
- throw new TypeError(
109
- 'Omni relation projection allowedKinds must be a non-empty unique list.',
110
- );
111
- }
112
- for (const kind of allowedKinds) {
113
- assertFixedValue(kind, 'Omni relation projection kind', 64);
114
- if (!omniRelationKindPattern.test(kind)) {
115
- throw new TypeError(
116
- 'Omni relation projection kind must use lowercase letters, digits, and underscores.',
117
- );
118
- }
119
- }
120
- assertFixedValue(
121
- relation.sourceKind,
122
- 'Omni relation projection source kind',
123
- 64,
124
- );
125
- assertFixedValue(
126
- relation.targetKind,
127
- 'Omni relation projection target kind',
128
- 64,
129
- );
130
- if (
131
- relation.status !== undefined &&
132
- !Object.values(OmniRelationStatus).includes(relation.status)
133
- ) {
134
- throw new TypeError(
135
- 'Omni relation projection status must be an Omni relation status.',
136
- );
137
- }
138
- if (relation.schema) {
139
- assertFixedValue(
140
- relation.schema.id,
141
- 'Omni relation projection schema id',
142
- 128,
143
- );
144
- if (
145
- !Number.isInteger(relation.schema.version) ||
146
- relation.schema.version < 1 ||
147
- relation.schema.version > 2_147_483_647
148
- ) {
149
- throw new TypeError(
150
- 'Omni relation projection schema version must be a positive signed 32-bit integer.',
151
- );
152
- }
153
- }
154
- const aliases = getOmniRelationProjectionAliases(definition);
155
- if (new Set(Object.values(aliases)).size !== Object.keys(aliases).length) {
156
- throw new TypeError('Omni relation projection aliases must be unique.');
157
- }
158
- for (const [role, alias] of Object.entries(aliases)) {
159
- if (!publicFieldPattern.test(alias)) {
160
- throw new TypeError(
161
- `Omni relation projection ${role} alias must be a GraphQL-safe field name.`,
162
- );
163
- }
164
- }
165
- return freeze(definition);
166
- }
1
+ import { OmniRelationStatus } from './omni-relation-status.enum.js';
2
+ import { omniRelationKindPattern } from './omni-relation-kind.contract.js';
3
+
4
+ export interface OmniRelationProjectionAliases {
5
+ /** Public field that maps to OmniRelationEntity.kind. */
6
+ kind?: string;
7
+ /** Public field that maps to OmniRelationEntity.sourceRecordId. */
8
+ source?: string;
9
+ /** Public field that maps to OmniRelationEntity.targetRecordId. */
10
+ target?: string;
11
+ /** Public field that maps to OmniRelationEntity.payload. */
12
+ payload?: string;
13
+ }
14
+
15
+ export interface OmniRelationProjectionDefinition {
16
+ id: string;
17
+ relation: {
18
+ /**
19
+ * Legacy single-kind shorthand. New multi-kind resources use
20
+ * allowedKinds instead.
21
+ */
22
+ kind?: string;
23
+ /** The non-empty registered kinds this one generated resource permits. */
24
+ allowedKinds?: readonly string[];
25
+ sourceKind: string;
26
+ targetKind: string;
27
+ status?: OmniRelationStatus;
28
+ schema?: {
29
+ id: string;
30
+ version: number;
31
+ };
32
+ };
33
+ /** Names exposed by generated REST and GraphQL transports. */
34
+ aliases?: OmniRelationProjectionAliases;
35
+ }
36
+
37
+ const publicFieldPattern = /^[_A-Za-z][_0-9A-Za-z]*$/;
38
+
39
+ function assertFixedValue(
40
+ value: unknown,
41
+ label: string,
42
+ max: number,
43
+ ): asserts value is string {
44
+ if (
45
+ typeof value !== 'string' ||
46
+ value.trim().length === 0 ||
47
+ value.length > max
48
+ ) {
49
+ throw new TypeError(
50
+ `${label} must be a non-empty string up to ${max} characters.`,
51
+ );
52
+ }
53
+ }
54
+
55
+ function freeze<T>(definition: T): Readonly<T> {
56
+ if (definition && typeof definition === 'object') {
57
+ Object.values(definition as Record<string, unknown>).forEach((value) => {
58
+ if (value && typeof value === 'object') freeze(value);
59
+ });
60
+ Object.freeze(definition);
61
+ }
62
+ return definition;
63
+ }
64
+
65
+ /** Resolves legacy kind syntax into the canonical immutable allowed-kind set. */
66
+ export function getOmniRelationProjectionAllowedKinds(
67
+ definition: OmniRelationProjectionDefinition,
68
+ ): readonly string[] {
69
+ return definition.relation.allowedKinds ?? [definition.relation.kind!];
70
+ }
71
+
72
+ /** Resolves omitted aliases to the native OmniRelationEntity field names. */
73
+ export function getOmniRelationProjectionAliases(
74
+ definition: OmniRelationProjectionDefinition,
75
+ ): Required<OmniRelationProjectionAliases> {
76
+ return {
77
+ kind: definition.aliases?.kind ?? 'kind',
78
+ source: definition.aliases?.source ?? 'sourceRecordId',
79
+ target: definition.aliases?.target ?? 'targetRecordId',
80
+ payload: definition.aliases?.payload ?? 'payload',
81
+ };
82
+ }
83
+
84
+ /**
85
+ * Defines one generated relation resource over omni-relation. A resource can
86
+ * expose one or more registered relation kinds, while status, schema, and
87
+ * endpoint kinds remain server-owned.
88
+ */
89
+ export function defineOmniRelationProjection<
90
+ TDefinition extends OmniRelationProjectionDefinition,
91
+ >(definition: TDefinition): Readonly<TDefinition> {
92
+ assertFixedValue(definition.id, 'Omni relation projection id', 128);
93
+ const relation = definition.relation;
94
+ if (!relation || typeof relation !== 'object') {
95
+ throw new TypeError('Omni relation projection relation must be an object.');
96
+ }
97
+ if (relation.kind !== undefined && relation.allowedKinds !== undefined) {
98
+ throw new TypeError(
99
+ 'Omni relation projection accepts either kind or allowedKinds, not both.',
100
+ );
101
+ }
102
+ const allowedKinds = getOmniRelationProjectionAllowedKinds(definition);
103
+ if (
104
+ !Array.isArray(allowedKinds) ||
105
+ allowedKinds.length === 0 ||
106
+ new Set(allowedKinds).size !== allowedKinds.length
107
+ ) {
108
+ throw new TypeError(
109
+ 'Omni relation projection allowedKinds must be a non-empty unique list.',
110
+ );
111
+ }
112
+ for (const kind of allowedKinds) {
113
+ assertFixedValue(kind, 'Omni relation projection kind', 64);
114
+ if (!omniRelationKindPattern.test(kind)) {
115
+ throw new TypeError(
116
+ 'Omni relation projection kind must use lowercase letters, digits, and underscores.',
117
+ );
118
+ }
119
+ }
120
+ assertFixedValue(
121
+ relation.sourceKind,
122
+ 'Omni relation projection source kind',
123
+ 64,
124
+ );
125
+ assertFixedValue(
126
+ relation.targetKind,
127
+ 'Omni relation projection target kind',
128
+ 64,
129
+ );
130
+ if (
131
+ relation.status !== undefined &&
132
+ !Object.values(OmniRelationStatus).includes(relation.status)
133
+ ) {
134
+ throw new TypeError(
135
+ 'Omni relation projection status must be an Omni relation status.',
136
+ );
137
+ }
138
+ if (relation.schema) {
139
+ assertFixedValue(
140
+ relation.schema.id,
141
+ 'Omni relation projection schema id',
142
+ 128,
143
+ );
144
+ if (
145
+ !Number.isInteger(relation.schema.version) ||
146
+ relation.schema.version < 1 ||
147
+ relation.schema.version > 2_147_483_647
148
+ ) {
149
+ throw new TypeError(
150
+ 'Omni relation projection schema version must be a positive signed 32-bit integer.',
151
+ );
152
+ }
153
+ }
154
+ const aliases = getOmniRelationProjectionAliases(definition);
155
+ if (new Set(Object.values(aliases)).size !== Object.keys(aliases).length) {
156
+ throw new TypeError('Omni relation projection aliases must be unique.');
157
+ }
158
+ for (const [role, alias] of Object.entries(aliases)) {
159
+ if (!publicFieldPattern.test(alias)) {
160
+ throw new TypeError(
161
+ `Omni relation projection ${role} alias must be a GraphQL-safe field name.`,
162
+ );
163
+ }
164
+ }
165
+ return freeze(definition);
166
+ }