@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
package/cjs/src/apiInfo.js
CHANGED
|
@@ -26,34 +26,30 @@ var import_signalDecorators = require("./signalDecorators");
|
|
|
26
26
|
var import_signalInfo = require("./signalInfo");
|
|
27
27
|
class ApiInfo {
|
|
28
28
|
type;
|
|
29
|
+
argNames = [];
|
|
29
30
|
args = [];
|
|
30
31
|
internalArgs = [];
|
|
31
32
|
returnRef;
|
|
32
33
|
signalOption;
|
|
33
|
-
guards;
|
|
34
34
|
execFn = null;
|
|
35
|
-
constructor(type, returnRef,
|
|
35
|
+
constructor(type, returnRef, signalOption = {}) {
|
|
36
36
|
this.type = type;
|
|
37
37
|
this.returnRef = returnRef;
|
|
38
|
-
this.signalOption =
|
|
39
|
-
this.guards = [
|
|
40
|
-
.../* @__PURE__ */ new Set([
|
|
41
|
-
...guards,
|
|
42
|
-
...typeof signalOptionOrGuard === "string" ? [signalOptionOrGuard] : ["Public"]
|
|
43
|
-
])
|
|
44
|
-
];
|
|
38
|
+
this.signalOption = signalOption;
|
|
45
39
|
}
|
|
46
40
|
param(name, argRef, option) {
|
|
47
41
|
if (this.execFn)
|
|
48
42
|
throw new Error("Query function is already set");
|
|
49
43
|
else if (this.args.at(-1)?.option?.nullable)
|
|
50
44
|
throw new Error("Last argument is nullable");
|
|
45
|
+
this.argNames.push(name);
|
|
51
46
|
this.args.push({ type: "Param", name, argRef, option });
|
|
52
47
|
return this;
|
|
53
48
|
}
|
|
54
49
|
body(name, argRef, option) {
|
|
55
50
|
if (this.execFn)
|
|
56
51
|
throw new Error("Query function is already set");
|
|
52
|
+
this.argNames.push(name);
|
|
57
53
|
this.args.push({ type: "Body", name, argRef, option });
|
|
58
54
|
return this;
|
|
59
55
|
}
|
|
@@ -62,6 +58,7 @@ class ApiInfo {
|
|
|
62
58
|
throw new Error("Query function is already set");
|
|
63
59
|
else if (this.args.at(-1)?.option?.nullable)
|
|
64
60
|
throw new Error("Last argument is nullable");
|
|
61
|
+
this.argNames.push(name);
|
|
65
62
|
this.args.push({ type: "Room", name, argRef, option });
|
|
66
63
|
return this;
|
|
67
64
|
}
|
|
@@ -70,12 +67,14 @@ class ApiInfo {
|
|
|
70
67
|
throw new Error("Query function is already set");
|
|
71
68
|
else if (this.args.at(-1)?.option?.nullable)
|
|
72
69
|
throw new Error("Last argument is nullable");
|
|
70
|
+
this.argNames.push(name);
|
|
73
71
|
this.args.push({ type: "Msg", name, argRef, option });
|
|
74
72
|
return this;
|
|
75
73
|
}
|
|
76
74
|
search(name, argRef, option) {
|
|
77
75
|
if (this.execFn)
|
|
78
76
|
throw new Error("Query function is already set");
|
|
77
|
+
this.argNames.push(name);
|
|
79
78
|
this.args.push({ type: "Query", name, argRef, option: { ...option, nullable: true } });
|
|
80
79
|
return this;
|
|
81
80
|
}
|
|
@@ -105,13 +104,12 @@ class ApiInfo {
|
|
|
105
104
|
const [singleReturnRef, returnArrDepth] = (0, import_base.getNonArrayModel)(this.returnRef);
|
|
106
105
|
const apiMeta = {
|
|
107
106
|
returns: () => (0, import_base.arraiedModel)(
|
|
108
|
-
|
|
107
|
+
(0, import_base.isEnum)(singleReturnRef) ? singleReturnRef.type : singleReturnRef,
|
|
109
108
|
returnArrDepth
|
|
110
109
|
),
|
|
111
110
|
signalOption: this.signalOption,
|
|
112
111
|
key,
|
|
113
112
|
descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true },
|
|
114
|
-
guards: this.guards,
|
|
115
113
|
type: ApiInfo.#typeTempMap[this.type]
|
|
116
114
|
};
|
|
117
115
|
sigRef.prototype[key] = this.execFn;
|
|
@@ -120,11 +118,15 @@ class ApiInfo {
|
|
|
120
118
|
(0, import_signalDecorators.setGqlMetaMapOnPrototype)(sigRef.prototype, metadataMap);
|
|
121
119
|
const argMetas = this.args.map((arg, idx) => {
|
|
122
120
|
const [singleArgRef, argArrDepth] = (0, import_base.getNonArrayModel)(arg.argRef);
|
|
123
|
-
const
|
|
121
|
+
const isEnumValue = (0, import_base.isEnum)(singleArgRef);
|
|
122
|
+
const returnRef = (0, import_base.arraiedModel)(
|
|
123
|
+
isEnumValue ? singleArgRef.type : singleArgRef,
|
|
124
|
+
argArrDepth
|
|
125
|
+
);
|
|
124
126
|
return {
|
|
125
127
|
name: arg.name,
|
|
126
128
|
returns: () => returnRef,
|
|
127
|
-
argsOption: { ...arg.option, enum:
|
|
129
|
+
argsOption: { ...arg.option, enum: isEnumValue ? arg.argRef : void 0 },
|
|
128
130
|
key,
|
|
129
131
|
idx,
|
|
130
132
|
type: arg.type
|
|
@@ -140,28 +142,8 @@ class ApiInfo {
|
|
|
140
142
|
}
|
|
141
143
|
}
|
|
142
144
|
const makeApiBuilder = () => ({
|
|
143
|
-
query: (returnRef,
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
...guards
|
|
148
|
-
),
|
|
149
|
-
mutation: (returnRef, signalOptionOrGuard, ...guards) => new ApiInfo(
|
|
150
|
-
"mutation",
|
|
151
|
-
returnRef,
|
|
152
|
-
signalOptionOrGuard,
|
|
153
|
-
...guards
|
|
154
|
-
),
|
|
155
|
-
pubsub: (returnRef, signalOptionOrGuard, ...guards) => new ApiInfo(
|
|
156
|
-
"pubsub",
|
|
157
|
-
returnRef,
|
|
158
|
-
signalOptionOrGuard,
|
|
159
|
-
...guards
|
|
160
|
-
),
|
|
161
|
-
message: (returnRef, signalOptionOrGuard, ...guards) => new ApiInfo(
|
|
162
|
-
"message",
|
|
163
|
-
returnRef,
|
|
164
|
-
signalOptionOrGuard,
|
|
165
|
-
...guards
|
|
166
|
-
)
|
|
145
|
+
query: (returnRef, signalOption) => new ApiInfo("query", returnRef, signalOption),
|
|
146
|
+
mutation: (returnRef, signalOption) => new ApiInfo("mutation", returnRef, signalOption),
|
|
147
|
+
pubsub: (returnRef, signalOption) => new ApiInfo("pubsub", returnRef, signalOption),
|
|
148
|
+
message: (returnRef, signalOption) => new ApiInfo("message", returnRef, signalOption)
|
|
167
149
|
});
|
package/cjs/src/base.signal.js
CHANGED
|
@@ -17,6 +17,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var base_signal_exports = {};
|
|
19
19
|
__export(base_signal_exports, {
|
|
20
|
+
Base: () => Base,
|
|
20
21
|
BaseEndpoint: () => BaseEndpoint,
|
|
21
22
|
BaseInternal: () => BaseInternal,
|
|
22
23
|
BaseSignal: () => BaseSignal
|
|
@@ -81,3 +82,5 @@ class BaseEndpoint extends (0, import_signalDecorators.endpoint)(srvBase, ({ que
|
|
|
81
82
|
}
|
|
82
83
|
class BaseSignal extends (0, import_signalDecorators.mergeSignals)(BaseEndpoint, BaseInternal) {
|
|
83
84
|
}
|
|
85
|
+
class Base extends (0, import_signalDecorators.serverSignalOf)(BaseSignal) {
|
|
86
|
+
}
|
package/cjs/src/doc.js
CHANGED
|
@@ -24,7 +24,6 @@ __export(doc_exports, {
|
|
|
24
24
|
module.exports = __toCommonJS(doc_exports);
|
|
25
25
|
var import_base = require("@akanjs/base");
|
|
26
26
|
var import_constant = require("@akanjs/constant");
|
|
27
|
-
var import_signalDecorators = require("./signalDecorators");
|
|
28
27
|
class ResponseExampleStorage {
|
|
29
28
|
}
|
|
30
29
|
const getPredefinedRequestExample = (modelRef) => {
|
|
@@ -77,25 +76,24 @@ const getRequestExample = (ref) => {
|
|
|
77
76
|
Reflect.defineMetadata(ref, example, RequestExampleStorage.prototype);
|
|
78
77
|
return example;
|
|
79
78
|
};
|
|
80
|
-
const makeRequestExample = (
|
|
81
|
-
|
|
82
|
-
return getExampleData(argMetas);
|
|
79
|
+
const makeRequestExample = (gqlMeta) => {
|
|
80
|
+
return getExampleData(gqlMeta.args);
|
|
83
81
|
};
|
|
84
82
|
const getExampleData = (argMetas, signalType = "graphql") => Object.fromEntries(
|
|
85
83
|
argMetas.filter((argMeta) => argMeta.type !== "Upload").map((argMeta) => {
|
|
86
|
-
const
|
|
84
|
+
const argRef = import_constant.constantInfo.getModelRef(argMeta.refName, argMeta.modelType);
|
|
87
85
|
const example = argMeta.argsOption.example ?? getRequestExample(argRef);
|
|
88
86
|
return [
|
|
89
87
|
argMeta.name,
|
|
90
88
|
(0, import_base.arraiedModel)(
|
|
91
89
|
signalType === "restapi" && argRef.prototype === import_base.JSON.prototype ? JSON.stringify(example, null, 2) : example,
|
|
92
|
-
|
|
90
|
+
argMeta.arrDepth
|
|
93
91
|
)
|
|
94
92
|
];
|
|
95
93
|
})
|
|
96
94
|
);
|
|
97
|
-
const makeResponseExample = (
|
|
98
|
-
const
|
|
99
|
-
const example = getResponseExample(gqlMeta.returns
|
|
95
|
+
const makeResponseExample = (gqlMeta) => {
|
|
96
|
+
const returnRef = import_constant.constantInfo.getModelRef(gqlMeta.returns.refName, gqlMeta.returns.modelType);
|
|
97
|
+
const example = getResponseExample((0, import_base.arraiedModel)(returnRef, gqlMeta.returns.arrDepth));
|
|
100
98
|
return example;
|
|
101
99
|
};
|
|
@@ -27,6 +27,7 @@ class InternalApiInfo {
|
|
|
27
27
|
type;
|
|
28
28
|
args = [];
|
|
29
29
|
internalArgs = [];
|
|
30
|
+
defaultArgs = [];
|
|
30
31
|
returnRef;
|
|
31
32
|
signalOption;
|
|
32
33
|
execFn = null;
|
|
@@ -34,6 +35,10 @@ class InternalApiInfo {
|
|
|
34
35
|
this.type = type;
|
|
35
36
|
this.returnRef = returnRef;
|
|
36
37
|
this.signalOption = signalOption;
|
|
38
|
+
if (type === "resolveField")
|
|
39
|
+
this.defaultArgs.push("Parent");
|
|
40
|
+
else if (type === "process")
|
|
41
|
+
this.defaultArgs.push("Job");
|
|
37
42
|
}
|
|
38
43
|
msg(name, argRef, option) {
|
|
39
44
|
if (this.execFn)
|
|
@@ -77,12 +82,12 @@ class InternalApiInfo {
|
|
|
77
82
|
Reflect.defineMetadata("resolveField", metadataMap, sigRef.prototype);
|
|
78
83
|
} else {
|
|
79
84
|
const metadataMap = (0, import_signalDecorators.getGqlMetaMapOnPrototype)(sigRef.prototype);
|
|
85
|
+
const isEnumValue = (0, import_base.isEnum)(this.returnRef);
|
|
80
86
|
const internalApiMeta = {
|
|
81
|
-
returns: () =>
|
|
87
|
+
returns: () => isEnumValue ? this.returnRef.type : this.returnRef,
|
|
82
88
|
signalOption: this.signalOption,
|
|
83
89
|
key,
|
|
84
90
|
descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true },
|
|
85
|
-
guards: ["None"],
|
|
86
91
|
type: InternalApiInfo.#typeTempMap[this.type]
|
|
87
92
|
};
|
|
88
93
|
sigRef.prototype[key] = this.execFn;
|
|
@@ -92,7 +97,7 @@ class InternalApiInfo {
|
|
|
92
97
|
const argMetas = this.args.map((arg, idx) => ({
|
|
93
98
|
name: arg.name,
|
|
94
99
|
returns: () => arg.argRef,
|
|
95
|
-
argsOption: { ...arg.option, enum: arg.argRef
|
|
100
|
+
argsOption: { ...arg.option, enum: (0, import_base.isEnum)(arg.argRef) ? arg.argRef : void 0 },
|
|
96
101
|
key,
|
|
97
102
|
idx,
|
|
98
103
|
type: arg.type
|
|
@@ -100,7 +105,7 @@ class InternalApiInfo {
|
|
|
100
105
|
const internalArgMetas = this.internalArgs.map((arg, idx) => ({
|
|
101
106
|
type: arg.type,
|
|
102
107
|
key,
|
|
103
|
-
idx,
|
|
108
|
+
idx: this.defaultArgs.length + this.args.length + idx,
|
|
104
109
|
option: arg.option
|
|
105
110
|
}));
|
|
106
111
|
(0, import_signalDecorators.setArgMetas)(sigRef, key, argMetas, internalArgMetas);
|
|
@@ -17,28 +17,9 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
17
17
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
18
|
var signalDecorators_exports = {};
|
|
19
19
|
__export(signalDecorators_exports, {
|
|
20
|
-
Access: () => Access,
|
|
21
|
-
Account: () => Account,
|
|
22
|
-
Arg: () => Arg,
|
|
23
|
-
Job: () => Job,
|
|
24
|
-
Me: () => Me,
|
|
25
|
-
Message: () => Message,
|
|
26
|
-
Mutation: () => Mutation,
|
|
27
|
-
Parent: () => Parent,
|
|
28
|
-
Process: () => Process,
|
|
29
|
-
Pubsub: () => Pubsub,
|
|
30
|
-
Query: () => Query,
|
|
31
|
-
Req: () => Req,
|
|
32
|
-
Res: () => Res,
|
|
33
|
-
ResolveField: () => ResolveField,
|
|
34
|
-
Schedule: () => Schedule,
|
|
35
|
-
Self: () => Self,
|
|
36
20
|
SignalStorage: () => SignalStorage,
|
|
37
|
-
UserIp: () => UserIp,
|
|
38
|
-
Ws: () => Ws,
|
|
39
21
|
argTypes: () => argTypes,
|
|
40
22
|
copySignal: () => copySignal,
|
|
41
|
-
createArgMetaDecorator: () => createArgMetaDecorator,
|
|
42
23
|
defaultAccount: () => defaultAccount,
|
|
43
24
|
done: () => done,
|
|
44
25
|
emit: () => emit,
|
|
@@ -56,19 +37,16 @@ __export(signalDecorators_exports, {
|
|
|
56
37
|
getResolveFieldMetas: () => getResolveFieldMetas,
|
|
57
38
|
getSigMeta: () => getSigMeta,
|
|
58
39
|
getSignalRefsOnStorage: () => getSignalRefsOnStorage,
|
|
59
|
-
guardTypes: () => guardTypes,
|
|
60
40
|
internal: () => internal,
|
|
61
|
-
internalArgTypes: () => internalArgTypes,
|
|
62
41
|
mergeSignals: () => mergeSignals,
|
|
63
42
|
resolve: () => resolve,
|
|
64
|
-
|
|
43
|
+
serverSignalOf: () => serverSignalOf,
|
|
65
44
|
setArgMetas: () => setArgMetas,
|
|
66
45
|
setGqlMetaMapOnPrototype: () => setGqlMetaMapOnPrototype,
|
|
67
46
|
setSigMeta: () => setSigMeta,
|
|
68
47
|
setSignalRefOnStorage: () => setSignalRefOnStorage,
|
|
69
48
|
signalTypes: () => signalTypes,
|
|
70
49
|
slice: () => slice,
|
|
71
|
-
ssoTypes: () => ssoTypes,
|
|
72
50
|
subscribe: () => subscribe
|
|
73
51
|
});
|
|
74
52
|
module.exports = __toCommonJS(signalDecorators_exports);
|
|
@@ -80,7 +58,6 @@ var import__ = require(".");
|
|
|
80
58
|
var import_apiInfo = require("./apiInfo");
|
|
81
59
|
var import_internalApiInfo = require("./internalApiInfo");
|
|
82
60
|
var import_signalInfo = require("./signalInfo");
|
|
83
|
-
const ssoTypes = ["github", "google", "facebook", "apple", "naver", "kakao"];
|
|
84
61
|
class SignalStorage {
|
|
85
62
|
}
|
|
86
63
|
const getAllSignalRefs = () => {
|
|
@@ -101,21 +78,7 @@ const done = (data) => data;
|
|
|
101
78
|
const subscribe = () => void 0;
|
|
102
79
|
const signalTypes = ["graphql", "restapi"];
|
|
103
80
|
const endpointTypes = ["Query", "Mutation", "Message", "Pubsub", "Process", "Schedule", "ResolveField"];
|
|
104
|
-
const guardTypes = ["Public", "None", "User", "Admin", "SuperAdmin", "Every", "Owner"];
|
|
105
|
-
const roleTypes = ["Public", "User", "Admin", "SuperAdmin"];
|
|
106
81
|
const argTypes = ["Body", "Param", "Query", "Upload", "Msg", "Room"];
|
|
107
|
-
const internalArgTypes = [
|
|
108
|
-
"Account",
|
|
109
|
-
"Me",
|
|
110
|
-
"Self",
|
|
111
|
-
"UserIp",
|
|
112
|
-
"Access",
|
|
113
|
-
"Parent",
|
|
114
|
-
"Req",
|
|
115
|
-
"Res",
|
|
116
|
-
"Ws",
|
|
117
|
-
"Job"
|
|
118
|
-
];
|
|
119
82
|
const getDefaultArg = (argRef) => {
|
|
120
83
|
const [modelRef, arrDepth] = (0, import_base.getNonArrayModel)(argRef);
|
|
121
84
|
if (arrDepth)
|
|
@@ -126,232 +89,10 @@ const getDefaultArg = (argRef) => {
|
|
|
126
89
|
else
|
|
127
90
|
return {};
|
|
128
91
|
};
|
|
129
|
-
const createArgMetaDecorator = (type) => {
|
|
130
|
-
return function(option = {}) {
|
|
131
|
-
return function(prototype, key, idx) {
|
|
132
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
133
|
-
argMetas[idx] = { key, idx, type, option };
|
|
134
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
135
|
-
};
|
|
136
|
-
};
|
|
137
|
-
};
|
|
138
|
-
const Account = createArgMetaDecorator("Account");
|
|
139
92
|
const defaultAccount = {
|
|
140
|
-
__InternalArg__: "Account",
|
|
141
93
|
appName: import_base.baseEnv.appName,
|
|
142
94
|
environment: import_base.baseEnv.environment
|
|
143
95
|
};
|
|
144
|
-
const Self = createArgMetaDecorator("Self");
|
|
145
|
-
const Me = createArgMetaDecorator("Me");
|
|
146
|
-
const UserIp = createArgMetaDecorator("UserIp");
|
|
147
|
-
const Access = createArgMetaDecorator("Access");
|
|
148
|
-
const Req = createArgMetaDecorator("Req");
|
|
149
|
-
const Res = createArgMetaDecorator("Res");
|
|
150
|
-
const Ws = createArgMetaDecorator("Ws");
|
|
151
|
-
const Job = createArgMetaDecorator("Job");
|
|
152
|
-
const getQuery = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
153
|
-
return (prototype, key, descriptor) => {
|
|
154
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
155
|
-
metadataMap.set(key, {
|
|
156
|
-
returns,
|
|
157
|
-
signalOption,
|
|
158
|
-
key,
|
|
159
|
-
descriptor,
|
|
160
|
-
guards: [allow, ...guards],
|
|
161
|
-
type: "Query"
|
|
162
|
-
});
|
|
163
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
164
|
-
};
|
|
165
|
-
};
|
|
166
|
-
const getMutation = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
167
|
-
return (prototype, key, descriptor) => {
|
|
168
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
169
|
-
metadataMap.set(key, {
|
|
170
|
-
returns,
|
|
171
|
-
signalOption,
|
|
172
|
-
key,
|
|
173
|
-
descriptor,
|
|
174
|
-
guards: [allow, ...guards],
|
|
175
|
-
type: "Mutation"
|
|
176
|
-
});
|
|
177
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
178
|
-
};
|
|
179
|
-
};
|
|
180
|
-
const getMessage = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
181
|
-
return (prototype, key, descriptor) => {
|
|
182
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
183
|
-
metadataMap.set(key, {
|
|
184
|
-
returns,
|
|
185
|
-
signalOption,
|
|
186
|
-
key,
|
|
187
|
-
descriptor,
|
|
188
|
-
guards: [allow, ...guards],
|
|
189
|
-
type: "Message"
|
|
190
|
-
});
|
|
191
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
192
|
-
};
|
|
193
|
-
};
|
|
194
|
-
const getPubsub = (allow) => function(returns, signalOption = {}, guards = []) {
|
|
195
|
-
return (prototype, key, descriptor) => {
|
|
196
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
197
|
-
metadataMap.set(key, {
|
|
198
|
-
returns,
|
|
199
|
-
signalOption,
|
|
200
|
-
key,
|
|
201
|
-
descriptor,
|
|
202
|
-
guards: [allow, ...guards],
|
|
203
|
-
type: "Pubsub"
|
|
204
|
-
});
|
|
205
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
206
|
-
};
|
|
207
|
-
};
|
|
208
|
-
const getProcess = (serverMode) => function(returns, signalOption = {}) {
|
|
209
|
-
return (prototype, key, descriptor) => {
|
|
210
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
211
|
-
metadataMap.set(key, {
|
|
212
|
-
returns,
|
|
213
|
-
signalOption: { ...signalOption, serverMode: (0, import_common.lowerlize)(serverMode) },
|
|
214
|
-
key,
|
|
215
|
-
descriptor,
|
|
216
|
-
guards: ["None"],
|
|
217
|
-
type: "Process"
|
|
218
|
-
});
|
|
219
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
220
|
-
};
|
|
221
|
-
};
|
|
222
|
-
const getScheduleInit = (scheduleType) => function(signalOption = {}) {
|
|
223
|
-
return (prototype, key, descriptor) => {
|
|
224
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
225
|
-
metadataMap.set(key, {
|
|
226
|
-
returns: () => import_base.JSON,
|
|
227
|
-
signalOption: { enabled: true, ...signalOption, scheduleType: (0, import_common.lowerlize)(scheduleType) },
|
|
228
|
-
key,
|
|
229
|
-
descriptor,
|
|
230
|
-
guards: ["None"],
|
|
231
|
-
type: "Schedule"
|
|
232
|
-
});
|
|
233
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
234
|
-
};
|
|
235
|
-
};
|
|
236
|
-
const getScheduleCron = () => function(cron, signalOption = {}) {
|
|
237
|
-
return (prototype, key, descriptor) => {
|
|
238
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
239
|
-
metadataMap.set(key, {
|
|
240
|
-
returns: () => import_base.JSON,
|
|
241
|
-
signalOption: { enabled: true, lock: true, ...signalOption, scheduleType: "cron", scheduleCron: cron },
|
|
242
|
-
key,
|
|
243
|
-
descriptor,
|
|
244
|
-
guards: ["None"],
|
|
245
|
-
type: "Schedule"
|
|
246
|
-
});
|
|
247
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
248
|
-
};
|
|
249
|
-
};
|
|
250
|
-
const getScheduleInterval = () => function(interval, signalOption = {}) {
|
|
251
|
-
return (prototype, key, descriptor) => {
|
|
252
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
253
|
-
metadataMap.set(key, {
|
|
254
|
-
returns: () => import_base.JSON,
|
|
255
|
-
signalOption: { enabled: true, lock: true, ...signalOption, scheduleType: "interval", scheduleTime: interval },
|
|
256
|
-
key,
|
|
257
|
-
descriptor,
|
|
258
|
-
guards: ["None"],
|
|
259
|
-
type: "Schedule"
|
|
260
|
-
});
|
|
261
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
262
|
-
};
|
|
263
|
-
};
|
|
264
|
-
const getScheduleTimeout = () => function(timeout, signalOption = {}) {
|
|
265
|
-
return (prototype, key, descriptor) => {
|
|
266
|
-
const metadataMap = getGqlMetaMapOnPrototype(prototype);
|
|
267
|
-
metadataMap.set(key, {
|
|
268
|
-
returns: () => import_base.JSON,
|
|
269
|
-
signalOption: { enabled: true, lock: true, ...signalOption, scheduleType: "timeout", scheduleTime: timeout },
|
|
270
|
-
key,
|
|
271
|
-
descriptor,
|
|
272
|
-
guards: ["None"],
|
|
273
|
-
type: "Schedule"
|
|
274
|
-
});
|
|
275
|
-
setGqlMetaMapOnPrototype(prototype, metadataMap);
|
|
276
|
-
};
|
|
277
|
-
};
|
|
278
|
-
const Query = {
|
|
279
|
-
Public: getQuery("Public"),
|
|
280
|
-
Every: getQuery("Every"),
|
|
281
|
-
Admin: getQuery("Admin"),
|
|
282
|
-
User: getQuery("User"),
|
|
283
|
-
SuperAdmin: getQuery("SuperAdmin"),
|
|
284
|
-
None: getQuery("None"),
|
|
285
|
-
Owner: getQuery("Owner")
|
|
286
|
-
};
|
|
287
|
-
const Mutation = {
|
|
288
|
-
Public: getMutation("Public"),
|
|
289
|
-
Every: getMutation("Every"),
|
|
290
|
-
Admin: getMutation("Admin"),
|
|
291
|
-
User: getMutation("User"),
|
|
292
|
-
SuperAdmin: getMutation("SuperAdmin"),
|
|
293
|
-
None: getMutation("None"),
|
|
294
|
-
Owner: getMutation("Owner")
|
|
295
|
-
};
|
|
296
|
-
const Message = {
|
|
297
|
-
Public: getMessage("Public"),
|
|
298
|
-
Every: getMessage("Every"),
|
|
299
|
-
Admin: getMessage("Admin"),
|
|
300
|
-
User: getMessage("User"),
|
|
301
|
-
SuperAdmin: getMessage("SuperAdmin"),
|
|
302
|
-
None: getMessage("None"),
|
|
303
|
-
Owner: getMessage("Owner")
|
|
304
|
-
};
|
|
305
|
-
const Pubsub = {
|
|
306
|
-
Public: getPubsub("Public"),
|
|
307
|
-
Every: getPubsub("Every"),
|
|
308
|
-
Admin: getPubsub("Admin"),
|
|
309
|
-
User: getPubsub("User"),
|
|
310
|
-
SuperAdmin: getPubsub("SuperAdmin"),
|
|
311
|
-
None: getPubsub("None"),
|
|
312
|
-
Owner: getPubsub("Owner")
|
|
313
|
-
};
|
|
314
|
-
const Process = {
|
|
315
|
-
Federation: getProcess("Federation"),
|
|
316
|
-
Batch: getProcess("Batch"),
|
|
317
|
-
All: getProcess("All")
|
|
318
|
-
};
|
|
319
|
-
const Schedule = {
|
|
320
|
-
Init: getScheduleInit("Init"),
|
|
321
|
-
Cron: getScheduleCron(),
|
|
322
|
-
Interval: getScheduleInterval(),
|
|
323
|
-
Timeout: getScheduleTimeout(),
|
|
324
|
-
Destroy: getScheduleInit("Destroy")
|
|
325
|
-
};
|
|
326
|
-
function ResolveField(returns, argsOption = {}) {
|
|
327
|
-
return function(target, key, descriptor) {
|
|
328
|
-
const metadataMap = getResolveFieldMetaMapOnPrototype(target);
|
|
329
|
-
metadataMap.set(key, { returns, argsOption, key, descriptor });
|
|
330
|
-
Reflect.defineMetadata("resolveField", metadataMap, target);
|
|
331
|
-
};
|
|
332
|
-
}
|
|
333
|
-
const getArg = (type) => function(name, returns, argsOption = {}) {
|
|
334
|
-
return function(prototype, key, idx) {
|
|
335
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
336
|
-
argMetas[idx] = { name, returns, argsOption, key, idx, type };
|
|
337
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
338
|
-
};
|
|
339
|
-
};
|
|
340
|
-
const Arg = {
|
|
341
|
-
Body: getArg("Body"),
|
|
342
|
-
Param: getArg("Param"),
|
|
343
|
-
Query: getArg("Query"),
|
|
344
|
-
Upload: getArg("Upload"),
|
|
345
|
-
Msg: getArg("Msg"),
|
|
346
|
-
Room: getArg("Room")
|
|
347
|
-
};
|
|
348
|
-
function Parent() {
|
|
349
|
-
return function(prototype, key, idx) {
|
|
350
|
-
const argMetas = getArgMetasOnPrototype(prototype, key);
|
|
351
|
-
argMetas[idx] = { key, idx, type: "Parent" };
|
|
352
|
-
setArgMetasOnPrototype(prototype, key, argMetas);
|
|
353
|
-
};
|
|
354
|
-
}
|
|
355
96
|
function internal(srv, internalBuilder, ...libInternals) {
|
|
356
97
|
const sigRef = libInternals.at(0) ?? class Internal {
|
|
357
98
|
};
|
|
@@ -379,37 +120,44 @@ function slice(srv, option, sliceBuilder, ...libSlices) {
|
|
|
379
120
|
updateModel: `update${className}`,
|
|
380
121
|
removeModel: `remove${className}`
|
|
381
122
|
};
|
|
382
|
-
const
|
|
383
|
-
const
|
|
384
|
-
const
|
|
123
|
+
const rootGuards = option.guards?.root ? Array.isArray(option.guards.root) ? option.guards.root : [option.guards.root] : [];
|
|
124
|
+
const getGuards = option.guards?.get ? Array.isArray(option.guards.get) ? option.guards.get : [option.guards.get] : [];
|
|
125
|
+
const cruGuards = option.guards?.cru ? Array.isArray(option.guards.cru) ? option.guards.cru : [option.guards.cru] : [];
|
|
126
|
+
const init = (0, import__.sliceInit)(modelName, srv.cnst.full, srv.cnst.light, srv.cnst.insight);
|
|
385
127
|
const { query, mutation } = (0, import_apiInfo.makeApiBuilder)();
|
|
386
128
|
const buildSlice = {
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
129
|
+
...rootGuards.length > 0 ? {
|
|
130
|
+
[""]: init({ guards: rootGuards }).search("query", import_base.JSON).exec(function(query2) {
|
|
131
|
+
return query2 ?? {};
|
|
132
|
+
})
|
|
133
|
+
} : {},
|
|
390
134
|
...sliceBuilder(init)
|
|
391
135
|
};
|
|
392
136
|
const buildEndpoint = {
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
137
|
+
...getGuards.length > 0 ? {
|
|
138
|
+
[names.model]: query(srv.cnst.full, { guards: getGuards }).param(names.modelId, import_base.ID).exec(async function(modelId) {
|
|
139
|
+
const service = this[names.modelService];
|
|
140
|
+
return await service[names.getModel](modelId);
|
|
141
|
+
}),
|
|
142
|
+
[names.lightModel]: query(srv.cnst.light, { guards: getGuards }).param(names.modelId, import_base.ID).exec(async function(modelId) {
|
|
143
|
+
const service = this[names.modelService];
|
|
144
|
+
return await service[names.getModel](modelId);
|
|
145
|
+
})
|
|
146
|
+
} : {},
|
|
147
|
+
...cruGuards.length > 0 ? {
|
|
148
|
+
[names.createModel]: mutation(srv.cnst.full, { guards: cruGuards }).body("data", srv.cnst.input).exec(async function(data) {
|
|
149
|
+
const service = this[names.modelService];
|
|
150
|
+
return await service[names.createModel](data);
|
|
151
|
+
}),
|
|
152
|
+
[names.updateModel]: mutation(srv.cnst.full, { guards: cruGuards }).param(names.modelId, import_base.ID).body("data", srv.cnst.input).exec(async function(modelId, data) {
|
|
153
|
+
const service = this[names.modelService];
|
|
154
|
+
return await service[names.updateModel](modelId, data);
|
|
155
|
+
}),
|
|
156
|
+
[names.removeModel]: mutation(srv.cnst.full, { partial: ["removedAt"], guards: cruGuards }).param(names.modelId, import_base.ID).exec(async function(modelId) {
|
|
157
|
+
const service = this[names.modelService];
|
|
158
|
+
return await service[names.removeModel](modelId);
|
|
159
|
+
})
|
|
160
|
+
} : {}
|
|
413
161
|
};
|
|
414
162
|
Object.entries(buildSlice).forEach(([key, slice2]) => {
|
|
415
163
|
if (!srv.cnst)
|
|
@@ -421,8 +169,8 @@ function slice(srv, option, sliceBuilder, ...libSlices) {
|
|
|
421
169
|
});
|
|
422
170
|
return sigRef;
|
|
423
171
|
}
|
|
424
|
-
function endpoint(srv, builder, ...
|
|
425
|
-
const sigRef =
|
|
172
|
+
function endpoint(srv, builder, ...libEndpoints) {
|
|
173
|
+
const sigRef = libEndpoints.at(0) ?? class Signal {
|
|
426
174
|
};
|
|
427
175
|
import_signalInfo.signalInfo.setRefNameTemp(sigRef, srv.refName);
|
|
428
176
|
const apiInfoMap = builder((0, import_apiInfo.makeApiBuilder)());
|
|
@@ -431,36 +179,39 @@ function endpoint(srv, builder, ...libSignals) {
|
|
|
431
179
|
});
|
|
432
180
|
return sigRef;
|
|
433
181
|
}
|
|
434
|
-
const mergeSignals = (
|
|
435
|
-
(0, import_common.applyMixins)(
|
|
436
|
-
const gqlMetaMap = getGqlMetaMapOnPrototype(
|
|
437
|
-
const resolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(
|
|
438
|
-
setResolveFieldMetaMapOnPrototype(
|
|
182
|
+
const mergeSignals = (endpointRef, internalRef, sliceRef) => {
|
|
183
|
+
(0, import_common.applyMixins)(endpointRef, [internalRef]);
|
|
184
|
+
const gqlMetaMap = getGqlMetaMapOnPrototype(endpointRef.prototype);
|
|
185
|
+
const resolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(endpointRef.prototype);
|
|
186
|
+
setResolveFieldMetaMapOnPrototype(endpointRef.prototype, resolveFieldMetaMap);
|
|
439
187
|
const internalGqlMetaMap = getGqlMetaMapOnPrototype(internalRef.prototype);
|
|
440
188
|
const internalResolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(internalRef.prototype);
|
|
441
189
|
internalGqlMetaMap.forEach((value, key) => {
|
|
442
190
|
gqlMetaMap.set(key, value);
|
|
443
191
|
const [argMetas, internalArgMetas] = getArgMetas(internalRef, key);
|
|
444
|
-
setArgMetas(
|
|
192
|
+
setArgMetas(endpointRef, key, argMetas, internalArgMetas);
|
|
445
193
|
});
|
|
446
194
|
internalResolveFieldMetaMap.forEach((value, key) => {
|
|
447
195
|
resolveFieldMetaMap.set(key, value);
|
|
448
196
|
const [argMetas, internalArgMetas] = getArgMetas(internalRef, key);
|
|
449
|
-
setArgMetas(
|
|
197
|
+
setArgMetas(endpointRef, key, argMetas, internalArgMetas);
|
|
450
198
|
});
|
|
451
199
|
if (sliceRef) {
|
|
452
200
|
const sliceGqlMetaMap = getGqlMetaMapOnPrototype(sliceRef.prototype);
|
|
453
|
-
(0, import_common.applyMixins)(
|
|
201
|
+
(0, import_common.applyMixins)(endpointRef, [sliceRef], /* @__PURE__ */ new Set([...gqlMetaMap.keys()]));
|
|
454
202
|
sliceGqlMetaMap.forEach((value, key) => {
|
|
455
203
|
if (gqlMetaMap.has(key))
|
|
456
204
|
return;
|
|
457
205
|
gqlMetaMap.set(key, value);
|
|
458
206
|
const [argMetas, internalArgMetas] = getArgMetas(sliceRef, key);
|
|
459
|
-
setArgMetas(
|
|
207
|
+
setArgMetas(endpointRef, key, argMetas, internalArgMetas);
|
|
460
208
|
});
|
|
461
209
|
}
|
|
462
|
-
setGqlMetaMapOnPrototype(
|
|
463
|
-
return
|
|
210
|
+
setGqlMetaMapOnPrototype(endpointRef.prototype, gqlMetaMap);
|
|
211
|
+
return endpointRef;
|
|
212
|
+
};
|
|
213
|
+
const serverSignalOf = (sigRef) => {
|
|
214
|
+
return sigRef;
|
|
464
215
|
};
|
|
465
216
|
const getSigMeta = (sigRef) => {
|
|
466
217
|
const sigMeta = Reflect.getMetadata("signal", sigRef.prototype);
|