@akanjs/signal 0.0.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -0
- package/index.d.ts +1 -0
- package/index.js +21 -0
- package/package.json +30 -0
- package/src/client.d.ts +51 -0
- package/src/client.js +164 -0
- package/src/doc.d.ts +9 -0
- package/src/doc.js +107 -0
- package/src/gql.d.ts +226 -0
- package/src/gql.js +860 -0
- package/src/immerify.d.ts +2 -0
- package/src/immerify.js +39 -0
- package/src/index.d.ts +5 -0
- package/src/index.js +37 -0
- package/src/signalDecorators.d.ts +295 -0
- package/src/signalDecorators.js +571 -0
|
@@ -0,0 +1,571 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
19
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
20
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
21
|
+
if (decorator = decorators[i])
|
|
22
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
23
|
+
if (kind && result)
|
|
24
|
+
__defProp(target, key, result);
|
|
25
|
+
return result;
|
|
26
|
+
};
|
|
27
|
+
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
|
+
var signalDecorators_exports = {};
|
|
29
|
+
__export(signalDecorators_exports, {
|
|
30
|
+
Access: () => Access,
|
|
31
|
+
Account: () => Account,
|
|
32
|
+
Arg: () => Arg,
|
|
33
|
+
DbSignal: () => DbSignal,
|
|
34
|
+
Job: () => Job,
|
|
35
|
+
LogSignal: () => LogSignal,
|
|
36
|
+
Me: () => Me,
|
|
37
|
+
Message: () => Message,
|
|
38
|
+
Mutation: () => Mutation,
|
|
39
|
+
Parent: () => Parent,
|
|
40
|
+
Process: () => Process,
|
|
41
|
+
Pubsub: () => Pubsub,
|
|
42
|
+
Query: () => Query,
|
|
43
|
+
Req: () => Req,
|
|
44
|
+
Res: () => Res,
|
|
45
|
+
ResolveField: () => ResolveField,
|
|
46
|
+
Self: () => Self,
|
|
47
|
+
Signal: () => Signal,
|
|
48
|
+
SignalStorage: () => SignalStorage,
|
|
49
|
+
UserIp: () => UserIp,
|
|
50
|
+
Ws: () => Ws,
|
|
51
|
+
argTypes: () => argTypes,
|
|
52
|
+
copySignal: () => copySignal,
|
|
53
|
+
createArgMetaDecorator: () => createArgMetaDecorator,
|
|
54
|
+
defaultAccount: () => defaultAccount,
|
|
55
|
+
done: () => done,
|
|
56
|
+
emit: () => emit,
|
|
57
|
+
endpointTypes: () => endpointTypes,
|
|
58
|
+
getAllSignalRefs: () => getAllSignalRefs,
|
|
59
|
+
getArgMetas: () => getArgMetas,
|
|
60
|
+
getControllerPath: () => getControllerPath,
|
|
61
|
+
getControllerPrefix: () => getControllerPrefix,
|
|
62
|
+
getGqlMeta: () => getGqlMeta,
|
|
63
|
+
getGqlMetaMapOnPrototype: () => getGqlMetaMapOnPrototype,
|
|
64
|
+
getGqlMetas: () => getGqlMetas,
|
|
65
|
+
getResolveFieldMetas: () => getResolveFieldMetas,
|
|
66
|
+
getSigMeta: () => getSigMeta,
|
|
67
|
+
getSignalRefsOnStorage: () => getSignalRefsOnStorage,
|
|
68
|
+
guardTypes: () => guardTypes,
|
|
69
|
+
internalArgTypes: () => internalArgTypes,
|
|
70
|
+
resolve: () => resolve,
|
|
71
|
+
roleTypes: () => roleTypes,
|
|
72
|
+
setArgMetas: () => setArgMetas,
|
|
73
|
+
setGqlMetaMapOnPrototype: () => setGqlMetaMapOnPrototype,
|
|
74
|
+
signalTypes: () => signalTypes,
|
|
75
|
+
ssoTypes: () => ssoTypes,
|
|
76
|
+
subscribe: () => subscribe
|
|
77
|
+
});
|
|
78
|
+
module.exports = __toCommonJS(signalDecorators_exports);
|
|
79
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
80
|
+
var import_base = require("@akanjs/base");
|
|
81
|
+
var import_common = require("@akanjs/common");
|
|
82
|
+
var import_constant = require("@akanjs/constant");
|
|
83
|
+
var import_gql = require("./gql");
|
|
84
|
+
const ssoTypes = ["github", "google", "facebook", "apple", "naver", "kakao"];
|
|
85
|
+
class SignalStorage {
|
|
86
|
+
}
|
|
87
|
+
const getAllSignalRefs = () => {
|
|
88
|
+
const signalNames = Reflect.getOwnMetadataKeys(SignalStorage.prototype);
|
|
89
|
+
const sigRefs = signalNames?.reduce((acc, signalName) => [...acc, ...getSignalRefsOnStorage(signalName)], []) ?? [];
|
|
90
|
+
return sigRefs;
|
|
91
|
+
};
|
|
92
|
+
const getSignalRefsOnStorage = (refName) => {
|
|
93
|
+
const sigRefs = Reflect.getMetadata(refName, SignalStorage.prototype);
|
|
94
|
+
return sigRefs ?? [];
|
|
95
|
+
};
|
|
96
|
+
const setSignalRefOnStorage = (refName, signalRef) => {
|
|
97
|
+
Reflect.defineMetadata(refName, [...getSignalRefsOnStorage(refName), signalRef], SignalStorage.prototype);
|
|
98
|
+
};
|
|
99
|
+
const resolve = (data) => data;
|
|
100
|
+
const emit = (data) => data;
|
|
101
|
+
const done = (data) => data;
|
|
102
|
+
const subscribe = () => void 0;
|
|
103
|
+
const signalTypes = ["graphql", "restapi"];
|
|
104
|
+
const endpointTypes = ["Query", "Mutation", "Message", "Pubsub", "Process"];
|
|
105
|
+
const guardTypes = ["Public", "None", "User", "Admin", "SuperAdmin", "Every", "Owner"];
|
|
106
|
+
const roleTypes = ["Public", "User", "Admin", "SuperAdmin"];
|
|
107
|
+
const argTypes = ["Body", "Param", "Query", "Upload", "Msg", "Room"];
|
|
108
|
+
const internalArgTypes = [
|
|
109
|
+
"Account",
|
|
110
|
+
"Me",
|
|
111
|
+
"Self",
|
|
112
|
+
"UserIp",
|
|
113
|
+
"Access",
|
|
114
|
+
"Parent",
|
|
115
|
+
"Req",
|
|
116
|
+
"Res",
|
|
117
|
+
"Ws",
|
|
118
|
+
"Job"
|
|
119
|
+
];
|
|
120
|
+
const getDefaultArg = (argRef) => {
|
|
121
|
+
const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(argRef);
|
|
122
|
+
if (arrDepth)
|
|
123
|
+
return [];
|
|
124
|
+
const scalarArg = import_base.scalarArgMap.get(modelRef);
|
|
125
|
+
if (scalarArg)
|
|
126
|
+
return scalarArg;
|
|
127
|
+
else
|
|
128
|
+
return {};
|
|
129
|
+
};
|
|
130
|
+
function Signal(returnsOrObj) {
|
|
131
|
+
const returns = typeof returnsOrObj === "function" ? returnsOrObj : void 0;
|
|
132
|
+
const prefix = typeof returnsOrObj === "object" ? returnsOrObj.prefix : void 0;
|
|
133
|
+
return function(target) {
|
|
134
|
+
if (returns) {
|
|
135
|
+
const modelRef = returns();
|
|
136
|
+
const classMeta = (0, import_constant.getClassMeta)(modelRef);
|
|
137
|
+
const gqlMetas = getGqlMetas(target);
|
|
138
|
+
const modelName = (0, import_common.lowerlize)(classMeta.refName);
|
|
139
|
+
const listName = `${modelName}ListIn`;
|
|
140
|
+
const slices = [
|
|
141
|
+
{ refName: modelName, sliceName: modelName, argLength: 1, defaultArgs: [{}] },
|
|
142
|
+
...gqlMetas.filter((gqlMeta) => {
|
|
143
|
+
const name = gqlMeta.signalOption.name ?? gqlMeta.key;
|
|
144
|
+
if (!name.includes(listName))
|
|
145
|
+
return false;
|
|
146
|
+
const [retRef, arrDepth] = (0, import_base.getNonArrayModel)(gqlMeta.returns());
|
|
147
|
+
return retRef.prototype === modelRef.prototype && arrDepth === 1;
|
|
148
|
+
}).map((gqlMeta) => {
|
|
149
|
+
const name = gqlMeta.signalOption.name ?? gqlMeta.key;
|
|
150
|
+
const sliceName = name.replace(listName, `${modelName}In`);
|
|
151
|
+
const [argMetas] = getArgMetas(target, gqlMeta.key);
|
|
152
|
+
const skipIdx = argMetas.findIndex((argMeta) => argMeta.name === "skip");
|
|
153
|
+
if (skipIdx === -1)
|
|
154
|
+
throw new Error(`Invalid Args for ${sliceName}`);
|
|
155
|
+
const argLength = skipIdx;
|
|
156
|
+
const queryArgRefs = argMetas.slice(0, skipIdx).map((argMeta) => argMeta.returns());
|
|
157
|
+
const defaultArgs = queryArgRefs.map(
|
|
158
|
+
(queryArgRef, idx) => argMetas[idx].argsOption.nullable ? null : getDefaultArg(queryArgRef)
|
|
159
|
+
);
|
|
160
|
+
return { refName: modelName, sliceName, argLength, defaultArgs };
|
|
161
|
+
})
|
|
162
|
+
];
|
|
163
|
+
setSigMeta(target, { returns, prefix, slices, refName: modelName });
|
|
164
|
+
setSignalRefOnStorage(modelName, target);
|
|
165
|
+
} else {
|
|
166
|
+
const refName = typeof returnsOrObj === "object" ? (0, import_common.lowerlize)(returnsOrObj.name) : void 0;
|
|
167
|
+
if (!refName)
|
|
168
|
+
throw new Error("Signal name is required");
|
|
169
|
+
setSigMeta(target, { returns, prefix, slices: [], refName });
|
|
170
|
+
setSignalRefOnStorage(refName, target);
|
|
171
|
+
}
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
const createArgMetaDecorator = (type) => {
|
|
175
|
+
return function(option = {}) {
|
|
176
|
+
return function(prototype, key, idx) {
|
|
177
|
+
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
178
|
+
argMetas[idx] = { key, idx, type, option };
|
|
179
|
+
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
180
|
+
};
|
|
181
|
+
};
|
|
182
|
+
};
|
|
183
|
+
const Account = createArgMetaDecorator("Account");
|
|
184
|
+
const defaultAccount = {
|
|
185
|
+
__InternalArg__: "Account",
|
|
186
|
+
appName: import_base.baseEnv.appName,
|
|
187
|
+
environment: import_base.baseEnv.environment
|
|
188
|
+
};
|
|
189
|
+
const Self = createArgMetaDecorator("Self");
|
|
190
|
+
const Me = createArgMetaDecorator("Me");
|
|
191
|
+
const UserIp = createArgMetaDecorator("UserIp");
|
|
192
|
+
const Access = createArgMetaDecorator("Access");
|
|
193
|
+
const Req = createArgMetaDecorator("Req");
|
|
194
|
+
const Res = createArgMetaDecorator("Res");
|
|
195
|
+
const Ws = createArgMetaDecorator("Ws");
|
|
196
|
+
const Job = createArgMetaDecorator("Job");
|
|
197
|
+
const getQuery = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
198
|
+
return (prototype, key, descriptor) => {
|
|
199
|
+
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
200
|
+
metadataMap.set(key, {
|
|
201
|
+
returns,
|
|
202
|
+
signalOption,
|
|
203
|
+
key,
|
|
204
|
+
descriptor,
|
|
205
|
+
guards: [allow, ...guards],
|
|
206
|
+
type: "Query"
|
|
207
|
+
});
|
|
208
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
209
|
+
};
|
|
210
|
+
};
|
|
211
|
+
const getMutation = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
212
|
+
return (prototype, key, descriptor) => {
|
|
213
|
+
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
214
|
+
metadataMap.set(key, {
|
|
215
|
+
returns,
|
|
216
|
+
signalOption,
|
|
217
|
+
key,
|
|
218
|
+
descriptor,
|
|
219
|
+
guards: [allow, ...guards],
|
|
220
|
+
type: "Mutation"
|
|
221
|
+
});
|
|
222
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
223
|
+
};
|
|
224
|
+
};
|
|
225
|
+
const getMessage = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
226
|
+
return (prototype, key, descriptor) => {
|
|
227
|
+
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
228
|
+
metadataMap.set(key, {
|
|
229
|
+
returns,
|
|
230
|
+
signalOption,
|
|
231
|
+
key,
|
|
232
|
+
descriptor,
|
|
233
|
+
guards: [allow, ...guards],
|
|
234
|
+
type: "Message"
|
|
235
|
+
});
|
|
236
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
237
|
+
};
|
|
238
|
+
};
|
|
239
|
+
const getPubsub = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
240
|
+
return (prototype, key, descriptor) => {
|
|
241
|
+
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
242
|
+
metadataMap.set(key, {
|
|
243
|
+
returns,
|
|
244
|
+
signalOption,
|
|
245
|
+
key,
|
|
246
|
+
descriptor,
|
|
247
|
+
guards: [allow, ...guards],
|
|
248
|
+
type: "Pubsub"
|
|
249
|
+
});
|
|
250
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
251
|
+
};
|
|
252
|
+
};
|
|
253
|
+
const getProcess = (serverType) => function(returns, signalOption = {}) {
|
|
254
|
+
return (prototype, key, descriptor) => {
|
|
255
|
+
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
256
|
+
metadataMap.set(key, {
|
|
257
|
+
returns,
|
|
258
|
+
signalOption: { ...signalOption, serverType: (0, import_common.lowerlize)(serverType) },
|
|
259
|
+
key,
|
|
260
|
+
descriptor,
|
|
261
|
+
guards: ["None"],
|
|
262
|
+
type: "Process"
|
|
263
|
+
});
|
|
264
|
+
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
265
|
+
};
|
|
266
|
+
};
|
|
267
|
+
const Query = {
|
|
268
|
+
Public: getQuery("Public"),
|
|
269
|
+
Every: getQuery("Every"),
|
|
270
|
+
Admin: getQuery("Admin"),
|
|
271
|
+
User: getQuery("User"),
|
|
272
|
+
SuperAdmin: getQuery("SuperAdmin"),
|
|
273
|
+
None: getQuery("None"),
|
|
274
|
+
Owner: getQuery("Owner")
|
|
275
|
+
};
|
|
276
|
+
const Mutation = {
|
|
277
|
+
Public: getMutation("Public"),
|
|
278
|
+
Every: getMutation("Every"),
|
|
279
|
+
Admin: getMutation("Admin"),
|
|
280
|
+
User: getMutation("User"),
|
|
281
|
+
SuperAdmin: getMutation("SuperAdmin"),
|
|
282
|
+
None: getMutation("None"),
|
|
283
|
+
Owner: getMutation("Owner")
|
|
284
|
+
};
|
|
285
|
+
const Message = {
|
|
286
|
+
Public: getMessage("Public"),
|
|
287
|
+
Every: getMessage("Every"),
|
|
288
|
+
Admin: getMessage("Admin"),
|
|
289
|
+
User: getMessage("User"),
|
|
290
|
+
SuperAdmin: getMessage("SuperAdmin"),
|
|
291
|
+
None: getMessage("None"),
|
|
292
|
+
Owner: getMessage("Owner")
|
|
293
|
+
};
|
|
294
|
+
const Pubsub = {
|
|
295
|
+
Public: getPubsub("Public"),
|
|
296
|
+
Every: getPubsub("Every"),
|
|
297
|
+
Admin: getPubsub("Admin"),
|
|
298
|
+
User: getPubsub("User"),
|
|
299
|
+
SuperAdmin: getPubsub("SuperAdmin"),
|
|
300
|
+
None: getPubsub("None"),
|
|
301
|
+
Owner: getPubsub("Owner")
|
|
302
|
+
};
|
|
303
|
+
const Process = {
|
|
304
|
+
Federation: getProcess("Federation"),
|
|
305
|
+
Batch: getProcess("Batch"),
|
|
306
|
+
All: getProcess("All")
|
|
307
|
+
};
|
|
308
|
+
function ResolveField(returns, argsOption = {}) {
|
|
309
|
+
return function(target, key, descriptor) {
|
|
310
|
+
const metadataMap = getResolveFieldMetaMapOnPrototype(target);
|
|
311
|
+
metadataMap.set(key, { returns, argsOption, key, descriptor });
|
|
312
|
+
Reflect.defineMetadata("resolveField", metadataMap, target);
|
|
313
|
+
};
|
|
314
|
+
}
|
|
315
|
+
const getArg = (type) => function(name, returns, argsOption = {}) {
|
|
316
|
+
return function(prototype, key, idx) {
|
|
317
|
+
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
318
|
+
argMetas[idx] = { name, returns, argsOption, key, idx, type };
|
|
319
|
+
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
320
|
+
};
|
|
321
|
+
};
|
|
322
|
+
const Arg = {
|
|
323
|
+
Body: getArg("Body"),
|
|
324
|
+
Param: getArg("Param"),
|
|
325
|
+
Query: getArg("Query"),
|
|
326
|
+
Upload: getArg("Upload"),
|
|
327
|
+
Msg: getArg("Msg"),
|
|
328
|
+
Room: getArg("Room")
|
|
329
|
+
};
|
|
330
|
+
function Parent() {
|
|
331
|
+
return function(prototype, key, idx) {
|
|
332
|
+
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
333
|
+
argMetas[idx] = { key, idx, type: "Parent" };
|
|
334
|
+
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
335
|
+
};
|
|
336
|
+
}
|
|
337
|
+
function LogSignal(srv) {
|
|
338
|
+
class BaseSignal {
|
|
339
|
+
}
|
|
340
|
+
return BaseSignal;
|
|
341
|
+
}
|
|
342
|
+
function DbSignal(constant, srv, option) {
|
|
343
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
344
|
+
const meta = (0, import_constant.getClassMeta)(constant.Full);
|
|
345
|
+
const serviceName = `${(0, import_common.lowerlize)(meta.refName)}Service`;
|
|
346
|
+
const [modelName, className] = [(0, import_common.lowerlize)(meta.refName), (0, import_common.capitalize)(meta.refName)];
|
|
347
|
+
const names = {
|
|
348
|
+
modelId: `${modelName}Id`,
|
|
349
|
+
model: modelName,
|
|
350
|
+
lightModel: `light${className}`,
|
|
351
|
+
modelList: `${modelName}List`,
|
|
352
|
+
modelInsight: `${modelName}Insight`,
|
|
353
|
+
modelExists: `${modelName}Exists`,
|
|
354
|
+
getModel: `get${className}`,
|
|
355
|
+
createModel: `create${className}`,
|
|
356
|
+
updateModel: `update${className}`,
|
|
357
|
+
removeModel: `remove${className}`
|
|
358
|
+
};
|
|
359
|
+
class BaseSignal {
|
|
360
|
+
async [_a = names.lightModel](id) {
|
|
361
|
+
const service = this[serviceName];
|
|
362
|
+
const model = await service[names.getModel](id);
|
|
363
|
+
return resolve(model);
|
|
364
|
+
}
|
|
365
|
+
async [_b = names.model](id) {
|
|
366
|
+
const service = this[serviceName];
|
|
367
|
+
const model = await service[names.getModel](id);
|
|
368
|
+
return resolve(model);
|
|
369
|
+
}
|
|
370
|
+
async [_c = names.modelList](query, skip, limit, sort) {
|
|
371
|
+
const service = this[serviceName];
|
|
372
|
+
const models = query?.$search ? await service.__searchDocs(query.$search, { skip, limit, sort }) : await service.__list(query, { skip, limit, sort });
|
|
373
|
+
return resolve(models);
|
|
374
|
+
}
|
|
375
|
+
async [_d = names.modelInsight](query) {
|
|
376
|
+
const service = this[serviceName];
|
|
377
|
+
const insight = query.$search ? { ...(0, import_gql.makeDefault)(constant.Insight), count: await service.__searchCount(query.$search) } : await service.__insight(query);
|
|
378
|
+
return resolve(insight);
|
|
379
|
+
}
|
|
380
|
+
async [_e = names.modelExists](query) {
|
|
381
|
+
const service = this[serviceName];
|
|
382
|
+
const exists = await service.__exists(query);
|
|
383
|
+
return resolve(exists);
|
|
384
|
+
}
|
|
385
|
+
async [_f = names.createModel](data) {
|
|
386
|
+
const service = this[serviceName];
|
|
387
|
+
const model = await service[names.createModel](data);
|
|
388
|
+
return resolve(model);
|
|
389
|
+
}
|
|
390
|
+
async [_g = names.updateModel](id, data) {
|
|
391
|
+
const service = this[serviceName];
|
|
392
|
+
const model = await service[names.updateModel](id, data);
|
|
393
|
+
return resolve(model);
|
|
394
|
+
}
|
|
395
|
+
async [_h = names.removeModel](id) {
|
|
396
|
+
const service = this[serviceName];
|
|
397
|
+
const model = await service[names.removeModel](id);
|
|
398
|
+
return resolve(model);
|
|
399
|
+
}
|
|
400
|
+
}
|
|
401
|
+
__decorateClass([
|
|
402
|
+
option.guards.get(() => constant.Light),
|
|
403
|
+
__decorateParam(0, Arg.Param(names.modelId, () => import_base.ID))
|
|
404
|
+
], BaseSignal.prototype, _a, 1);
|
|
405
|
+
__decorateClass([
|
|
406
|
+
option.guards.get(() => constant.Full),
|
|
407
|
+
__decorateParam(0, Arg.Param(names.modelId, () => import_base.ID))
|
|
408
|
+
], BaseSignal.prototype, _b, 1);
|
|
409
|
+
__decorateClass([
|
|
410
|
+
Query.Admin(() => [constant.Full]),
|
|
411
|
+
__decorateParam(0, Arg.Query("query", () => import_base.JSON)),
|
|
412
|
+
__decorateParam(1, Arg.Query("skip", () => import_base.Int, { nullable: true, example: 0 })),
|
|
413
|
+
__decorateParam(2, Arg.Query("limit", () => import_base.Int, { nullable: true, example: 20 })),
|
|
414
|
+
__decorateParam(3, Arg.Query("sort", () => String, { nullable: true, example: "latest" }))
|
|
415
|
+
], BaseSignal.prototype, _c, 1);
|
|
416
|
+
__decorateClass([
|
|
417
|
+
Query.Admin(() => constant.Insight),
|
|
418
|
+
__decorateParam(0, Arg.Query("query", () => import_base.JSON))
|
|
419
|
+
], BaseSignal.prototype, _d, 1);
|
|
420
|
+
__decorateClass([
|
|
421
|
+
Query.Admin(() => Boolean),
|
|
422
|
+
__decorateParam(0, Arg.Query("query", () => import_base.JSON))
|
|
423
|
+
], BaseSignal.prototype, _e, 1);
|
|
424
|
+
__decorateClass([
|
|
425
|
+
option.guards.cru(() => constant.Full),
|
|
426
|
+
__decorateParam(0, Arg.Body(`data`, () => constant.Input))
|
|
427
|
+
], BaseSignal.prototype, _f, 1);
|
|
428
|
+
__decorateClass([
|
|
429
|
+
option.guards.cru(() => constant.Full),
|
|
430
|
+
__decorateParam(0, Arg.Param(names.modelId, () => import_base.ID)),
|
|
431
|
+
__decorateParam(1, Arg.Body("data", () => constant.Input))
|
|
432
|
+
], BaseSignal.prototype, _g, 1);
|
|
433
|
+
__decorateClass([
|
|
434
|
+
option.guards.cru(() => constant.Full, { partial: ["status", "removedAt"] }),
|
|
435
|
+
__decorateParam(0, Arg.Param(names.modelId, () => import_base.ID))
|
|
436
|
+
], BaseSignal.prototype, _h, 1);
|
|
437
|
+
return BaseSignal;
|
|
438
|
+
}
|
|
439
|
+
const getSigMeta = (sigRef) => {
|
|
440
|
+
const sigMeta = Reflect.getMetadata("signal", sigRef.prototype);
|
|
441
|
+
if (!sigMeta)
|
|
442
|
+
throw new Error(`No SignalMeta found for ${sigRef.name}`);
|
|
443
|
+
return sigMeta;
|
|
444
|
+
};
|
|
445
|
+
const setSigMeta = (sigRef, sigMeta) => {
|
|
446
|
+
Reflect.defineMetadata("signal", sigMeta, sigRef.prototype);
|
|
447
|
+
};
|
|
448
|
+
const getGqlMeta = (sigRef, key) => {
|
|
449
|
+
const gqlMetaMap = Reflect.getMetadata("gql", sigRef.prototype);
|
|
450
|
+
if (!gqlMetaMap)
|
|
451
|
+
throw new Error(`No GqlMeta found for ${sigRef.name}`);
|
|
452
|
+
const gqlMeta = gqlMetaMap.get(key);
|
|
453
|
+
if (!gqlMeta)
|
|
454
|
+
throw new Error(`No GqlMeta found for ${key}`);
|
|
455
|
+
return gqlMeta;
|
|
456
|
+
};
|
|
457
|
+
const getGqlMetaMapOnPrototype = (prototype) => {
|
|
458
|
+
const gqlMetaMap = Reflect.getMetadata("gql", prototype);
|
|
459
|
+
return gqlMetaMap ?? /* @__PURE__ */ new Map();
|
|
460
|
+
};
|
|
461
|
+
const getGqlMetas = (sigRef) => {
|
|
462
|
+
const gqlMetaMap = Reflect.getMetadata("gql", sigRef.prototype);
|
|
463
|
+
return gqlMetaMap ? [...gqlMetaMap.values()] : [];
|
|
464
|
+
};
|
|
465
|
+
const setGqlMetaMapOnPrototype = (prototype, gqlMetaMap) => {
|
|
466
|
+
Reflect.defineMetadata("gql", gqlMetaMap, prototype);
|
|
467
|
+
};
|
|
468
|
+
const getArgMetas = (sigRef, key) => {
|
|
469
|
+
const metas = Reflect.getMetadata("args", sigRef.prototype, key) ?? [];
|
|
470
|
+
const argMetas = metas.filter((meta) => !!meta.returns);
|
|
471
|
+
const internalArgMetas = metas.filter((meta) => !meta.returns);
|
|
472
|
+
return [argMetas, internalArgMetas];
|
|
473
|
+
};
|
|
474
|
+
const getArgMetasOnPrototype = (prototype, key) => {
|
|
475
|
+
return Reflect.getMetadata("args", prototype, key) ?? [];
|
|
476
|
+
};
|
|
477
|
+
const setArgMetas = (sigRef, key, argMetas, internalArgMetas) => {
|
|
478
|
+
Reflect.defineMetadata("args", [...argMetas, ...internalArgMetas], sigRef.prototype, key);
|
|
479
|
+
};
|
|
480
|
+
const setArgMetasOnPrototype = (prototype, key, argMetas) => {
|
|
481
|
+
Reflect.defineMetadata("args", argMetas, prototype, key);
|
|
482
|
+
};
|
|
483
|
+
const getResolveFieldMetaMapOnPrototype = (prototype) => {
|
|
484
|
+
const resolveFieldMetaMap = Reflect.getMetadata("resolveField", prototype);
|
|
485
|
+
return resolveFieldMetaMap ?? /* @__PURE__ */ new Map();
|
|
486
|
+
};
|
|
487
|
+
const getResolveFieldMetas = (sigRef) => {
|
|
488
|
+
const resolveFieldMetaMap = Reflect.getMetadata("resolveField", sigRef.prototype);
|
|
489
|
+
return resolveFieldMetaMap ? [...resolveFieldMetaMap.values()] : [];
|
|
490
|
+
};
|
|
491
|
+
const setResolveFieldMetaMapOnPrototype = (prototype, resolveFieldMetaMap) => {
|
|
492
|
+
Reflect.defineMetadata("resolveField", resolveFieldMetaMap, prototype);
|
|
493
|
+
};
|
|
494
|
+
const getControllerPrefix = (sigMeta) => {
|
|
495
|
+
return sigMeta.returns ? (0, import_common.lowerlize)((0, import_constant.getClassMeta)(sigMeta.returns()).refName) : sigMeta.prefix;
|
|
496
|
+
};
|
|
497
|
+
const getControllerPath = (gqlMeta, paramArgMetas) => {
|
|
498
|
+
return gqlMeta.signalOption.path ?? [gqlMeta.signalOption.name ?? gqlMeta.key, ...paramArgMetas.map((argMeta) => `:${argMeta.name}`)].join("/");
|
|
499
|
+
};
|
|
500
|
+
const copySignal = (sigRef) => {
|
|
501
|
+
class CopiedSignal {
|
|
502
|
+
}
|
|
503
|
+
(0, import_common.applyMixins)(CopiedSignal, [sigRef]);
|
|
504
|
+
const sigMeta = getSigMeta(sigRef);
|
|
505
|
+
setSigMeta(CopiedSignal, sigMeta);
|
|
506
|
+
const gqlMetaMap = getGqlMetaMapOnPrototype(sigRef.prototype);
|
|
507
|
+
setGqlMetaMapOnPrototype(CopiedSignal.prototype, new Map(gqlMetaMap));
|
|
508
|
+
const resolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(sigRef.prototype);
|
|
509
|
+
setResolveFieldMetaMapOnPrototype(CopiedSignal.prototype, new Map(resolveFieldMetaMap));
|
|
510
|
+
for (const endpointMeta of [...gqlMetaMap.values(), ...resolveFieldMetaMap.values()]) {
|
|
511
|
+
const argMetas = getArgMetasOnPrototype(sigRef.prototype, endpointMeta.key);
|
|
512
|
+
setArgMetasOnPrototype(CopiedSignal.prototype, endpointMeta.key, [...argMetas]);
|
|
513
|
+
const paramtypes = Reflect.getMetadata(
|
|
514
|
+
"design:paramtypes",
|
|
515
|
+
sigRef.prototype,
|
|
516
|
+
endpointMeta.key
|
|
517
|
+
);
|
|
518
|
+
Reflect.defineMetadata("design:paramtypes", [...paramtypes], CopiedSignal.prototype, endpointMeta.key);
|
|
519
|
+
}
|
|
520
|
+
return CopiedSignal;
|
|
521
|
+
};
|
|
522
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
523
|
+
0 && (module.exports = {
|
|
524
|
+
Access,
|
|
525
|
+
Account,
|
|
526
|
+
Arg,
|
|
527
|
+
DbSignal,
|
|
528
|
+
Job,
|
|
529
|
+
LogSignal,
|
|
530
|
+
Me,
|
|
531
|
+
Message,
|
|
532
|
+
Mutation,
|
|
533
|
+
Parent,
|
|
534
|
+
Process,
|
|
535
|
+
Pubsub,
|
|
536
|
+
Query,
|
|
537
|
+
Req,
|
|
538
|
+
Res,
|
|
539
|
+
ResolveField,
|
|
540
|
+
Self,
|
|
541
|
+
Signal,
|
|
542
|
+
SignalStorage,
|
|
543
|
+
UserIp,
|
|
544
|
+
Ws,
|
|
545
|
+
argTypes,
|
|
546
|
+
copySignal,
|
|
547
|
+
createArgMetaDecorator,
|
|
548
|
+
defaultAccount,
|
|
549
|
+
done,
|
|
550
|
+
emit,
|
|
551
|
+
endpointTypes,
|
|
552
|
+
getAllSignalRefs,
|
|
553
|
+
getArgMetas,
|
|
554
|
+
getControllerPath,
|
|
555
|
+
getControllerPrefix,
|
|
556
|
+
getGqlMeta,
|
|
557
|
+
getGqlMetaMapOnPrototype,
|
|
558
|
+
getGqlMetas,
|
|
559
|
+
getResolveFieldMetas,
|
|
560
|
+
getSigMeta,
|
|
561
|
+
getSignalRefsOnStorage,
|
|
562
|
+
guardTypes,
|
|
563
|
+
internalArgTypes,
|
|
564
|
+
resolve,
|
|
565
|
+
roleTypes,
|
|
566
|
+
setArgMetas,
|
|
567
|
+
setGqlMetaMapOnPrototype,
|
|
568
|
+
signalTypes,
|
|
569
|
+
ssoTypes,
|
|
570
|
+
subscribe
|
|
571
|
+
});
|