@nest-yalc-2/omnikernel-module 2.2.1 → 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 +22 -14
  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,53 +1,53 @@
1
- import type { InjectionToken } from '@nestjs/common';
2
- import type { EntityManager, ObjectLiteral } from 'typeorm';
3
- import type { OmniProjectionTransactionReaders } from './omni-projection.catalog.js';
4
- import type { OmniScope } from './omni-scope.js';
5
-
6
- /**
7
- * Transaction-aware policy seam shared by fixed Omni projections. Policies
8
- * are optional, but when registered they are invoked by the store itself—not
9
- * by transport adapters—so generated REST and GraphQL cannot bypass them.
10
- */
11
- export interface OmniProjectionLifecycleContext<
12
- Definition,
13
- Entity extends ObjectLiteral,
14
- > {
15
- readonly definition: Definition;
16
- readonly scope: OmniScope;
17
- readonly manager: EntityManager;
18
- /**
19
- * Manager-bound, scope-constrained readers registered by the composed
20
- * projections. Policies use these instead of reaching for repositories.
21
- */
22
- readonly readers: OmniProjectionTransactionReaders;
23
- readonly input: Readonly<Record<string, unknown>>;
24
- /** Present for update and delete after fixed scope/metadata constraints. */
25
- readonly current?: Entity;
26
- }
27
-
28
- export interface OmniProjectionLifecycle<
29
- Definition,
30
- Entity extends ObjectLiteral,
31
- > {
32
- beforeCreate?(
33
- context: OmniProjectionLifecycleContext<Definition, Entity>,
34
- ): void | Promise<void>;
35
- beforeUpdate?(
36
- context: OmniProjectionLifecycleContext<Definition, Entity>,
37
- ): void | Promise<void>;
38
- beforeDelete?(
39
- context: OmniProjectionLifecycleContext<Definition, Entity>,
40
- ): void | Promise<void>;
41
- }
42
-
43
- /**
44
- * A Nest token for a request-scoped policy. Resource registrations inject the
45
- * token into their generated service factory, so the policy is shared by REST
46
- * and GraphQL but remains app-owned and DI-created.
47
- */
48
- export interface OmniProjectionLifecycleProvider<
49
- Definition,
50
- Entity extends ObjectLiteral,
51
- > {
52
- readonly token: InjectionToken<OmniProjectionLifecycle<Definition, Entity>>;
53
- }
1
+ import type { InjectionToken } from '@nestjs/common';
2
+ import type { EntityManager, ObjectLiteral } from 'typeorm';
3
+ import type { OmniProjectionTransactionReaders } from './omni-projection.catalog.js';
4
+ import type { OmniScope } from './omni-scope.js';
5
+
6
+ /**
7
+ * Transaction-aware policy seam shared by fixed Omni projections. Policies
8
+ * are optional, but when registered they are invoked by the store itself—not
9
+ * by transport adapters—so generated REST and GraphQL cannot bypass them.
10
+ */
11
+ export interface OmniProjectionLifecycleContext<
12
+ Definition,
13
+ Entity extends ObjectLiteral,
14
+ > {
15
+ readonly definition: Definition;
16
+ readonly scope: OmniScope;
17
+ readonly manager: EntityManager;
18
+ /**
19
+ * Manager-bound, scope-constrained readers registered by the composed
20
+ * projections. Policies use these instead of reaching for repositories.
21
+ */
22
+ readonly readers: OmniProjectionTransactionReaders;
23
+ readonly input: Readonly<Record<string, unknown>>;
24
+ /** Present for update and delete after fixed scope/metadata constraints. */
25
+ readonly current?: Entity;
26
+ }
27
+
28
+ export interface OmniProjectionLifecycle<
29
+ Definition,
30
+ Entity extends ObjectLiteral,
31
+ > {
32
+ beforeCreate?(
33
+ context: OmniProjectionLifecycleContext<Definition, Entity>,
34
+ ): void | Promise<void>;
35
+ beforeUpdate?(
36
+ context: OmniProjectionLifecycleContext<Definition, Entity>,
37
+ ): void | Promise<void>;
38
+ beforeDelete?(
39
+ context: OmniProjectionLifecycleContext<Definition, Entity>,
40
+ ): void | Promise<void>;
41
+ }
42
+
43
+ /**
44
+ * A Nest token for a request-scoped policy. Resource registrations inject the
45
+ * token into their generated service factory, so the policy is shared by REST
46
+ * and GraphQL but remains app-owned and DI-created.
47
+ */
48
+ export interface OmniProjectionLifecycleProvider<
49
+ Definition,
50
+ Entity extends ObjectLiteral,
51
+ > {
52
+ readonly token: InjectionToken<OmniProjectionLifecycle<Definition, Entity>>;
53
+ }
@@ -1,11 +1,11 @@
1
- import { registerEnumType } from '@nestjs/graphql';
2
-
3
- export enum OmniRecordStatus {
4
- Draft = 'draft',
5
- Active = 'active',
6
- Archived = 'archived',
7
- }
8
-
9
- registerEnumType(OmniRecordStatus, {
10
- name: 'OmniRecordStatus',
11
- });
1
+ import { registerEnumType } from '@nestjs/graphql';
2
+
3
+ export enum OmniRecordStatus {
4
+ Draft = 'draft',
5
+ Active = 'active',
6
+ Archived = 'archived',
7
+ }
8
+
9
+ registerEnumType(OmniRecordStatus, {
10
+ name: 'OmniRecordStatus',
11
+ });
@@ -1,19 +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
- });
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
+ });
@@ -1,157 +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 '@node-yalc/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
- ) {}
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 '@node-yalc/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
+ ) {}