@akanjs/server 0.0.40 → 0.0.41

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/src/module.js DELETED
@@ -1,347 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var module_exports = {};
20
- __export(module_exports, {
21
- batchModuleOf: () => batchModuleOf,
22
- databaseModuleOf: () => databaseModuleOf,
23
- scalarModuleOf: () => scalarModuleOf,
24
- scalarModulesOf: () => scalarModulesOf,
25
- serviceModuleOf: () => serviceModuleOf,
26
- useGlobals: () => useGlobals
27
- });
28
- module.exports = __toCommonJS(module_exports);
29
- var import_common = require("@akanjs/common");
30
- var import_constant = require("@akanjs/constant");
31
- var import_document = require("@akanjs/document");
32
- var import_service = require("@akanjs/service");
33
- var import_signal = require("@akanjs/signal");
34
- var import_bull = require("@nestjs/bull");
35
- var import_common2 = require("@nestjs/common");
36
- var import_mongoose = require("@nestjs/mongoose");
37
- var import_controller = require("./controller");
38
- var import_processor = require("./processor");
39
- var import_resolver = require("./resolver");
40
- var import_schema = require("./schema");
41
- var import_websocket = require("./websocket");
42
- function _ts_decorate(decorators, target, key, desc) {
43
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
44
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
45
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
46
- return c > 3 && r && Object.defineProperty(target, key, r), r;
47
- }
48
- __name(_ts_decorate, "_ts_decorate");
49
- const hasWebsocket = /* @__PURE__ */ __name((signal) => (0, import_signal.getGqlMetas)(signal).some((gqlMeta) => [
50
- "Message",
51
- "Pubsub"
52
- ].includes(gqlMeta.type)), "hasWebsocket");
53
- const hasProcessor = /* @__PURE__ */ __name((signal) => (0, import_signal.getGqlMetas)(signal).some((gqlMeta) => gqlMeta.type === "Process"), "hasProcessor");
54
- const filterSrvs = /* @__PURE__ */ __name((srvs) => Object.fromEntries(Object.entries(srvs).filter(([_, srv]) => !!srv)), "filterSrvs");
55
- const databaseModuleOf = /* @__PURE__ */ __name(({ constant, database, signal, service, uses = {}, useAsyncs = {}, providers = [], extended }, allSrvs) => {
56
- if (!(0, import_service.isServiceEnabled)(service)) return null;
57
- const [modelName, className] = [
58
- (0, import_common.lowerlize)(constant.refName),
59
- (0, import_common.capitalize)(constant.refName)
60
- ];
61
- const mongoToken = (0, import_mongoose.getModelToken)(className);
62
- let DatabaseModule = class DatabaseModule {
63
- static {
64
- __name(this, "DatabaseModule");
65
- }
66
- };
67
- DatabaseModule = _ts_decorate([
68
- (0, import_common2.Global)(),
69
- (0, import_common2.Module)({
70
- imports: [
71
- import_mongoose.MongooseModule.forFeature([
72
- {
73
- name: className,
74
- schema: extended ? (0, import_schema.addSchema)(database.Model, database.Doc, database.Input, database.Middleware) : (0, import_schema.schemaOf)(database.Model, database.Doc, database.Middleware)
75
- }
76
- ]),
77
- ...hasProcessor(signal) ? [
78
- import_bull.BullModule.registerQueue({
79
- name: modelName,
80
- defaultJobOptions: {
81
- removeOnComplete: true,
82
- removeOnFail: true
83
- }
84
- })
85
- ] : []
86
- ],
87
- providers: [
88
- (0, import_service.serviceOf)(service),
89
- (0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs)),
90
- ...hasProcessor(signal) ? [
91
- (0, import_processor.processorOf)(signal, filterSrvs(allSrvs)),
92
- {
93
- provide: `${className}Queue`,
94
- useFactory: /* @__PURE__ */ __name((queue) => queue, "useFactory"),
95
- inject: [
96
- (0, import_bull.getQueueToken)(modelName)
97
- ]
98
- }
99
- ] : [],
100
- ...hasWebsocket(signal) ? [
101
- (0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs)),
102
- {
103
- provide: "Websocket",
104
- useClass: (0, import_websocket.websocketServerOf)(signal)
105
- }
106
- ] : [],
107
- ...Object.entries(uses).map(([key, useValue]) => ({
108
- provide: (0, import_common.capitalize)(key),
109
- useValue
110
- })),
111
- ...Object.entries(useAsyncs).map(([key, useFactory]) => ({
112
- provide: (0, import_common.capitalize)(key),
113
- useFactory
114
- })),
115
- {
116
- provide: `${modelName}Model`,
117
- useFactory: /* @__PURE__ */ __name((model, redis, meili) => {
118
- return (0, import_document.databaseModelOf)(database, model, redis, meili);
119
- }, "useFactory"),
120
- inject: [
121
- mongoToken,
122
- "REDIS_CLIENT",
123
- "MEILI_CLIENT"
124
- ]
125
- },
126
- ...providers
127
- ],
128
- controllers: [
129
- (0, import_controller.controllerOf)(signal, filterSrvs(allSrvs))
130
- ],
131
- exports: [
132
- service
133
- ]
134
- })
135
- ], DatabaseModule);
136
- return DatabaseModule;
137
- }, "databaseModuleOf");
138
- const serviceModuleOf = /* @__PURE__ */ __name(({ signal, service, uses = {}, useAsyncs = {}, providers = [] }, allSrvs) => {
139
- if (!(0, import_service.isServiceEnabled)(service)) return null;
140
- const sigMeta = (0, import_signal.getSigMeta)(signal);
141
- const [modelName, className] = [
142
- (0, import_common.lowerlize)(sigMeta.refName),
143
- (0, import_common.capitalize)(sigMeta.refName)
144
- ];
145
- let ServiceModule = class ServiceModule {
146
- static {
147
- __name(this, "ServiceModule");
148
- }
149
- };
150
- ServiceModule = _ts_decorate([
151
- (0, import_common2.Global)(),
152
- (0, import_common2.Module)({
153
- imports: [
154
- ...hasProcessor(signal) ? [
155
- import_bull.BullModule.registerQueue({
156
- name: modelName,
157
- defaultJobOptions: {
158
- removeOnComplete: true,
159
- removeOnFail: true
160
- }
161
- })
162
- ] : []
163
- ],
164
- providers: [
165
- (0, import_service.serviceOf)(service),
166
- (0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs)),
167
- ...hasWebsocket(signal) ? [
168
- (0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs)),
169
- {
170
- provide: "Websocket",
171
- useClass: (0, import_websocket.websocketServerOf)(signal)
172
- }
173
- ] : [],
174
- ...hasProcessor(signal) ? [
175
- (0, import_processor.processorOf)(signal, filterSrvs(allSrvs)),
176
- {
177
- provide: `${className}Queue`,
178
- useFactory: /* @__PURE__ */ __name((queue) => queue, "useFactory"),
179
- inject: [
180
- (0, import_bull.getQueueToken)(modelName)
181
- ]
182
- }
183
- ] : [],
184
- ...Object.entries(uses).map(([key, useValue]) => ({
185
- provide: (0, import_common.capitalize)(key),
186
- useValue
187
- })),
188
- ...Object.entries(useAsyncs).map(([key, useFactory]) => ({
189
- provide: (0, import_common.capitalize)(key),
190
- useFactory
191
- })),
192
- ...providers
193
- ],
194
- controllers: [
195
- (0, import_controller.controllerOf)(signal, filterSrvs(allSrvs))
196
- ],
197
- exports: [
198
- service
199
- ]
200
- })
201
- ], ServiceModule);
202
- return ServiceModule;
203
- }, "serviceModuleOf");
204
- const scalarModuleOf = /* @__PURE__ */ __name(({ signals, uses = {}, useAsyncs = {}, providers = [], enabled = true }, allSrvs) => {
205
- if (!enabled) return null;
206
- let ScalarModule = class ScalarModule {
207
- static {
208
- __name(this, "ScalarModule");
209
- }
210
- };
211
- ScalarModule = _ts_decorate([
212
- (0, import_common2.Global)(),
213
- (0, import_common2.Module)({
214
- imports: [],
215
- providers: [
216
- ...signals.map((signal) => (0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs))),
217
- ...signals.filter(hasWebsocket).map((signal) => [
218
- (0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs)),
219
- {
220
- provide: "Websocket",
221
- useClass: (0, import_websocket.websocketServerOf)(signal)
222
- }
223
- ]).flat(),
224
- ...Object.entries(uses).map(([key, useValue]) => ({
225
- provide: (0, import_common.capitalize)(key),
226
- useValue
227
- })),
228
- ...Object.entries(useAsyncs).map(([key, useFactory]) => ({
229
- provide: (0, import_common.capitalize)(key),
230
- useFactory
231
- })),
232
- ...providers
233
- ],
234
- controllers: signals.map((signal) => (0, import_controller.controllerOf)(signal, filterSrvs(allSrvs)))
235
- })
236
- ], ScalarModule);
237
- return ScalarModule;
238
- }, "scalarModuleOf");
239
- const scalarModulesOf = /* @__PURE__ */ __name(({ constants }, allSrvs) => {
240
- const signals = constants.filter((modelRef) => {
241
- const childRefs = (0, import_constant.getChildClassRefs)(modelRef);
242
- return childRefs.some((childRef) => {
243
- const classMeta = (0, import_constant.getClassMeta)(childRef);
244
- return [
245
- "full",
246
- "light"
247
- ].includes(classMeta.type);
248
- });
249
- }).map((modelRef) => {
250
- let ScalarSignal = class ScalarSignal extends (0, import_signal.LogSignal)({}) {
251
- static {
252
- __name(this, "ScalarSignal");
253
- }
254
- };
255
- ScalarSignal = _ts_decorate([
256
- (0, import_signal.Signal)(() => modelRef)
257
- ], ScalarSignal);
258
- return ScalarSignal;
259
- });
260
- let ScalarModule = class ScalarModule {
261
- static {
262
- __name(this, "ScalarModule");
263
- }
264
- };
265
- ScalarModule = _ts_decorate([
266
- (0, import_common2.Global)(),
267
- (0, import_common2.Module)({
268
- imports: [],
269
- providers: [
270
- ...signals.map((signal) => (0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs)))
271
- ]
272
- })
273
- ], ScalarModule);
274
- return ScalarModule;
275
- }, "scalarModulesOf");
276
- const batchModuleOf = /* @__PURE__ */ __name(({ service, uses = {}, useAsyncs = {}, providers = [] }) => {
277
- if (!(0, import_service.isServiceEnabled)(service)) return null;
278
- let BatchModule = class BatchModule {
279
- static {
280
- __name(this, "BatchModule");
281
- }
282
- };
283
- BatchModule = _ts_decorate([
284
- (0, import_common2.Global)(),
285
- (0, import_common2.Module)({
286
- imports: [],
287
- providers: [
288
- (0, import_service.serviceOf)(service),
289
- ...Object.entries(uses).map(([key, useValue]) => ({
290
- provide: (0, import_common.capitalize)(key),
291
- useValue
292
- })),
293
- ...Object.entries(useAsyncs).map(([key, useFactory]) => ({
294
- provide: (0, import_common.capitalize)(key),
295
- useFactory
296
- })),
297
- ...providers
298
- ],
299
- exports: [
300
- service
301
- ]
302
- })
303
- ], BatchModule);
304
- return BatchModule;
305
- }, "batchModuleOf");
306
- const useGlobals = /* @__PURE__ */ __name(({ uses, useAsyncs, injects }) => {
307
- let GlobalsModule = class GlobalsModule {
308
- static {
309
- __name(this, "GlobalsModule");
310
- }
311
- };
312
- GlobalsModule = _ts_decorate([
313
- (0, import_common2.Global)(),
314
- (0, import_common2.Module)({
315
- imports: [],
316
- providers: [
317
- ...Object.entries(uses ?? {}).map(([key, useValue]) => ({
318
- provide: (0, import_common.capitalize)(key),
319
- useValue
320
- })),
321
- ...Object.entries(useAsyncs ?? {}).map(([key, useFactory]) => ({
322
- provide: (0, import_common.capitalize)(key),
323
- useFactory
324
- })),
325
- ...Object.entries(injects ?? {}).map(([key, inject]) => ({
326
- provide: (0, import_common.capitalize)(key),
327
- useClass: inject
328
- }))
329
- ],
330
- exports: [
331
- ...Object.keys(uses ?? {}).map((key) => (0, import_common.capitalize)(key)),
332
- ...Object.keys(useAsyncs ?? {}).map((key) => (0, import_common.capitalize)(key)),
333
- ...Object.keys(injects ?? {}).map((key) => (0, import_common.capitalize)(key))
334
- ]
335
- })
336
- ], GlobalsModule);
337
- return GlobalsModule;
338
- }, "useGlobals");
339
- // Annotate the CommonJS export names for ESM import in node:
340
- 0 && (module.exports = {
341
- batchModuleOf,
342
- databaseModuleOf,
343
- scalarModuleOf,
344
- scalarModulesOf,
345
- serviceModuleOf,
346
- useGlobals
347
- });
package/src/processor.js DELETED
@@ -1,85 +0,0 @@
1
- var __defProp = Object.defineProperty;
2
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
- var __getOwnPropNames = Object.getOwnPropertyNames;
4
- var __hasOwnProp = Object.prototype.hasOwnProperty;
5
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
6
- var __export = (target, all) => {
7
- for (var name in all)
8
- __defProp(target, name, { get: all[name], enumerable: true });
9
- };
10
- var __copyProps = (to, from, except, desc) => {
11
- if (from && typeof from === "object" || typeof from === "function") {
12
- for (let key of __getOwnPropNames(from))
13
- if (!__hasOwnProp.call(to, key) && key !== except)
14
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
- }
16
- return to;
17
- };
18
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
- var processor_exports = {};
20
- __export(processor_exports, {
21
- processorOf: () => processorOf,
22
- queueOf: () => queueOf
23
- });
24
- module.exports = __toCommonJS(processor_exports);
25
- var import_common = require("@akanjs/common");
26
- var import_service = require("@akanjs/service");
27
- var import_signal = require("@akanjs/signal");
28
- var import_bull = require("@nestjs/bull");
29
- var import_common2 = require("@nestjs/common");
30
- const convertProcessFunction = /* @__PURE__ */ __name((gqlMeta, argMetas, internalArgMetas, fn) => {
31
- return async function(job, done) {
32
- const args = [];
33
- argMetas.forEach((argMeta) => {
34
- if (argMeta.type === "Msg") args[argMeta.idx] = (0, import_signal.deserializeArg)(argMeta, job.data[argMeta.idx]);
35
- else throw new Error(`Invalid ArgMeta Type ${argMeta.type}`);
36
- });
37
- internalArgMetas.forEach((internalArgMeta) => {
38
- if (internalArgMeta.type === "Job") args[internalArgMeta.idx] = job;
39
- else throw new Error(`Invalid InternalArgMeta Type ${internalArgMeta.type}`);
40
- });
41
- this.logger?.log(`Process-${gqlMeta.key} started`);
42
- const result = await fn.apply(this, args);
43
- this.logger?.log(`Process-${gqlMeta.key} finished`);
44
- done(null, result);
45
- };
46
- }, "convertProcessFunction");
47
- const processorOf = /* @__PURE__ */ __name((sigRef, allSrvs) => {
48
- const sigMeta = (0, import_signal.getSigMeta)(sigRef);
49
- const serverMode = process.env.SERVER_MODE ?? "federation";
50
- const gqlMetas = (0, import_signal.getGqlMetas)(sigRef).filter((gqlMeta) => gqlMeta.type === "Process").filter((gqlMeta) => gqlMeta.signalOption.serverType === "all" || serverMode === "all" || gqlMeta.signalOption.serverType === serverMode);
51
- let QueueProcessor = class QueueProcessor {
52
- static {
53
- __name(this, "QueueProcessor");
54
- }
55
- };
56
- Object.keys(allSrvs).forEach((srv) => {
57
- if (!(0, import_service.isServiceEnabled)(allSrvs[srv])) return;
58
- (0, import_common2.Inject)(allSrvs[srv])(QueueProcessor.prototype, (0, import_common.lowerlize)(srv));
59
- });
60
- for (const gqlMeta of gqlMetas) {
61
- const [argMetas, internalArgMetas] = (0, import_signal.getArgMetas)(sigRef, gqlMeta.key);
62
- const descriptor = {
63
- ...Object.getOwnPropertyDescriptor(sigRef.prototype, gqlMeta.key) ?? {}
64
- };
65
- descriptor.value = convertProcessFunction(gqlMeta, argMetas, internalArgMetas, descriptor.value);
66
- Object.defineProperty(QueueProcessor.prototype, gqlMeta.key, descriptor);
67
- (0, import_bull.Process)(gqlMeta.key)(QueueProcessor.prototype, gqlMeta.key, descriptor);
68
- }
69
- (0, import_bull.Processor)(sigMeta.refName)(QueueProcessor);
70
- return QueueProcessor;
71
- }, "processorOf");
72
- const queueOf = /* @__PURE__ */ __name((sigRef, queue) => {
73
- const sigMeta = (0, import_signal.getSigMeta)(sigRef);
74
- const gqlMetas = (0, import_signal.getGqlMetas)(sigRef).filter((gqlMeta) => gqlMeta.type === "Process");
75
- for (const gqlMeta of gqlMetas) {
76
- if (queue[gqlMeta.key]) throw new Error(`Queue already has ${gqlMeta.key} in ${sigMeta.refName}`);
77
- queue[gqlMeta.key] = (...args) => queue.add(gqlMeta.key, args);
78
- }
79
- return queue;
80
- }, "queueOf");
81
- // Annotate the CommonJS export names for ESM import in node:
82
- 0 && (module.exports = {
83
- processorOf,
84
- queueOf
85
- });
package/src/resolver.js DELETED
@@ -1,161 +0,0 @@
1
- var __create = Object.create;
2
- var __defProp = Object.defineProperty;
3
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
- var __getOwnPropNames = Object.getOwnPropertyNames;
5
- var __getProtoOf = Object.getPrototypeOf;
6
- var __hasOwnProp = Object.prototype.hasOwnProperty;
7
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
- var resolver_exports = {};
30
- __export(resolver_exports, {
31
- resolverOf: () => resolverOf
32
- });
33
- module.exports = __toCommonJS(resolver_exports);
34
- var import_base = require("@akanjs/base");
35
- var import_common = require("@akanjs/common");
36
- var import_constant = require("@akanjs/constant");
37
- var import_nest = require("@akanjs/nest");
38
- var import_service = require("@akanjs/service");
39
- var import_signal = require("@akanjs/signal");
40
- var import_common2 = require("@nestjs/common");
41
- var Nest = __toESM(require("@nestjs/graphql"));
42
- var import_graphql_type_json = __toESM(require("graphql-type-json"));
43
- var import_graphql_upload = require("graphql-upload");
44
- var import_gql = require("./gql");
45
- const scalarNestReturnMap = /* @__PURE__ */ new Map([
46
- [
47
- import_base.Upload,
48
- import_graphql_upload.GraphQLUpload
49
- ],
50
- [
51
- import_base.ID,
52
- Nest.ID
53
- ],
54
- [
55
- import_base.Int,
56
- Nest.Int
57
- ],
58
- [
59
- import_base.Float,
60
- Nest.Float
61
- ],
62
- [
63
- import_base.JSON,
64
- import_graphql_type_json.default
65
- ],
66
- [
67
- Boolean,
68
- Boolean
69
- ],
70
- [
71
- Date,
72
- Date
73
- ],
74
- [
75
- String,
76
- String
77
- ],
78
- [
79
- Map,
80
- import_graphql_type_json.default
81
- ]
82
- ]);
83
- const getNestReturn = /* @__PURE__ */ __name((returns, type = "object") => {
84
- const [model, arrDepth] = (0, import_base.getNonArrayModel)(returns());
85
- const modelRef = scalarNestReturnMap.get(model) ?? (type === "object" ? (0, import_gql.generateGql)(model) : (0, import_gql.generateGqlInput)(model));
86
- return () => (0, import_base.arraiedModel)(modelRef, arrDepth);
87
- }, "getNestReturn");
88
- const internalArgMap = {
89
- Parent: Nest.Parent,
90
- Account: import_nest.Account,
91
- UserIp: import_nest.UserIp,
92
- Access: import_nest.Access,
93
- Self: import_nest.Self,
94
- Me: import_nest.Me,
95
- Req: import_nest.Req,
96
- Res: import_nest.Res
97
- };
98
- const resolverOf = /* @__PURE__ */ __name((sigRef, allSrvs) => {
99
- const Rsv = (0, import_signal.copySignal)(sigRef);
100
- const sigMeta = (0, import_signal.getSigMeta)(Rsv);
101
- const gqlMetas = (0, import_signal.getGqlMetas)(Rsv);
102
- Object.keys(allSrvs).forEach((srv) => {
103
- if (!(0, import_service.isServiceEnabled)(allSrvs[srv])) return;
104
- (0, import_common2.Inject)(allSrvs[srv])(Rsv.prototype, (0, import_common.lowerlize)(srv));
105
- });
106
- for (const gqlMeta of gqlMetas) {
107
- if (gqlMeta.guards.some((guard) => guard === "None") || gqlMeta.signalOption.onlyFor === "restapi" || ![
108
- "Query",
109
- "Mutation"
110
- ].includes(gqlMeta.type)) continue;
111
- else if (gqlMeta.signalOption.sso) continue;
112
- const [argMetas, internalArgMetas] = (0, import_signal.getArgMetas)(Rsv, gqlMeta.key);
113
- const descriptor = Object.getOwnPropertyDescriptor(Rsv.prototype, gqlMeta.key) ?? {};
114
- for (const argMeta of argMetas) {
115
- Nest.Args({
116
- name: argMeta.name,
117
- type: getNestReturn(argMeta.returns, "input"),
118
- ...argMeta.argsOption
119
- })(Rsv.prototype, gqlMeta.key, argMeta.idx);
120
- }
121
- for (const internalArgMeta of internalArgMetas) {
122
- const decorate = internalArgMap[internalArgMeta.type];
123
- decorate(internalArgMeta.option ?? {})(Rsv.prototype, gqlMeta.key, internalArgMeta.idx);
124
- }
125
- (0, import_common2.UseGuards)(...gqlMeta.guards.map((guard) => import_nest.guards[guard]))(Rsv.prototype, gqlMeta.key, descriptor);
126
- if (gqlMeta.type === "Query") Nest.Query(getNestReturn(gqlMeta.returns), gqlMeta.signalOption)(Rsv.prototype, gqlMeta.key, descriptor);
127
- else if (gqlMeta.type === "Mutation") Nest.Mutation(getNestReturn(gqlMeta.returns), gqlMeta.signalOption)(Rsv.prototype, gqlMeta.key, descriptor);
128
- }
129
- const resolveFieldMetas = (0, import_signal.getResolveFieldMetas)(Rsv);
130
- if (sigMeta.returns) {
131
- const modelRef = sigMeta.returns();
132
- const fieldMetas = (0, import_constant.getFieldMetas)(modelRef);
133
- fieldMetas.filter((fieldMeta) => fieldMeta.isClass && !fieldMeta.isScalar).forEach((fieldMeta) => {
134
- const classMeta = (0, import_constant.getClassMeta)(fieldMeta.modelRef);
135
- const modelName = (0, import_common.lowerlize)(classMeta.type === "light" ? classMeta.refName.slice(5) : classMeta.refName);
136
- const className = (0, import_common.capitalize)(modelName);
137
- const serviceName = `${modelName}Service`;
138
- Rsv.prototype[fieldMeta.key] = async function(parent) {
139
- const service = this[serviceName];
140
- return fieldMeta.arrDepth ? await service[`load${className}Many`](parent[fieldMeta.key]) : await service[`load${className}`](parent[fieldMeta.key]);
141
- };
142
- Nest.Parent()(Rsv.prototype, fieldMeta.key, 0);
143
- Nest.ResolveField(getNestReturn(() => (0, import_base.arraiedModel)(fieldMeta.modelRef, fieldMeta.arrDepth)))(Rsv.prototype, fieldMeta.key, Object.getOwnPropertyDescriptor(Rsv.prototype, fieldMeta.key) ?? {});
144
- });
145
- }
146
- for (const resolveFieldMeta of resolveFieldMetas) {
147
- const [, internalArgMetas] = (0, import_signal.getArgMetas)(Rsv, resolveFieldMeta.key);
148
- for (const internalArgMeta of internalArgMetas) {
149
- const decorate = internalArgMap[internalArgMeta.type];
150
- decorate(internalArgMeta.option ?? {})(Rsv.prototype, resolveFieldMeta.key, internalArgMeta.idx);
151
- }
152
- Nest.ResolveField(getNestReturn(resolveFieldMeta.returns))(Rsv.prototype, resolveFieldMeta.key, Object.getOwnPropertyDescriptor(Rsv.prototype, resolveFieldMeta.key) ?? {});
153
- }
154
- if (sigMeta.returns) Nest.Resolver(getNestReturn(sigMeta.returns))(Rsv);
155
- else Nest.Resolver()(Rsv);
156
- return Rsv;
157
- }, "resolverOf");
158
- // Annotate the CommonJS export names for ESM import in node:
159
- 0 && (module.exports = {
160
- resolverOf
161
- });