@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,274 +1,274 @@
1
- import { Scope, type InjectionToken, type Provider } from '@nestjs/common';
2
- import { getDataSourceToken } from '@nestjs/typeorm';
3
- import {
4
- createProjectionDialect,
5
- createProjectionGraphqlTypes,
6
- CrudGenResourceFactory,
7
- getServiceToken,
8
- type ICrudGenResourceFactoryResult,
9
- type ProjectionGraphqlTypes,
10
- } from '@nest-yalc-2/crud-gen';
11
- import {
12
- GQLDataLoader,
13
- getDataloaderToken,
14
- getFn,
15
- } from '@nest-yalc-2/data-loader';
16
- import { YalcEventService } from '@nest-yalc-2/event-manager';
17
- import type { ClassType } from '@node-yalc/types/globals.js';
18
- import type { DataSource, EntityTarget, ObjectLiteral } from 'typeorm';
19
- import { OmniRecordEntity } from './base/omni-record.entity.js';
20
- import type { OmniExtensionProjectionDefinition } from './omni-extension-projection.definition.js';
21
- import { OmniExtensionProjectionService } from './omni-extension-projection.service.js';
22
- import type {
23
- OmniExtensionProjectionReaderRegistration,
24
- OmniProjectionReaderCatalogProvider,
25
- } from './omni-projection.catalog.js';
26
- import type { OmniProjectionLifecycleProvider } from './omni-projection.lifecycle.js';
27
- import { OmniScopeContext } from './omni-scope.js';
28
-
29
- export interface OmniExtensionProjectionGraphqlNames {
30
- object: string;
31
- create: string;
32
- patch: string;
33
- conditions: string;
34
- }
35
-
36
- export interface OmniExtensionProjectionRegistrationOptions<
37
- Extension extends ObjectLiteral,
38
- Api extends ObjectLiteral,
39
- > {
40
- /** The dynamically created class from createOmniExtensionProjectionEntity. */
41
- entity: EntityTarget<Extension>;
42
- /** API-only model used by CrudGen to derive operation names and tokens. */
43
- apiModel: ClassType<Api>;
44
- definition: OmniExtensionProjectionDefinition;
45
- /** Shared catalog provider, normally built from all returned registrations. */
46
- catalog?: OmniProjectionReaderCatalogProvider;
47
- /** Request-scoped app policy shared by generated REST and GraphQL. */
48
- lifecycle?: OmniProjectionLifecycleProvider<
49
- OmniExtensionProjectionDefinition,
50
- Extension
51
- >;
52
- dbConnection: string;
53
- rest?: {
54
- path?: string;
55
- };
56
- graphql?: {
57
- prefix?: string;
58
- names?: OmniExtensionProjectionGraphqlNames;
59
- };
60
- /** Optional consumer-owned ModuleRef token for generated GraphQL DI. */
61
- moduleRefToken?: InjectionToken;
62
- }
63
-
64
- export interface OmniExtensionProjectionRegistration<
65
- Extension extends ObjectLiteral,
66
- Api extends ObjectLiteral,
67
- > {
68
- /** Immutable source contract shared by service, transport, and migrations. */
69
- definition: OmniExtensionProjectionDefinition;
70
- /** Register these entities with TypeOrmModule.forFeature in the app module. */
71
- entities: readonly EntityTarget<Extension>[];
72
- /** Pass these into OmniKernelModule.register({ reservedRecordKinds }) . */
73
- reservedRecordKinds: readonly string[];
74
- /** Include this in createOmniProjectionReaderCatalog([...]). */
75
- reader: OmniExtensionProjectionReaderRegistration<Extension>;
76
- /** Generated GraphQL classes, useful when composing additional schema. */
77
- graphqlTypes: ProjectionGraphqlTypes;
78
- resource: ICrudGenResourceFactoryResult<Api>;
79
- controllers: readonly ClassType[];
80
- providers: readonly Provider[];
81
- serviceToken: string;
82
- dataLoaderToken: string;
83
- }
84
-
85
- function dialectFor(dataSource: DataSource) {
86
- if (
87
- dataSource.options.type !== 'sqlite' &&
88
- dataSource.options.type !== 'postgres'
89
- ) {
90
- throw new TypeError(
91
- 'Omni extension projections require a SQLite or PostgreSQL data source.',
92
- );
93
- }
94
- return createProjectionDialect(dataSource.options.type);
95
- }
96
-
97
- function defaultGraphqlNames(
98
- apiModel: ClassType,
99
- ): OmniExtensionProjectionGraphqlNames {
100
- return {
101
- object: apiModel.name,
102
- create: `${apiModel.name}CreateInput`,
103
- patch: `${apiModel.name}UpdateInput`,
104
- conditions: `${apiModel.name}Condition`,
105
- };
106
- }
107
-
108
- /**
109
- * Composes the standard CrudGen REST and GraphQL surfaces for one Omni-owned
110
- * extension. It deliberately supplies no handwritten controller or resolver:
111
- * consumers register the returned controllers/providers alongside their
112
- * trusted OmniKernel scope module and TypeOrmModule.forFeature entities.
113
- */
114
- export function createOmniExtensionProjectionRegistration<
115
- Extension extends ObjectLiteral,
116
- Api extends ObjectLiteral,
117
- >(
118
- options: OmniExtensionProjectionRegistrationOptions<Extension, Api>,
119
- ): OmniExtensionProjectionRegistration<Extension, Api> {
120
- const graphqlTypes = createProjectionGraphqlTypes(
121
- options.definition,
122
- options.graphql?.names ?? defaultGraphqlNames(options.apiModel),
123
- );
124
- const serviceToken = getServiceToken(options.apiModel);
125
- const dataLoaderToken = getDataloaderToken(options.apiModel);
126
- const resource = CrudGenResourceFactory<Api>({
127
- entityModel: options.apiModel,
128
- backend: false,
129
- graphql: {
130
- resolver: {
131
- dto: graphqlTypes.object as ClassType,
132
- input: {
133
- create: graphqlTypes.create as ClassType,
134
- update: graphqlTypes.patch as ClassType,
135
- conditions: graphqlTypes.conditions as ClassType,
136
- },
137
- ...(options.graphql?.prefix ? { prefix: options.graphql.prefix } : {}),
138
- ...(options.moduleRefToken !== undefined
139
- ? { moduleRefToken: options.moduleRefToken }
140
- : {}),
141
- queries: {
142
- getResource: { idName: options.definition.identity.column },
143
- },
144
- },
145
- serviceToken,
146
- dataLoaderToken,
147
- },
148
- rest: {
149
- dto: graphqlTypes.object as ClassType,
150
- serialize: true,
151
- ...(options.rest?.path ? { path: options.rest.path } : {}),
152
- idField: options.definition.identity.column as keyof Api & string,
153
- serviceToken,
154
- },
155
- });
156
-
157
- const reader = Object.freeze({
158
- type: 'extension' as const,
159
- id: options.definition.id,
160
- entity: options.entity,
161
- definition: options.definition,
162
- }) as OmniExtensionProjectionReaderRegistration<Extension>;
163
- const serviceProvider: Provider =
164
- options.lifecycle && options.catalog
165
- ? {
166
- provide: serviceToken,
167
- scope: Scope.REQUEST,
168
- useFactory: (
169
- dataSource: DataSource,
170
- scope: OmniScopeContext,
171
- events: YalcEventService,
172
- lifecycle: any,
173
- catalog: any,
174
- ) =>
175
- new OmniExtensionProjectionService(
176
- dataSource.getRepository(options.entity),
177
- dataSource.getRepository(OmniRecordEntity),
178
- dataSource,
179
- scope,
180
- dialectFor(dataSource),
181
- events,
182
- options.definition,
183
- lifecycle,
184
- catalog,
185
- ),
186
- inject: [
187
- getDataSourceToken(options.dbConnection),
188
- OmniScopeContext,
189
- YalcEventService,
190
- options.lifecycle.token,
191
- options.catalog.token,
192
- ],
193
- }
194
- : options.lifecycle
195
- ? {
196
- provide: serviceToken,
197
- scope: Scope.REQUEST,
198
- useFactory: (
199
- dataSource: DataSource,
200
- scope: OmniScopeContext,
201
- events: YalcEventService,
202
- lifecycle: any,
203
- ) =>
204
- new OmniExtensionProjectionService(
205
- dataSource.getRepository(options.entity),
206
- dataSource.getRepository(OmniRecordEntity),
207
- dataSource,
208
- scope,
209
- dialectFor(dataSource),
210
- events,
211
- options.definition,
212
- lifecycle,
213
- ),
214
- inject: [
215
- getDataSourceToken(options.dbConnection),
216
- OmniScopeContext,
217
- YalcEventService,
218
- options.lifecycle.token,
219
- ],
220
- }
221
- : {
222
- provide: serviceToken,
223
- scope: Scope.REQUEST,
224
- useFactory: (
225
- dataSource: DataSource,
226
- scope: OmniScopeContext,
227
- events: YalcEventService,
228
- ) =>
229
- new OmniExtensionProjectionService(
230
- dataSource.getRepository(options.entity),
231
- dataSource.getRepository(OmniRecordEntity),
232
- dataSource,
233
- scope,
234
- dialectFor(dataSource),
235
- events,
236
- options.definition,
237
- undefined,
238
- ),
239
- inject: [
240
- getDataSourceToken(options.dbConnection),
241
- OmniScopeContext,
242
- YalcEventService,
243
- ],
244
- };
245
- const providers: Provider[] = [
246
- serviceProvider,
247
- {
248
- provide: dataLoaderToken,
249
- scope: Scope.REQUEST,
250
- useFactory: (
251
- service: OmniExtensionProjectionService<Extension>,
252
- scope: OmniScopeContext,
253
- ) =>
254
- new GQLDataLoader(getFn(service as never), 'guid', undefined, {
255
- cacheKeyFn: (key) => scope.cacheKey(key),
256
- }),
257
- inject: [serviceToken, OmniScopeContext],
258
- },
259
- ...resource.providers,
260
- ];
261
-
262
- return Object.freeze({
263
- definition: options.definition,
264
- entities: Object.freeze([options.entity]),
265
- reservedRecordKinds: Object.freeze([options.definition.owner.kind]),
266
- reader,
267
- graphqlTypes: Object.freeze(graphqlTypes),
268
- resource,
269
- controllers: Object.freeze([...resource.controllers]),
270
- providers: Object.freeze(providers),
271
- serviceToken,
272
- dataLoaderToken,
273
- });
274
- }
1
+ import { Scope, type InjectionToken, type Provider } from '@nestjs/common';
2
+ import { getDataSourceToken } from '@nestjs/typeorm';
3
+ import {
4
+ createProjectionDialect,
5
+ createProjectionGraphqlTypes,
6
+ CrudGenResourceFactory,
7
+ getServiceToken,
8
+ type ICrudGenResourceFactoryResult,
9
+ type ProjectionGraphqlTypes,
10
+ } from '@nest-yalc-2/crud-gen';
11
+ import {
12
+ GQLDataLoader,
13
+ getDataloaderToken,
14
+ getFn,
15
+ } from '@nest-yalc-2/data-loader';
16
+ import { YalcEventService } from '@nest-yalc-2/event-manager';
17
+ import type { ClassType } from '@node-yalc/types/globals.js';
18
+ import type { DataSource, EntityTarget, ObjectLiteral } from 'typeorm';
19
+ import { OmniRecordEntity } from './base/omni-record.entity.js';
20
+ import type { OmniExtensionProjectionDefinition } from './omni-extension-projection.definition.js';
21
+ import { OmniExtensionProjectionService } from './omni-extension-projection.service.js';
22
+ import type {
23
+ OmniExtensionProjectionReaderRegistration,
24
+ OmniProjectionReaderCatalogProvider,
25
+ } from './omni-projection.catalog.js';
26
+ import type { OmniProjectionLifecycleProvider } from './omni-projection.lifecycle.js';
27
+ import { OmniScopeContext } from './omni-scope.js';
28
+
29
+ export interface OmniExtensionProjectionGraphqlNames {
30
+ object: string;
31
+ create: string;
32
+ patch: string;
33
+ conditions: string;
34
+ }
35
+
36
+ export interface OmniExtensionProjectionRegistrationOptions<
37
+ Extension extends ObjectLiteral,
38
+ Api extends ObjectLiteral,
39
+ > {
40
+ /** The dynamically created class from createOmniExtensionProjectionEntity. */
41
+ entity: EntityTarget<Extension>;
42
+ /** API-only model used by CrudGen to derive operation names and tokens. */
43
+ apiModel: ClassType<Api>;
44
+ definition: OmniExtensionProjectionDefinition;
45
+ /** Shared catalog provider, normally built from all returned registrations. */
46
+ catalog?: OmniProjectionReaderCatalogProvider;
47
+ /** Request-scoped app policy shared by generated REST and GraphQL. */
48
+ lifecycle?: OmniProjectionLifecycleProvider<
49
+ OmniExtensionProjectionDefinition,
50
+ Extension
51
+ >;
52
+ dbConnection: string;
53
+ rest?: {
54
+ path?: string;
55
+ };
56
+ graphql?: {
57
+ prefix?: string;
58
+ names?: OmniExtensionProjectionGraphqlNames;
59
+ };
60
+ /** Optional consumer-owned ModuleRef token for generated GraphQL DI. */
61
+ moduleRefToken?: InjectionToken;
62
+ }
63
+
64
+ export interface OmniExtensionProjectionRegistration<
65
+ Extension extends ObjectLiteral,
66
+ Api extends ObjectLiteral,
67
+ > {
68
+ /** Immutable source contract shared by service, transport, and migrations. */
69
+ definition: OmniExtensionProjectionDefinition;
70
+ /** Register these entities with TypeOrmModule.forFeature in the app module. */
71
+ entities: readonly EntityTarget<Extension>[];
72
+ /** Pass these into OmniKernelModule.register({ reservedRecordKinds }) . */
73
+ reservedRecordKinds: readonly string[];
74
+ /** Include this in createOmniProjectionReaderCatalog([...]). */
75
+ reader: OmniExtensionProjectionReaderRegistration<Extension>;
76
+ /** Generated GraphQL classes, useful when composing additional schema. */
77
+ graphqlTypes: ProjectionGraphqlTypes;
78
+ resource: ICrudGenResourceFactoryResult<Api>;
79
+ controllers: readonly ClassType[];
80
+ providers: readonly Provider[];
81
+ serviceToken: string;
82
+ dataLoaderToken: string;
83
+ }
84
+
85
+ function dialectFor(dataSource: DataSource) {
86
+ if (
87
+ dataSource.options.type !== 'sqlite' &&
88
+ dataSource.options.type !== 'postgres'
89
+ ) {
90
+ throw new TypeError(
91
+ 'Omni extension projections require a SQLite or PostgreSQL data source.',
92
+ );
93
+ }
94
+ return createProjectionDialect(dataSource.options.type);
95
+ }
96
+
97
+ function defaultGraphqlNames(
98
+ apiModel: ClassType,
99
+ ): OmniExtensionProjectionGraphqlNames {
100
+ return {
101
+ object: apiModel.name,
102
+ create: `${apiModel.name}CreateInput`,
103
+ patch: `${apiModel.name}UpdateInput`,
104
+ conditions: `${apiModel.name}Condition`,
105
+ };
106
+ }
107
+
108
+ /**
109
+ * Composes the standard CrudGen REST and GraphQL surfaces for one Omni-owned
110
+ * extension. It deliberately supplies no handwritten controller or resolver:
111
+ * consumers register the returned controllers/providers alongside their
112
+ * trusted OmniKernel scope module and TypeOrmModule.forFeature entities.
113
+ */
114
+ export function createOmniExtensionProjectionRegistration<
115
+ Extension extends ObjectLiteral,
116
+ Api extends ObjectLiteral,
117
+ >(
118
+ options: OmniExtensionProjectionRegistrationOptions<Extension, Api>,
119
+ ): OmniExtensionProjectionRegistration<Extension, Api> {
120
+ const graphqlTypes = createProjectionGraphqlTypes(
121
+ options.definition,
122
+ options.graphql?.names ?? defaultGraphqlNames(options.apiModel),
123
+ );
124
+ const serviceToken = getServiceToken(options.apiModel);
125
+ const dataLoaderToken = getDataloaderToken(options.apiModel);
126
+ const resource = CrudGenResourceFactory<Api>({
127
+ entityModel: options.apiModel,
128
+ backend: false,
129
+ graphql: {
130
+ resolver: {
131
+ dto: graphqlTypes.object as ClassType,
132
+ input: {
133
+ create: graphqlTypes.create as ClassType,
134
+ update: graphqlTypes.patch as ClassType,
135
+ conditions: graphqlTypes.conditions as ClassType,
136
+ },
137
+ ...(options.graphql?.prefix ? { prefix: options.graphql.prefix } : {}),
138
+ ...(options.moduleRefToken !== undefined
139
+ ? { moduleRefToken: options.moduleRefToken }
140
+ : {}),
141
+ queries: {
142
+ getResource: { idName: options.definition.identity.column },
143
+ },
144
+ },
145
+ serviceToken,
146
+ dataLoaderToken,
147
+ },
148
+ rest: {
149
+ dto: graphqlTypes.object as ClassType,
150
+ serialize: true,
151
+ ...(options.rest?.path ? { path: options.rest.path } : {}),
152
+ idField: options.definition.identity.column as keyof Api & string,
153
+ serviceToken,
154
+ },
155
+ });
156
+
157
+ const reader = Object.freeze({
158
+ type: 'extension' as const,
159
+ id: options.definition.id,
160
+ entity: options.entity,
161
+ definition: options.definition,
162
+ }) as OmniExtensionProjectionReaderRegistration<Extension>;
163
+ const serviceProvider: Provider =
164
+ options.lifecycle && options.catalog
165
+ ? {
166
+ provide: serviceToken,
167
+ scope: Scope.REQUEST,
168
+ useFactory: (
169
+ dataSource: DataSource,
170
+ scope: OmniScopeContext,
171
+ events: YalcEventService,
172
+ lifecycle: any,
173
+ catalog: any,
174
+ ) =>
175
+ new OmniExtensionProjectionService(
176
+ dataSource.getRepository(options.entity),
177
+ dataSource.getRepository(OmniRecordEntity),
178
+ dataSource,
179
+ scope,
180
+ dialectFor(dataSource),
181
+ events,
182
+ options.definition,
183
+ lifecycle,
184
+ catalog,
185
+ ),
186
+ inject: [
187
+ getDataSourceToken(options.dbConnection),
188
+ OmniScopeContext,
189
+ YalcEventService,
190
+ options.lifecycle.token,
191
+ options.catalog.token,
192
+ ],
193
+ }
194
+ : options.lifecycle
195
+ ? {
196
+ provide: serviceToken,
197
+ scope: Scope.REQUEST,
198
+ useFactory: (
199
+ dataSource: DataSource,
200
+ scope: OmniScopeContext,
201
+ events: YalcEventService,
202
+ lifecycle: any,
203
+ ) =>
204
+ new OmniExtensionProjectionService(
205
+ dataSource.getRepository(options.entity),
206
+ dataSource.getRepository(OmniRecordEntity),
207
+ dataSource,
208
+ scope,
209
+ dialectFor(dataSource),
210
+ events,
211
+ options.definition,
212
+ lifecycle,
213
+ ),
214
+ inject: [
215
+ getDataSourceToken(options.dbConnection),
216
+ OmniScopeContext,
217
+ YalcEventService,
218
+ options.lifecycle.token,
219
+ ],
220
+ }
221
+ : {
222
+ provide: serviceToken,
223
+ scope: Scope.REQUEST,
224
+ useFactory: (
225
+ dataSource: DataSource,
226
+ scope: OmniScopeContext,
227
+ events: YalcEventService,
228
+ ) =>
229
+ new OmniExtensionProjectionService(
230
+ dataSource.getRepository(options.entity),
231
+ dataSource.getRepository(OmniRecordEntity),
232
+ dataSource,
233
+ scope,
234
+ dialectFor(dataSource),
235
+ events,
236
+ options.definition,
237
+ undefined,
238
+ ),
239
+ inject: [
240
+ getDataSourceToken(options.dbConnection),
241
+ OmniScopeContext,
242
+ YalcEventService,
243
+ ],
244
+ };
245
+ const providers: Provider[] = [
246
+ serviceProvider,
247
+ {
248
+ provide: dataLoaderToken,
249
+ scope: Scope.REQUEST,
250
+ useFactory: (
251
+ service: OmniExtensionProjectionService<Extension>,
252
+ scope: OmniScopeContext,
253
+ ) =>
254
+ new GQLDataLoader(getFn(service as never), 'guid', undefined, {
255
+ cacheKeyFn: (key) => scope.cacheKey(key),
256
+ }),
257
+ inject: [serviceToken, OmniScopeContext],
258
+ },
259
+ ...resource.providers,
260
+ ];
261
+
262
+ return Object.freeze({
263
+ definition: options.definition,
264
+ entities: Object.freeze([options.entity]),
265
+ reservedRecordKinds: Object.freeze([options.definition.owner.kind]),
266
+ reader,
267
+ graphqlTypes: Object.freeze(graphqlTypes),
268
+ resource,
269
+ controllers: Object.freeze([...resource.controllers]),
270
+ providers: Object.freeze(providers),
271
+ serviceToken,
272
+ dataLoaderToken,
273
+ });
274
+ }