@akanjs/signal 0.9.56 → 0.9.57
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/apiInfo.js +19 -37
- package/cjs/src/base.signal.js +3 -0
- package/cjs/src/doc.js +7 -9
- package/cjs/src/internalApiInfo.js +9 -4
- package/cjs/src/signalDecorators.js +50 -299
- package/cjs/src/signalInfo.js +9 -1
- package/cjs/src/sliceInfo.js +15 -14
- package/esm/src/apiInfo.js +24 -38
- package/esm/src/base.signal.js +4 -1
- package/esm/src/doc.js +8 -10
- package/esm/src/internalApiInfo.js +10 -5
- package/esm/src/signalDecorators.js +51 -300
- package/esm/src/signalInfo.js +9 -1
- package/esm/src/sliceInfo.js +21 -15
- package/package.json +1 -1
- package/src/apiInfo.d.ts +24 -24
- package/src/base.signal.d.ts +22 -98
- package/src/doc.d.ts +5 -5
- package/src/fetch.d.ts +8 -8
- package/src/gql.d.ts +17 -32
- package/src/internalApiInfo.d.ts +26 -24
- package/src/signalDecorators.d.ts +35 -204
- package/src/signalInfo.d.ts +15 -7
- package/src/sliceInfo.d.ts +25 -33
|
@@ -6,13 +6,12 @@ import {
|
|
|
6
6
|
JSON,
|
|
7
7
|
scalarArgMap
|
|
8
8
|
} from "@akanjs/base";
|
|
9
|
-
import { applyMixins, capitalize
|
|
9
|
+
import { applyMixins, capitalize } from "@akanjs/common";
|
|
10
10
|
import { constantInfo } from "@akanjs/constant";
|
|
11
11
|
import { sliceInit } from ".";
|
|
12
12
|
import { makeApiBuilder } from "./apiInfo";
|
|
13
13
|
import { makeInternalApiBuilder } from "./internalApiInfo";
|
|
14
14
|
import { signalInfo } from "./signalInfo";
|
|
15
|
-
const ssoTypes = ["github", "google", "facebook", "apple", "naver", "kakao"];
|
|
16
15
|
class SignalStorage {
|
|
17
16
|
}
|
|
18
17
|
const getAllSignalRefs = () => {
|
|
@@ -33,21 +32,7 @@ const done = (data) => data;
|
|
|
33
32
|
const subscribe = () => void 0;
|
|
34
33
|
const signalTypes = ["graphql", "restapi"];
|
|
35
34
|
const endpointTypes = ["Query", "Mutation", "Message", "Pubsub", "Process", "Schedule", "ResolveField"];
|
|
36
|
-
const guardTypes = ["Public", "None", "User", "Admin", "SuperAdmin", "Every", "Owner"];
|
|
37
|
-
const roleTypes = ["Public", "User", "Admin", "SuperAdmin"];
|
|
38
35
|
const argTypes = ["Body", "Param", "Query", "Upload", "Msg", "Room"];
|
|
39
|
-
const internalArgTypes = [
|
|
40
|
-
"Account",
|
|
41
|
-
"Me",
|
|
42
|
-
"Self",
|
|
43
|
-
"UserIp",
|
|
44
|
-
"Access",
|
|
45
|
-
"Parent",
|
|
46
|
-
"Req",
|
|
47
|
-
"Res",
|
|
48
|
-
"Ws",
|
|
49
|
-
"Job"
|
|
50
|
-
];
|
|
51
36
|
const getDefaultArg = (argRef) => {
|
|
52
37
|
const [modelRef, arrDepth] = getNonArrayModel(argRef);
|
|
53
38
|
if (arrDepth)
|
|
@@ -58,232 +43,10 @@ const getDefaultArg = (argRef) => {
|
|
|
58
43
|
else
|
|
59
44
|
return {};
|
|
60
45
|
};
|
|
61
|
-
const createArgMetaDecorator = (type) => {
|
|
62
|
-
return function(option = {}) {
|
|
63
|
-
return function(prototype, key, idx) {
|
|
64
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
65
|
-
argMetas[idx] = { key, idx, type, option };
|
|
66
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
};
|
|
70
|
-
const Account = createArgMetaDecorator("Account");
|
|
71
46
|
const defaultAccount = {
|
|
72
|
-
__InternalArg__: "Account",
|
|
73
47
|
appName: baseEnv.appName,
|
|
74
48
|
environment: baseEnv.environment
|
|
75
49
|
};
|
|
76
|
-
const Self = createArgMetaDecorator("Self");
|
|
77
|
-
const Me = createArgMetaDecorator("Me");
|
|
78
|
-
const UserIp = createArgMetaDecorator("UserIp");
|
|
79
|
-
const Access = createArgMetaDecorator("Access");
|
|
80
|
-
const Req = createArgMetaDecorator("Req");
|
|
81
|
-
const Res = createArgMetaDecorator("Res");
|
|
82
|
-
const Ws = createArgMetaDecorator("Ws");
|
|
83
|
-
const Job = createArgMetaDecorator("Job");
|
|
84
|
-
const getQuery = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
85
|
-
return (prototype, key, descriptor) => {
|
|
86
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
87
|
-
metadataMap.set(key, {
|
|
88
|
-
returns,
|
|
89
|
-
signalOption,
|
|
90
|
-
key,
|
|
91
|
-
descriptor,
|
|
92
|
-
guards: [allow, ...guards],
|
|
93
|
-
type: "Query"
|
|
94
|
-
});
|
|
95
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
96
|
-
};
|
|
97
|
-
};
|
|
98
|
-
const getMutation = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
99
|
-
return (prototype, key, descriptor) => {
|
|
100
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
101
|
-
metadataMap.set(key, {
|
|
102
|
-
returns,
|
|
103
|
-
signalOption,
|
|
104
|
-
key,
|
|
105
|
-
descriptor,
|
|
106
|
-
guards: [allow, ...guards],
|
|
107
|
-
type: "Mutation"
|
|
108
|
-
});
|
|
109
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
110
|
-
};
|
|
111
|
-
};
|
|
112
|
-
const getMessage = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
113
|
-
return (prototype, key, descriptor) => {
|
|
114
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
115
|
-
metadataMap.set(key, {
|
|
116
|
-
returns,
|
|
117
|
-
signalOption,
|
|
118
|
-
key,
|
|
119
|
-
descriptor,
|
|
120
|
-
guards: [allow, ...guards],
|
|
121
|
-
type: "Message"
|
|
122
|
-
});
|
|
123
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
124
|
-
};
|
|
125
|
-
};
|
|
126
|
-
const getPubsub = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
127
|
-
return (prototype, key, descriptor) => {
|
|
128
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
129
|
-
metadataMap.set(key, {
|
|
130
|
-
returns,
|
|
131
|
-
signalOption,
|
|
132
|
-
key,
|
|
133
|
-
descriptor,
|
|
134
|
-
guards: [allow, ...guards],
|
|
135
|
-
type: "Pubsub"
|
|
136
|
-
});
|
|
137
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
138
|
-
};
|
|
139
|
-
};
|
|
140
|
-
const getProcess = (serverMode) => function(returns, signalOption = {}) {
|
|
141
|
-
return (prototype, key, descriptor) => {
|
|
142
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
143
|
-
metadataMap.set(key, {
|
|
144
|
-
returns,
|
|
145
|
-
signalOption: { ...signalOption, serverMode: lowerlize(serverMode) },
|
|
146
|
-
key,
|
|
147
|
-
descriptor,
|
|
148
|
-
guards: ["None"],
|
|
149
|
-
type: "Process"
|
|
150
|
-
});
|
|
151
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
152
|
-
};
|
|
153
|
-
};
|
|
154
|
-
const getScheduleInit = (scheduleType) => function(signalOption = {}) {
|
|
155
|
-
return (prototype, key, descriptor) => {
|
|
156
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
157
|
-
metadataMap.set(key, {
|
|
158
|
-
returns: () => JSON,
|
|
159
|
-
signalOption: { enabled: true, ...signalOption, scheduleType: lowerlize(scheduleType) },
|
|
160
|
-
key,
|
|
161
|
-
descriptor,
|
|
162
|
-
guards: ["None"],
|
|
163
|
-
type: "Schedule"
|
|
164
|
-
});
|
|
165
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
166
|
-
};
|
|
167
|
-
};
|
|
168
|
-
const getScheduleCron = () => function(cron, signalOption = {}) {
|
|
169
|
-
return (prototype, key, descriptor) => {
|
|
170
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
171
|
-
metadataMap.set(key, {
|
|
172
|
-
returns: () => JSON,
|
|
173
|
-
signalOption: { enabled: true, lock: true, ...signalOption, scheduleType: "cron", scheduleCron: cron },
|
|
174
|
-
key,
|
|
175
|
-
descriptor,
|
|
176
|
-
guards: ["None"],
|
|
177
|
-
type: "Schedule"
|
|
178
|
-
});
|
|
179
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
180
|
-
};
|
|
181
|
-
};
|
|
182
|
-
const getScheduleInterval = () => function(interval, signalOption = {}) {
|
|
183
|
-
return (prototype, key, descriptor) => {
|
|
184
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
185
|
-
metadataMap.set(key, {
|
|
186
|
-
returns: () => JSON,
|
|
187
|
-
signalOption: { enabled: true, lock: true, ...signalOption, scheduleType: "interval", scheduleTime: interval },
|
|
188
|
-
key,
|
|
189
|
-
descriptor,
|
|
190
|
-
guards: ["None"],
|
|
191
|
-
type: "Schedule"
|
|
192
|
-
});
|
|
193
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
194
|
-
};
|
|
195
|
-
};
|
|
196
|
-
const getScheduleTimeout = () => function(timeout, signalOption = {}) {
|
|
197
|
-
return (prototype, key, descriptor) => {
|
|
198
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
199
|
-
metadataMap.set(key, {
|
|
200
|
-
returns: () => JSON,
|
|
201
|
-
signalOption: { enabled: true, lock: true, ...signalOption, scheduleType: "timeout", scheduleTime: timeout },
|
|
202
|
-
key,
|
|
203
|
-
descriptor,
|
|
204
|
-
guards: ["None"],
|
|
205
|
-
type: "Schedule"
|
|
206
|
-
});
|
|
207
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
208
|
-
};
|
|
209
|
-
};
|
|
210
|
-
const Query = {
|
|
211
|
-
Public: getQuery("Public"),
|
|
212
|
-
Every: getQuery("Every"),
|
|
213
|
-
Admin: getQuery("Admin"),
|
|
214
|
-
User: getQuery("User"),
|
|
215
|
-
SuperAdmin: getQuery("SuperAdmin"),
|
|
216
|
-
None: getQuery("None"),
|
|
217
|
-
Owner: getQuery("Owner")
|
|
218
|
-
};
|
|
219
|
-
const Mutation = {
|
|
220
|
-
Public: getMutation("Public"),
|
|
221
|
-
Every: getMutation("Every"),
|
|
222
|
-
Admin: getMutation("Admin"),
|
|
223
|
-
User: getMutation("User"),
|
|
224
|
-
SuperAdmin: getMutation("SuperAdmin"),
|
|
225
|
-
None: getMutation("None"),
|
|
226
|
-
Owner: getMutation("Owner")
|
|
227
|
-
};
|
|
228
|
-
const Message = {
|
|
229
|
-
Public: getMessage("Public"),
|
|
230
|
-
Every: getMessage("Every"),
|
|
231
|
-
Admin: getMessage("Admin"),
|
|
232
|
-
User: getMessage("User"),
|
|
233
|
-
SuperAdmin: getMessage("SuperAdmin"),
|
|
234
|
-
None: getMessage("None"),
|
|
235
|
-
Owner: getMessage("Owner")
|
|
236
|
-
};
|
|
237
|
-
const Pubsub = {
|
|
238
|
-
Public: getPubsub("Public"),
|
|
239
|
-
Every: getPubsub("Every"),
|
|
240
|
-
Admin: getPubsub("Admin"),
|
|
241
|
-
User: getPubsub("User"),
|
|
242
|
-
SuperAdmin: getPubsub("SuperAdmin"),
|
|
243
|
-
None: getPubsub("None"),
|
|
244
|
-
Owner: getPubsub("Owner")
|
|
245
|
-
};
|
|
246
|
-
const Process = {
|
|
247
|
-
Federation: getProcess("Federation"),
|
|
248
|
-
Batch: getProcess("Batch"),
|
|
249
|
-
All: getProcess("All")
|
|
250
|
-
};
|
|
251
|
-
const Schedule = {
|
|
252
|
-
Init: getScheduleInit("Init"),
|
|
253
|
-
Cron: getScheduleCron(),
|
|
254
|
-
Interval: getScheduleInterval(),
|
|
255
|
-
Timeout: getScheduleTimeout(),
|
|
256
|
-
Destroy: getScheduleInit("Destroy")
|
|
257
|
-
};
|
|
258
|
-
function ResolveField(returns, argsOption = {}) {
|
|
259
|
-
return function(target, key, descriptor) {
|
|
260
|
-
const metadataMap = getResolveFieldMetaMapOnPrototype(target);
|
|
261
|
-
metadataMap.set(key, { returns, argsOption, key, descriptor });
|
|
262
|
-
Reflect.defineMetadata("resolveField", metadataMap, target);
|
|
263
|
-
};
|
|
264
|
-
}
|
|
265
|
-
const getArg = (type) => function(name, returns, argsOption = {}) {
|
|
266
|
-
return function(prototype, key, idx) {
|
|
267
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
268
|
-
argMetas[idx] = { name, returns, argsOption, key, idx, type };
|
|
269
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
270
|
-
};
|
|
271
|
-
};
|
|
272
|
-
const Arg = {
|
|
273
|
-
Body: getArg("Body"),
|
|
274
|
-
Param: getArg("Param"),
|
|
275
|
-
Query: getArg("Query"),
|
|
276
|
-
Upload: getArg("Upload"),
|
|
277
|
-
Msg: getArg("Msg"),
|
|
278
|
-
Room: getArg("Room")
|
|
279
|
-
};
|
|
280
|
-
function Parent() {
|
|
281
|
-
return function(prototype, key, idx) {
|
|
282
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
283
|
-
argMetas[idx] = { key, idx, type: "Parent" };
|
|
284
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
285
|
-
};
|
|
286
|
-
}
|
|
287
50
|
function internal(srv, internalBuilder, ...libInternals) {
|
|
288
51
|
const sigRef = libInternals.at(0) ?? class Internal {
|
|
289
52
|
};
|
|
@@ -311,37 +74,44 @@ function slice(srv, option, sliceBuilder, ...libSlices) {
|
|
|
311
74
|
updateModel: `update${className}`,
|
|
312
75
|
removeModel: `remove${className}`
|
|
313
76
|
};
|
|
314
|
-
const
|
|
315
|
-
const
|
|
316
|
-
const
|
|
77
|
+
const rootGuards = option.guards?.root ? Array.isArray(option.guards.root) ? option.guards.root : [option.guards.root] : [];
|
|
78
|
+
const getGuards = option.guards?.get ? Array.isArray(option.guards.get) ? option.guards.get : [option.guards.get] : [];
|
|
79
|
+
const cruGuards = option.guards?.cru ? Array.isArray(option.guards.cru) ? option.guards.cru : [option.guards.cru] : [];
|
|
80
|
+
const init = sliceInit(modelName, srv.cnst.full, srv.cnst.light, srv.cnst.insight);
|
|
317
81
|
const { query, mutation } = makeApiBuilder();
|
|
318
82
|
const buildSlice = {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
83
|
+
...rootGuards.length > 0 ? {
|
|
84
|
+
[""]: init({ guards: rootGuards }).search("query", JSON).exec(function(query2) {
|
|
85
|
+
return query2 ?? {};
|
|
86
|
+
})
|
|
87
|
+
} : {},
|
|
322
88
|
...sliceBuilder(init)
|
|
323
89
|
};
|
|
324
90
|
const buildEndpoint = {
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
91
|
+
...getGuards.length > 0 ? {
|
|
92
|
+
[names.model]: query(srv.cnst.full, { guards: getGuards }).param(names.modelId, ID).exec(async function(modelId) {
|
|
93
|
+
const service = this[names.modelService];
|
|
94
|
+
return await service[names.getModel](modelId);
|
|
95
|
+
}),
|
|
96
|
+
[names.lightModel]: query(srv.cnst.light, { guards: getGuards }).param(names.modelId, ID).exec(async function(modelId) {
|
|
97
|
+
const service = this[names.modelService];
|
|
98
|
+
return await service[names.getModel](modelId);
|
|
99
|
+
})
|
|
100
|
+
} : {},
|
|
101
|
+
...cruGuards.length > 0 ? {
|
|
102
|
+
[names.createModel]: mutation(srv.cnst.full, { guards: cruGuards }).body("data", srv.cnst.input).exec(async function(data) {
|
|
103
|
+
const service = this[names.modelService];
|
|
104
|
+
return await service[names.createModel](data);
|
|
105
|
+
}),
|
|
106
|
+
[names.updateModel]: mutation(srv.cnst.full, { guards: cruGuards }).param(names.modelId, ID).body("data", srv.cnst.input).exec(async function(modelId, data) {
|
|
107
|
+
const service = this[names.modelService];
|
|
108
|
+
return await service[names.updateModel](modelId, data);
|
|
109
|
+
}),
|
|
110
|
+
[names.removeModel]: mutation(srv.cnst.full, { partial: ["removedAt"], guards: cruGuards }).param(names.modelId, ID).exec(async function(modelId) {
|
|
111
|
+
const service = this[names.modelService];
|
|
112
|
+
return await service[names.removeModel](modelId);
|
|
113
|
+
})
|
|
114
|
+
} : {}
|
|
345
115
|
};
|
|
346
116
|
Object.entries(buildSlice).forEach(([key, slice2]) => {
|
|
347
117
|
if (!srv.cnst)
|
|
@@ -353,8 +123,8 @@ function slice(srv, option, sliceBuilder, ...libSlices) {
|
|
|
353
123
|
});
|
|
354
124
|
return sigRef;
|
|
355
125
|
}
|
|
356
|
-
function endpoint(srv, builder, ...
|
|
357
|
-
const sigRef =
|
|
126
|
+
function endpoint(srv, builder, ...libEndpoints) {
|
|
127
|
+
const sigRef = libEndpoints.at(0) ?? class Signal {
|
|
358
128
|
};
|
|
359
129
|
signalInfo.setRefNameTemp(sigRef, srv.refName);
|
|
360
130
|
const apiInfoMap = builder(makeApiBuilder());
|
|
@@ -363,36 +133,39 @@ function endpoint(srv, builder, ...libSignals) {
|
|
|
363
133
|
});
|
|
364
134
|
return sigRef;
|
|
365
135
|
}
|
|
366
|
-
const mergeSignals = (
|
|
367
|
-
applyMixins(
|
|
368
|
-
const gqlMetaMap = getGqlMetaMapOnPrototype(
|
|
369
|
-
const resolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(
|
|
370
|
-
setResolveFieldMetaMapOnPrototype(
|
|
136
|
+
const mergeSignals = (endpointRef, internalRef, sliceRef) => {
|
|
137
|
+
applyMixins(endpointRef, [internalRef]);
|
|
138
|
+
const gqlMetaMap = getGqlMetaMapOnPrototype(endpointRef.prototype);
|
|
139
|
+
const resolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(endpointRef.prototype);
|
|
140
|
+
setResolveFieldMetaMapOnPrototype(endpointRef.prototype, resolveFieldMetaMap);
|
|
371
141
|
const internalGqlMetaMap = getGqlMetaMapOnPrototype(internalRef.prototype);
|
|
372
142
|
const internalResolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(internalRef.prototype);
|
|
373
143
|
internalGqlMetaMap.forEach((value, key) => {
|
|
374
144
|
gqlMetaMap.set(key, value);
|
|
375
145
|
const [argMetas, internalArgMetas] = getArgMetas(internalRef, key);
|
|
376
|
-
setArgMetas(
|
|
146
|
+
setArgMetas(endpointRef, key, argMetas, internalArgMetas);
|
|
377
147
|
});
|
|
378
148
|
internalResolveFieldMetaMap.forEach((value, key) => {
|
|
379
149
|
resolveFieldMetaMap.set(key, value);
|
|
380
150
|
const [argMetas, internalArgMetas] = getArgMetas(internalRef, key);
|
|
381
|
-
setArgMetas(
|
|
151
|
+
setArgMetas(endpointRef, key, argMetas, internalArgMetas);
|
|
382
152
|
});
|
|
383
153
|
if (sliceRef) {
|
|
384
154
|
const sliceGqlMetaMap = getGqlMetaMapOnPrototype(sliceRef.prototype);
|
|
385
|
-
applyMixins(
|
|
155
|
+
applyMixins(endpointRef, [sliceRef], /* @__PURE__ */ new Set([...gqlMetaMap.keys()]));
|
|
386
156
|
sliceGqlMetaMap.forEach((value, key) => {
|
|
387
157
|
if (gqlMetaMap.has(key))
|
|
388
158
|
return;
|
|
389
159
|
gqlMetaMap.set(key, value);
|
|
390
160
|
const [argMetas, internalArgMetas] = getArgMetas(sliceRef, key);
|
|
391
|
-
setArgMetas(
|
|
161
|
+
setArgMetas(endpointRef, key, argMetas, internalArgMetas);
|
|
392
162
|
});
|
|
393
163
|
}
|
|
394
|
-
setGqlMetaMapOnPrototype(
|
|
395
|
-
return
|
|
164
|
+
setGqlMetaMapOnPrototype(endpointRef.prototype, gqlMetaMap);
|
|
165
|
+
return endpointRef;
|
|
166
|
+
};
|
|
167
|
+
const serverSignalOf = (sigRef) => {
|
|
168
|
+
return sigRef;
|
|
396
169
|
};
|
|
397
170
|
const getSigMeta = (sigRef) => {
|
|
398
171
|
const sigMeta = Reflect.getMetadata("signal", sigRef.prototype);
|
|
@@ -477,28 +250,9 @@ const copySignal = (sigRef) => {
|
|
|
477
250
|
return CopiedSignal;
|
|
478
251
|
};
|
|
479
252
|
export {
|
|
480
|
-
Access,
|
|
481
|
-
Account,
|
|
482
|
-
Arg,
|
|
483
|
-
Job,
|
|
484
|
-
Me,
|
|
485
|
-
Message,
|
|
486
|
-
Mutation,
|
|
487
|
-
Parent,
|
|
488
|
-
Process,
|
|
489
|
-
Pubsub,
|
|
490
|
-
Query,
|
|
491
|
-
Req,
|
|
492
|
-
Res,
|
|
493
|
-
ResolveField,
|
|
494
|
-
Schedule,
|
|
495
|
-
Self,
|
|
496
253
|
SignalStorage,
|
|
497
|
-
UserIp,
|
|
498
|
-
Ws,
|
|
499
254
|
argTypes,
|
|
500
255
|
copySignal,
|
|
501
|
-
createArgMetaDecorator,
|
|
502
256
|
defaultAccount,
|
|
503
257
|
done,
|
|
504
258
|
emit,
|
|
@@ -516,18 +270,15 @@ export {
|
|
|
516
270
|
getResolveFieldMetas,
|
|
517
271
|
getSigMeta,
|
|
518
272
|
getSignalRefsOnStorage,
|
|
519
|
-
guardTypes,
|
|
520
273
|
internal,
|
|
521
|
-
internalArgTypes,
|
|
522
274
|
mergeSignals,
|
|
523
275
|
resolve,
|
|
524
|
-
|
|
276
|
+
serverSignalOf,
|
|
525
277
|
setArgMetas,
|
|
526
278
|
setGqlMetaMapOnPrototype,
|
|
527
279
|
setSigMeta,
|
|
528
280
|
setSignalRefOnStorage,
|
|
529
281
|
signalTypes,
|
|
530
282
|
slice,
|
|
531
|
-
ssoTypes,
|
|
532
283
|
subscribe
|
|
533
284
|
};
|
package/esm/src/signalInfo.js
CHANGED
|
@@ -129,7 +129,14 @@ const signalInfo = {
|
|
|
129
129
|
const refName2 = isGqlScalar ? scalarNameMap.get(returnRef) : constantInfo.getRefName(returnRef);
|
|
130
130
|
serializedSignal.endpoint[key] = {
|
|
131
131
|
type: lowerlize(gqlMeta.type),
|
|
132
|
-
signalOption:
|
|
132
|
+
signalOption: {
|
|
133
|
+
nullable: gqlMeta.signalOption.nullable,
|
|
134
|
+
path: gqlMeta.signalOption.path,
|
|
135
|
+
onlyFor: gqlMeta.signalOption.onlyFor,
|
|
136
|
+
partial: gqlMeta.signalOption.partial,
|
|
137
|
+
guards: gqlMeta.signalOption.guards?.map((guard) => guard.name),
|
|
138
|
+
name: gqlMeta.signalOption.name
|
|
139
|
+
},
|
|
133
140
|
returns: { refName: refName2, modelType, arrDepth },
|
|
134
141
|
args: argMetas.map((argMeta) => {
|
|
135
142
|
const [argRef, arrDepth2] = getNonArrayModel(argMeta.returns());
|
|
@@ -158,6 +165,7 @@ const signalInfo = {
|
|
|
158
165
|
return signalInfo.buildFetch(signalInfo.serializedSignals);
|
|
159
166
|
},
|
|
160
167
|
buildFetch(signals = [], cnstInfo = constantInfo) {
|
|
168
|
+
global.signals = signals;
|
|
161
169
|
const databaseSignals = signals.filter((signal) => cnstInfo.database.has(signal.refName));
|
|
162
170
|
const serviceSignals = signals.filter((signal) => !cnstInfo.database.has(signal.refName));
|
|
163
171
|
const fetchComponent = Object.assign(
|
package/esm/src/sliceInfo.js
CHANGED
|
@@ -1,4 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {
|
|
2
|
+
arraiedModel,
|
|
3
|
+
getNonArrayModel,
|
|
4
|
+
Int,
|
|
5
|
+
isEnum
|
|
6
|
+
} from "@akanjs/base";
|
|
2
7
|
import { capitalize } from "@akanjs/common";
|
|
3
8
|
import {
|
|
4
9
|
getGqlMetaMapOnPrototype,
|
|
@@ -7,31 +12,28 @@ import {
|
|
|
7
12
|
} from "./signalDecorators";
|
|
8
13
|
import { signalInfo } from "./signalInfo";
|
|
9
14
|
class SliceInfo {
|
|
15
|
+
refName;
|
|
10
16
|
full;
|
|
11
17
|
light;
|
|
12
18
|
insight;
|
|
19
|
+
argNames = [];
|
|
13
20
|
args = [];
|
|
14
21
|
internalArgs = [];
|
|
15
22
|
signalOption;
|
|
16
|
-
guards;
|
|
17
23
|
execFn = null;
|
|
18
|
-
constructor(full, light, insight,
|
|
24
|
+
constructor(refName, full, light, insight, signalOption = {}) {
|
|
25
|
+
this.refName = refName;
|
|
19
26
|
this.full = full;
|
|
20
27
|
this.light = light;
|
|
21
28
|
this.insight = insight;
|
|
22
|
-
this.signalOption =
|
|
23
|
-
this.guards = [
|
|
24
|
-
.../* @__PURE__ */ new Set([
|
|
25
|
-
...guards,
|
|
26
|
-
...typeof signalOptionOrGuard === "string" ? [signalOptionOrGuard] : ["Public"]
|
|
27
|
-
])
|
|
28
|
-
];
|
|
29
|
+
this.signalOption = signalOption;
|
|
29
30
|
}
|
|
30
31
|
param(name, argRef, option) {
|
|
31
32
|
if (this.execFn)
|
|
32
33
|
throw new Error("Query function is already set");
|
|
33
34
|
else if (this.args.at(-1)?.option?.nullable)
|
|
34
35
|
throw new Error("Last argument is nullable");
|
|
36
|
+
this.argNames.push(name);
|
|
35
37
|
this.args.push({ type: "Param", name, argRef, option });
|
|
36
38
|
return this;
|
|
37
39
|
}
|
|
@@ -40,12 +42,14 @@ class SliceInfo {
|
|
|
40
42
|
throw new Error("Query function is already set");
|
|
41
43
|
else if (this.args.at(-1)?.option?.nullable)
|
|
42
44
|
throw new Error("Last argument is nullable");
|
|
45
|
+
this.argNames.push(name);
|
|
43
46
|
this.args.push({ type: "Body", name, argRef, option });
|
|
44
47
|
return this;
|
|
45
48
|
}
|
|
46
49
|
search(name, argRef, option) {
|
|
47
50
|
if (this.execFn)
|
|
48
51
|
throw new Error("Query function is already set");
|
|
52
|
+
this.argNames.push(name);
|
|
49
53
|
this.args.push({ type: "Query", name, argRef, option: { ...option, nullable: true } });
|
|
50
54
|
return this;
|
|
51
55
|
}
|
|
@@ -70,11 +74,15 @@ class SliceInfo {
|
|
|
70
74
|
const gqlMetaMap = getGqlMetaMapOnPrototype(sigRef.prototype);
|
|
71
75
|
const argMetas = this.args.map((arg, idx) => {
|
|
72
76
|
const [singleArgRef, argArrDepth] = getNonArrayModel(arg.argRef);
|
|
73
|
-
const
|
|
77
|
+
const isEnumValue = isEnum(singleArgRef);
|
|
78
|
+
const returnRef = arraiedModel(
|
|
79
|
+
isEnumValue ? singleArgRef.type : singleArgRef,
|
|
80
|
+
argArrDepth
|
|
81
|
+
);
|
|
74
82
|
return {
|
|
75
83
|
name: arg.name,
|
|
76
84
|
returns: () => returnRef,
|
|
77
|
-
argsOption: { ...arg.option, enum:
|
|
85
|
+
argsOption: { ...arg.option, enum: isEnumValue ? arg.argRef : void 0 },
|
|
78
86
|
key,
|
|
79
87
|
idx,
|
|
80
88
|
type: arg.type
|
|
@@ -132,7 +140,6 @@ class SliceInfo {
|
|
|
132
140
|
signalOption: this.signalOption,
|
|
133
141
|
key: listKey,
|
|
134
142
|
descriptor: { value: listFn, writable: true, enumerable: false, configurable: true },
|
|
135
|
-
guards: this.guards,
|
|
136
143
|
type: "Query"
|
|
137
144
|
};
|
|
138
145
|
gqlMetaMap.set(listKey, listApiMeta);
|
|
@@ -158,7 +165,6 @@ class SliceInfo {
|
|
|
158
165
|
signalOption: this.signalOption,
|
|
159
166
|
key: insightKey,
|
|
160
167
|
descriptor: { value: insightFn, writable: true, enumerable: false, configurable: true },
|
|
161
|
-
guards: this.guards,
|
|
162
168
|
type: "Query"
|
|
163
169
|
};
|
|
164
170
|
gqlMetaMap.set(insightKey, insightApiMeta);
|
|
@@ -171,7 +177,7 @@ class SliceInfo {
|
|
|
171
177
|
setGqlMetaMapOnPrototype(sigRef.prototype, gqlMetaMap);
|
|
172
178
|
}
|
|
173
179
|
}
|
|
174
|
-
const sliceInit = (full, light, insight) => (
|
|
180
|
+
const sliceInit = (refName, full, light, insight) => (signalOption) => new SliceInfo(refName, full, light, insight, signalOption);
|
|
175
181
|
export {
|
|
176
182
|
SliceInfo,
|
|
177
183
|
sliceInit
|