@akanjs/signal 0.0.97 → 0.0.99
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/index.cjs +17 -0
- package/index.js +1 -17
- package/package.json +5 -5
- package/src/baseFetch.cjs +34 -0
- package/src/baseFetch.js +5 -24
- package/src/{client.mjs → client.cjs} +40 -21
- package/src/client.js +21 -40
- package/src/doc.cjs +101 -0
- package/src/doc.js +23 -42
- package/src/{gql.mjs → gql.cjs} +141 -144
- package/src/gql.js +144 -141
- package/src/immerify.cjs +35 -0
- package/src/immerify.js +7 -26
- package/src/index.cjs +30 -0
- package/src/index.js +9 -29
- package/src/{signalDecorators.mjs → signalDecorators.cjs} +95 -87
- package/src/signalDecorators.js +87 -95
- package/index.mjs +0 -1
- package/src/baseFetch.mjs +0 -15
- package/src/doc.mjs +0 -82
- package/src/immerify.mjs +0 -16
- package/src/index.mjs +0 -10
package/src/signalDecorators.js
CHANGED
|
@@ -1,20 +1,5 @@
|
|
|
1
1
|
var __defProp = Object.defineProperty;
|
|
2
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
3
|
var __decorateClass = (decorators, target, key, kind) => {
|
|
19
4
|
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
20
5
|
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
@@ -25,62 +10,20 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
25
10
|
return result;
|
|
26
11
|
};
|
|
27
12
|
var __decorateParam = (index, decorator) => (target, key) => decorator(target, key, index);
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
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");
|
|
13
|
+
import "reflect-metadata";
|
|
14
|
+
import {
|
|
15
|
+
baseEnv,
|
|
16
|
+
getNonArrayModel,
|
|
17
|
+
ID,
|
|
18
|
+
Int,
|
|
19
|
+
JSON,
|
|
20
|
+
scalarArgMap
|
|
21
|
+
} from "@akanjs/base";
|
|
22
|
+
import { applyMixins, capitalize, lowerlize } from "@akanjs/common";
|
|
23
|
+
import {
|
|
24
|
+
getClassMeta
|
|
25
|
+
} from "@akanjs/constant";
|
|
26
|
+
import { makeDefault } from "./gql";
|
|
84
27
|
const ssoTypes = ["github", "google", "facebook", "apple", "naver", "kakao"];
|
|
85
28
|
class SignalStorage {
|
|
86
29
|
}
|
|
@@ -118,10 +61,10 @@ const internalArgTypes = [
|
|
|
118
61
|
"Job"
|
|
119
62
|
];
|
|
120
63
|
const getDefaultArg = (argRef) => {
|
|
121
|
-
const [modelRef, arrDepth] =
|
|
64
|
+
const [modelRef, arrDepth] = getNonArrayModel(argRef);
|
|
122
65
|
if (arrDepth)
|
|
123
66
|
return [];
|
|
124
|
-
const scalarArg =
|
|
67
|
+
const scalarArg = scalarArgMap.get(modelRef);
|
|
125
68
|
if (scalarArg)
|
|
126
69
|
return scalarArg;
|
|
127
70
|
else
|
|
@@ -133,9 +76,9 @@ function Signal(returnsOrObj) {
|
|
|
133
76
|
return function(target) {
|
|
134
77
|
if (returns) {
|
|
135
78
|
const modelRef = returns();
|
|
136
|
-
const classMeta =
|
|
79
|
+
const classMeta = getClassMeta(modelRef);
|
|
137
80
|
const gqlMetas = getGqlMetas(target);
|
|
138
|
-
const modelName =
|
|
81
|
+
const modelName = lowerlize(classMeta.refName);
|
|
139
82
|
const listName = `${modelName}ListIn`;
|
|
140
83
|
const slices = [
|
|
141
84
|
{ refName: modelName, sliceName: modelName, argLength: 1, defaultArgs: [{}] },
|
|
@@ -143,7 +86,7 @@ function Signal(returnsOrObj) {
|
|
|
143
86
|
const name = gqlMeta.signalOption.name ?? gqlMeta.key;
|
|
144
87
|
if (!name.includes(listName))
|
|
145
88
|
return false;
|
|
146
|
-
const [retRef, arrDepth] =
|
|
89
|
+
const [retRef, arrDepth] = getNonArrayModel(gqlMeta.returns());
|
|
147
90
|
return retRef.prototype === modelRef.prototype && arrDepth === 1;
|
|
148
91
|
}).map((gqlMeta) => {
|
|
149
92
|
const name = gqlMeta.signalOption.name ?? gqlMeta.key;
|
|
@@ -163,7 +106,7 @@ function Signal(returnsOrObj) {
|
|
|
163
106
|
setSigMeta(target, { returns, prefix, slices, refName: modelName });
|
|
164
107
|
setSignalRefOnStorage(modelName, target);
|
|
165
108
|
} else {
|
|
166
|
-
const refName = typeof returnsOrObj === "object" ?
|
|
109
|
+
const refName = typeof returnsOrObj === "object" ? lowerlize(returnsOrObj.name) : void 0;
|
|
167
110
|
if (!refName)
|
|
168
111
|
throw new Error("Signal name is required");
|
|
169
112
|
setSigMeta(target, { returns, prefix, slices: [], refName });
|
|
@@ -183,8 +126,8 @@ const createArgMetaDecorator = (type) => {
|
|
|
183
126
|
const Account = createArgMetaDecorator("Account");
|
|
184
127
|
const defaultAccount = {
|
|
185
128
|
__InternalArg__: "Account",
|
|
186
|
-
appName:
|
|
187
|
-
environment:
|
|
129
|
+
appName: baseEnv.appName,
|
|
130
|
+
environment: baseEnv.environment
|
|
188
131
|
};
|
|
189
132
|
const Self = createArgMetaDecorator("Self");
|
|
190
133
|
const Me = createArgMetaDecorator("Me");
|
|
@@ -255,7 +198,7 @@ const getProcess = (serverType) => function(returns, signalOption = {}) {
|
|
|
255
198
|
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
256
199
|
metadataMap.set(key, {
|
|
257
200
|
returns,
|
|
258
|
-
signalOption: { ...signalOption, serverType:
|
|
201
|
+
signalOption: { ...signalOption, serverType: lowerlize(serverType) },
|
|
259
202
|
key,
|
|
260
203
|
descriptor,
|
|
261
204
|
guards: ["None"],
|
|
@@ -341,9 +284,9 @@ function LogSignal(srv) {
|
|
|
341
284
|
}
|
|
342
285
|
function DbSignal(constant, srv, option) {
|
|
343
286
|
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
344
|
-
const meta =
|
|
345
|
-
const serviceName = `${
|
|
346
|
-
const [modelName, className] = [
|
|
287
|
+
const meta = getClassMeta(constant.Full);
|
|
288
|
+
const serviceName = `${lowerlize(meta.refName)}Service`;
|
|
289
|
+
const [modelName, className] = [lowerlize(meta.refName), capitalize(meta.refName)];
|
|
347
290
|
const names = {
|
|
348
291
|
modelId: `${modelName}Id`,
|
|
349
292
|
model: modelName,
|
|
@@ -374,7 +317,7 @@ function DbSignal(constant, srv, option) {
|
|
|
374
317
|
}
|
|
375
318
|
async [_d = names.modelInsight](query) {
|
|
376
319
|
const service = this[serviceName];
|
|
377
|
-
const insight = query.$search ? { ...
|
|
320
|
+
const insight = query.$search ? { ...makeDefault(constant.Insight), count: await service.__searchCount(query.$search) } : await service.__insight(query);
|
|
378
321
|
return resolve(insight);
|
|
379
322
|
}
|
|
380
323
|
async [_e = names.modelExists](query) {
|
|
@@ -400,26 +343,26 @@ function DbSignal(constant, srv, option) {
|
|
|
400
343
|
}
|
|
401
344
|
__decorateClass([
|
|
402
345
|
option.guards.get(() => constant.Light),
|
|
403
|
-
__decorateParam(0, Arg.Param(names.modelId, () =>
|
|
346
|
+
__decorateParam(0, Arg.Param(names.modelId, () => ID))
|
|
404
347
|
], BaseSignal.prototype, _a, 1);
|
|
405
348
|
__decorateClass([
|
|
406
349
|
option.guards.get(() => constant.Full),
|
|
407
|
-
__decorateParam(0, Arg.Param(names.modelId, () =>
|
|
350
|
+
__decorateParam(0, Arg.Param(names.modelId, () => ID))
|
|
408
351
|
], BaseSignal.prototype, _b, 1);
|
|
409
352
|
__decorateClass([
|
|
410
353
|
Query.Admin(() => [constant.Full]),
|
|
411
|
-
__decorateParam(0, Arg.Query("query", () =>
|
|
412
|
-
__decorateParam(1, Arg.Query("skip", () =>
|
|
413
|
-
__decorateParam(2, Arg.Query("limit", () =>
|
|
354
|
+
__decorateParam(0, Arg.Query("query", () => JSON)),
|
|
355
|
+
__decorateParam(1, Arg.Query("skip", () => Int, { nullable: true, example: 0 })),
|
|
356
|
+
__decorateParam(2, Arg.Query("limit", () => Int, { nullable: true, example: 20 })),
|
|
414
357
|
__decorateParam(3, Arg.Query("sort", () => String, { nullable: true, example: "latest" }))
|
|
415
358
|
], BaseSignal.prototype, _c, 1);
|
|
416
359
|
__decorateClass([
|
|
417
360
|
Query.Admin(() => constant.Insight),
|
|
418
|
-
__decorateParam(0, Arg.Query("query", () =>
|
|
361
|
+
__decorateParam(0, Arg.Query("query", () => JSON))
|
|
419
362
|
], BaseSignal.prototype, _d, 1);
|
|
420
363
|
__decorateClass([
|
|
421
364
|
Query.Admin(() => Boolean),
|
|
422
|
-
__decorateParam(0, Arg.Query("query", () =>
|
|
365
|
+
__decorateParam(0, Arg.Query("query", () => JSON))
|
|
423
366
|
], BaseSignal.prototype, _e, 1);
|
|
424
367
|
__decorateClass([
|
|
425
368
|
option.guards.cru(() => constant.Full),
|
|
@@ -427,12 +370,12 @@ function DbSignal(constant, srv, option) {
|
|
|
427
370
|
], BaseSignal.prototype, _f, 1);
|
|
428
371
|
__decorateClass([
|
|
429
372
|
option.guards.cru(() => constant.Full),
|
|
430
|
-
__decorateParam(0, Arg.Param(names.modelId, () =>
|
|
373
|
+
__decorateParam(0, Arg.Param(names.modelId, () => ID)),
|
|
431
374
|
__decorateParam(1, Arg.Body("data", () => constant.Input))
|
|
432
375
|
], BaseSignal.prototype, _g, 1);
|
|
433
376
|
__decorateClass([
|
|
434
377
|
option.guards.cru(() => constant.Full, { partial: ["status", "removedAt"] }),
|
|
435
|
-
__decorateParam(0, Arg.Param(names.modelId, () =>
|
|
378
|
+
__decorateParam(0, Arg.Param(names.modelId, () => ID))
|
|
436
379
|
], BaseSignal.prototype, _h, 1);
|
|
437
380
|
return BaseSignal;
|
|
438
381
|
}
|
|
@@ -492,7 +435,7 @@ const setResolveFieldMetaMapOnPrototype = (prototype, resolveFieldMetaMap) => {
|
|
|
492
435
|
Reflect.defineMetadata("resolveField", resolveFieldMetaMap, prototype);
|
|
493
436
|
};
|
|
494
437
|
const getControllerPrefix = (sigMeta) => {
|
|
495
|
-
return sigMeta.returns ?
|
|
438
|
+
return sigMeta.returns ? lowerlize(getClassMeta(sigMeta.returns()).refName) : sigMeta.prefix;
|
|
496
439
|
};
|
|
497
440
|
const getControllerPath = (gqlMeta, paramArgMetas) => {
|
|
498
441
|
return gqlMeta.signalOption.path ?? [gqlMeta.signalOption.name ?? gqlMeta.key, ...paramArgMetas.map((argMeta) => `:${argMeta.name}`)].join("/");
|
|
@@ -500,7 +443,7 @@ const getControllerPath = (gqlMeta, paramArgMetas) => {
|
|
|
500
443
|
const copySignal = (sigRef) => {
|
|
501
444
|
class CopiedSignal {
|
|
502
445
|
}
|
|
503
|
-
|
|
446
|
+
applyMixins(CopiedSignal, [sigRef]);
|
|
504
447
|
const sigMeta = getSigMeta(sigRef);
|
|
505
448
|
setSigMeta(CopiedSignal, sigMeta);
|
|
506
449
|
const gqlMetaMap = getGqlMetaMapOnPrototype(sigRef.prototype);
|
|
@@ -518,3 +461,52 @@ const copySignal = (sigRef) => {
|
|
|
518
461
|
}
|
|
519
462
|
return CopiedSignal;
|
|
520
463
|
};
|
|
464
|
+
export {
|
|
465
|
+
Access,
|
|
466
|
+
Account,
|
|
467
|
+
Arg,
|
|
468
|
+
DbSignal,
|
|
469
|
+
Job,
|
|
470
|
+
LogSignal,
|
|
471
|
+
Me,
|
|
472
|
+
Message,
|
|
473
|
+
Mutation,
|
|
474
|
+
Parent,
|
|
475
|
+
Process,
|
|
476
|
+
Pubsub,
|
|
477
|
+
Query,
|
|
478
|
+
Req,
|
|
479
|
+
Res,
|
|
480
|
+
ResolveField,
|
|
481
|
+
Self,
|
|
482
|
+
Signal,
|
|
483
|
+
SignalStorage,
|
|
484
|
+
UserIp,
|
|
485
|
+
Ws,
|
|
486
|
+
argTypes,
|
|
487
|
+
copySignal,
|
|
488
|
+
createArgMetaDecorator,
|
|
489
|
+
defaultAccount,
|
|
490
|
+
done,
|
|
491
|
+
emit,
|
|
492
|
+
endpointTypes,
|
|
493
|
+
getAllSignalRefs,
|
|
494
|
+
getArgMetas,
|
|
495
|
+
getControllerPath,
|
|
496
|
+
getControllerPrefix,
|
|
497
|
+
getGqlMeta,
|
|
498
|
+
getGqlMetaMapOnPrototype,
|
|
499
|
+
getGqlMetas,
|
|
500
|
+
getResolveFieldMetas,
|
|
501
|
+
getSigMeta,
|
|
502
|
+
getSignalRefsOnStorage,
|
|
503
|
+
guardTypes,
|
|
504
|
+
internalArgTypes,
|
|
505
|
+
resolve,
|
|
506
|
+
roleTypes,
|
|
507
|
+
setArgMetas,
|
|
508
|
+
setGqlMetaMapOnPrototype,
|
|
509
|
+
signalTypes,
|
|
510
|
+
ssoTypes,
|
|
511
|
+
subscribe
|
|
512
|
+
};
|
package/index.mjs
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./src";
|
package/src/baseFetch.mjs
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { client } from "./client";
|
|
2
|
-
const nativeFetch = fetch;
|
|
3
|
-
const baseFetch = Object.assign(nativeFetch, {
|
|
4
|
-
client,
|
|
5
|
-
clone: function(option = {}) {
|
|
6
|
-
return {
|
|
7
|
-
...this,
|
|
8
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-call, @typescript-eslint/no-unsafe-member-access
|
|
9
|
-
client: this.client.clone(option)
|
|
10
|
-
};
|
|
11
|
-
}
|
|
12
|
-
});
|
|
13
|
-
export {
|
|
14
|
-
baseFetch
|
|
15
|
-
};
|
package/src/doc.mjs
DELETED
|
@@ -1,82 +0,0 @@
|
|
|
1
|
-
import { arraiedModel, getNonArrayModel, isGqlScalar, JSON as GqlJSON } from "@akanjs/base";
|
|
2
|
-
import { getFieldMetas, getScalarExample } from "@akanjs/constant";
|
|
3
|
-
import { getArgMetas, getGqlMeta } from "./signalDecorators";
|
|
4
|
-
class ResponseExampleStorage {
|
|
5
|
-
}
|
|
6
|
-
const getPredefinedRequestExample = (modelRef) => {
|
|
7
|
-
return Reflect.getMetadata(modelRef, ResponseExampleStorage.prototype);
|
|
8
|
-
};
|
|
9
|
-
const getPredefinedResponseExample = (modelRef) => {
|
|
10
|
-
return Reflect.getMetadata(modelRef, ResponseExampleStorage.prototype);
|
|
11
|
-
};
|
|
12
|
-
const getResponseExample = (ref) => {
|
|
13
|
-
const [modelRef, arrDepth] = getNonArrayModel(ref);
|
|
14
|
-
const existing = getPredefinedRequestExample(modelRef);
|
|
15
|
-
if (existing)
|
|
16
|
-
return existing;
|
|
17
|
-
const isScalar = isGqlScalar(modelRef);
|
|
18
|
-
if (isScalar)
|
|
19
|
-
return arraiedModel(getScalarExample(modelRef), arrDepth);
|
|
20
|
-
const fieldMetas = getFieldMetas(modelRef);
|
|
21
|
-
const example = {};
|
|
22
|
-
fieldMetas.forEach((fieldMeta) => {
|
|
23
|
-
if (fieldMeta.example)
|
|
24
|
-
example[fieldMeta.key] = fieldMeta.example;
|
|
25
|
-
else if (fieldMeta.enum)
|
|
26
|
-
example[fieldMeta.key] = arraiedModel(fieldMeta.enum.values[0], fieldMeta.arrDepth);
|
|
27
|
-
else
|
|
28
|
-
example[fieldMeta.key] = getResponseExample(fieldMeta.modelRef);
|
|
29
|
-
});
|
|
30
|
-
const result = arraiedModel(example, arrDepth);
|
|
31
|
-
Reflect.defineMetadata(ref, result, ResponseExampleStorage.prototype);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
class RequestExampleStorage {
|
|
35
|
-
}
|
|
36
|
-
const getRequestExample = (ref) => {
|
|
37
|
-
const existing = getPredefinedRequestExample(ref);
|
|
38
|
-
if (existing)
|
|
39
|
-
return existing;
|
|
40
|
-
const fieldMetas = getFieldMetas(ref);
|
|
41
|
-
const example = {};
|
|
42
|
-
const isScalar = isGqlScalar(ref);
|
|
43
|
-
if (isScalar)
|
|
44
|
-
return getScalarExample(ref);
|
|
45
|
-
else {
|
|
46
|
-
fieldMetas.forEach((fieldMeta) => {
|
|
47
|
-
if (!fieldMeta.isScalar && fieldMeta.isClass)
|
|
48
|
-
example[fieldMeta.key] = "ObjectID";
|
|
49
|
-
else
|
|
50
|
-
example[fieldMeta.key] = fieldMeta.example ?? fieldMeta.enum ? arraiedModel(fieldMeta.example ?? (fieldMeta.enum?.values)[0], fieldMeta.optArrDepth) : arraiedModel(getRequestExample(fieldMeta.modelRef), fieldMeta.arrDepth);
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
Reflect.defineMetadata(ref, example, RequestExampleStorage.prototype);
|
|
54
|
-
return example;
|
|
55
|
-
};
|
|
56
|
-
const makeRequestExample = (sigRef, key) => {
|
|
57
|
-
const [argMetas] = getArgMetas(sigRef, key);
|
|
58
|
-
return getExampleData(argMetas);
|
|
59
|
-
};
|
|
60
|
-
const getExampleData = (argMetas, signalType = "graphql") => Object.fromEntries(
|
|
61
|
-
argMetas.filter((argMeta) => argMeta.type !== "Upload").map((argMeta) => {
|
|
62
|
-
const [argRef, argArrDepth] = getNonArrayModel(argMeta.returns());
|
|
63
|
-
const example = argMeta.argsOption.example ?? getRequestExample(argRef);
|
|
64
|
-
return [
|
|
65
|
-
argMeta.name,
|
|
66
|
-
arraiedModel(
|
|
67
|
-
signalType === "restapi" && argRef.prototype === GqlJSON.prototype ? JSON.stringify(example, null, 2) : example,
|
|
68
|
-
argArrDepth
|
|
69
|
-
)
|
|
70
|
-
];
|
|
71
|
-
})
|
|
72
|
-
);
|
|
73
|
-
const makeResponseExample = (sigRef, key) => {
|
|
74
|
-
const gqlMeta = getGqlMeta(sigRef, key);
|
|
75
|
-
const example = getResponseExample(gqlMeta.returns());
|
|
76
|
-
return example;
|
|
77
|
-
};
|
|
78
|
-
export {
|
|
79
|
-
getExampleData,
|
|
80
|
-
makeRequestExample,
|
|
81
|
-
makeResponseExample
|
|
82
|
-
};
|
package/src/immerify.mjs
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { getFieldMetas } from "@akanjs/constant";
|
|
2
|
-
import { immerable } from "immer";
|
|
3
|
-
const immerify = (modelRef, objOrArr) => {
|
|
4
|
-
if (Array.isArray(objOrArr))
|
|
5
|
-
return objOrArr.map((val) => immerify(modelRef, val));
|
|
6
|
-
const fieldMetas = getFieldMetas(modelRef);
|
|
7
|
-
const immeredObj = Object.assign({}, objOrArr, { [immerable]: true });
|
|
8
|
-
fieldMetas.forEach((fieldMeta) => {
|
|
9
|
-
if (fieldMeta.isScalar && fieldMeta.isClass && !!objOrArr[fieldMeta.key])
|
|
10
|
-
immeredObj[fieldMeta.key] = immerify(fieldMeta.modelRef, objOrArr[fieldMeta.key]);
|
|
11
|
-
});
|
|
12
|
-
return immeredObj;
|
|
13
|
-
};
|
|
14
|
-
export {
|
|
15
|
-
immerify
|
|
16
|
-
};
|
package/src/index.mjs
DELETED