@akanjs/server 0.9.40 → 0.9.42
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/cjs/src/base.module.js +1 -2
- package/cjs/src/boot.js +7 -6
- package/cjs/src/controller.js +4 -3
- package/cjs/src/module.js +42 -92
- package/cjs/src/processor.js +15 -11
- package/cjs/src/resolver.js +4 -3
- package/cjs/src/schema.js +37 -12
- package/cjs/src/websocket.js +14 -21
- package/esm/src/base.module.js +1 -2
- package/esm/src/boot.js +7 -6
- package/esm/src/controller.js +5 -4
- package/esm/src/module.js +49 -97
- package/esm/src/processor.js +15 -11
- package/esm/src/resolver.js +5 -4
- package/esm/src/schema.js +46 -13
- package/esm/src/websocket.js +13 -20
- package/package.json +1 -1
- package/src/module.d.ts +5 -44
- package/src/processor.d.ts +1 -2
- package/src/schema.d.ts +1 -0
- package/src/websocket.d.ts +3 -5
package/cjs/src/base.module.js
CHANGED
|
@@ -27,8 +27,7 @@ const registerBaseModule = (option) => {
|
|
|
27
27
|
return (0, import_module.serviceModuleOf)(
|
|
28
28
|
{
|
|
29
29
|
signal: import_signal.BaseSignal,
|
|
30
|
-
service: import_service.BaseService
|
|
31
|
-
uses: { onCleanup: option.onCleanup }
|
|
30
|
+
service: import_service.BaseService
|
|
32
31
|
},
|
|
33
32
|
import_service.allSrvs
|
|
34
33
|
);
|
package/cjs/src/boot.js
CHANGED
|
@@ -98,9 +98,9 @@ const createNestApp = async ({ registerModules, serverMode = "federation", env,
|
|
|
98
98
|
(0, import_common2.Injectable)()
|
|
99
99
|
], AuthMiddleWare);
|
|
100
100
|
const redisClient = await (0, import_redis.createClient)({ url: redisUri }).connect();
|
|
101
|
-
let
|
|
101
|
+
let GlobalProvideModule = class {
|
|
102
102
|
};
|
|
103
|
-
|
|
103
|
+
GlobalProvideModule = __decorateClass([
|
|
104
104
|
(0, import_common2.Global)(),
|
|
105
105
|
(0, import_common2.Module)({
|
|
106
106
|
providers: [
|
|
@@ -108,11 +108,12 @@ const createNestApp = async ({ registerModules, serverMode = "federation", env,
|
|
|
108
108
|
{
|
|
109
109
|
provide: "MEILI_CLIENT",
|
|
110
110
|
useFactory: () => new import_meilisearch.MeiliSearch({ host: meiliUri, apiKey: (0, import_nest.generateMeiliKey)(env) })
|
|
111
|
-
}
|
|
111
|
+
},
|
|
112
|
+
{ provide: "GLOBAL_ENV", useValue: env }
|
|
112
113
|
],
|
|
113
|
-
exports: ["REDIS_CLIENT", "MEILI_CLIENT"]
|
|
114
|
+
exports: ["REDIS_CLIENT", "MEILI_CLIENT", "GLOBAL_ENV"]
|
|
114
115
|
})
|
|
115
|
-
],
|
|
116
|
+
], GlobalProvideModule);
|
|
116
117
|
let AppModule = class {
|
|
117
118
|
configure(consumer) {
|
|
118
119
|
consumer.apply(AuthMiddleWare).forRoutes({ path: "*", method: import_common2.RequestMethod.ALL });
|
|
@@ -139,7 +140,7 @@ const createNestApp = async ({ registerModules, serverMode = "federation", env,
|
|
|
139
140
|
import_mongoose.MongooseModule.forRootAsync({
|
|
140
141
|
useFactory: () => ({ uri: mongoUri, autoIndex: import_base.baseEnv.environment !== "main" })
|
|
141
142
|
}),
|
|
142
|
-
|
|
143
|
+
GlobalProvideModule,
|
|
143
144
|
(0, import_module.useGlobals)({
|
|
144
145
|
injects: { SearchClient: import_nest.SearchClient, DatabaseClient: import_nest.DatabaseClient, CacheClient: import_nest.CacheClient }
|
|
145
146
|
}),
|
package/cjs/src/controller.js
CHANGED
|
@@ -43,10 +43,11 @@ const controllerOf = (sigRef, allSrvs) => {
|
|
|
43
43
|
const gqlMetas = (0, import_signal.getGqlMetas)(sigRef);
|
|
44
44
|
const prefix = (0, import_signal.getControllerPrefix)(sigMeta);
|
|
45
45
|
const Ctrl = (0, import_signal.copySignal)(sigRef);
|
|
46
|
-
Object.keys(allSrvs).forEach((
|
|
47
|
-
if (!(0, import_service.isServiceEnabled)(allSrvs[
|
|
46
|
+
Object.keys(allSrvs).forEach((srvName) => {
|
|
47
|
+
if (!(0, import_service.isServiceEnabled)(allSrvs[srvName]))
|
|
48
48
|
return;
|
|
49
|
-
|
|
49
|
+
const srvRef = (0, import_service.getServiceRefs)(srvName)[0];
|
|
50
|
+
(0, import_common2.Inject)(srvRef)(Ctrl.prototype, (0, import_common.lowerlize)(srvName));
|
|
50
51
|
});
|
|
51
52
|
for (const gqlMeta of gqlMetas) {
|
|
52
53
|
if (gqlMeta.guards.some((guard) => guard === "None") || gqlMeta.signalOption.onlyFor === "graphql" || !["Query", "Mutation"].includes(gqlMeta.type))
|
package/cjs/src/module.js
CHANGED
|
@@ -26,9 +26,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
26
26
|
};
|
|
27
27
|
var module_exports = {};
|
|
28
28
|
__export(module_exports, {
|
|
29
|
-
batchModuleOf: () => batchModuleOf,
|
|
30
29
|
databaseModuleOf: () => databaseModuleOf,
|
|
31
|
-
scalarModuleOf: () => scalarModuleOf,
|
|
32
30
|
scalarModulesOf: () => scalarModulesOf,
|
|
33
31
|
serviceModuleOf: () => serviceModuleOf,
|
|
34
32
|
useGlobals: () => useGlobals
|
|
@@ -50,20 +48,12 @@ var import_websocket = require("./websocket");
|
|
|
50
48
|
const hasWebsocket = (signal) => (0, import_signal.getGqlMetas)(signal).some((gqlMeta) => ["Message", "Pubsub"].includes(gqlMeta.type));
|
|
51
49
|
const hasProcessor = (signal) => (0, import_signal.getGqlMetas)(signal).some((gqlMeta) => gqlMeta.type === "Process");
|
|
52
50
|
const filterSrvs = (srvs) => Object.fromEntries(Object.entries(srvs).filter(([_, srv]) => !!srv));
|
|
53
|
-
const databaseModuleOf = ({
|
|
54
|
-
constant,
|
|
55
|
-
database,
|
|
56
|
-
signal,
|
|
57
|
-
service,
|
|
58
|
-
uses = {},
|
|
59
|
-
useAsyncs = {},
|
|
60
|
-
providers = [],
|
|
61
|
-
extended
|
|
62
|
-
}, allSrvs) => {
|
|
51
|
+
const databaseModuleOf = ({ constant, database, signal, service }, allSrvs) => {
|
|
63
52
|
if (!(0, import_service.isServiceEnabled)(service))
|
|
64
53
|
return null;
|
|
65
54
|
const [modelName, className] = [(0, import_common.lowerlize)(constant.refName), (0, import_common.capitalize)(constant.refName)];
|
|
66
55
|
const mongoToken = (0, import_mongoose.getModelToken)(className);
|
|
56
|
+
const srvRef = (0, import_service.serviceOf)(service);
|
|
67
57
|
let DatabaseModule = class {
|
|
68
58
|
};
|
|
69
59
|
DatabaseModule = __decorateClass([
|
|
@@ -73,7 +63,7 @@ const databaseModuleOf = ({
|
|
|
73
63
|
import_mongoose.MongooseModule.forFeature([
|
|
74
64
|
{
|
|
75
65
|
name: className,
|
|
76
|
-
schema:
|
|
66
|
+
schema: (0, import_schema.hasSchema)(constant.Full) ? (0, import_schema.addSchema)(database.Model, database.Doc, database.Input, database.Middleware) : (0, import_schema.schemaOf)(database.Model, database.Doc, database.Middleware)
|
|
77
67
|
}
|
|
78
68
|
]),
|
|
79
69
|
...hasProcessor(signal) ? [
|
|
@@ -84,15 +74,11 @@ const databaseModuleOf = ({
|
|
|
84
74
|
] : []
|
|
85
75
|
],
|
|
86
76
|
providers: [
|
|
87
|
-
|
|
77
|
+
...service === srvRef ? [srvRef] : [],
|
|
88
78
|
(0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs)),
|
|
89
|
-
...
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
] : [],
|
|
93
|
-
...hasWebsocket(signal) ? [(0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs)), { provide: "Websocket", useClass: (0, import_websocket.websocketServerOf)(signal) }] : [],
|
|
94
|
-
...Object.entries(uses).map(([key, useValue]) => ({ provide: (0, import_common.capitalize)(key), useValue })),
|
|
95
|
-
...Object.entries(useAsyncs).map(([key, useFactory]) => ({ provide: (0, import_common.capitalize)(key), useFactory })),
|
|
79
|
+
...hasWebsocket(signal) ? [(0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs))] : [],
|
|
80
|
+
...hasProcessor(signal) ? [(0, import_processor.processorOf)(signal, filterSrvs(allSrvs))] : [],
|
|
81
|
+
{ provide: `${className}Signal`, useClass: makeSigForSrv(signal) },
|
|
96
82
|
{
|
|
97
83
|
provide: `${modelName}Model`,
|
|
98
84
|
useFactory: (model, redis, meili) => {
|
|
@@ -100,74 +86,52 @@ const databaseModuleOf = ({
|
|
|
100
86
|
},
|
|
101
87
|
inject: [mongoToken, "REDIS_CLIENT", "MEILI_CLIENT"]
|
|
102
88
|
},
|
|
103
|
-
...
|
|
89
|
+
...(0, import_service.makeProvidersForSrv)(srvRef)
|
|
104
90
|
],
|
|
105
91
|
controllers: [(0, import_controller.controllerOf)(signal, filterSrvs(allSrvs))],
|
|
106
|
-
exports: [
|
|
92
|
+
exports: service === srvRef ? [srvRef] : []
|
|
107
93
|
})
|
|
108
94
|
], DatabaseModule);
|
|
109
95
|
return DatabaseModule;
|
|
110
96
|
};
|
|
111
|
-
const serviceModuleOf = ({ signal, service
|
|
97
|
+
const serviceModuleOf = ({ signal, service }, allSrvs) => {
|
|
112
98
|
if (!(0, import_service.isServiceEnabled)(service))
|
|
113
99
|
return null;
|
|
114
|
-
const
|
|
115
|
-
|
|
100
|
+
const serviceMeta = (0, import_service.getServiceMeta)(service);
|
|
101
|
+
if (!serviceMeta)
|
|
102
|
+
throw new Error(`Service ${service} is not a valid service`);
|
|
103
|
+
const refName = serviceMeta.name.replace("Service", "");
|
|
104
|
+
const [modelName, className] = [(0, import_common.lowerlize)(refName), (0, import_common.capitalize)(refName)];
|
|
105
|
+
const srvRef = (0, import_service.serviceOf)(service);
|
|
116
106
|
let ServiceModule = class {
|
|
117
107
|
};
|
|
118
108
|
ServiceModule = __decorateClass([
|
|
119
109
|
(0, import_common2.Global)(),
|
|
120
110
|
(0, import_common2.Module)({
|
|
121
|
-
imports: [
|
|
111
|
+
imports: signal ? [
|
|
122
112
|
...hasProcessor(signal) ? [
|
|
123
113
|
import_bull.BullModule.registerQueue({
|
|
124
114
|
name: modelName,
|
|
125
115
|
defaultJobOptions: { removeOnComplete: true, removeOnFail: true }
|
|
126
116
|
})
|
|
127
117
|
] : []
|
|
128
|
-
],
|
|
118
|
+
] : [],
|
|
129
119
|
providers: [
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
(0, import_processor.processorOf)(signal, filterSrvs(allSrvs)),
|
|
135
|
-
{ provide: `${className}
|
|
120
|
+
...service === srvRef ? [srvRef] : [],
|
|
121
|
+
...signal ? [
|
|
122
|
+
(0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs)),
|
|
123
|
+
...hasWebsocket(signal) ? [(0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs))] : [],
|
|
124
|
+
...hasProcessor(signal) ? [(0, import_processor.processorOf)(signal, filterSrvs(allSrvs))] : [],
|
|
125
|
+
{ provide: `${className}Signal`, useClass: makeSigForSrv(signal) }
|
|
136
126
|
] : [],
|
|
137
|
-
...
|
|
138
|
-
...Object.entries(useAsyncs).map(([key, useFactory]) => ({ provide: (0, import_common.capitalize)(key), useFactory })),
|
|
139
|
-
...providers
|
|
127
|
+
...(0, import_service.makeProvidersForSrv)(srvRef)
|
|
140
128
|
],
|
|
141
|
-
controllers: [(0, import_controller.controllerOf)(signal, filterSrvs(allSrvs))],
|
|
142
|
-
exports: [
|
|
129
|
+
controllers: signal ? [(0, import_controller.controllerOf)(signal, filterSrvs(allSrvs))] : [],
|
|
130
|
+
exports: service === srvRef ? [srvRef] : []
|
|
143
131
|
})
|
|
144
132
|
], ServiceModule);
|
|
145
133
|
return ServiceModule;
|
|
146
134
|
};
|
|
147
|
-
const scalarModuleOf = ({ signals, uses = {}, useAsyncs = {}, providers = [], enabled = true }, allSrvs) => {
|
|
148
|
-
if (!enabled)
|
|
149
|
-
return null;
|
|
150
|
-
let ScalarModule = class {
|
|
151
|
-
};
|
|
152
|
-
ScalarModule = __decorateClass([
|
|
153
|
-
(0, import_common2.Global)(),
|
|
154
|
-
(0, import_common2.Module)({
|
|
155
|
-
imports: [],
|
|
156
|
-
providers: [
|
|
157
|
-
...signals.map((signal) => (0, import_resolver.resolverOf)(signal, filterSrvs(allSrvs))),
|
|
158
|
-
...signals.filter(hasWebsocket).map((signal) => [
|
|
159
|
-
(0, import_websocket.websocketOf)(signal, filterSrvs(allSrvs)),
|
|
160
|
-
{ provide: "Websocket", useClass: (0, import_websocket.websocketServerOf)(signal) }
|
|
161
|
-
]).flat(),
|
|
162
|
-
...Object.entries(uses).map(([key, useValue]) => ({ provide: (0, import_common.capitalize)(key), useValue })),
|
|
163
|
-
...Object.entries(useAsyncs).map(([key, useFactory]) => ({ provide: (0, import_common.capitalize)(key), useFactory })),
|
|
164
|
-
...providers
|
|
165
|
-
],
|
|
166
|
-
controllers: signals.map((signal) => (0, import_controller.controllerOf)(signal, filterSrvs(allSrvs)))
|
|
167
|
-
})
|
|
168
|
-
], ScalarModule);
|
|
169
|
-
return ScalarModule;
|
|
170
|
-
};
|
|
171
135
|
const scalarModulesOf = ({ constants }, allSrvs) => {
|
|
172
136
|
const signals = constants.filter((modelRef) => {
|
|
173
137
|
const childRefs = (0, import_constant.getChildClassRefs)(modelRef);
|
|
@@ -194,32 +158,7 @@ const scalarModulesOf = ({ constants }, allSrvs) => {
|
|
|
194
158
|
], ScalarModule);
|
|
195
159
|
return ScalarModule;
|
|
196
160
|
};
|
|
197
|
-
const
|
|
198
|
-
service,
|
|
199
|
-
uses = {},
|
|
200
|
-
useAsyncs = {},
|
|
201
|
-
providers = []
|
|
202
|
-
}) => {
|
|
203
|
-
if (!(0, import_service.isServiceEnabled)(service))
|
|
204
|
-
return null;
|
|
205
|
-
let BatchModule = class {
|
|
206
|
-
};
|
|
207
|
-
BatchModule = __decorateClass([
|
|
208
|
-
(0, import_common2.Global)(),
|
|
209
|
-
(0, import_common2.Module)({
|
|
210
|
-
imports: [],
|
|
211
|
-
providers: [
|
|
212
|
-
(0, import_service.serviceOf)(service),
|
|
213
|
-
...Object.entries(uses).map(([key, useValue]) => ({ provide: (0, import_common.capitalize)(key), useValue })),
|
|
214
|
-
...Object.entries(useAsyncs).map(([key, useFactory]) => ({ provide: (0, import_common.capitalize)(key), useFactory })),
|
|
215
|
-
...providers
|
|
216
|
-
],
|
|
217
|
-
exports: [service]
|
|
218
|
-
})
|
|
219
|
-
], BatchModule);
|
|
220
|
-
return BatchModule;
|
|
221
|
-
};
|
|
222
|
-
const useGlobals = ({ uses, useAsyncs, injects }) => {
|
|
161
|
+
const useGlobals = ({ uses, useAsyncs, providers = [], injects }) => {
|
|
223
162
|
let GlobalsModule = class {
|
|
224
163
|
};
|
|
225
164
|
GlobalsModule = __decorateClass([
|
|
@@ -232,7 +171,8 @@ const useGlobals = ({ uses, useAsyncs, injects }) => {
|
|
|
232
171
|
useValue
|
|
233
172
|
})),
|
|
234
173
|
...Object.entries(useAsyncs ?? {}).map(([key, useFactory]) => ({ provide: (0, import_common.capitalize)(key), useFactory })),
|
|
235
|
-
...Object.entries(injects ?? {}).map(([key, inject]) => ({ provide: (0, import_common.capitalize)(key), useClass: inject }))
|
|
174
|
+
...Object.entries(injects ?? {}).map(([key, inject]) => ({ provide: (0, import_common.capitalize)(key), useClass: inject })),
|
|
175
|
+
...providers
|
|
236
176
|
],
|
|
237
177
|
exports: [
|
|
238
178
|
...Object.keys(uses ?? {}).map((key) => (0, import_common.capitalize)(key)),
|
|
@@ -243,11 +183,21 @@ const useGlobals = ({ uses, useAsyncs, injects }) => {
|
|
|
243
183
|
], GlobalsModule);
|
|
244
184
|
return GlobalsModule;
|
|
245
185
|
};
|
|
186
|
+
const makeSigForSrv = (sigRef) => {
|
|
187
|
+
let Sig = class {
|
|
188
|
+
};
|
|
189
|
+
Sig = __decorateClass([
|
|
190
|
+
(0, import_common2.Injectable)()
|
|
191
|
+
], Sig);
|
|
192
|
+
if (hasWebsocket(sigRef))
|
|
193
|
+
(0, import_websocket.applyWebsocketSignal)(Sig, sigRef);
|
|
194
|
+
if (hasProcessor(sigRef))
|
|
195
|
+
(0, import_processor.applyQueueSignal)(Sig, sigRef);
|
|
196
|
+
return Sig;
|
|
197
|
+
};
|
|
246
198
|
// Annotate the CommonJS export names for ESM import in node:
|
|
247
199
|
0 && (module.exports = {
|
|
248
|
-
batchModuleOf,
|
|
249
200
|
databaseModuleOf,
|
|
250
|
-
scalarModuleOf,
|
|
251
201
|
scalarModulesOf,
|
|
252
202
|
serviceModuleOf,
|
|
253
203
|
useGlobals
|
package/cjs/src/processor.js
CHANGED
|
@@ -17,8 +17,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var processor_exports = {};
|
|
19
19
|
__export(processor_exports, {
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
applyQueueSignal: () => applyQueueSignal,
|
|
21
|
+
processorOf: () => processorOf
|
|
22
22
|
});
|
|
23
23
|
module.exports = __toCommonJS(processor_exports);
|
|
24
24
|
var import_common = require("@akanjs/common");
|
|
@@ -55,10 +55,11 @@ const processorOf = (sigRef, allSrvs) => {
|
|
|
55
55
|
);
|
|
56
56
|
class QueueProcessor {
|
|
57
57
|
}
|
|
58
|
-
Object.keys(allSrvs).forEach((
|
|
59
|
-
if (!(0, import_service.isServiceEnabled)(allSrvs[
|
|
58
|
+
Object.keys(allSrvs).forEach((srvName) => {
|
|
59
|
+
if (!(0, import_service.isServiceEnabled)(allSrvs[srvName]))
|
|
60
60
|
return;
|
|
61
|
-
|
|
61
|
+
const srvRef = (0, import_service.getServiceRefs)(srvName)[0];
|
|
62
|
+
(0, import_common2.Inject)(srvRef)(QueueProcessor.prototype, (0, import_common.lowerlize)(srvName));
|
|
62
63
|
});
|
|
63
64
|
for (const gqlMeta of gqlMetas) {
|
|
64
65
|
const [argMetas, internalArgMetas] = (0, import_signal.getArgMetas)(sigRef, gqlMeta.key);
|
|
@@ -75,18 +76,21 @@ const processorOf = (sigRef, allSrvs) => {
|
|
|
75
76
|
(0, import_bull.Processor)(sigMeta.refName)(QueueProcessor);
|
|
76
77
|
return QueueProcessor;
|
|
77
78
|
};
|
|
78
|
-
const
|
|
79
|
+
const applyQueueSignal = (targetRef, sigRef) => {
|
|
79
80
|
const sigMeta = (0, import_signal.getSigMeta)(sigRef);
|
|
80
81
|
const gqlMetas = (0, import_signal.getGqlMetas)(sigRef).filter((gqlMeta) => gqlMeta.type === "Process");
|
|
82
|
+
(0, import_common2.Inject)((0, import_bull.getQueueToken)(sigMeta.refName))(targetRef.prototype, "queue");
|
|
81
83
|
for (const gqlMeta of gqlMetas) {
|
|
82
|
-
if (
|
|
84
|
+
if (targetRef.prototype[gqlMeta.key])
|
|
83
85
|
throw new Error(`Queue already has ${gqlMeta.key} in ${sigMeta.refName}`);
|
|
84
|
-
|
|
86
|
+
targetRef.prototype[gqlMeta.key] = function(...args) {
|
|
87
|
+
return this.queue.add(gqlMeta.key, args);
|
|
88
|
+
};
|
|
85
89
|
}
|
|
86
|
-
return
|
|
90
|
+
return targetRef;
|
|
87
91
|
};
|
|
88
92
|
// Annotate the CommonJS export names for ESM import in node:
|
|
89
93
|
0 && (module.exports = {
|
|
90
|
-
|
|
91
|
-
|
|
94
|
+
applyQueueSignal,
|
|
95
|
+
processorOf
|
|
92
96
|
});
|
package/cjs/src/resolver.js
CHANGED
|
@@ -71,10 +71,11 @@ const resolverOf = (sigRef, allSrvs) => {
|
|
|
71
71
|
const Rsv = (0, import_signal.copySignal)(sigRef);
|
|
72
72
|
const sigMeta = (0, import_signal.getSigMeta)(Rsv);
|
|
73
73
|
const gqlMetas = (0, import_signal.getGqlMetas)(Rsv);
|
|
74
|
-
Object.keys(allSrvs).forEach((
|
|
75
|
-
if (!(0, import_service.isServiceEnabled)(allSrvs[
|
|
74
|
+
Object.keys(allSrvs).forEach((srvName) => {
|
|
75
|
+
if (!(0, import_service.isServiceEnabled)(allSrvs[srvName]))
|
|
76
76
|
return;
|
|
77
|
-
|
|
77
|
+
const srvRef = (0, import_service.getServiceRefs)(srvName)[0];
|
|
78
|
+
(0, import_common2.Inject)(srvRef)(Rsv.prototype, (0, import_common.lowerlize)(srvName));
|
|
78
79
|
});
|
|
79
80
|
for (const gqlMeta of gqlMetas) {
|
|
80
81
|
if (gqlMeta.guards.some((guard) => guard === "None") || gqlMeta.signalOption.onlyFor === "restapi" || !["Query", "Mutation"].includes(gqlMeta.type))
|
package/cjs/src/schema.js
CHANGED
|
@@ -18,6 +18,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
18
18
|
var schema_exports = {};
|
|
19
19
|
__export(schema_exports, {
|
|
20
20
|
addSchema: () => addSchema,
|
|
21
|
+
hasSchema: () => hasSchema,
|
|
21
22
|
schemaOf: () => schemaOf
|
|
22
23
|
});
|
|
23
24
|
module.exports = __toCommonJS(schema_exports);
|
|
@@ -32,6 +33,24 @@ class ScalarSchemaStorage {
|
|
|
32
33
|
}
|
|
33
34
|
class SchemaStorage {
|
|
34
35
|
}
|
|
36
|
+
const getSchemaMetaByName = (refName) => {
|
|
37
|
+
const schemaMeta = Reflect.getMetadata(refName, SchemaStorage.prototype);
|
|
38
|
+
return schemaMeta;
|
|
39
|
+
};
|
|
40
|
+
const setSchemaMetaByName = (refName, schema) => {
|
|
41
|
+
Reflect.defineMetadata(refName, schema, SchemaStorage.prototype);
|
|
42
|
+
};
|
|
43
|
+
const hasSchema = (modelRef) => {
|
|
44
|
+
const classMeta = (0, import_constant.getClassMeta)(modelRef);
|
|
45
|
+
return !!getSchemaMetaByName(classMeta.refName);
|
|
46
|
+
};
|
|
47
|
+
const getScalarSchemaMetaByName = (refName) => {
|
|
48
|
+
const schemaMeta = Reflect.getMetadata(refName, ScalarSchemaStorage.prototype);
|
|
49
|
+
return schemaMeta;
|
|
50
|
+
};
|
|
51
|
+
const setScalarSchemaMetaByName = (refName, schema) => {
|
|
52
|
+
Reflect.defineMetadata(refName, schema, ScalarSchemaStorage.prototype);
|
|
53
|
+
};
|
|
35
54
|
const scalarMongoTypeMap = /* @__PURE__ */ new Map([
|
|
36
55
|
[import_base.ID, import_document.ObjectId],
|
|
37
56
|
[import_base.Int, Number],
|
|
@@ -71,12 +90,12 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
71
90
|
}
|
|
72
91
|
prop = { type: (0, import_base.arraiedModel)(prop, fieldMeta.optArrDepth), default: [], required: true };
|
|
73
92
|
if (fieldMeta.modelRef.prototype === Date.prototype) {
|
|
74
|
-
prop.get = (dates) =>
|
|
75
|
-
prop.set = (days) =>
|
|
93
|
+
prop.get = (dates) => (0, import_base.applyFnToArrayObjects)(dates, (date) => (0, import_base.dayjs)(date));
|
|
94
|
+
prop.set = (days) => (0, import_base.applyFnToArrayObjects)(days, (day) => day.toDate());
|
|
76
95
|
}
|
|
77
96
|
if (fieldMeta.isClass && !fieldMeta.isScalar || fieldMeta.modelRef.prototype === import_base.ID.prototype) {
|
|
78
|
-
prop.get = (ids) =>
|
|
79
|
-
prop.set = (ids) =>
|
|
97
|
+
prop.get = (ids) => (0, import_base.applyFnToArrayObjects)(ids, (id) => id.toString());
|
|
98
|
+
prop.set = (ids) => (0, import_base.applyFnToArrayObjects)(ids, (id) => new import_mongoose.Types.ObjectId(id));
|
|
80
99
|
}
|
|
81
100
|
} else {
|
|
82
101
|
prop.type = (0, import_base.arraiedModel)(type, fieldMeta.arrDepth);
|
|
@@ -118,12 +137,17 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
118
137
|
prop.set = (v) => v === null ? void 0 : v;
|
|
119
138
|
}
|
|
120
139
|
if (fieldMeta.modelRef.prototype === Date.prototype) {
|
|
121
|
-
prop.get = (date) => date ? (0, import_base.dayjs)(
|
|
122
|
-
prop.set = (day) => day ? (0, import_base.dayjs)(
|
|
140
|
+
prop.get = (date) => (0, import_base.applyFnToArrayObjects)(date, (date2) => date2 ? (0, import_base.dayjs)(date2) : void 0);
|
|
141
|
+
prop.set = (day) => (0, import_base.applyFnToArrayObjects)(day, (day2) => day2 ? (0, import_base.dayjs)(day2).toDate() : void 0);
|
|
123
142
|
}
|
|
124
143
|
if (fieldMeta.isClass && !fieldMeta.isScalar || fieldMeta.modelRef.prototype === import_base.ID.prototype) {
|
|
125
|
-
|
|
126
|
-
|
|
144
|
+
if (fieldMeta.arrDepth === 0) {
|
|
145
|
+
prop.get = (id) => id ? id.toString() : void 0;
|
|
146
|
+
prop.set = (id) => id ? new import_mongoose.Types.ObjectId(id) : void 0;
|
|
147
|
+
} else {
|
|
148
|
+
prop.get = (val) => (0, import_base.applyFnToArrayObjects)(val, (id) => id ? id.toString() : void 0);
|
|
149
|
+
prop.set = (val) => (0, import_base.applyFnToArrayObjects)(val, (id) => id ? new import_mongoose.Types.ObjectId(id) : void 0);
|
|
150
|
+
}
|
|
127
151
|
}
|
|
128
152
|
if (fieldMeta.isClass && fieldMeta.isScalar && fieldMeta.default === null && !fieldMeta.nullable) {
|
|
129
153
|
prop.default = (0, import_signal.makeDefault)(fieldMeta.modelRef);
|
|
@@ -138,7 +162,7 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
138
162
|
};
|
|
139
163
|
const createSchema = (modelRef) => {
|
|
140
164
|
const classMeta = (0, import_constant.getClassMeta)(modelRef);
|
|
141
|
-
const schemaMeta =
|
|
165
|
+
const schemaMeta = getScalarSchemaMetaByName(classMeta.refName);
|
|
142
166
|
if (schemaMeta)
|
|
143
167
|
return schemaMeta;
|
|
144
168
|
const fieldMetas = (0, import_constant.getFieldMetas)(modelRef);
|
|
@@ -147,12 +171,12 @@ const createSchema = (modelRef) => {
|
|
|
147
171
|
applyMongoProp(schemaProps, fieldMeta);
|
|
148
172
|
});
|
|
149
173
|
const schema = new import_mongoose.Schema(schemaProps);
|
|
150
|
-
|
|
174
|
+
setScalarSchemaMetaByName(classMeta.refName, schema);
|
|
151
175
|
return schema;
|
|
152
176
|
};
|
|
153
177
|
const schemaOf = (modelRef, docRef, middleware) => {
|
|
154
178
|
const classMeta = (0, import_constant.getClassMeta)(docRef);
|
|
155
|
-
const schemaMeta =
|
|
179
|
+
const schemaMeta = getSchemaMetaByName(classMeta.refName);
|
|
156
180
|
if (schemaMeta)
|
|
157
181
|
return schemaMeta;
|
|
158
182
|
const fieldMetas = (0, import_constant.getFieldMetas)(docRef);
|
|
@@ -192,7 +216,7 @@ const schemaOf = (modelRef, docRef, middleware) => {
|
|
|
192
216
|
const onSchema = Object.getOwnPropertyDescriptor(middleware.prototype, "onSchema")?.value;
|
|
193
217
|
onSchema?.(schema);
|
|
194
218
|
schema.index({ removedAt: -1 });
|
|
195
|
-
|
|
219
|
+
setSchemaMetaByName(classMeta.refName, schema);
|
|
196
220
|
return schema;
|
|
197
221
|
};
|
|
198
222
|
const addSchema = (modelRef, docRef, inputRef, middleware) => {
|
|
@@ -239,5 +263,6 @@ const addSchema = (modelRef, docRef, inputRef, middleware) => {
|
|
|
239
263
|
// Annotate the CommonJS export names for ESM import in node:
|
|
240
264
|
0 && (module.exports = {
|
|
241
265
|
addSchema,
|
|
266
|
+
hasSchema,
|
|
242
267
|
schemaOf
|
|
243
268
|
});
|
package/cjs/src/websocket.js
CHANGED
|
@@ -26,8 +26,8 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
26
26
|
};
|
|
27
27
|
var websocket_exports = {};
|
|
28
28
|
__export(websocket_exports, {
|
|
29
|
-
|
|
30
|
-
|
|
29
|
+
applyWebsocketSignal: () => applyWebsocketSignal,
|
|
30
|
+
websocketOf: () => websocketOf
|
|
31
31
|
});
|
|
32
32
|
module.exports = __toCommonJS(websocket_exports);
|
|
33
33
|
var import_common = require("@akanjs/common");
|
|
@@ -73,10 +73,11 @@ const websocketOf = (sigRef, allSrvs) => {
|
|
|
73
73
|
class WsGateway {
|
|
74
74
|
__sigRef__ = sigRef;
|
|
75
75
|
}
|
|
76
|
-
Object.keys(allSrvs).forEach((
|
|
77
|
-
if (!(0, import_service.isServiceEnabled)(allSrvs[
|
|
76
|
+
Object.keys(allSrvs).forEach((srvName) => {
|
|
77
|
+
if (!(0, import_service.isServiceEnabled)(allSrvs[srvName]))
|
|
78
78
|
return;
|
|
79
|
-
|
|
79
|
+
const srvRef = (0, import_service.getServiceRefs)(srvName)[0];
|
|
80
|
+
(0, import_common2.Inject)(srvRef)(WsGateway.prototype, (0, import_common.lowerlize)(srvName));
|
|
80
81
|
});
|
|
81
82
|
const messageGqlMetas = (0, import_signal.getGqlMetas)(sigRef).filter((gqlMeta) => gqlMeta.type === "Message");
|
|
82
83
|
for (const gqlMeta of messageGqlMetas) {
|
|
@@ -115,32 +116,24 @@ const websocketOf = (sigRef, allSrvs) => {
|
|
|
115
116
|
(0, import_websockets.WebSocketGateway)({ cors: { origin: "*" }, transports: ["websocket"] })(WsGateway);
|
|
116
117
|
return WsGateway;
|
|
117
118
|
};
|
|
118
|
-
const
|
|
119
|
+
const applyWebsocketSignal = (targetRef, sigRef) => {
|
|
119
120
|
const pubsubGqlMetas = (0, import_signal.getGqlMetas)(sigRef).filter((gqlMeta) => gqlMeta.type === "Pubsub");
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
};
|
|
123
|
-
__decorateClass([
|
|
124
|
-
(0, import_websockets.WebSocketServer)()
|
|
125
|
-
], Websocket.prototype, "server", 2);
|
|
126
|
-
Websocket = __decorateClass([
|
|
127
|
-
(0, import_common2.Injectable)(),
|
|
128
|
-
(0, import_websockets.WebSocketGateway)({ cors: { origin: "*" }, transports: ["websocket"] })
|
|
129
|
-
], Websocket);
|
|
121
|
+
(0, import_websockets.WebSocketGateway)({ cors: { origin: "*" }, transports: ["websocket"] })(targetRef);
|
|
122
|
+
(0, import_websockets.WebSocketServer)()(targetRef.prototype, "websocket");
|
|
130
123
|
for (const gqlMeta of pubsubGqlMetas) {
|
|
131
124
|
const [argMetas] = (0, import_signal.getArgMetas)(sigRef, gqlMeta.key);
|
|
132
|
-
|
|
125
|
+
targetRef.prototype[gqlMeta.key] = function(...args) {
|
|
133
126
|
const roomId = makeRoomId(
|
|
134
127
|
gqlMeta.key,
|
|
135
128
|
argMetas.map((argMeta) => args[argMeta.idx])
|
|
136
129
|
);
|
|
137
|
-
this.
|
|
130
|
+
this.websocket.to(roomId).emit(roomId, args.at(-1));
|
|
138
131
|
};
|
|
139
132
|
}
|
|
140
|
-
return
|
|
133
|
+
return targetRef;
|
|
141
134
|
};
|
|
142
135
|
// Annotate the CommonJS export names for ESM import in node:
|
|
143
136
|
0 && (module.exports = {
|
|
144
|
-
|
|
145
|
-
|
|
137
|
+
applyWebsocketSignal,
|
|
138
|
+
websocketOf
|
|
146
139
|
});
|
package/esm/src/base.module.js
CHANGED
package/esm/src/boot.js
CHANGED
|
@@ -89,9 +89,9 @@ const createNestApp = async ({ registerModules, serverMode = "federation", env,
|
|
|
89
89
|
Injectable()
|
|
90
90
|
], AuthMiddleWare);
|
|
91
91
|
const redisClient = await createClient({ url: redisUri }).connect();
|
|
92
|
-
let
|
|
92
|
+
let GlobalProvideModule = class {
|
|
93
93
|
};
|
|
94
|
-
|
|
94
|
+
GlobalProvideModule = __decorateClass([
|
|
95
95
|
Global(),
|
|
96
96
|
Module({
|
|
97
97
|
providers: [
|
|
@@ -99,11 +99,12 @@ const createNestApp = async ({ registerModules, serverMode = "federation", env,
|
|
|
99
99
|
{
|
|
100
100
|
provide: "MEILI_CLIENT",
|
|
101
101
|
useFactory: () => new MeiliSearch({ host: meiliUri, apiKey: generateMeiliKey(env) })
|
|
102
|
-
}
|
|
102
|
+
},
|
|
103
|
+
{ provide: "GLOBAL_ENV", useValue: env }
|
|
103
104
|
],
|
|
104
|
-
exports: ["REDIS_CLIENT", "MEILI_CLIENT"]
|
|
105
|
+
exports: ["REDIS_CLIENT", "MEILI_CLIENT", "GLOBAL_ENV"]
|
|
105
106
|
})
|
|
106
|
-
],
|
|
107
|
+
], GlobalProvideModule);
|
|
107
108
|
let AppModule = class {
|
|
108
109
|
configure(consumer) {
|
|
109
110
|
consumer.apply(AuthMiddleWare).forRoutes({ path: "*", method: RequestMethod.ALL });
|
|
@@ -130,7 +131,7 @@ const createNestApp = async ({ registerModules, serverMode = "federation", env,
|
|
|
130
131
|
MongooseModule.forRootAsync({
|
|
131
132
|
useFactory: () => ({ uri: mongoUri, autoIndex: baseEnv.environment !== "main" })
|
|
132
133
|
}),
|
|
133
|
-
|
|
134
|
+
GlobalProvideModule,
|
|
134
135
|
useGlobals({
|
|
135
136
|
injects: { SearchClient, DatabaseClient, CacheClient }
|
|
136
137
|
}),
|
package/esm/src/controller.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
Self,
|
|
14
14
|
UserIp
|
|
15
15
|
} from "@akanjs/nest";
|
|
16
|
-
import { isServiceEnabled } from "@akanjs/service";
|
|
16
|
+
import { getServiceRefs, isServiceEnabled } from "@akanjs/service";
|
|
17
17
|
import {
|
|
18
18
|
copySignal,
|
|
19
19
|
getArgMetas,
|
|
@@ -51,10 +51,11 @@ const controllerOf = (sigRef, allSrvs) => {
|
|
|
51
51
|
const gqlMetas = getGqlMetas(sigRef);
|
|
52
52
|
const prefix = getControllerPrefix(sigMeta);
|
|
53
53
|
const Ctrl = copySignal(sigRef);
|
|
54
|
-
Object.keys(allSrvs).forEach((
|
|
55
|
-
if (!isServiceEnabled(allSrvs[
|
|
54
|
+
Object.keys(allSrvs).forEach((srvName) => {
|
|
55
|
+
if (!isServiceEnabled(allSrvs[srvName]))
|
|
56
56
|
return;
|
|
57
|
-
|
|
57
|
+
const srvRef = getServiceRefs(srvName)[0];
|
|
58
|
+
Inject(srvRef)(Ctrl.prototype, lowerlize(srvName));
|
|
58
59
|
});
|
|
59
60
|
for (const gqlMeta of gqlMetas) {
|
|
60
61
|
if (gqlMeta.guards.some((guard) => guard === "None") || gqlMeta.signalOption.onlyFor === "graphql" || !["Query", "Mutation"].includes(gqlMeta.type))
|
package/esm/src/module.js
CHANGED
|
@@ -12,33 +12,25 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
12
12
|
import { capitalize, lowerlize } from "@akanjs/common";
|
|
13
13
|
import { getChildClassRefs, getClassMeta } from "@akanjs/constant";
|
|
14
14
|
import { databaseModelOf } from "@akanjs/document";
|
|
15
|
-
import { isServiceEnabled, serviceOf } from "@akanjs/service";
|
|
16
|
-
import { getGqlMetas,
|
|
17
|
-
import { BullModule
|
|
18
|
-
import { Global, Module } from "@nestjs/common";
|
|
15
|
+
import { getServiceMeta, isServiceEnabled, makeProvidersForSrv, serviceOf } from "@akanjs/service";
|
|
16
|
+
import { getGqlMetas, LogSignal, Signal } from "@akanjs/signal";
|
|
17
|
+
import { BullModule } from "@nestjs/bull";
|
|
18
|
+
import { Global, Injectable, Module } from "@nestjs/common";
|
|
19
19
|
import { getModelToken, MongooseModule } from "@nestjs/mongoose";
|
|
20
20
|
import { controllerOf } from "./controller";
|
|
21
|
-
import { processorOf } from "./processor";
|
|
21
|
+
import { applyQueueSignal, processorOf } from "./processor";
|
|
22
22
|
import { resolverOf } from "./resolver";
|
|
23
|
-
import { addSchema, schemaOf } from "./schema";
|
|
24
|
-
import {
|
|
23
|
+
import { addSchema, hasSchema, schemaOf } from "./schema";
|
|
24
|
+
import { applyWebsocketSignal, websocketOf } from "./websocket";
|
|
25
25
|
const hasWebsocket = (signal) => getGqlMetas(signal).some((gqlMeta) => ["Message", "Pubsub"].includes(gqlMeta.type));
|
|
26
26
|
const hasProcessor = (signal) => getGqlMetas(signal).some((gqlMeta) => gqlMeta.type === "Process");
|
|
27
27
|
const filterSrvs = (srvs) => Object.fromEntries(Object.entries(srvs).filter(([_, srv]) => !!srv));
|
|
28
|
-
const databaseModuleOf = ({
|
|
29
|
-
constant,
|
|
30
|
-
database,
|
|
31
|
-
signal,
|
|
32
|
-
service,
|
|
33
|
-
uses = {},
|
|
34
|
-
useAsyncs = {},
|
|
35
|
-
providers = [],
|
|
36
|
-
extended
|
|
37
|
-
}, allSrvs) => {
|
|
28
|
+
const databaseModuleOf = ({ constant, database, signal, service }, allSrvs) => {
|
|
38
29
|
if (!isServiceEnabled(service))
|
|
39
30
|
return null;
|
|
40
31
|
const [modelName, className] = [lowerlize(constant.refName), capitalize(constant.refName)];
|
|
41
32
|
const mongoToken = getModelToken(className);
|
|
33
|
+
const srvRef = serviceOf(service);
|
|
42
34
|
let DatabaseModule = class {
|
|
43
35
|
};
|
|
44
36
|
DatabaseModule = __decorateClass([
|
|
@@ -48,7 +40,7 @@ const databaseModuleOf = ({
|
|
|
48
40
|
MongooseModule.forFeature([
|
|
49
41
|
{
|
|
50
42
|
name: className,
|
|
51
|
-
schema:
|
|
43
|
+
schema: hasSchema(constant.Full) ? addSchema(database.Model, database.Doc, database.Input, database.Middleware) : schemaOf(database.Model, database.Doc, database.Middleware)
|
|
52
44
|
}
|
|
53
45
|
]),
|
|
54
46
|
...hasProcessor(signal) ? [
|
|
@@ -59,15 +51,11 @@ const databaseModuleOf = ({
|
|
|
59
51
|
] : []
|
|
60
52
|
],
|
|
61
53
|
providers: [
|
|
62
|
-
|
|
54
|
+
...service === srvRef ? [srvRef] : [],
|
|
63
55
|
resolverOf(signal, filterSrvs(allSrvs)),
|
|
64
|
-
...
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
] : [],
|
|
68
|
-
...hasWebsocket(signal) ? [websocketOf(signal, filterSrvs(allSrvs)), { provide: "Websocket", useClass: websocketServerOf(signal) }] : [],
|
|
69
|
-
...Object.entries(uses).map(([key, useValue]) => ({ provide: capitalize(key), useValue })),
|
|
70
|
-
...Object.entries(useAsyncs).map(([key, useFactory]) => ({ provide: capitalize(key), useFactory })),
|
|
56
|
+
...hasWebsocket(signal) ? [websocketOf(signal, filterSrvs(allSrvs))] : [],
|
|
57
|
+
...hasProcessor(signal) ? [processorOf(signal, filterSrvs(allSrvs))] : [],
|
|
58
|
+
{ provide: `${className}Signal`, useClass: makeSigForSrv(signal) },
|
|
71
59
|
{
|
|
72
60
|
provide: `${modelName}Model`,
|
|
73
61
|
useFactory: (model, redis, meili) => {
|
|
@@ -75,74 +63,52 @@ const databaseModuleOf = ({
|
|
|
75
63
|
},
|
|
76
64
|
inject: [mongoToken, "REDIS_CLIENT", "MEILI_CLIENT"]
|
|
77
65
|
},
|
|
78
|
-
...
|
|
66
|
+
...makeProvidersForSrv(srvRef)
|
|
79
67
|
],
|
|
80
68
|
controllers: [controllerOf(signal, filterSrvs(allSrvs))],
|
|
81
|
-
exports: [
|
|
69
|
+
exports: service === srvRef ? [srvRef] : []
|
|
82
70
|
})
|
|
83
71
|
], DatabaseModule);
|
|
84
72
|
return DatabaseModule;
|
|
85
73
|
};
|
|
86
|
-
const serviceModuleOf = ({ signal, service
|
|
74
|
+
const serviceModuleOf = ({ signal, service }, allSrvs) => {
|
|
87
75
|
if (!isServiceEnabled(service))
|
|
88
76
|
return null;
|
|
89
|
-
const
|
|
90
|
-
|
|
77
|
+
const serviceMeta = getServiceMeta(service);
|
|
78
|
+
if (!serviceMeta)
|
|
79
|
+
throw new Error(`Service ${service} is not a valid service`);
|
|
80
|
+
const refName = serviceMeta.name.replace("Service", "");
|
|
81
|
+
const [modelName, className] = [lowerlize(refName), capitalize(refName)];
|
|
82
|
+
const srvRef = serviceOf(service);
|
|
91
83
|
let ServiceModule = class {
|
|
92
84
|
};
|
|
93
85
|
ServiceModule = __decorateClass([
|
|
94
86
|
Global(),
|
|
95
87
|
Module({
|
|
96
|
-
imports: [
|
|
88
|
+
imports: signal ? [
|
|
97
89
|
...hasProcessor(signal) ? [
|
|
98
90
|
BullModule.registerQueue({
|
|
99
91
|
name: modelName,
|
|
100
92
|
defaultJobOptions: { removeOnComplete: true, removeOnFail: true }
|
|
101
93
|
})
|
|
102
94
|
] : []
|
|
103
|
-
],
|
|
95
|
+
] : [],
|
|
104
96
|
providers: [
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
processorOf(signal, filterSrvs(allSrvs)),
|
|
110
|
-
{ provide: `${className}
|
|
97
|
+
...service === srvRef ? [srvRef] : [],
|
|
98
|
+
...signal ? [
|
|
99
|
+
resolverOf(signal, filterSrvs(allSrvs)),
|
|
100
|
+
...hasWebsocket(signal) ? [websocketOf(signal, filterSrvs(allSrvs))] : [],
|
|
101
|
+
...hasProcessor(signal) ? [processorOf(signal, filterSrvs(allSrvs))] : [],
|
|
102
|
+
{ provide: `${className}Signal`, useClass: makeSigForSrv(signal) }
|
|
111
103
|
] : [],
|
|
112
|
-
...
|
|
113
|
-
...Object.entries(useAsyncs).map(([key, useFactory]) => ({ provide: capitalize(key), useFactory })),
|
|
114
|
-
...providers
|
|
104
|
+
...makeProvidersForSrv(srvRef)
|
|
115
105
|
],
|
|
116
|
-
controllers: [controllerOf(signal, filterSrvs(allSrvs))],
|
|
117
|
-
exports: [
|
|
106
|
+
controllers: signal ? [controllerOf(signal, filterSrvs(allSrvs))] : [],
|
|
107
|
+
exports: service === srvRef ? [srvRef] : []
|
|
118
108
|
})
|
|
119
109
|
], ServiceModule);
|
|
120
110
|
return ServiceModule;
|
|
121
111
|
};
|
|
122
|
-
const scalarModuleOf = ({ signals, uses = {}, useAsyncs = {}, providers = [], enabled = true }, allSrvs) => {
|
|
123
|
-
if (!enabled)
|
|
124
|
-
return null;
|
|
125
|
-
let ScalarModule = class {
|
|
126
|
-
};
|
|
127
|
-
ScalarModule = __decorateClass([
|
|
128
|
-
Global(),
|
|
129
|
-
Module({
|
|
130
|
-
imports: [],
|
|
131
|
-
providers: [
|
|
132
|
-
...signals.map((signal) => resolverOf(signal, filterSrvs(allSrvs))),
|
|
133
|
-
...signals.filter(hasWebsocket).map((signal) => [
|
|
134
|
-
websocketOf(signal, filterSrvs(allSrvs)),
|
|
135
|
-
{ provide: "Websocket", useClass: websocketServerOf(signal) }
|
|
136
|
-
]).flat(),
|
|
137
|
-
...Object.entries(uses).map(([key, useValue]) => ({ provide: capitalize(key), useValue })),
|
|
138
|
-
...Object.entries(useAsyncs).map(([key, useFactory]) => ({ provide: capitalize(key), useFactory })),
|
|
139
|
-
...providers
|
|
140
|
-
],
|
|
141
|
-
controllers: signals.map((signal) => controllerOf(signal, filterSrvs(allSrvs)))
|
|
142
|
-
})
|
|
143
|
-
], ScalarModule);
|
|
144
|
-
return ScalarModule;
|
|
145
|
-
};
|
|
146
112
|
const scalarModulesOf = ({ constants }, allSrvs) => {
|
|
147
113
|
const signals = constants.filter((modelRef) => {
|
|
148
114
|
const childRefs = getChildClassRefs(modelRef);
|
|
@@ -169,32 +135,7 @@ const scalarModulesOf = ({ constants }, allSrvs) => {
|
|
|
169
135
|
], ScalarModule);
|
|
170
136
|
return ScalarModule;
|
|
171
137
|
};
|
|
172
|
-
const
|
|
173
|
-
service,
|
|
174
|
-
uses = {},
|
|
175
|
-
useAsyncs = {},
|
|
176
|
-
providers = []
|
|
177
|
-
}) => {
|
|
178
|
-
if (!isServiceEnabled(service))
|
|
179
|
-
return null;
|
|
180
|
-
let BatchModule = class {
|
|
181
|
-
};
|
|
182
|
-
BatchModule = __decorateClass([
|
|
183
|
-
Global(),
|
|
184
|
-
Module({
|
|
185
|
-
imports: [],
|
|
186
|
-
providers: [
|
|
187
|
-
serviceOf(service),
|
|
188
|
-
...Object.entries(uses).map(([key, useValue]) => ({ provide: capitalize(key), useValue })),
|
|
189
|
-
...Object.entries(useAsyncs).map(([key, useFactory]) => ({ provide: capitalize(key), useFactory })),
|
|
190
|
-
...providers
|
|
191
|
-
],
|
|
192
|
-
exports: [service]
|
|
193
|
-
})
|
|
194
|
-
], BatchModule);
|
|
195
|
-
return BatchModule;
|
|
196
|
-
};
|
|
197
|
-
const useGlobals = ({ uses, useAsyncs, injects }) => {
|
|
138
|
+
const useGlobals = ({ uses, useAsyncs, providers = [], injects }) => {
|
|
198
139
|
let GlobalsModule = class {
|
|
199
140
|
};
|
|
200
141
|
GlobalsModule = __decorateClass([
|
|
@@ -207,7 +148,8 @@ const useGlobals = ({ uses, useAsyncs, injects }) => {
|
|
|
207
148
|
useValue
|
|
208
149
|
})),
|
|
209
150
|
...Object.entries(useAsyncs ?? {}).map(([key, useFactory]) => ({ provide: capitalize(key), useFactory })),
|
|
210
|
-
...Object.entries(injects ?? {}).map(([key, inject]) => ({ provide: capitalize(key), useClass: inject }))
|
|
151
|
+
...Object.entries(injects ?? {}).map(([key, inject]) => ({ provide: capitalize(key), useClass: inject })),
|
|
152
|
+
...providers
|
|
211
153
|
],
|
|
212
154
|
exports: [
|
|
213
155
|
...Object.keys(uses ?? {}).map((key) => capitalize(key)),
|
|
@@ -218,10 +160,20 @@ const useGlobals = ({ uses, useAsyncs, injects }) => {
|
|
|
218
160
|
], GlobalsModule);
|
|
219
161
|
return GlobalsModule;
|
|
220
162
|
};
|
|
163
|
+
const makeSigForSrv = (sigRef) => {
|
|
164
|
+
let Sig = class {
|
|
165
|
+
};
|
|
166
|
+
Sig = __decorateClass([
|
|
167
|
+
Injectable()
|
|
168
|
+
], Sig);
|
|
169
|
+
if (hasWebsocket(sigRef))
|
|
170
|
+
applyWebsocketSignal(Sig, sigRef);
|
|
171
|
+
if (hasProcessor(sigRef))
|
|
172
|
+
applyQueueSignal(Sig, sigRef);
|
|
173
|
+
return Sig;
|
|
174
|
+
};
|
|
221
175
|
export {
|
|
222
|
-
batchModuleOf,
|
|
223
176
|
databaseModuleOf,
|
|
224
|
-
scalarModuleOf,
|
|
225
177
|
scalarModulesOf,
|
|
226
178
|
serviceModuleOf,
|
|
227
179
|
useGlobals
|
package/esm/src/processor.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { lowerlize } from "@akanjs/common";
|
|
2
|
-
import { isServiceEnabled } from "@akanjs/service";
|
|
2
|
+
import { getServiceRefs, isServiceEnabled } from "@akanjs/service";
|
|
3
3
|
import {
|
|
4
4
|
deserializeArg,
|
|
5
5
|
getArgMetas,
|
|
6
6
|
getGqlMetas,
|
|
7
7
|
getSigMeta
|
|
8
8
|
} from "@akanjs/signal";
|
|
9
|
-
import { Process, Processor } from "@nestjs/bull";
|
|
9
|
+
import { getQueueToken, Process, Processor } from "@nestjs/bull";
|
|
10
10
|
import { Inject } from "@nestjs/common";
|
|
11
11
|
const convertProcessFunction = (gqlMeta, argMetas, internalArgMetas, fn) => {
|
|
12
12
|
return async function(job, done) {
|
|
@@ -37,10 +37,11 @@ const processorOf = (sigRef, allSrvs) => {
|
|
|
37
37
|
);
|
|
38
38
|
class QueueProcessor {
|
|
39
39
|
}
|
|
40
|
-
Object.keys(allSrvs).forEach((
|
|
41
|
-
if (!isServiceEnabled(allSrvs[
|
|
40
|
+
Object.keys(allSrvs).forEach((srvName) => {
|
|
41
|
+
if (!isServiceEnabled(allSrvs[srvName]))
|
|
42
42
|
return;
|
|
43
|
-
|
|
43
|
+
const srvRef = getServiceRefs(srvName)[0];
|
|
44
|
+
Inject(srvRef)(QueueProcessor.prototype, lowerlize(srvName));
|
|
44
45
|
});
|
|
45
46
|
for (const gqlMeta of gqlMetas) {
|
|
46
47
|
const [argMetas, internalArgMetas] = getArgMetas(sigRef, gqlMeta.key);
|
|
@@ -57,17 +58,20 @@ const processorOf = (sigRef, allSrvs) => {
|
|
|
57
58
|
Processor(sigMeta.refName)(QueueProcessor);
|
|
58
59
|
return QueueProcessor;
|
|
59
60
|
};
|
|
60
|
-
const
|
|
61
|
+
const applyQueueSignal = (targetRef, sigRef) => {
|
|
61
62
|
const sigMeta = getSigMeta(sigRef);
|
|
62
63
|
const gqlMetas = getGqlMetas(sigRef).filter((gqlMeta) => gqlMeta.type === "Process");
|
|
64
|
+
Inject(getQueueToken(sigMeta.refName))(targetRef.prototype, "queue");
|
|
63
65
|
for (const gqlMeta of gqlMetas) {
|
|
64
|
-
if (
|
|
66
|
+
if (targetRef.prototype[gqlMeta.key])
|
|
65
67
|
throw new Error(`Queue already has ${gqlMeta.key} in ${sigMeta.refName}`);
|
|
66
|
-
|
|
68
|
+
targetRef.prototype[gqlMeta.key] = function(...args) {
|
|
69
|
+
return this.queue.add(gqlMeta.key, args);
|
|
70
|
+
};
|
|
67
71
|
}
|
|
68
|
-
return
|
|
72
|
+
return targetRef;
|
|
69
73
|
};
|
|
70
74
|
export {
|
|
71
|
-
|
|
72
|
-
|
|
75
|
+
applyQueueSignal,
|
|
76
|
+
processorOf
|
|
73
77
|
};
|
package/esm/src/resolver.js
CHANGED
|
@@ -2,7 +2,7 @@ import { arraiedModel, Float, getNonArrayModel, ID, Int, JSON, Upload } from "@a
|
|
|
2
2
|
import { capitalize, lowerlize } from "@akanjs/common";
|
|
3
3
|
import { getClassMeta, getFieldMetas } from "@akanjs/constant";
|
|
4
4
|
import { Access, Account, guards, Me, Req, Res, Self, UserIp } from "@akanjs/nest";
|
|
5
|
-
import { isServiceEnabled } from "@akanjs/service";
|
|
5
|
+
import { getServiceRefs, isServiceEnabled } from "@akanjs/service";
|
|
6
6
|
import {
|
|
7
7
|
copySignal,
|
|
8
8
|
getArgMetas,
|
|
@@ -45,10 +45,11 @@ const resolverOf = (sigRef, allSrvs) => {
|
|
|
45
45
|
const Rsv = copySignal(sigRef);
|
|
46
46
|
const sigMeta = getSigMeta(Rsv);
|
|
47
47
|
const gqlMetas = getGqlMetas(Rsv);
|
|
48
|
-
Object.keys(allSrvs).forEach((
|
|
49
|
-
if (!isServiceEnabled(allSrvs[
|
|
48
|
+
Object.keys(allSrvs).forEach((srvName) => {
|
|
49
|
+
if (!isServiceEnabled(allSrvs[srvName]))
|
|
50
50
|
return;
|
|
51
|
-
|
|
51
|
+
const srvRef = getServiceRefs(srvName)[0];
|
|
52
|
+
Inject(srvRef)(Rsv.prototype, lowerlize(srvName));
|
|
52
53
|
});
|
|
53
54
|
for (const gqlMeta of gqlMetas) {
|
|
54
55
|
if (gqlMeta.guards.some((guard) => guard === "None") || gqlMeta.signalOption.onlyFor === "restapi" || !["Query", "Mutation"].includes(gqlMeta.type))
|
package/esm/src/schema.js
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
applyFnToArrayObjects,
|
|
3
|
+
arraiedModel,
|
|
4
|
+
dayjs,
|
|
5
|
+
Enum,
|
|
6
|
+
Float,
|
|
7
|
+
ID,
|
|
8
|
+
Int,
|
|
9
|
+
JSON
|
|
10
|
+
} from "@akanjs/base";
|
|
2
11
|
import { isDayjs } from "@akanjs/common";
|
|
3
12
|
import { getClassMeta, getFieldMetas, getFullModelRef, getInputModelRef } from "@akanjs/constant";
|
|
4
13
|
import { getDefaultSchemaOptions, ObjectId } from "@akanjs/document";
|
|
@@ -9,6 +18,24 @@ class ScalarSchemaStorage {
|
|
|
9
18
|
}
|
|
10
19
|
class SchemaStorage {
|
|
11
20
|
}
|
|
21
|
+
const getSchemaMetaByName = (refName) => {
|
|
22
|
+
const schemaMeta = Reflect.getMetadata(refName, SchemaStorage.prototype);
|
|
23
|
+
return schemaMeta;
|
|
24
|
+
};
|
|
25
|
+
const setSchemaMetaByName = (refName, schema) => {
|
|
26
|
+
Reflect.defineMetadata(refName, schema, SchemaStorage.prototype);
|
|
27
|
+
};
|
|
28
|
+
const hasSchema = (modelRef) => {
|
|
29
|
+
const classMeta = getClassMeta(modelRef);
|
|
30
|
+
return !!getSchemaMetaByName(classMeta.refName);
|
|
31
|
+
};
|
|
32
|
+
const getScalarSchemaMetaByName = (refName) => {
|
|
33
|
+
const schemaMeta = Reflect.getMetadata(refName, ScalarSchemaStorage.prototype);
|
|
34
|
+
return schemaMeta;
|
|
35
|
+
};
|
|
36
|
+
const setScalarSchemaMetaByName = (refName, schema) => {
|
|
37
|
+
Reflect.defineMetadata(refName, schema, ScalarSchemaStorage.prototype);
|
|
38
|
+
};
|
|
12
39
|
const scalarMongoTypeMap = /* @__PURE__ */ new Map([
|
|
13
40
|
[ID, ObjectId],
|
|
14
41
|
[Int, Number],
|
|
@@ -48,12 +75,12 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
48
75
|
}
|
|
49
76
|
prop = { type: arraiedModel(prop, fieldMeta.optArrDepth), default: [], required: true };
|
|
50
77
|
if (fieldMeta.modelRef.prototype === Date.prototype) {
|
|
51
|
-
prop.get = (dates) => dates
|
|
52
|
-
prop.set = (days) => days
|
|
78
|
+
prop.get = (dates) => applyFnToArrayObjects(dates, (date) => dayjs(date));
|
|
79
|
+
prop.set = (days) => applyFnToArrayObjects(days, (day) => day.toDate());
|
|
53
80
|
}
|
|
54
81
|
if (fieldMeta.isClass && !fieldMeta.isScalar || fieldMeta.modelRef.prototype === ID.prototype) {
|
|
55
|
-
prop.get = (ids) => ids
|
|
56
|
-
prop.set = (ids) => ids
|
|
82
|
+
prop.get = (ids) => applyFnToArrayObjects(ids, (id) => id.toString());
|
|
83
|
+
prop.set = (ids) => applyFnToArrayObjects(ids, (id) => new Types.ObjectId(id));
|
|
57
84
|
}
|
|
58
85
|
} else {
|
|
59
86
|
prop.type = arraiedModel(type, fieldMeta.arrDepth);
|
|
@@ -95,12 +122,17 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
95
122
|
prop.set = (v) => v === null ? void 0 : v;
|
|
96
123
|
}
|
|
97
124
|
if (fieldMeta.modelRef.prototype === Date.prototype) {
|
|
98
|
-
prop.get = (date) => date ? dayjs(
|
|
99
|
-
prop.set = (day) => day ? dayjs(
|
|
125
|
+
prop.get = (date) => applyFnToArrayObjects(date, (date2) => date2 ? dayjs(date2) : void 0);
|
|
126
|
+
prop.set = (day) => applyFnToArrayObjects(day, (day2) => day2 ? dayjs(day2).toDate() : void 0);
|
|
100
127
|
}
|
|
101
128
|
if (fieldMeta.isClass && !fieldMeta.isScalar || fieldMeta.modelRef.prototype === ID.prototype) {
|
|
102
|
-
|
|
103
|
-
|
|
129
|
+
if (fieldMeta.arrDepth === 0) {
|
|
130
|
+
prop.get = (id) => id ? id.toString() : void 0;
|
|
131
|
+
prop.set = (id) => id ? new Types.ObjectId(id) : void 0;
|
|
132
|
+
} else {
|
|
133
|
+
prop.get = (val) => applyFnToArrayObjects(val, (id) => id ? id.toString() : void 0);
|
|
134
|
+
prop.set = (val) => applyFnToArrayObjects(val, (id) => id ? new Types.ObjectId(id) : void 0);
|
|
135
|
+
}
|
|
104
136
|
}
|
|
105
137
|
if (fieldMeta.isClass && fieldMeta.isScalar && fieldMeta.default === null && !fieldMeta.nullable) {
|
|
106
138
|
prop.default = makeDefault(fieldMeta.modelRef);
|
|
@@ -115,7 +147,7 @@ const applyMongoProp = (schemaProps, fieldMeta) => {
|
|
|
115
147
|
};
|
|
116
148
|
const createSchema = (modelRef) => {
|
|
117
149
|
const classMeta = getClassMeta(modelRef);
|
|
118
|
-
const schemaMeta =
|
|
150
|
+
const schemaMeta = getScalarSchemaMetaByName(classMeta.refName);
|
|
119
151
|
if (schemaMeta)
|
|
120
152
|
return schemaMeta;
|
|
121
153
|
const fieldMetas = getFieldMetas(modelRef);
|
|
@@ -124,12 +156,12 @@ const createSchema = (modelRef) => {
|
|
|
124
156
|
applyMongoProp(schemaProps, fieldMeta);
|
|
125
157
|
});
|
|
126
158
|
const schema = new Schema(schemaProps);
|
|
127
|
-
|
|
159
|
+
setScalarSchemaMetaByName(classMeta.refName, schema);
|
|
128
160
|
return schema;
|
|
129
161
|
};
|
|
130
162
|
const schemaOf = (modelRef, docRef, middleware) => {
|
|
131
163
|
const classMeta = getClassMeta(docRef);
|
|
132
|
-
const schemaMeta =
|
|
164
|
+
const schemaMeta = getSchemaMetaByName(classMeta.refName);
|
|
133
165
|
if (schemaMeta)
|
|
134
166
|
return schemaMeta;
|
|
135
167
|
const fieldMetas = getFieldMetas(docRef);
|
|
@@ -169,7 +201,7 @@ const schemaOf = (modelRef, docRef, middleware) => {
|
|
|
169
201
|
const onSchema = Object.getOwnPropertyDescriptor(middleware.prototype, "onSchema")?.value;
|
|
170
202
|
onSchema?.(schema);
|
|
171
203
|
schema.index({ removedAt: -1 });
|
|
172
|
-
|
|
204
|
+
setSchemaMetaByName(classMeta.refName, schema);
|
|
173
205
|
return schema;
|
|
174
206
|
};
|
|
175
207
|
const addSchema = (modelRef, docRef, inputRef, middleware) => {
|
|
@@ -215,5 +247,6 @@ const addSchema = (modelRef, docRef, inputRef, middleware) => {
|
|
|
215
247
|
};
|
|
216
248
|
export {
|
|
217
249
|
addSchema,
|
|
250
|
+
hasSchema,
|
|
218
251
|
schemaOf
|
|
219
252
|
};
|
package/esm/src/websocket.js
CHANGED
|
@@ -11,7 +11,7 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
11
11
|
};
|
|
12
12
|
import { lowerlize } from "@akanjs/common";
|
|
13
13
|
import { Access, Account, getBodyPipes, Me, Self, UserIp, Ws } from "@akanjs/nest";
|
|
14
|
-
import { isServiceEnabled } from "@akanjs/service";
|
|
14
|
+
import { getServiceRefs, isServiceEnabled } from "@akanjs/service";
|
|
15
15
|
import { getArgMetas, getGqlMetas, getSigMeta } from "@akanjs/signal";
|
|
16
16
|
import { Inject, Injectable, UseInterceptors } from "@nestjs/common";
|
|
17
17
|
import { MessageBody, SubscribeMessage, WebSocketGateway, WebSocketServer } from "@nestjs/websockets";
|
|
@@ -52,10 +52,11 @@ const websocketOf = (sigRef, allSrvs) => {
|
|
|
52
52
|
class WsGateway {
|
|
53
53
|
__sigRef__ = sigRef;
|
|
54
54
|
}
|
|
55
|
-
Object.keys(allSrvs).forEach((
|
|
56
|
-
if (!isServiceEnabled(allSrvs[
|
|
55
|
+
Object.keys(allSrvs).forEach((srvName) => {
|
|
56
|
+
if (!isServiceEnabled(allSrvs[srvName]))
|
|
57
57
|
return;
|
|
58
|
-
|
|
58
|
+
const srvRef = getServiceRefs(srvName)[0];
|
|
59
|
+
Inject(srvRef)(WsGateway.prototype, lowerlize(srvName));
|
|
59
60
|
});
|
|
60
61
|
const messageGqlMetas = getGqlMetas(sigRef).filter((gqlMeta) => gqlMeta.type === "Message");
|
|
61
62
|
for (const gqlMeta of messageGqlMetas) {
|
|
@@ -94,31 +95,23 @@ const websocketOf = (sigRef, allSrvs) => {
|
|
|
94
95
|
WebSocketGateway({ cors: { origin: "*" }, transports: ["websocket"] })(WsGateway);
|
|
95
96
|
return WsGateway;
|
|
96
97
|
};
|
|
97
|
-
const
|
|
98
|
+
const applyWebsocketSignal = (targetRef, sigRef) => {
|
|
98
99
|
const pubsubGqlMetas = getGqlMetas(sigRef).filter((gqlMeta) => gqlMeta.type === "Pubsub");
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
};
|
|
102
|
-
__decorateClass([
|
|
103
|
-
WebSocketServer()
|
|
104
|
-
], Websocket.prototype, "server", 2);
|
|
105
|
-
Websocket = __decorateClass([
|
|
106
|
-
Injectable(),
|
|
107
|
-
WebSocketGateway({ cors: { origin: "*" }, transports: ["websocket"] })
|
|
108
|
-
], Websocket);
|
|
100
|
+
WebSocketGateway({ cors: { origin: "*" }, transports: ["websocket"] })(targetRef);
|
|
101
|
+
WebSocketServer()(targetRef.prototype, "websocket");
|
|
109
102
|
for (const gqlMeta of pubsubGqlMetas) {
|
|
110
103
|
const [argMetas] = getArgMetas(sigRef, gqlMeta.key);
|
|
111
|
-
|
|
104
|
+
targetRef.prototype[gqlMeta.key] = function(...args) {
|
|
112
105
|
const roomId = makeRoomId(
|
|
113
106
|
gqlMeta.key,
|
|
114
107
|
argMetas.map((argMeta) => args[argMeta.idx])
|
|
115
108
|
);
|
|
116
|
-
this.
|
|
109
|
+
this.websocket.to(roomId).emit(roomId, args.at(-1));
|
|
117
110
|
};
|
|
118
111
|
}
|
|
119
|
-
return
|
|
112
|
+
return targetRef;
|
|
120
113
|
};
|
|
121
114
|
export {
|
|
122
|
-
|
|
123
|
-
|
|
115
|
+
applyWebsocketSignal,
|
|
116
|
+
websocketOf
|
|
124
117
|
};
|
package/package.json
CHANGED
package/src/module.d.ts
CHANGED
|
@@ -7,44 +7,15 @@ interface DatabaseModuleCreateOptions {
|
|
|
7
7
|
database: Database<string, any, any, any, any, any, any, any, any>;
|
|
8
8
|
signal: Type;
|
|
9
9
|
service: Type;
|
|
10
|
-
uses?: {
|
|
11
|
-
[key: string]: any;
|
|
12
|
-
};
|
|
13
|
-
useAsyncs?: {
|
|
14
|
-
[key: string]: () => Promise<any>;
|
|
15
|
-
};
|
|
16
|
-
providers?: Type[];
|
|
17
|
-
extended?: boolean;
|
|
18
10
|
}
|
|
19
|
-
export declare const databaseModuleOf: ({ constant, database, signal, service
|
|
11
|
+
export declare const databaseModuleOf: ({ constant, database, signal, service }: DatabaseModuleCreateOptions, allSrvs: {
|
|
20
12
|
[key: string]: Type | undefined;
|
|
21
13
|
}) => DynamicModule | null;
|
|
22
14
|
interface ServiceModuleCreateOptions {
|
|
23
|
-
signal
|
|
15
|
+
signal?: Type;
|
|
24
16
|
service: Type;
|
|
25
|
-
uses?: {
|
|
26
|
-
[key: string]: any;
|
|
27
|
-
};
|
|
28
|
-
useAsyncs?: {
|
|
29
|
-
[key: string]: () => Promise<any>;
|
|
30
|
-
};
|
|
31
|
-
providers?: Type[];
|
|
32
17
|
}
|
|
33
|
-
export declare const serviceModuleOf: ({ signal, service
|
|
34
|
-
[key: string]: Type | undefined;
|
|
35
|
-
}) => DynamicModule | null;
|
|
36
|
-
interface ScalarModuleCreateOptions {
|
|
37
|
-
signals: Type[];
|
|
38
|
-
uses?: {
|
|
39
|
-
[key: string]: any;
|
|
40
|
-
};
|
|
41
|
-
useAsyncs?: {
|
|
42
|
-
[key: string]: () => Promise<any>;
|
|
43
|
-
};
|
|
44
|
-
providers?: Type[];
|
|
45
|
-
enabled?: boolean;
|
|
46
|
-
}
|
|
47
|
-
export declare const scalarModuleOf: ({ signals, uses, useAsyncs, providers, enabled }: ScalarModuleCreateOptions, allSrvs: {
|
|
18
|
+
export declare const serviceModuleOf: ({ signal, service }: ServiceModuleCreateOptions, allSrvs: {
|
|
48
19
|
[key: string]: Type | undefined;
|
|
49
20
|
}) => DynamicModule | null;
|
|
50
21
|
interface ScalarModulesCreateOptions {
|
|
@@ -53,17 +24,6 @@ interface ScalarModulesCreateOptions {
|
|
|
53
24
|
export declare const scalarModulesOf: ({ constants }: ScalarModulesCreateOptions, allSrvs: {
|
|
54
25
|
[key: string]: Type | undefined;
|
|
55
26
|
}) => DynamicModule | null;
|
|
56
|
-
interface BatchModuleCreateOptions {
|
|
57
|
-
service: Type;
|
|
58
|
-
uses?: {
|
|
59
|
-
[key: string]: any;
|
|
60
|
-
};
|
|
61
|
-
useAsyncs?: {
|
|
62
|
-
[key: string]: () => Promise<any>;
|
|
63
|
-
};
|
|
64
|
-
providers?: Type[];
|
|
65
|
-
}
|
|
66
|
-
export declare const batchModuleOf: ({ service, uses, useAsyncs, providers, }: BatchModuleCreateOptions) => DynamicModule | null;
|
|
67
27
|
interface UseGlobalsCreateOptions {
|
|
68
28
|
uses?: {
|
|
69
29
|
[key: string]: any;
|
|
@@ -71,9 +31,10 @@ interface UseGlobalsCreateOptions {
|
|
|
71
31
|
useAsyncs?: {
|
|
72
32
|
[key: string]: () => Promise<any>;
|
|
73
33
|
};
|
|
34
|
+
providers?: Type[];
|
|
74
35
|
injects?: {
|
|
75
36
|
[key: string]: Type;
|
|
76
37
|
};
|
|
77
38
|
}
|
|
78
|
-
export declare const useGlobals: ({ uses, useAsyncs, injects }: UseGlobalsCreateOptions) => DynamicModule;
|
|
39
|
+
export declare const useGlobals: ({ uses, useAsyncs, providers, injects }: UseGlobalsCreateOptions) => DynamicModule;
|
|
79
40
|
export {};
|
package/src/processor.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { Type } from "@akanjs/base";
|
|
2
|
-
import type { Queue } from "bull";
|
|
3
2
|
export declare const processorOf: (sigRef: Type, allSrvs: {
|
|
4
3
|
[key: string]: Type;
|
|
5
4
|
}) => {
|
|
6
5
|
new (): {};
|
|
7
6
|
};
|
|
8
|
-
export declare const
|
|
7
|
+
export declare const applyQueueSignal: (targetRef: Type, sigRef: Type) => Type;
|
package/src/schema.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Type } from "@akanjs/base";
|
|
2
2
|
import { BaseMiddleware } from "@akanjs/document";
|
|
3
3
|
import { Schema } from "mongoose";
|
|
4
|
+
export declare const hasSchema: (modelRef: Type) => boolean;
|
|
4
5
|
export declare const schemaOf: <Mdl, Doc, Middleware extends BaseMiddleware>(modelRef: Type<Mdl>, docRef: Type<Doc>, middleware: Type<Middleware>) => Schema<null, Mdl, Doc, undefined, null, Mdl>;
|
|
5
6
|
export declare const addSchema: <Mdl, Doc, Input, Middleware extends BaseMiddleware>(modelRef: Type<Mdl>, docRef: Type<Doc>, inputRef: Type<Input>, middleware: Type<Middleware>) => Schema<null, Mdl, Doc, undefined, null, Mdl>;
|
package/src/websocket.d.ts
CHANGED
|
@@ -10,8 +10,6 @@ export declare const websocketOf: (sigRef: Type, allSrvs: {
|
|
|
10
10
|
__sigRef__: Type;
|
|
11
11
|
};
|
|
12
12
|
};
|
|
13
|
-
export declare const
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
};
|
|
17
|
-
};
|
|
13
|
+
export declare const applyWebsocketSignal: (targetRef: Type, sigRef: Type) => Type<{
|
|
14
|
+
websocket: Server;
|
|
15
|
+
}>;
|