@akanjs/signal 0.9.48 → 0.9.49

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.
@@ -0,0 +1,125 @@
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 graphql_exports = {};
19
+ __export(graphql_exports, {
20
+ getGqlStr: () => getGqlStr,
21
+ graphql: () => graphql,
22
+ makeFragment: () => makeFragment
23
+ });
24
+ module.exports = __toCommonJS(graphql_exports);
25
+ var import_base = require("@akanjs/base");
26
+ var import_common = require("@akanjs/common");
27
+ var import_constant = require("@akanjs/constant");
28
+ class FragmentStorage {
29
+ }
30
+ const getPredefinedFragment = (refName) => {
31
+ const fragment = Reflect.getMetadata(refName, FragmentStorage.prototype);
32
+ return fragment;
33
+ };
34
+ const setPredefinedFragment = (refName, fragment) => {
35
+ Reflect.defineMetadata(refName, fragment, FragmentStorage.prototype);
36
+ };
37
+ const makeArgStr = (args) => {
38
+ return args.length ? `(${args.map((arg) => {
39
+ const argRef = import_constant.constantInfo.getModelRef(arg.refName, arg.modelType);
40
+ const argRefType = (0, import_base.isGqlScalar)(argRef) ? "gqlScalar" : "class";
41
+ const gqlTypeStr = "[".repeat(arg.arrDepth) + `${(0, import_constant.getGqlTypeStr)(argRef)}${argRefType === "class" ? "Input" : ""}` + "!]".repeat(arg.arrDepth);
42
+ return `$${arg.name}: ` + gqlTypeStr + (arg.argsOption.nullable ? "" : "!");
43
+ }).join(", ")})` : "";
44
+ };
45
+ const makeArgAssignStr = (args) => {
46
+ return args.length ? `(${args.map((arg) => `${arg.name}: $${arg.name}`).join(", ")})` : "";
47
+ };
48
+ const makeReturnStr = (returnRef, partial) => {
49
+ const isScalar = (0, import_base.isGqlScalar)(returnRef);
50
+ if (isScalar)
51
+ return "";
52
+ const refName = import_constant.constantInfo.getRefName(returnRef);
53
+ const fragmentName = `${import_constant.constantInfo.isLight(returnRef) ? "Light" : ""}${(0, import_common.capitalize)(refName)}${import_constant.constantInfo.isInsight(returnRef) ? "Insight" : ""}`;
54
+ if (!partial?.length)
55
+ return ` {
56
+ ...${(0, import_common.lowerlize)(fragmentName)}Fragment
57
+ }`;
58
+ const targetKeys = import_constant.constantInfo.isScalar(returnRef) ? partial : [.../* @__PURE__ */ new Set(["id", ...partial, "updatedAt"])];
59
+ const fieldMetaMap = (0, import_constant.getFieldMetaMap)(returnRef);
60
+ return ` {
61
+ ${targetKeys.map((key) => fieldMetaMap.get(key)).filter((metadata) => metadata && metadata.fieldType !== "hidden").map(
62
+ (fieldMeta) => fieldMeta.isClass ? ` ${fieldMeta.key} {
63
+ ...${(0, import_common.lowerlize)((0, import_constant.getGqlTypeStr)(fieldMeta.modelRef))}Fragment
64
+ }` : ` ${fieldMeta.key}`
65
+ ).join("\n")}
66
+ }`;
67
+ };
68
+ const fragmentize = (modelRef, fragMap = /* @__PURE__ */ new Map(), partial) => {
69
+ const refName = import_constant.constantInfo.getRefName(modelRef);
70
+ const fragmentName = `${import_constant.constantInfo.isLight(modelRef) ? "Light" : ""}${(0, import_common.capitalize)(refName)}${import_constant.constantInfo.isInsight(modelRef) ? "Insight" : ""}`;
71
+ const gqlName = `${(0, import_common.capitalize)(refName)}${import_constant.constantInfo.isInsight(modelRef) ? "Insight" : ""}`;
72
+ const metadatas = (0, import_constant.getFieldMetas)(modelRef);
73
+ const selectKeys = partial ? ["id", ...partial, "updatedAt"] : metadatas.map((metadata) => metadata.key);
74
+ const selectKeySet = new Set(selectKeys);
75
+ const fragment = `fragment ${(0, import_common.lowerlize)(fragmentName)}Fragment on ${gqlName} {
76
+ ` + metadatas.filter((metadata) => metadata.fieldType !== "hidden" && selectKeySet.has(metadata.key)).map((metadata) => {
77
+ return metadata.isClass ? ` ${metadata.key} {
78
+ ...${(0, import_common.lowerlize)(`${import_constant.constantInfo.isLight(metadata.modelRef) ? "Light" : ""}${(0, import_common.capitalize)(import_constant.constantInfo.getRefName(metadata.modelRef))}${import_constant.constantInfo.isInsight(metadata.modelRef) ? "Insight" : ""}`)}Fragment
79
+ }` : ` ${metadata.key}`;
80
+ }).join(`
81
+ `) + `
82
+ }`;
83
+ fragMap.set(fragmentName, fragment);
84
+ metadatas.filter((metadata) => metadata.fieldType !== "hidden" && selectKeySet.has(metadata.key) && metadata.isClass).forEach((metadata) => fragmentize(metadata.modelRef, fragMap));
85
+ return fragMap;
86
+ };
87
+ const makeFragment = (modelRef, option = {}) => {
88
+ const refName = import_constant.constantInfo.getRefName(modelRef);
89
+ const fragmentName = `${import_constant.constantInfo.isLight(modelRef) ? "Light" : ""}${(0, import_common.capitalize)(refName)}${import_constant.constantInfo.isInsight(modelRef) ? "Insight" : ""}`;
90
+ const fragment = getPredefinedFragment(fragmentName);
91
+ if (fragment && !option.overwrite && !option.excludeSelf && !option.partial?.length)
92
+ return fragment;
93
+ const fragMap = new Map(fragmentize(modelRef, /* @__PURE__ */ new Map(), option.partial));
94
+ if (option.excludeSelf)
95
+ fragMap.delete(fragmentName);
96
+ const gqlStr = [...fragMap.values()].join("\n");
97
+ if (!option.excludeSelf)
98
+ setPredefinedFragment(fragmentName, gqlStr);
99
+ return gqlStr;
100
+ };
101
+ const getGqlStr = (modelRef, key, endpoint, returnRef, partial) => {
102
+ const isScalar = (0, import_base.isGqlScalar)(modelRef);
103
+ const argStr = makeArgStr(endpoint.args);
104
+ const argAssignStr = makeArgAssignStr(endpoint.args);
105
+ const returnStr = makeReturnStr(returnRef, partial);
106
+ const gqlStr = `${isScalar ? "" : makeFragment(returnRef, { excludeSelf: !!partial?.length, partial })}
107
+ ${endpoint.type + " " + key + argStr}{
108
+ ${key}${argAssignStr}${returnStr}
109
+ }
110
+ `;
111
+ return gqlStr;
112
+ };
113
+ function graphql(literals, ...args) {
114
+ if (typeof literals === "string")
115
+ literals = [literals];
116
+ let result = literals[0];
117
+ args.forEach((arg, i) => {
118
+ if (arg && arg.kind === "Document")
119
+ result += arg.loc.source.body;
120
+ else
121
+ result += arg;
122
+ result += literals[i + 1];
123
+ });
124
+ return result;
125
+ }
package/cjs/src/index.js CHANGED
@@ -30,3 +30,8 @@ __reExport(src_exports, require("./doc"), module.exports);
30
30
  __reExport(src_exports, require("./baseFetch"), module.exports);
31
31
  __reExport(src_exports, require("./base.signal"), module.exports);
32
32
  __reExport(src_exports, require("./fetch"), module.exports);
33
+ __reExport(src_exports, require("./signalInfo"), module.exports);
34
+ __reExport(src_exports, require("./apiInfo"), module.exports);
35
+ __reExport(src_exports, require("./sliceInfo"), module.exports);
36
+ __reExport(src_exports, require("./fetchInfo"), module.exports);
37
+ __reExport(src_exports, require("./graphql"), module.exports);
@@ -0,0 +1,151 @@
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 internalApiInfo_exports = {};
19
+ __export(internalApiInfo_exports, {
20
+ InternalApiInfo: () => InternalApiInfo,
21
+ makeInternalApiBuilder: () => makeInternalApiBuilder
22
+ });
23
+ module.exports = __toCommonJS(internalApiInfo_exports);
24
+ var import_base = require("@akanjs/base");
25
+ var import_signalDecorators = require("./signalDecorators");
26
+ class InternalApiInfo {
27
+ type;
28
+ args = [];
29
+ internalArgs = [];
30
+ returnRef;
31
+ signalOption;
32
+ execFn = null;
33
+ constructor(type, returnRef, signalOption = {}) {
34
+ this.type = type;
35
+ this.returnRef = returnRef;
36
+ this.signalOption = signalOption;
37
+ }
38
+ msg(name, argRef, option) {
39
+ if (this.execFn)
40
+ throw new Error("Query function is already set");
41
+ else if (this.args.at(-1)?.option?.nullable)
42
+ throw new Error("Last argument is nullable");
43
+ this.args.push({ type: "Msg", name, argRef, option });
44
+ return this;
45
+ }
46
+ with(argType, option) {
47
+ if (this.execFn)
48
+ throw new Error("Query function is already set");
49
+ this.internalArgs.push({ type: argType, option });
50
+ return this;
51
+ }
52
+ exec(query) {
53
+ if (this.execFn)
54
+ throw new Error("Query function is already set");
55
+ this.execFn = query;
56
+ return this;
57
+ }
58
+ static #typeTempMap = {
59
+ resolveField: "ResolveField",
60
+ interval: "Schedule",
61
+ cron: "Schedule",
62
+ timeout: "Schedule",
63
+ init: "Schedule",
64
+ destroy: "Schedule",
65
+ process: "Process"
66
+ };
67
+ applyApiMeta(sigRef, key) {
68
+ if (this.type === "resolveField") {
69
+ const metadataMap2 = (0, import_signalDecorators.getResolveFieldMetaMapOnPrototype)(sigRef.prototype);
70
+ metadataMap2.set(key, {
71
+ returns: () => this.returnRef,
72
+ argsOption: this.signalOption,
73
+ key,
74
+ descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true }
75
+ });
76
+ sigRef.prototype[key] = this.execFn;
77
+ Reflect.defineMetadata("resolveField", metadataMap2, sigRef.prototype);
78
+ return;
79
+ }
80
+ const internalApiMeta = {
81
+ returns: () => this.returnRef instanceof import_base.Enum ? this.returnRef.type : this.returnRef,
82
+ signalOption: this.signalOption,
83
+ key,
84
+ descriptor: { value: this.execFn, writable: true, enumerable: false, configurable: true },
85
+ guards: ["None"],
86
+ type: InternalApiInfo.#typeTempMap[this.type]
87
+ };
88
+ sigRef.prototype[key] = this.execFn;
89
+ const metadataMap = (0, import_signalDecorators.getGqlMetaMapOnPrototype)(sigRef.prototype);
90
+ metadataMap.set(key, internalApiMeta);
91
+ (0, import_signalDecorators.setGqlMetaMapOnPrototype)(sigRef.prototype, metadataMap);
92
+ const argMetas = this.args.map((arg, idx) => ({
93
+ name: arg.name,
94
+ returns: () => arg.argRef,
95
+ argsOption: { ...arg.option, enum: arg.argRef instanceof import_base.Enum ? arg.argRef : void 0 },
96
+ key,
97
+ idx,
98
+ type: arg.type
99
+ }));
100
+ const internalArgMetas = this.internalArgs.map((arg, idx) => ({
101
+ type: arg.type,
102
+ key,
103
+ idx,
104
+ option: arg.option
105
+ }));
106
+ (0, import_signalDecorators.setArgMetas)(sigRef, key, argMetas, internalArgMetas);
107
+ }
108
+ }
109
+ const makeInternalApiBuilder = () => ({
110
+ resolveField: (returnRef, signalOption) => new InternalApiInfo(
111
+ "resolveField",
112
+ returnRef,
113
+ signalOption
114
+ ),
115
+ interval: (scheduleTime, signalOption) => new InternalApiInfo("interval", import_base.JSON, {
116
+ enabled: true,
117
+ lock: true,
118
+ scheduleType: "interval",
119
+ scheduleTime,
120
+ ...signalOption
121
+ }),
122
+ cron: (scheduleCron, signalOption) => new InternalApiInfo("cron", import_base.JSON, {
123
+ enabled: true,
124
+ lock: true,
125
+ scheduleType: "cron",
126
+ scheduleCron,
127
+ ...signalOption
128
+ }),
129
+ timeout: (timeout, signalOption) => new InternalApiInfo("timeout", import_base.JSON, {
130
+ enabled: true,
131
+ lock: true,
132
+ scheduleType: "timeout",
133
+ scheduleTime: timeout,
134
+ ...signalOption
135
+ }),
136
+ initialize: (signalOption) => new InternalApiInfo("init", import_base.JSON, {
137
+ enabled: true,
138
+ scheduleType: "init",
139
+ ...signalOption
140
+ }),
141
+ destroy: (signalOption) => new InternalApiInfo("destroy", import_base.JSON, {
142
+ enabled: true,
143
+ lock: true,
144
+ scheduleType: "destroy",
145
+ ...signalOption
146
+ }),
147
+ process: (returnRef, signalOption) => new InternalApiInfo("process", returnRef, {
148
+ serverMode: "all",
149
+ ...signalOption
150
+ })
151
+ });
@@ -15,24 +15,12 @@ var __copyProps = (to, from, except, desc) => {
15
15
  return to;
16
16
  };
17
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
18
  var signalDecorators_exports = {};
29
19
  __export(signalDecorators_exports, {
30
20
  Access: () => Access,
31
21
  Account: () => Account,
32
22
  Arg: () => Arg,
33
- DbSignal: () => DbSignal,
34
23
  Job: () => Job,
35
- LogSignal: () => LogSignal,
36
24
  Me: () => Me,
37
25
  Message: () => Message,
38
26
  Mutation: () => Mutation,
@@ -45,7 +33,6 @@ __export(signalDecorators_exports, {
45
33
  ResolveField: () => ResolveField,
46
34
  Schedule: () => Schedule,
47
35
  Self: () => Self,
48
- Signal: () => Signal,
49
36
  SignalStorage: () => SignalStorage,
50
37
  UserIp: () => UserIp,
51
38
  Ws: () => Ws,
@@ -55,24 +42,32 @@ __export(signalDecorators_exports, {
55
42
  defaultAccount: () => defaultAccount,
56
43
  done: () => done,
57
44
  emit: () => emit,
45
+ endpoint: () => endpoint,
58
46
  endpointTypes: () => endpointTypes,
59
47
  getAllSignalRefs: () => getAllSignalRefs,
60
48
  getArgMetas: () => getArgMetas,
61
49
  getControllerPath: () => getControllerPath,
62
50
  getControllerPrefix: () => getControllerPrefix,
51
+ getDefaultArg: () => getDefaultArg,
63
52
  getGqlMeta: () => getGqlMeta,
64
53
  getGqlMetaMapOnPrototype: () => getGqlMetaMapOnPrototype,
65
54
  getGqlMetas: () => getGqlMetas,
55
+ getResolveFieldMetaMapOnPrototype: () => getResolveFieldMetaMapOnPrototype,
66
56
  getResolveFieldMetas: () => getResolveFieldMetas,
67
57
  getSigMeta: () => getSigMeta,
68
58
  getSignalRefsOnStorage: () => getSignalRefsOnStorage,
69
59
  guardTypes: () => guardTypes,
60
+ internal: () => internal,
70
61
  internalArgTypes: () => internalArgTypes,
62
+ mergeSignals: () => mergeSignals,
71
63
  resolve: () => resolve,
72
64
  roleTypes: () => roleTypes,
73
65
  setArgMetas: () => setArgMetas,
74
66
  setGqlMetaMapOnPrototype: () => setGqlMetaMapOnPrototype,
67
+ setSigMeta: () => setSigMeta,
68
+ setSignalRefOnStorage: () => setSignalRefOnStorage,
75
69
  signalTypes: () => signalTypes,
70
+ slice: () => slice,
76
71
  ssoTypes: () => ssoTypes,
77
72
  subscribe: () => subscribe
78
73
  });
@@ -81,7 +76,10 @@ var import_reflect_metadata = require("reflect-metadata");
81
76
  var import_base = require("@akanjs/base");
82
77
  var import_common = require("@akanjs/common");
83
78
  var import_constant = require("@akanjs/constant");
84
- var import_gql = require("./gql");
79
+ var import__ = require(".");
80
+ var import_apiInfo = require("./apiInfo");
81
+ var import_internalApiInfo = require("./internalApiInfo");
82
+ var import_signalInfo = require("./signalInfo");
85
83
  const ssoTypes = ["github", "google", "facebook", "apple", "naver", "kakao"];
86
84
  class SignalStorage {
87
85
  }
@@ -102,7 +100,7 @@ const emit = (data) => data;
102
100
  const done = (data) => data;
103
101
  const subscribe = () => void 0;
104
102
  const signalTypes = ["graphql", "restapi"];
105
- const endpointTypes = ["Query", "Mutation", "Message", "Pubsub", "Process", "Schedule"];
103
+ const endpointTypes = ["Query", "Mutation", "Message", "Pubsub", "Process", "Schedule", "ResolveField"];
106
104
  const guardTypes = ["Public", "None", "User", "Admin", "SuperAdmin", "Every", "Owner"];
107
105
  const roleTypes = ["Public", "User", "Admin", "SuperAdmin"];
108
106
  const argTypes = ["Body", "Param", "Query", "Upload", "Msg", "Room"];
@@ -128,50 +126,6 @@ const getDefaultArg = (argRef) => {
128
126
  else
129
127
  return {};
130
128
  };
131
- function Signal(returnsOrObj) {
132
- const returns = typeof returnsOrObj === "function" ? returnsOrObj : void 0;
133
- const prefix = typeof returnsOrObj === "object" ? returnsOrObj.prefix : void 0;
134
- return function(target) {
135
- if (returns) {
136
- const modelRef = returns();
137
- const classMeta = (0, import_constant.getClassMeta)(modelRef);
138
- const gqlMetas = getGqlMetas(target);
139
- const modelName = (0, import_common.lowerlize)(classMeta.refName);
140
- const listName = `${modelName}ListIn`;
141
- const slices = [
142
- { refName: modelName, sliceName: modelName, argLength: 1, defaultArgs: [{}] },
143
- ...gqlMetas.filter((gqlMeta) => {
144
- const name = gqlMeta.signalOption.name ?? gqlMeta.key;
145
- if (!name.includes(listName))
146
- return false;
147
- const [retRef, arrDepth] = (0, import_base.getNonArrayModel)(gqlMeta.returns());
148
- return retRef.prototype === modelRef.prototype && arrDepth === 1;
149
- }).map((gqlMeta) => {
150
- const name = gqlMeta.signalOption.name ?? gqlMeta.key;
151
- const sliceName = name.replace(listName, `${modelName}In`);
152
- const [argMetas] = getArgMetas(target, gqlMeta.key);
153
- const skipIdx = argMetas.findIndex((argMeta) => argMeta.name === "skip");
154
- if (skipIdx === -1)
155
- throw new Error(`Invalid Args for ${sliceName}`);
156
- const argLength = skipIdx;
157
- const queryArgRefs = argMetas.slice(0, skipIdx).map((argMeta) => argMeta.returns());
158
- const defaultArgs = queryArgRefs.map(
159
- (queryArgRef, idx) => argMetas[idx].argsOption.nullable ? null : getDefaultArg(queryArgRef)
160
- );
161
- return { refName: modelName, sliceName, argLength, defaultArgs };
162
- })
163
- ];
164
- setSigMeta(target, { returns, prefix, slices, refName: modelName });
165
- setSignalRefOnStorage(modelName, target);
166
- } else {
167
- const refName = typeof returnsOrObj === "object" ? (0, import_common.lowerlize)(returnsOrObj.name) : void 0;
168
- if (!refName)
169
- throw new Error("Signal name is required");
170
- setSigMeta(target, { returns, prefix, slices: [], refName });
171
- setSignalRefOnStorage(refName, target);
172
- }
173
- };
174
- }
175
129
  const createArgMetaDecorator = (type) => {
176
130
  return function(option = {}) {
177
131
  return function(prototype, key, idx) {
@@ -398,106 +352,118 @@ function Parent() {
398
352
  setArgMetasOnPrototype(prototype, key, argMetas);
399
353
  };
400
354
  }
401
- function LogSignal(srv) {
402
- class BaseSignal {
403
- }
404
- return BaseSignal;
355
+ function internal(srv, internalBuilder, ...libInternals) {
356
+ const sigRef = libInternals.at(0) ?? class Internal {
357
+ };
358
+ import_signalInfo.signalInfo.setRefNameTemp(sigRef, srv.refName);
359
+ const buildInternal = internalBuilder((0, import_internalApiInfo.makeInternalApiBuilder)());
360
+ Object.entries(buildInternal).forEach(([key, internal2]) => {
361
+ internal2.applyApiMeta(sigRef, key);
362
+ });
363
+ return sigRef;
405
364
  }
406
- function DbSignal(constant, srv, option) {
407
- var _a, _b, _c, _d, _e, _f, _g, _h;
408
- const meta = (0, import_constant.getClassMeta)(constant.Full);
409
- const serviceName = `${(0, import_common.lowerlize)(meta.refName)}Service`;
410
- const [modelName, className] = [(0, import_common.lowerlize)(meta.refName), (0, import_common.capitalize)(meta.refName)];
365
+ function slice(srv, option, sliceBuilder, ...libSlices) {
366
+ if (!srv.cnst)
367
+ throw new Error("cnst is required");
368
+ const sigRef = libSlices.at(0) ?? class Slice {
369
+ };
370
+ import_signalInfo.signalInfo.setRefNameTemp(sigRef, srv.refName);
371
+ const [modelName, className] = [srv.cnst.refName, (0, import_common.capitalize)(srv.cnst.refName)];
411
372
  const names = {
412
373
  modelId: `${modelName}Id`,
413
374
  model: modelName,
414
375
  lightModel: `light${className}`,
415
- modelList: `${modelName}List`,
416
- modelInsight: `${modelName}Insight`,
417
- modelExists: `${modelName}Exists`,
376
+ modelService: `${modelName}Service`,
418
377
  getModel: `get${className}`,
419
378
  createModel: `create${className}`,
420
379
  updateModel: `update${className}`,
421
380
  removeModel: `remove${className}`
422
381
  };
382
+ const getGuard = option.guards?.get ?? "Public";
383
+ const cruGuard = option.guards?.cru ?? "Public";
384
+ const init = (0, import__.sliceInit)(srv.cnst.full, srv.cnst.light, srv.cnst.insight);
385
+ const { query, mutation } = (0, import_apiInfo.makeApiBuilder)();
386
+ const buildSlice = {
387
+ [""]: init("Admin").search("query", import_base.JSON).exec(function(query2) {
388
+ return query2 ?? {};
389
+ }),
390
+ ...sliceBuilder(init)
391
+ };
392
+ const buildEndpoint = {
393
+ [names.model]: query(srv.cnst.full, getGuard).param(names.modelId, import_base.ID).exec(async function(modelId) {
394
+ const service = this[names.modelService];
395
+ return await service[names.getModel](modelId);
396
+ }),
397
+ [names.lightModel]: query(srv.cnst.light, getGuard).param(names.modelId, import_base.ID).exec(async function(modelId) {
398
+ const service = this[names.modelService];
399
+ return await service[names.getModel](modelId);
400
+ }),
401
+ [names.createModel]: mutation(srv.cnst.full, cruGuard).body("data", srv.cnst.input).exec(async function(data) {
402
+ const service = this[names.modelService];
403
+ return await service[names.createModel](data);
404
+ }),
405
+ [names.updateModel]: mutation(srv.cnst.full, cruGuard).param(names.modelId, import_base.ID).body("data", srv.cnst.input).exec(async function(modelId, data) {
406
+ const service = this[names.modelService];
407
+ return await service[names.updateModel](modelId, data);
408
+ }),
409
+ [names.removeModel]: mutation(srv.cnst.full, { partial: ["removedAt"] }, cruGuard).param(names.modelId, import_base.ID).exec(async function(modelId) {
410
+ const service = this[names.modelService];
411
+ return await service[names.removeModel](modelId);
412
+ })
413
+ };
414
+ Object.entries(buildSlice).forEach(([key, slice2]) => {
415
+ if (!srv.cnst)
416
+ return;
417
+ slice2.applySliceMeta(srv.cnst.refName, sigRef, key);
418
+ });
419
+ Object.entries(buildEndpoint).forEach(([key, endpoint2]) => {
420
+ endpoint2.applyApiMeta(sigRef, key);
421
+ });
422
+ return sigRef;
423
+ }
424
+ function endpoint(srv, builder, ...libSignals) {
425
+ const sigRef = libSignals.at(0) ?? class Signal {
426
+ };
427
+ import_signalInfo.signalInfo.setRefNameTemp(sigRef, srv.refName);
428
+ const apiInfoMap = builder((0, import_apiInfo.makeApiBuilder)());
429
+ Object.entries(apiInfoMap).forEach(([key, apiInfo]) => {
430
+ apiInfo.applyApiMeta(sigRef, key);
431
+ });
432
+ return sigRef;
433
+ }
434
+ const mergeSignals = (signalRef, internalRef, sliceRef) => {
435
+ (0, import_common.applyMixins)(signalRef, [internalRef, ...sliceRef ? [sliceRef] : []]);
436
+ const gqlMetaMap = getGqlMetaMapOnPrototype(signalRef.prototype);
437
+ const resolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(signalRef.prototype);
438
+ setResolveFieldMetaMapOnPrototype(signalRef.prototype, resolveFieldMetaMap);
439
+ const internalGqlMetaMap = getGqlMetaMapOnPrototype(internalRef.prototype);
440
+ const internalResolveFieldMetaMap = getResolveFieldMetaMapOnPrototype(internalRef.prototype);
441
+ internalGqlMetaMap.forEach((value, key) => {
442
+ gqlMetaMap.set(key, value);
443
+ const [argMetas, internalArgMetas] = getArgMetas(internalRef, key);
444
+ setArgMetas(signalRef, key, argMetas, internalArgMetas);
445
+ });
446
+ internalResolveFieldMetaMap.forEach((value, key) => {
447
+ resolveFieldMetaMap.set(key, value);
448
+ });
449
+ if (sliceRef) {
450
+ const sliceGqlMetaMap = getGqlMetaMapOnPrototype(sliceRef.prototype);
451
+ sliceGqlMetaMap.forEach((value, key) => {
452
+ if (gqlMetaMap.has(key))
453
+ return;
454
+ gqlMetaMap.set(key, value);
455
+ const [argMetas, internalArgMetas] = getArgMetas(sliceRef, key);
456
+ setArgMetas(signalRef, key, argMetas, internalArgMetas);
457
+ });
458
+ }
459
+ setGqlMetaMapOnPrototype(signalRef.prototype, gqlMetaMap);
460
+ return signalRef;
461
+ };
462
+ function LogSignal(refName, srv, option) {
423
463
  class BaseSignal {
424
- async [_a = names.lightModel](id) {
425
- const service = this[serviceName];
426
- const model = await service[names.getModel](id);
427
- return resolve(model);
428
- }
429
- async [_b = names.model](id) {
430
- const service = this[serviceName];
431
- const model = await service[names.getModel](id);
432
- return resolve(model);
433
- }
434
- async [_c = names.modelList](query, skip, limit, sort) {
435
- const service = this[serviceName];
436
- const models = query?.$search ? await service.__searchDocs(query.$search, { skip, limit, sort }) : await service.__list(query, { skip, limit, sort });
437
- return resolve(models);
438
- }
439
- async [_d = names.modelInsight](query) {
440
- const service = this[serviceName];
441
- const insight = query.$search ? { ...(0, import_gql.makeDefault)(constant.Insight), count: await service.__searchCount(query.$search) } : await service.__insight(query);
442
- return resolve(insight);
443
- }
444
- async [_e = names.modelExists](query) {
445
- const service = this[serviceName];
446
- const exists = await service.__exists(query);
447
- return resolve(exists);
448
- }
449
- async [_f = names.createModel](data) {
450
- const service = this[serviceName];
451
- const model = await service[names.createModel](data);
452
- return resolve(model);
453
- }
454
- async [_g = names.updateModel](id, data) {
455
- const service = this[serviceName];
456
- const model = await service[names.updateModel](id, data);
457
- return resolve(model);
458
- }
459
- async [_h = names.removeModel](id) {
460
- const service = this[serviceName];
461
- const model = await service[names.removeModel](id);
462
- return resolve(model);
463
- }
464
464
  }
465
- __decorateClass([
466
- option.guards.get(() => constant.Light),
467
- __decorateParam(0, Arg.Param(names.modelId, () => import_base.ID))
468
- ], BaseSignal.prototype, _a, 1);
469
- __decorateClass([
470
- option.guards.get(() => constant.Full),
471
- __decorateParam(0, Arg.Param(names.modelId, () => import_base.ID))
472
- ], BaseSignal.prototype, _b, 1);
473
- __decorateClass([
474
- Query.Admin(() => [constant.Full]),
475
- __decorateParam(0, Arg.Query("query", () => import_base.JSON)),
476
- __decorateParam(1, Arg.Query("skip", () => import_base.Int, { nullable: true, example: 0 })),
477
- __decorateParam(2, Arg.Query("limit", () => import_base.Int, { nullable: true, example: 20 })),
478
- __decorateParam(3, Arg.Query("sort", () => String, { nullable: true, example: "latest" }))
479
- ], BaseSignal.prototype, _c, 1);
480
- __decorateClass([
481
- Query.Admin(() => constant.Insight),
482
- __decorateParam(0, Arg.Query("query", () => import_base.JSON))
483
- ], BaseSignal.prototype, _d, 1);
484
- __decorateClass([
485
- Query.Admin(() => Boolean),
486
- __decorateParam(0, Arg.Query("query", () => import_base.JSON))
487
- ], BaseSignal.prototype, _e, 1);
488
- __decorateClass([
489
- option.guards.cru(() => constant.Full),
490
- __decorateParam(0, Arg.Body(`data`, () => constant.Input))
491
- ], BaseSignal.prototype, _f, 1);
492
- __decorateClass([
493
- option.guards.cru(() => constant.Full),
494
- __decorateParam(0, Arg.Param(names.modelId, () => import_base.ID)),
495
- __decorateParam(1, Arg.Body("data", () => constant.Input))
496
- ], BaseSignal.prototype, _g, 1);
497
- __decorateClass([
498
- option.guards.cru(() => constant.Full, { partial: ["status", "removedAt"] }),
499
- __decorateParam(0, Arg.Param(names.modelId, () => import_base.ID))
500
- ], BaseSignal.prototype, _h, 1);
465
+ import_signalInfo.signalInfo.setRefNameTemp(BaseSignal, refName);
466
+ import_signalInfo.signalInfo.setPrefixTemp(BaseSignal, option?.prefix ?? "");
501
467
  return BaseSignal;
502
468
  }
503
469
  const getSigMeta = (sigRef) => {
@@ -556,7 +522,7 @@ const setResolveFieldMetaMapOnPrototype = (prototype, resolveFieldMetaMap) => {
556
522
  Reflect.defineMetadata("resolveField", resolveFieldMetaMap, prototype);
557
523
  };
558
524
  const getControllerPrefix = (sigMeta) => {
559
- return sigMeta.returns ? (0, import_common.lowerlize)((0, import_constant.getClassMeta)(sigMeta.returns()).refName) : sigMeta.prefix;
525
+ return sigMeta.returns ? import_constant.constantInfo.getRefName(sigMeta.returns()) : sigMeta.prefix;
560
526
  };
561
527
  const getControllerPath = (gqlMeta, paramArgMetas) => {
562
528
  return gqlMeta.signalOption.path ?? [gqlMeta.signalOption.name ?? gqlMeta.key, ...paramArgMetas.map((argMeta) => `:${argMeta.name}`)].join("/");