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

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,52 +1,52 @@
1
- import { OmniCollectionKind } from './omni-collection-kind.enum.js';
2
- import { OmniDocumentKind } from './omni-document-kind.enum.js';
3
- import { OmniRelationKind } from './omni-relation-kind.enum.js';
4
-
5
- export interface OmniRelationSemanticsInput {
6
- sourceKind: string;
7
- targetKind: string;
8
- relationKind: string;
9
- }
10
-
11
- export const OMNI_COLLECTION_MEMBERSHIP_RELATION_KIND =
12
- OmniRelationKind.Contains;
13
-
14
- const hasKind = (kind: string): boolean => kind.trim().length > 0;
15
-
16
- export const isOmniCollectionRecordKind = (kind: string): boolean =>
17
- kind === OmniCollectionKind.Collection;
18
-
19
- export const isOmniDocumentRecordKind = (kind: string): boolean =>
20
- kind === OmniDocumentKind.Document;
21
-
22
- export const isCanonicalCollectionMembershipRelation = ({
23
- sourceKind,
24
- relationKind,
25
- }: Pick<OmniRelationSemanticsInput, 'sourceKind' | 'relationKind'>): boolean =>
26
- relationKind === OMNI_COLLECTION_MEMBERSHIP_RELATION_KIND &&
27
- isOmniCollectionRecordKind(sourceKind);
28
-
29
- export const isAllowedOmniRelation = ({
30
- sourceKind,
31
- targetKind,
32
- relationKind,
33
- }: OmniRelationSemanticsInput): boolean => {
34
- if (!hasKind(sourceKind) || !hasKind(targetKind)) {
35
- return false;
36
- }
37
-
38
- switch (relationKind) {
39
- case OmniRelationKind.Contains:
40
- return isOmniCollectionRecordKind(sourceKind);
41
- case OmniRelationKind.DerivedFrom:
42
- return (
43
- isOmniDocumentRecordKind(sourceKind) &&
44
- isOmniDocumentRecordKind(targetKind)
45
- );
46
- case OmniRelationKind.References:
47
- case OmniRelationKind.RelatedTo:
48
- return true;
49
- default:
50
- return false;
51
- }
52
- };
1
+ import { OmniCollectionKind } from './omni-collection-kind.enum.js';
2
+ import { OmniDocumentKind } from './omni-document-kind.enum.js';
3
+ import { OmniRelationKind } from './omni-relation-kind.enum.js';
4
+
5
+ export interface OmniRelationSemanticsInput {
6
+ sourceKind: string;
7
+ targetKind: string;
8
+ relationKind: string;
9
+ }
10
+
11
+ export const OMNI_COLLECTION_MEMBERSHIP_RELATION_KIND =
12
+ OmniRelationKind.Contains;
13
+
14
+ const hasKind = (kind: string): boolean => kind.trim().length > 0;
15
+
16
+ export const isOmniCollectionRecordKind = (kind: string): boolean =>
17
+ kind === OmniCollectionKind.Collection;
18
+
19
+ export const isOmniDocumentRecordKind = (kind: string): boolean =>
20
+ kind === OmniDocumentKind.Document;
21
+
22
+ export const isCanonicalCollectionMembershipRelation = ({
23
+ sourceKind,
24
+ relationKind,
25
+ }: Pick<OmniRelationSemanticsInput, 'sourceKind' | 'relationKind'>): boolean =>
26
+ relationKind === OMNI_COLLECTION_MEMBERSHIP_RELATION_KIND &&
27
+ isOmniCollectionRecordKind(sourceKind);
28
+
29
+ export const isAllowedOmniRelation = ({
30
+ sourceKind,
31
+ targetKind,
32
+ relationKind,
33
+ }: OmniRelationSemanticsInput): boolean => {
34
+ if (!hasKind(sourceKind) || !hasKind(targetKind)) {
35
+ return false;
36
+ }
37
+
38
+ switch (relationKind) {
39
+ case OmniRelationKind.Contains:
40
+ return isOmniCollectionRecordKind(sourceKind);
41
+ case OmniRelationKind.DerivedFrom:
42
+ return (
43
+ isOmniDocumentRecordKind(sourceKind) &&
44
+ isOmniDocumentRecordKind(targetKind)
45
+ );
46
+ case OmniRelationKind.References:
47
+ case OmniRelationKind.RelatedTo:
48
+ return true;
49
+ default:
50
+ return false;
51
+ }
52
+ };
@@ -1,11 +1,11 @@
1
- import { registerEnumType } from '@nestjs/graphql';
2
-
3
- export enum OmniRelationStatus {
4
- Active = 'active',
5
- Inactive = 'inactive',
6
- Archived = 'archived',
7
- }
8
-
9
- registerEnumType(OmniRelationStatus, {
10
- name: 'OmniRelationStatus',
11
- });
1
+ import { registerEnumType } from '@nestjs/graphql';
2
+
3
+ export enum OmniRelationStatus {
4
+ Active = 'active',
5
+ Inactive = 'inactive',
6
+ Archived = 'archived',
7
+ }
8
+
9
+ registerEnumType(OmniRelationStatus, {
10
+ name: 'OmniRelationStatus',
11
+ });
@@ -1,21 +1,21 @@
1
- import { getRepositoryToken } from '@nestjs/typeorm';
2
- import { OmniRelationEntity } from './base/omni-relation.entity.js';
3
- import { OmniRecordEntity } from './base/omni-record.entity.js';
4
- import { createOmniRelationKindContract } from './omni-relation-kind.contract.js';
5
- import { OmniRelationService } from './omni-relation.service.js';
6
- import { omniScopedBackendProvidersFactory } from './omni-scoped.backend.js';
7
-
8
- export const omniRelationBackendProvidersFactory = (dbConnection: string) =>
9
- omniScopedBackendProvidersFactory<OmniRelationEntity>({
10
- entityModel: OmniRelationEntity,
11
- dbConnection,
12
- additionalInject: [getRepositoryToken(OmniRecordEntity, dbConnection)],
13
- createService: (repository, scope, options, recordRepository) =>
14
- new OmniRelationService(
15
- repository,
16
- scope,
17
- options.deletion.relation,
18
- recordRepository as never,
19
- createOmniRelationKindContract(options.relationKinds),
20
- ),
21
- });
1
+ import { getRepositoryToken } from '@nestjs/typeorm';
2
+ import { OmniRelationEntity } from './base/omni-relation.entity.js';
3
+ import { OmniRecordEntity } from './base/omni-record.entity.js';
4
+ import { createOmniRelationKindContract } from './omni-relation-kind.contract.js';
5
+ import { OmniRelationService } from './omni-relation.service.js';
6
+ import { omniScopedBackendProvidersFactory } from './omni-scoped.backend.js';
7
+
8
+ export const omniRelationBackendProvidersFactory = (dbConnection: string) =>
9
+ omniScopedBackendProvidersFactory<OmniRelationEntity>({
10
+ entityModel: OmniRelationEntity,
11
+ dbConnection,
12
+ additionalInject: [getRepositoryToken(OmniRecordEntity, dbConnection)],
13
+ createService: (repository, scope, options, recordRepository) =>
14
+ new OmniRelationService(
15
+ repository,
16
+ scope,
17
+ options.deletion.relation,
18
+ recordRepository as never,
19
+ createOmniRelationKindContract(options.relationKinds),
20
+ ),
21
+ });
@@ -1,142 +1,142 @@
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
- Matches,
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 { OmniRecordType } from './omni-record.dto.js';
29
- import { omniRelationKindPattern } from './omni-relation-kind.contract.js';
30
- import { OmniRelationStatus } from './omni-relation-status.enum.js';
31
-
32
- @ObjectType()
33
- @ModelObject()
34
- export class OmniRelationType extends OmniRelationEntity {
35
- constructor(data?: Partial<OmniRelationType>) {
36
- super();
37
- if (data) {
38
- assignOmniPublicDto(this, data);
39
- }
40
- }
41
-
42
- @ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
43
- @IsUUID()
44
- guid!: string;
45
-
46
- @ModelField({ gqlType: returnValue(Int) })
47
- @IsInt()
48
- revision!: number;
49
-
50
- @ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
51
- @IsUUID()
52
- sourceRecordId!: string;
53
-
54
- @ModelField({
55
- gqlType: () => OmniRecordType,
56
- gqlOptions: { nullable: false },
57
- relation: {
58
- relationType: 'many-to-one',
59
- sourceKey: { dst: 'sourceRecordId', alias: 'sourceRecordId' },
60
- targetKey: { dst: 'guid', alias: 'guid' },
61
- type: () => OmniRecordEntity,
62
- },
63
- })
64
- sourceRecord!: Relation<OmniRecordType>;
65
-
66
- @ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
67
- @IsUUID()
68
- targetRecordId!: string;
69
-
70
- @ModelField({
71
- gqlType: () => OmniRecordType,
72
- gqlOptions: { nullable: false },
73
- relation: {
74
- relationType: 'many-to-one',
75
- sourceKey: { dst: 'targetRecordId', alias: 'targetRecordId' },
76
- targetKey: { dst: 'guid', alias: 'guid' },
77
- type: () => OmniRecordEntity,
78
- },
79
- })
80
- targetRecord!: Relation<OmniRecordType>;
81
-
82
- @ModelField({ gqlType: returnValue(String) })
83
- @IsString()
84
- @Matches(omniRelationKindPattern)
85
- kind!: string;
86
-
87
- @ModelField({ gqlType: returnValue(OmniRelationStatus) })
88
- @IsEnum(OmniRelationStatus)
89
- status!: OmniRelationStatus;
90
-
91
- @ModelField({
92
- gqlType: returnValue(GraphQLJSONObject),
93
- gqlOptions: { nullable: true },
94
- })
95
- @IsOptional()
96
- @IsObject()
97
- payload?: Record<string, unknown> | null;
98
-
99
- @ModelField({
100
- gqlType: returnValue(String),
101
- gqlOptions: { nullable: true },
102
- })
103
- @IsOptional()
104
- @IsString()
105
- payloadSchemaId?: string | null;
106
-
107
- @ModelField({
108
- gqlType: returnValue(Int),
109
- gqlOptions: { nullable: true },
110
- })
111
- @IsOptional()
112
- @IsInt()
113
- payloadSchemaVersion?: number | null;
114
- }
115
-
116
- @InputType()
117
- @ModelObject()
118
- export class OmniRelationCreateInput extends OmitType(
119
- OmniRelationType,
120
- [
121
- 'createdAt',
122
- 'updatedAt',
123
- 'revision',
124
- 'sourceRecord',
125
- 'targetRecord',
126
- ] as const,
127
- InputType,
128
- ) {}
129
-
130
- @InputType()
131
- @ModelObject({ copyFrom: OmniRelationType })
132
- export class OmniRelationCondition extends PartialType(
133
- OmniRelationCreateInput,
134
- InputType,
135
- ) {}
136
-
137
- @InputType()
138
- @ModelObject({ copyFrom: OmniRelationType })
139
- export class OmniRelationUpdateInput extends PartialType(
140
- OmniRelationCreateInput,
141
- InputType,
142
- ) {}
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
+ Matches,
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 { OmniRecordType } from './omni-record.dto.js';
29
+ import { omniRelationKindPattern } from './omni-relation-kind.contract.js';
30
+ import { OmniRelationStatus } from './omni-relation-status.enum.js';
31
+
32
+ @ObjectType()
33
+ @ModelObject()
34
+ export class OmniRelationType extends OmniRelationEntity {
35
+ constructor(data?: Partial<OmniRelationType>) {
36
+ super();
37
+ if (data) {
38
+ assignOmniPublicDto(this, data);
39
+ }
40
+ }
41
+
42
+ @ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
43
+ @IsUUID()
44
+ guid!: string;
45
+
46
+ @ModelField({ gqlType: returnValue(Int) })
47
+ @IsInt()
48
+ revision!: number;
49
+
50
+ @ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
51
+ @IsUUID()
52
+ sourceRecordId!: string;
53
+
54
+ @ModelField({
55
+ gqlType: () => OmniRecordType,
56
+ gqlOptions: { nullable: false },
57
+ relation: {
58
+ relationType: 'many-to-one',
59
+ sourceKey: { dst: 'sourceRecordId', alias: 'sourceRecordId' },
60
+ targetKey: { dst: 'guid', alias: 'guid' },
61
+ type: () => OmniRecordEntity,
62
+ },
63
+ })
64
+ sourceRecord!: Relation<OmniRecordType>;
65
+
66
+ @ModelField({ gqlType: returnValue(UUIDScalar), isRequired: true })
67
+ @IsUUID()
68
+ targetRecordId!: string;
69
+
70
+ @ModelField({
71
+ gqlType: () => OmniRecordType,
72
+ gqlOptions: { nullable: false },
73
+ relation: {
74
+ relationType: 'many-to-one',
75
+ sourceKey: { dst: 'targetRecordId', alias: 'targetRecordId' },
76
+ targetKey: { dst: 'guid', alias: 'guid' },
77
+ type: () => OmniRecordEntity,
78
+ },
79
+ })
80
+ targetRecord!: Relation<OmniRecordType>;
81
+
82
+ @ModelField({ gqlType: returnValue(String) })
83
+ @IsString()
84
+ @Matches(omniRelationKindPattern)
85
+ kind!: string;
86
+
87
+ @ModelField({ gqlType: returnValue(OmniRelationStatus) })
88
+ @IsEnum(OmniRelationStatus)
89
+ status!: OmniRelationStatus;
90
+
91
+ @ModelField({
92
+ gqlType: returnValue(GraphQLJSONObject),
93
+ gqlOptions: { nullable: true },
94
+ })
95
+ @IsOptional()
96
+ @IsObject()
97
+ payload?: Record<string, unknown> | null;
98
+
99
+ @ModelField({
100
+ gqlType: returnValue(String),
101
+ gqlOptions: { nullable: true },
102
+ })
103
+ @IsOptional()
104
+ @IsString()
105
+ payloadSchemaId?: string | null;
106
+
107
+ @ModelField({
108
+ gqlType: returnValue(Int),
109
+ gqlOptions: { nullable: true },
110
+ })
111
+ @IsOptional()
112
+ @IsInt()
113
+ payloadSchemaVersion?: number | null;
114
+ }
115
+
116
+ @InputType()
117
+ @ModelObject()
118
+ export class OmniRelationCreateInput extends OmitType(
119
+ OmniRelationType,
120
+ [
121
+ 'createdAt',
122
+ 'updatedAt',
123
+ 'revision',
124
+ 'sourceRecord',
125
+ 'targetRecord',
126
+ ] as const,
127
+ InputType,
128
+ ) {}
129
+
130
+ @InputType()
131
+ @ModelObject({ copyFrom: OmniRelationType })
132
+ export class OmniRelationCondition extends PartialType(
133
+ OmniRelationCreateInput,
134
+ InputType,
135
+ ) {}
136
+
137
+ @InputType()
138
+ @ModelObject({ copyFrom: OmniRelationType })
139
+ export class OmniRelationUpdateInput extends PartialType(
140
+ OmniRelationCreateInput,
141
+ InputType,
142
+ ) {}