@akanjs/service 0.0.44 → 0.0.45
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.js +859 -842
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,230 +1,248 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
)
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
__defProp(target, key, result);
|
|
38
|
-
return result;
|
|
39
|
-
};
|
|
1
|
+
var __create = Object.create;
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
6
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
7
|
+
var __export = (target, all) => {
|
|
8
|
+
for (var name in all)
|
|
9
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
10
|
+
};
|
|
11
|
+
var __copyProps = (to, from, except, desc) => {
|
|
12
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
13
|
+
for (let key of __getOwnPropNames(from))
|
|
14
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
15
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
16
|
+
}
|
|
17
|
+
return to;
|
|
18
|
+
};
|
|
19
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
20
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
21
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
22
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
23
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
24
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
25
|
+
mod
|
|
26
|
+
));
|
|
27
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
28
|
+
var __decorateClass = (decorators, target, key, kind) => {
|
|
29
|
+
var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
|
|
30
|
+
for (var i = decorators.length - 1, decorator; i >= 0; i--)
|
|
31
|
+
if (decorator = decorators[i])
|
|
32
|
+
result = (kind ? decorator(target, key, result) : decorator(result)) || result;
|
|
33
|
+
if (kind && result)
|
|
34
|
+
__defProp(target, key, result);
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
40
37
|
|
|
41
|
-
|
|
42
|
-
|
|
38
|
+
// pkgs/@akanjs/service/index.ts
|
|
39
|
+
var service_exports = {};
|
|
40
|
+
__export(service_exports, {
|
|
41
|
+
Db: () => Db,
|
|
42
|
+
DbService: () => DbService,
|
|
43
|
+
ExtendedSettingService: () => ExtendedSettingService,
|
|
44
|
+
ExtendedSummaryService: () => ExtendedSummaryService,
|
|
45
|
+
ExtendedUserService: () => ExtendedUserService,
|
|
46
|
+
LogService: () => LogService,
|
|
47
|
+
MixSrvs: () => MixSrvs,
|
|
48
|
+
Queue: () => Queue,
|
|
49
|
+
Service: () => Service,
|
|
50
|
+
ServiceStorage: () => ServiceStorage,
|
|
51
|
+
Srv: () => Srv,
|
|
52
|
+
Use: () => Use,
|
|
53
|
+
Websocket: () => Websocket,
|
|
54
|
+
isServiceEnabled: () => isServiceEnabled,
|
|
55
|
+
serviceOf: () => serviceOf
|
|
56
|
+
});
|
|
57
|
+
module.exports = __toCommonJS(service_exports);
|
|
43
58
|
|
|
44
|
-
|
|
45
|
-
|
|
59
|
+
// pkgs/@akanjs/service/src/serviceDecorators.ts
|
|
60
|
+
var import_reflect_metadata5 = require("reflect-metadata");
|
|
46
61
|
|
|
47
|
-
|
|
48
|
-
|
|
62
|
+
// pkgs/@akanjs/common/src/isDayjs.ts
|
|
63
|
+
var import_dayjs = require("dayjs");
|
|
49
64
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
var import_customParseFormat = __toESM(__require("dayjs/plugin/customParseFormat"));
|
|
53
|
-
import_dayjs3.default.extend(import_customParseFormat.default);
|
|
65
|
+
// pkgs/@akanjs/common/src/isQueryEqual.ts
|
|
66
|
+
var import_dayjs2 = __toESM(require("dayjs"));
|
|
54
67
|
|
|
55
|
-
|
|
56
|
-
|
|
68
|
+
// pkgs/@akanjs/common/src/isValidDate.ts
|
|
69
|
+
var import_dayjs3 = __toESM(require("dayjs"));
|
|
70
|
+
var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
|
|
71
|
+
import_dayjs3.default.extend(import_customParseFormat.default);
|
|
57
72
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
return descriptors;
|
|
69
|
-
};
|
|
70
|
-
var applyMixins = (derivedCtor, constructors, avoidKeys) => {
|
|
71
|
-
constructors.forEach((baseCtor) => {
|
|
72
|
-
Object.entries(getAllPropertyDescriptors(baseCtor)).forEach(([name, descriptor]) => {
|
|
73
|
-
if (name === "constructor" || avoidKeys?.has(name))
|
|
74
|
-
return;
|
|
75
|
-
Object.defineProperty(derivedCtor.prototype, name, { ...descriptor, configurable: true });
|
|
76
|
-
});
|
|
73
|
+
// pkgs/@akanjs/common/src/pluralize.ts
|
|
74
|
+
var import_pluralize = __toESM(require("pluralize"));
|
|
75
|
+
|
|
76
|
+
// pkgs/@akanjs/common/src/applyMixins.ts
|
|
77
|
+
var getAllPropertyDescriptors = (objRef) => {
|
|
78
|
+
const descriptors = {};
|
|
79
|
+
let current = objRef.prototype;
|
|
80
|
+
while (current) {
|
|
81
|
+
Object.getOwnPropertyNames(current).forEach((name) => {
|
|
82
|
+
descriptors[name] ??= Object.getOwnPropertyDescriptor(current, name);
|
|
77
83
|
});
|
|
78
|
-
|
|
84
|
+
current = Object.getPrototypeOf(current);
|
|
85
|
+
}
|
|
86
|
+
return descriptors;
|
|
87
|
+
};
|
|
88
|
+
var applyMixins = (derivedCtor, constructors, avoidKeys) => {
|
|
89
|
+
constructors.forEach((baseCtor) => {
|
|
90
|
+
Object.entries(getAllPropertyDescriptors(baseCtor)).forEach(([name, descriptor]) => {
|
|
91
|
+
if (name === "constructor" || avoidKeys?.has(name))
|
|
92
|
+
return;
|
|
93
|
+
Object.defineProperty(derivedCtor.prototype, name, { ...descriptor, configurable: true });
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
79
97
|
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
98
|
+
// pkgs/@akanjs/common/src/capitalize.ts
|
|
99
|
+
var capitalize = (str) => {
|
|
100
|
+
return str.charAt(0).toUpperCase() + str.slice(1);
|
|
101
|
+
};
|
|
84
102
|
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
103
|
+
// pkgs/@akanjs/common/src/Logger.ts
|
|
104
|
+
var import_dayjs4 = __toESM(require("dayjs"));
|
|
105
|
+
var logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
|
|
106
|
+
var clc = {
|
|
107
|
+
bold: (text) => `\x1B[1m${text}\x1B[0m`,
|
|
108
|
+
green: (text) => `\x1B[32m${text}\x1B[39m`,
|
|
109
|
+
yellow: (text) => `\x1B[33m${text}\x1B[39m`,
|
|
110
|
+
red: (text) => `\x1B[31m${text}\x1B[39m`,
|
|
111
|
+
magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
|
|
112
|
+
cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
|
|
113
|
+
};
|
|
114
|
+
var colorizeMap = {
|
|
115
|
+
trace: clc.bold,
|
|
116
|
+
verbose: clc.cyanBright,
|
|
117
|
+
debug: clc.magentaBright,
|
|
118
|
+
log: clc.green,
|
|
119
|
+
info: clc.green,
|
|
120
|
+
warn: clc.yellow,
|
|
121
|
+
error: clc.red
|
|
122
|
+
};
|
|
123
|
+
var Logger = class _Logger {
|
|
124
|
+
static #ignoreCtxSet = /* @__PURE__ */ new Set([
|
|
125
|
+
"InstanceLoader",
|
|
126
|
+
"RoutesResolver",
|
|
127
|
+
"RouterExplorer",
|
|
128
|
+
"NestFactory",
|
|
129
|
+
"WebSocketsController",
|
|
130
|
+
"GraphQLModule",
|
|
131
|
+
"NestApplication"
|
|
132
|
+
]);
|
|
133
|
+
static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
|
|
134
|
+
static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
|
|
135
|
+
static #startAt = (0, import_dayjs4.default)();
|
|
136
|
+
static setLevel(level) {
|
|
137
|
+
this.level = level;
|
|
138
|
+
this.#levelIdx = logLevels.findIndex((l) => l === level);
|
|
139
|
+
}
|
|
140
|
+
name;
|
|
141
|
+
constructor(name) {
|
|
142
|
+
this.name = name;
|
|
143
|
+
}
|
|
144
|
+
trace(msg, context = "") {
|
|
145
|
+
if (_Logger.#levelIdx <= 0)
|
|
146
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "trace");
|
|
147
|
+
}
|
|
148
|
+
verbose(msg, context = "") {
|
|
149
|
+
if (_Logger.#levelIdx <= 1)
|
|
150
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
|
|
151
|
+
}
|
|
152
|
+
debug(msg, context = "") {
|
|
153
|
+
if (_Logger.#levelIdx <= 2)
|
|
154
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "debug");
|
|
155
|
+
}
|
|
156
|
+
log(msg, context = "") {
|
|
157
|
+
if (_Logger.#levelIdx <= 3)
|
|
158
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "log");
|
|
159
|
+
}
|
|
160
|
+
info(msg, context = "") {
|
|
161
|
+
if (_Logger.#levelIdx <= 4)
|
|
162
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "info");
|
|
163
|
+
}
|
|
164
|
+
warn(msg, context = "") {
|
|
165
|
+
if (_Logger.#levelIdx <= 5)
|
|
166
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "warn");
|
|
167
|
+
}
|
|
168
|
+
error(msg, context = "") {
|
|
169
|
+
if (_Logger.#levelIdx <= 6)
|
|
170
|
+
_Logger.#printMessages(this.name ?? "App", msg, context, "error");
|
|
171
|
+
}
|
|
172
|
+
raw(msg, method) {
|
|
173
|
+
_Logger.rawLog(msg, method);
|
|
174
|
+
}
|
|
175
|
+
rawLog(msg, method) {
|
|
176
|
+
_Logger.rawLog(msg, method);
|
|
177
|
+
}
|
|
178
|
+
static trace(msg, context = "") {
|
|
179
|
+
if (_Logger.#levelIdx <= 0)
|
|
180
|
+
_Logger.#printMessages("App", msg, context, "trace");
|
|
181
|
+
}
|
|
182
|
+
static verbose(msg, context = "") {
|
|
183
|
+
if (_Logger.#levelIdx <= 1)
|
|
184
|
+
_Logger.#printMessages("App", msg, context, "verbose");
|
|
185
|
+
}
|
|
186
|
+
static debug(msg, context = "") {
|
|
187
|
+
if (_Logger.#levelIdx <= 2)
|
|
188
|
+
_Logger.#printMessages("App", msg, context, "debug");
|
|
189
|
+
}
|
|
190
|
+
static log(msg, context = "") {
|
|
191
|
+
if (_Logger.#levelIdx <= 3)
|
|
192
|
+
_Logger.#printMessages("App", msg, context, "log");
|
|
193
|
+
}
|
|
194
|
+
static info(msg, context = "") {
|
|
195
|
+
if (_Logger.#levelIdx <= 4)
|
|
196
|
+
_Logger.#printMessages("App", msg, context, "info");
|
|
197
|
+
}
|
|
198
|
+
static warn(msg, context = "") {
|
|
199
|
+
if (_Logger.#levelIdx <= 5)
|
|
200
|
+
_Logger.#printMessages("App", msg, context, "warn");
|
|
201
|
+
}
|
|
202
|
+
static error(msg, context = "") {
|
|
203
|
+
if (_Logger.#levelIdx <= 6)
|
|
204
|
+
_Logger.#printMessages("App", msg, context, "error");
|
|
205
|
+
}
|
|
206
|
+
static #colorize(msg, logLevel) {
|
|
207
|
+
return colorizeMap[logLevel](msg);
|
|
208
|
+
}
|
|
209
|
+
static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
|
|
210
|
+
if (this.#ignoreCtxSet.has(context))
|
|
211
|
+
return;
|
|
212
|
+
const now = (0, import_dayjs4.default)();
|
|
213
|
+
const processMsg = this.#colorize(
|
|
214
|
+
`[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
|
|
215
|
+
logLevel
|
|
216
|
+
);
|
|
217
|
+
const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
|
|
218
|
+
const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
|
|
219
|
+
const contextMsg = context ? clc.yellow(`[${context}] `) : "";
|
|
220
|
+
const contentMsg = this.#colorize(content, logLevel);
|
|
221
|
+
const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
|
|
222
|
+
if (typeof window === "undefined")
|
|
223
|
+
process[writeStreamType].write(
|
|
224
|
+
`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
207
225
|
`
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
226
|
+
);
|
|
227
|
+
else
|
|
228
|
+
console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
211
229
|
`);
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
230
|
+
}
|
|
231
|
+
static rawLog(msg, method) {
|
|
232
|
+
this.raw(`${msg}
|
|
215
233
|
`, method);
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
234
|
+
}
|
|
235
|
+
static raw(msg, method) {
|
|
236
|
+
if (typeof window === "undefined" && method !== "console" && global.process)
|
|
237
|
+
global.process.stdout.write(msg);
|
|
238
|
+
else
|
|
239
|
+
console.log(msg);
|
|
240
|
+
}
|
|
241
|
+
};
|
|
224
242
|
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
243
|
+
// pkgs/@akanjs/base/src/base.ts
|
|
244
|
+
var version = "0.9.0";
|
|
245
|
+
var logo = `
|
|
228
246
|
_ _ _
|
|
229
247
|
/ \\ | | ____ _ _ __ (_)___
|
|
230
248
|
/ _ \\ | |/ / _' | '_ \\ | / __|
|
|
@@ -236,655 +254,654 @@
|
|
|
236
254
|
|
|
237
255
|
`;
|
|
238
256
|
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
257
|
+
// pkgs/@akanjs/base/src/baseEnv.ts
|
|
258
|
+
var appName = process.env.NEXT_PUBLIC_APP_NAME ?? "unknown";
|
|
259
|
+
var repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? "unknown";
|
|
260
|
+
var serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "unknown";
|
|
261
|
+
if (appName === "unknown")
|
|
262
|
+
throw new Error("environment variable NEXT_PUBLIC_APP_NAME is required");
|
|
263
|
+
if (repoName === "unknown")
|
|
264
|
+
throw new Error("environment variable NEXT_PUBLIC_REPO_NAME is required");
|
|
265
|
+
if (serveDomain === "unknown")
|
|
266
|
+
throw new Error("environment variable NEXT_PUBLIC_SERVE_DOMAIN is required");
|
|
267
|
+
var environment = process.env.NEXT_PUBLIC_ENV ?? "debug";
|
|
268
|
+
var operationType = typeof window !== "undefined" ? "client" : process.env.NEXT_RUNTIME ? "client" : "server";
|
|
269
|
+
var operationMode = process.env.NEXT_PUBLIC_OPERATION_MODE ?? "cloud";
|
|
270
|
+
var networkType = process.env.NEXT_PUBLIC_NETWORK_TYPE ?? (environment === "main" ? "mainnet" : environment === "develop" ? "testnet" : "debugnet");
|
|
271
|
+
var tunnelUsername = process.env.SSU_TUNNEL_USERNAME ?? "root";
|
|
272
|
+
var tunnelPassword = process.env.SSU_TUNNEL_PASSWORD ?? repoName;
|
|
273
|
+
var baseEnv = {
|
|
274
|
+
repoName,
|
|
275
|
+
serveDomain,
|
|
276
|
+
appName,
|
|
277
|
+
environment,
|
|
278
|
+
operationType,
|
|
279
|
+
operationMode,
|
|
280
|
+
networkType,
|
|
281
|
+
tunnelUsername,
|
|
282
|
+
tunnelPassword
|
|
283
|
+
};
|
|
284
|
+
var side = typeof window === "undefined" ? "server" : "client";
|
|
285
|
+
var renderMode = process.env.RENDER_ENV ?? "ssr";
|
|
286
|
+
var clientHost = process.env.NEXT_PUBLIC_CLIENT_HOST ?? (operationMode === "local" || side === "server" ? "localhost" : window.location.hostname);
|
|
287
|
+
var clientPort = parseInt(
|
|
288
|
+
process.env.NEXT_PUBLIC_CLIENT_PORT ?? (operationMode === "local" ? renderMode === "ssr" ? "4200" : "4201" : "443")
|
|
289
|
+
);
|
|
290
|
+
var clientHttpProtocol = side === "client" ? window.location.protocol : clientHost === "localhost" ? "http:" : "https:";
|
|
291
|
+
var clientHttpUri = `${clientHttpProtocol}//${clientHost}${clientPort === 443 ? "" : `:${clientPort}`}`;
|
|
292
|
+
var serverHost = process.env.SERVER_HOST ?? (operationMode === "local" ? typeof window === "undefined" ? "localhost" : window.location.host.split(":")[0] : renderMode === "csr" ? `${appName}-${environment}.${serveDomain}` : side === "client" ? window.location.host.split(":")[0] : operationMode === "cloud" ? `backend-svc.${appName}-${environment}.svc.cluster.local` : "localhost");
|
|
293
|
+
var serverPort = parseInt(
|
|
294
|
+
process.env.SERVER_PORT ?? (operationMode === "local" || side === "server" ? "8080" : "443")
|
|
295
|
+
);
|
|
296
|
+
var serverHttpProtocol = side === "client" ? window.location.protocol : "http:";
|
|
297
|
+
var serverHttpUri = `${serverHttpProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}/backend`;
|
|
298
|
+
var serverGraphqlUri = `${serverHttpUri}/graphql`;
|
|
299
|
+
var serverWsProtocol = serverHttpProtocol === "http:" ? "ws:" : "wss:";
|
|
300
|
+
var serverWsUri = `${serverWsProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}`;
|
|
301
|
+
var baseClientEnv = {
|
|
302
|
+
...baseEnv,
|
|
303
|
+
side,
|
|
304
|
+
renderMode,
|
|
305
|
+
websocket: true,
|
|
306
|
+
clientHost,
|
|
307
|
+
clientPort,
|
|
308
|
+
clientHttpProtocol,
|
|
309
|
+
clientHttpUri,
|
|
310
|
+
serverHost,
|
|
311
|
+
serverPort,
|
|
312
|
+
serverHttpProtocol,
|
|
313
|
+
serverHttpUri,
|
|
314
|
+
serverGraphqlUri,
|
|
315
|
+
serverWsProtocol,
|
|
316
|
+
serverWsUri
|
|
317
|
+
};
|
|
300
318
|
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
319
|
+
// pkgs/@akanjs/base/src/scalar.ts
|
|
320
|
+
var import_dayjs5 = __toESM(require("dayjs"));
|
|
321
|
+
var dayjs4 = import_dayjs5.default;
|
|
322
|
+
var Int = class {
|
|
323
|
+
__Scalar__;
|
|
324
|
+
};
|
|
325
|
+
var Upload = class {
|
|
326
|
+
__Scalar__;
|
|
327
|
+
filename;
|
|
328
|
+
mimetype;
|
|
329
|
+
encoding;
|
|
330
|
+
createReadStream;
|
|
331
|
+
};
|
|
332
|
+
var Float = class {
|
|
333
|
+
__Scalar__;
|
|
334
|
+
};
|
|
335
|
+
var ID = class {
|
|
336
|
+
__Scalar__;
|
|
337
|
+
};
|
|
338
|
+
var JSON = class {
|
|
339
|
+
__Scalar__;
|
|
340
|
+
};
|
|
341
|
+
var getNonArrayModel = (arraiedModel) => {
|
|
342
|
+
let arrDepth = 0;
|
|
343
|
+
let target = arraiedModel;
|
|
344
|
+
while (Array.isArray(target)) {
|
|
345
|
+
target = target[0];
|
|
346
|
+
arrDepth++;
|
|
347
|
+
}
|
|
348
|
+
return [target, arrDepth];
|
|
349
|
+
};
|
|
350
|
+
var scalarSet = /* @__PURE__ */ new Set([String, Boolean, Date, ID, Int, Float, Upload, JSON, Map]);
|
|
351
|
+
var scalarNameMap = /* @__PURE__ */ new Map([
|
|
352
|
+
[ID, "ID"],
|
|
353
|
+
[Int, "Int"],
|
|
354
|
+
[Float, "Float"],
|
|
355
|
+
[String, "String"],
|
|
356
|
+
[Boolean, "Boolean"],
|
|
357
|
+
[Date, "Date"],
|
|
358
|
+
[Upload, "Upload"],
|
|
359
|
+
[JSON, "JSON"],
|
|
360
|
+
[Map, "Map"]
|
|
361
|
+
]);
|
|
362
|
+
var scalarArgMap = /* @__PURE__ */ new Map([
|
|
363
|
+
[ID, null],
|
|
364
|
+
[String, ""],
|
|
365
|
+
[Boolean, false],
|
|
366
|
+
[Date, dayjs4(/* @__PURE__ */ new Date(-1))],
|
|
367
|
+
[Int, 0],
|
|
368
|
+
[Float, 0],
|
|
369
|
+
[JSON, {}],
|
|
370
|
+
[Map, {}]
|
|
371
|
+
]);
|
|
372
|
+
var scalarDefaultMap = /* @__PURE__ */ new Map([
|
|
373
|
+
[ID, null],
|
|
374
|
+
[String, ""],
|
|
375
|
+
[Boolean, false],
|
|
376
|
+
[Date, dayjs4(/* @__PURE__ */ new Date(-1))],
|
|
377
|
+
[Int, 0],
|
|
378
|
+
[Float, 0],
|
|
379
|
+
[JSON, {}]
|
|
380
|
+
]);
|
|
381
|
+
var isGqlScalar = (modelRef) => scalarSet.has(modelRef);
|
|
382
|
+
var isGqlMap = (modelRef) => modelRef === Map;
|
|
365
383
|
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
384
|
+
// pkgs/@akanjs/constant/src/scalar.ts
|
|
385
|
+
var import_reflect_metadata = require("reflect-metadata");
|
|
386
|
+
var scalarExampleMap = /* @__PURE__ */ new Map([
|
|
387
|
+
[ID, "1234567890abcdef12345678"],
|
|
388
|
+
[Int, 0],
|
|
389
|
+
[Float, 0],
|
|
390
|
+
[String, "String"],
|
|
391
|
+
[Boolean, true],
|
|
392
|
+
[Date, (/* @__PURE__ */ new Date()).toISOString()],
|
|
393
|
+
[Upload, "FileUpload"],
|
|
394
|
+
[JSON, {}],
|
|
395
|
+
[Map, {}]
|
|
396
|
+
]);
|
|
397
|
+
var getClassMeta = (modelRef) => {
|
|
398
|
+
const [target] = getNonArrayModel(modelRef);
|
|
399
|
+
const classMeta = Reflect.getMetadata("class", target.prototype);
|
|
400
|
+
if (!classMeta)
|
|
401
|
+
throw new Error(`No ClassMeta for this target ${target.name}`);
|
|
402
|
+
return classMeta;
|
|
403
|
+
};
|
|
404
|
+
var getFieldMetas = (modelRef) => {
|
|
405
|
+
const [target] = getNonArrayModel(modelRef);
|
|
406
|
+
const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
|
|
407
|
+
const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
|
|
408
|
+
return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
|
|
409
|
+
};
|
|
410
|
+
var getFieldMetaMapOnPrototype = (prototype) => {
|
|
411
|
+
const metadataMap = Reflect.getMetadata("fields", prototype) ?? /* @__PURE__ */ new Map();
|
|
412
|
+
return new Map(metadataMap);
|
|
413
|
+
};
|
|
414
|
+
var setFieldMetaMapOnPrototype = (prototype, metadataMap) => {
|
|
415
|
+
Reflect.defineMetadata("fields", new Map(metadataMap), prototype);
|
|
416
|
+
};
|
|
399
417
|
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
};
|
|
441
|
-
const metadataMap = getFieldMetaMapOnPrototype(prototype);
|
|
442
|
-
metadataMap.set(key, metadata);
|
|
443
|
-
setFieldMetaMapOnPrototype(prototype, metadataMap);
|
|
418
|
+
// pkgs/@akanjs/constant/src/fieldMeta.ts
|
|
419
|
+
var applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
|
|
420
|
+
const isArray = arrDepth > 0;
|
|
421
|
+
const isClass = !isGqlScalar(modelRef);
|
|
422
|
+
const isMap = isGqlMap(modelRef);
|
|
423
|
+
const { refName, type } = isClass ? getClassMeta(modelRef) : { refName: "", type: "scalar" };
|
|
424
|
+
const name = isClass ? refName : scalarNameMap.get(modelRef) ?? "Unknown";
|
|
425
|
+
if (isMap && !option.of)
|
|
426
|
+
throw new Error("Map type must have 'of' option");
|
|
427
|
+
return (prototype, key) => {
|
|
428
|
+
const metadata = {
|
|
429
|
+
nullable: option.nullable ?? false,
|
|
430
|
+
ref: option.ref,
|
|
431
|
+
refPath: option.refPath,
|
|
432
|
+
refType: option.refType,
|
|
433
|
+
default: option.default ?? (isArray ? [] : null),
|
|
434
|
+
type: option.type,
|
|
435
|
+
fieldType: option.fieldType ?? "property",
|
|
436
|
+
immutable: option.immutable ?? false,
|
|
437
|
+
min: option.min,
|
|
438
|
+
max: option.max,
|
|
439
|
+
enum: option.enum,
|
|
440
|
+
select: option.select ?? true,
|
|
441
|
+
minlength: option.minlength,
|
|
442
|
+
maxlength: option.maxlength,
|
|
443
|
+
query: option.query,
|
|
444
|
+
accumulate: option.accumulate,
|
|
445
|
+
example: option.example,
|
|
446
|
+
validate: option.validate,
|
|
447
|
+
key,
|
|
448
|
+
name,
|
|
449
|
+
isClass,
|
|
450
|
+
isScalar: type === "scalar",
|
|
451
|
+
modelRef,
|
|
452
|
+
arrDepth,
|
|
453
|
+
isArray,
|
|
454
|
+
optArrDepth: optionArrDepth,
|
|
455
|
+
isMap,
|
|
456
|
+
of: option.of,
|
|
457
|
+
text: option.text
|
|
444
458
|
};
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
}
|
|
459
|
+
const metadataMap = getFieldMetaMapOnPrototype(prototype);
|
|
460
|
+
metadataMap.set(key, metadata);
|
|
461
|
+
setFieldMetaMapOnPrototype(prototype, metadataMap);
|
|
462
|
+
};
|
|
463
|
+
};
|
|
464
|
+
var makeField = (customOption) => (returns, fieldOption) => {
|
|
465
|
+
const [modelRef, arrDepth] = getNonArrayModel(returns());
|
|
466
|
+
if (!fieldOption)
|
|
467
|
+
return applyFieldMeta(modelRef, arrDepth, { ...customOption }, arrDepth);
|
|
468
|
+
const [opt, optArrDepth] = getNonArrayModel(fieldOption);
|
|
469
|
+
return applyFieldMeta(modelRef, arrDepth, { ...opt, ...customOption }, optArrDepth);
|
|
470
|
+
};
|
|
471
|
+
var Field = {
|
|
472
|
+
Prop: makeField({ fieldType: "property" }),
|
|
473
|
+
Hidden: makeField({ fieldType: "hidden", nullable: true }),
|
|
474
|
+
Secret: makeField({ fieldType: "hidden", select: false, nullable: true }),
|
|
475
|
+
Resolve: makeField({ fieldType: "resolve" })
|
|
476
|
+
};
|
|
459
477
|
|
|
460
|
-
|
|
461
|
-
|
|
478
|
+
// pkgs/@akanjs/constant/src/constantDecorator.ts
|
|
479
|
+
var import_reflect_metadata2 = require("reflect-metadata");
|
|
462
480
|
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
481
|
+
// pkgs/@akanjs/constant/src/filterMeta.ts
|
|
482
|
+
var setFilterMeta = (filterRef, filterMeta) => {
|
|
483
|
+
const existingFilterMeta = Reflect.getMetadata("filter", filterRef.prototype);
|
|
484
|
+
if (existingFilterMeta)
|
|
485
|
+
Object.assign(filterMeta.sort, existingFilterMeta.sort);
|
|
486
|
+
Reflect.defineMetadata("filter", filterMeta, filterRef.prototype);
|
|
487
|
+
};
|
|
488
|
+
var getFilterKeyMetaMapOnPrototype = (prototype) => {
|
|
489
|
+
const metadataMap = Reflect.getMetadata("filterKey", prototype) ?? /* @__PURE__ */ new Map();
|
|
490
|
+
return new Map(metadataMap);
|
|
491
|
+
};
|
|
492
|
+
var setFilterKeyMetaMapOnPrototype = (prototype, metadataMap) => {
|
|
493
|
+
Reflect.defineMetadata("filterKey", new Map(metadataMap), prototype);
|
|
494
|
+
};
|
|
495
|
+
var applyFilterKeyMeta = (option) => {
|
|
496
|
+
return (prototype, key, descriptor) => {
|
|
497
|
+
const metadata = { key, ...option, descriptor };
|
|
498
|
+
const metadataMap = getFilterKeyMetaMapOnPrototype(prototype);
|
|
499
|
+
metadataMap.set(key, metadata);
|
|
500
|
+
setFilterKeyMetaMapOnPrototype(prototype, metadataMap);
|
|
501
|
+
};
|
|
502
|
+
};
|
|
503
|
+
var makeFilter = (customOption) => (fieldOption) => {
|
|
504
|
+
return applyFilterKeyMeta({ ...customOption, ...fieldOption });
|
|
505
|
+
};
|
|
506
|
+
var getFilterArgMetasOnPrototype = (prototype, key) => {
|
|
507
|
+
const filterArgMetas = Reflect.getMetadata("filterArg", prototype, key) ?? [];
|
|
508
|
+
return filterArgMetas;
|
|
509
|
+
};
|
|
510
|
+
var setFilterArgMetasOnPrototype = (prototype, key, filterArgMetas) => {
|
|
511
|
+
Reflect.defineMetadata("filterArg", filterArgMetas, prototype, key);
|
|
512
|
+
};
|
|
513
|
+
var applyFilterArgMeta = (name, returns, argOption) => {
|
|
514
|
+
return (prototype, key, idx) => {
|
|
515
|
+
const [modelRef, arrDepth] = getNonArrayModel(returns());
|
|
516
|
+
const [opt, optArrDepth] = getNonArrayModel(argOption ?? {});
|
|
517
|
+
const filterArgMeta = { name, ...opt, modelRef, arrDepth, isArray: arrDepth > 0, optArrDepth };
|
|
518
|
+
const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
|
|
519
|
+
filterArgMetas[idx] = filterArgMeta;
|
|
520
|
+
setFilterArgMetasOnPrototype(prototype, key, filterArgMetas);
|
|
521
|
+
};
|
|
522
|
+
};
|
|
523
|
+
var getFilterQuery = (filterRef, key) => {
|
|
524
|
+
const filterKeyMetaMap = getFilterKeyMetaMapOnPrototype(filterRef.prototype);
|
|
525
|
+
const filterKeyMeta = filterKeyMetaMap.get(key);
|
|
526
|
+
if (!filterKeyMeta?.descriptor.value)
|
|
527
|
+
throw new Error(`filterKeyMeta is not defined for key: ${key}`);
|
|
528
|
+
return filterKeyMeta.descriptor.value;
|
|
529
|
+
};
|
|
530
|
+
var Filter = {
|
|
531
|
+
Mongo: makeFilter({ type: "mongo" }),
|
|
532
|
+
// Meili: makeFilter({ fieldType: "hidden", nullable: true }),
|
|
533
|
+
Arg: applyFilterArgMeta
|
|
534
|
+
};
|
|
517
535
|
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
536
|
+
// pkgs/@akanjs/constant/src/baseGql.ts
|
|
537
|
+
var import_reflect_metadata3 = require("reflect-metadata");
|
|
538
|
+
var defaultFieldMeta = {
|
|
539
|
+
fieldType: "property",
|
|
540
|
+
immutable: false,
|
|
541
|
+
select: true,
|
|
542
|
+
isClass: false,
|
|
543
|
+
isScalar: true,
|
|
544
|
+
nullable: false,
|
|
545
|
+
isArray: false,
|
|
546
|
+
arrDepth: 0,
|
|
547
|
+
optArrDepth: 0,
|
|
548
|
+
default: null,
|
|
549
|
+
isMap: false
|
|
550
|
+
};
|
|
551
|
+
var idFieldMeta = { ...defaultFieldMeta, key: "id", name: "ID", modelRef: ID };
|
|
552
|
+
var createdAtFieldMeta = { ...defaultFieldMeta, key: "createdAt", name: "Date", modelRef: Date };
|
|
553
|
+
var updatedAtFieldMeta = { ...defaultFieldMeta, key: "updatedAt", name: "Date", modelRef: Date };
|
|
554
|
+
var removedAtFieldMeta = {
|
|
555
|
+
...defaultFieldMeta,
|
|
556
|
+
key: "removedAt",
|
|
557
|
+
name: "Date",
|
|
558
|
+
modelRef: Date,
|
|
559
|
+
nullable: true,
|
|
560
|
+
default: null
|
|
561
|
+
};
|
|
544
562
|
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
};
|
|
563
|
+
// pkgs/@akanjs/constant/src/classMeta.ts
|
|
564
|
+
var import_reflect_metadata4 = require("reflect-metadata");
|
|
565
|
+
var InputModelStorage = class {
|
|
566
|
+
};
|
|
567
|
+
var LightModelStorage = class {
|
|
568
|
+
};
|
|
569
|
+
var FullModelStorage = class {
|
|
570
|
+
};
|
|
571
|
+
var ScalarModelStorage = class {
|
|
572
|
+
};
|
|
573
|
+
var FilterModelStorage = class {
|
|
574
|
+
};
|
|
575
|
+
var hasTextField = (modelRef) => {
|
|
576
|
+
const fieldMetas = getFieldMetas(modelRef);
|
|
577
|
+
return fieldMetas.some(
|
|
578
|
+
(fieldMeta) => !!fieldMeta.text || fieldMeta.isScalar && fieldMeta.isClass && fieldMeta.select && hasTextField(fieldMeta.modelRef)
|
|
579
|
+
);
|
|
580
|
+
};
|
|
581
|
+
var applyClassMeta = (type, modelType, storage) => {
|
|
582
|
+
return function(refName) {
|
|
583
|
+
return function(target) {
|
|
584
|
+
const modelRef = target;
|
|
585
|
+
const classMeta = { refName, type, modelType, modelRef, hasTextField: hasTextField(modelRef) };
|
|
586
|
+
Reflect.defineMetadata("class", classMeta, modelRef.prototype);
|
|
587
|
+
Reflect.defineMetadata(refName, modelRef, storage.prototype);
|
|
571
588
|
};
|
|
572
589
|
};
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
590
|
+
};
|
|
591
|
+
var applyFilterMeta = (storage) => {
|
|
592
|
+
return function(refName) {
|
|
593
|
+
return function(target) {
|
|
594
|
+
const modelRef = target;
|
|
595
|
+
setFilterMeta(modelRef, { refName, sort: {} });
|
|
596
|
+
Reflect.defineMetadata(refName, modelRef, storage.prototype);
|
|
580
597
|
};
|
|
581
598
|
};
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
599
|
+
};
|
|
600
|
+
var Model = {
|
|
601
|
+
Light: applyClassMeta("light", "data", LightModelStorage),
|
|
602
|
+
Object: applyClassMeta("full", "ephemeral", FullModelStorage),
|
|
603
|
+
Full: applyClassMeta("full", "data", FullModelStorage),
|
|
604
|
+
Input: applyClassMeta("input", "data", InputModelStorage),
|
|
605
|
+
Scalar: applyClassMeta("scalar", "data", ScalarModelStorage),
|
|
606
|
+
Summary: applyClassMeta("scalar", "summary", ScalarModelStorage),
|
|
607
|
+
Insight: applyClassMeta("scalar", "insight", ScalarModelStorage),
|
|
608
|
+
Filter: applyFilterMeta(FilterModelStorage)
|
|
609
|
+
};
|
|
592
610
|
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
return target;
|
|
633
|
-
setServiceRefs(name, [...services, target]);
|
|
611
|
+
// pkgs/@akanjs/service/src/serviceDecorators.ts
|
|
612
|
+
var import_common4 = require("@nestjs/common");
|
|
613
|
+
var import_mongoose = require("@nestjs/mongoose");
|
|
614
|
+
var ServiceStorage = class {
|
|
615
|
+
};
|
|
616
|
+
var getServiceRefs = (refName) => {
|
|
617
|
+
return Reflect.getMetadata(refName, ServiceStorage.prototype) ?? [];
|
|
618
|
+
};
|
|
619
|
+
var setServiceRefs = (refName, services) => {
|
|
620
|
+
Reflect.defineMetadata(refName, services, ServiceStorage.prototype);
|
|
621
|
+
};
|
|
622
|
+
var isServiceDefined = (srvRef) => {
|
|
623
|
+
return Reflect.getMetadata("service", srvRef.prototype) ?? false;
|
|
624
|
+
};
|
|
625
|
+
var setServiceDefined = (srvRef) => {
|
|
626
|
+
Reflect.defineMetadata("service", true, srvRef.prototype);
|
|
627
|
+
};
|
|
628
|
+
var setServiceMeta = (srvRef, meta) => {
|
|
629
|
+
Reflect.defineMetadata("serviceMeta", meta, srvRef.prototype);
|
|
630
|
+
};
|
|
631
|
+
var getServiceMeta = (srvRef) => {
|
|
632
|
+
return Reflect.getMetadata("serviceMeta", srvRef.prototype);
|
|
633
|
+
};
|
|
634
|
+
var isServiceEnabled = (srvRef) => {
|
|
635
|
+
const meta = getServiceMeta(srvRef);
|
|
636
|
+
return meta?.enabled ?? false;
|
|
637
|
+
};
|
|
638
|
+
var getServiceInjectMetaMapOnPrototype = (prototype) => {
|
|
639
|
+
return Reflect.getMetadata("inject", prototype) ?? /* @__PURE__ */ new Map();
|
|
640
|
+
};
|
|
641
|
+
var setServiceInjectMetaMapOnPrototype = (prototype, injectMetaMap) => {
|
|
642
|
+
Reflect.defineMetadata("inject", injectMetaMap, prototype);
|
|
643
|
+
};
|
|
644
|
+
function Service(name, { enabled = true, serverMode } = {}) {
|
|
645
|
+
return function(target) {
|
|
646
|
+
const services = getServiceRefs(name);
|
|
647
|
+
const isEnabled = enabled && (!serverMode || process.env.SERVER_MODE === serverMode || process.env.SERVER_MODE === "all");
|
|
648
|
+
setServiceMeta(target, { name, enabled: isEnabled });
|
|
649
|
+
if (!isEnabled)
|
|
634
650
|
return target;
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
};
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
};
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
};
|
|
651
|
+
setServiceRefs(name, [...services, target]);
|
|
652
|
+
return target;
|
|
653
|
+
};
|
|
654
|
+
}
|
|
655
|
+
function Srv(name) {
|
|
656
|
+
return function(prototype, key) {
|
|
657
|
+
const metadataMap = getServiceInjectMetaMapOnPrototype(prototype);
|
|
658
|
+
metadataMap.set(key, { type: "Srv", key, name: name ?? capitalize(key) });
|
|
659
|
+
setServiceInjectMetaMapOnPrototype(prototype, metadataMap);
|
|
660
|
+
};
|
|
661
|
+
}
|
|
662
|
+
function Use(name) {
|
|
663
|
+
return function(prototype, key) {
|
|
664
|
+
const metadataMap = getServiceInjectMetaMapOnPrototype(prototype);
|
|
665
|
+
metadataMap.set(key, { type: "Use", key, name: name ?? capitalize(key) });
|
|
666
|
+
setServiceInjectMetaMapOnPrototype(prototype, metadataMap);
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
function Queue(name) {
|
|
670
|
+
return function(prototype, key) {
|
|
671
|
+
const metadataMap = getServiceInjectMetaMapOnPrototype(prototype);
|
|
672
|
+
metadataMap.set(key, { type: "Queue", key, name: name ?? capitalize(key) });
|
|
673
|
+
setServiceInjectMetaMapOnPrototype(prototype, metadataMap);
|
|
674
|
+
};
|
|
675
|
+
}
|
|
676
|
+
function Websocket(name) {
|
|
677
|
+
return function(prototype, key) {
|
|
678
|
+
const metadataMap = getServiceInjectMetaMapOnPrototype(prototype);
|
|
679
|
+
metadataMap.set(key, { type: "Websocket", key, name: name ?? capitalize(key) });
|
|
680
|
+
setServiceInjectMetaMapOnPrototype(prototype, metadataMap);
|
|
681
|
+
};
|
|
682
|
+
}
|
|
683
|
+
function Db(name) {
|
|
684
|
+
return function(prototype, key) {
|
|
685
|
+
const metadataMap = getServiceInjectMetaMapOnPrototype(prototype);
|
|
686
|
+
metadataMap.set(key, { type: "Db", key, name });
|
|
687
|
+
setServiceInjectMetaMapOnPrototype(prototype, metadataMap);
|
|
688
|
+
};
|
|
689
|
+
}
|
|
690
|
+
var serviceOf = (srvRef) => {
|
|
691
|
+
if (isServiceDefined(srvRef))
|
|
692
|
+
return srvRef;
|
|
693
|
+
const injectMetaMap = getServiceInjectMetaMapOnPrototype(srvRef.prototype);
|
|
694
|
+
for (const injectMeta of [...injectMetaMap.values()]) {
|
|
695
|
+
if (injectMeta.type === "Db")
|
|
696
|
+
(0, import_mongoose.InjectModel)(injectMeta.name)(srvRef.prototype, injectMeta.key);
|
|
697
|
+
else if (injectMeta.type === "Use")
|
|
698
|
+
(0, import_common4.Inject)(injectMeta.name)(srvRef.prototype, injectMeta.key);
|
|
699
|
+
else if (injectMeta.type === "Srv") {
|
|
700
|
+
const services = getServiceRefs(injectMeta.name);
|
|
701
|
+
if (!services.length)
|
|
702
|
+
throw new Error(`Service ${injectMeta.name} not found`);
|
|
703
|
+
(0, import_common4.Inject)(services.at(-1))(srvRef.prototype, injectMeta.key);
|
|
704
|
+
} else if (injectMeta.type === "Queue")
|
|
705
|
+
(0, import_common4.Inject)(injectMeta.name)(srvRef.prototype, injectMeta.key);
|
|
706
|
+
else
|
|
707
|
+
(0, import_common4.Inject)(injectMeta.name)(srvRef.prototype, injectMeta.key);
|
|
657
708
|
}
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
709
|
+
(0, import_mongoose.InjectConnection)()(srvRef.prototype, "connection");
|
|
710
|
+
(0, import_common4.Injectable)()(srvRef);
|
|
711
|
+
setServiceDefined(srvRef);
|
|
712
|
+
return srvRef;
|
|
713
|
+
};
|
|
714
|
+
var AVOID_MIX_SRV_KEY_SET = /* @__PURE__ */ new Set(["onModuleInit", "onModuleDestroy"]);
|
|
715
|
+
function MixSrvs(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) {
|
|
716
|
+
class Mix extends t1 {
|
|
664
717
|
}
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
const
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
}
|
|
718
|
+
const injectMetadataMap = new Map(
|
|
719
|
+
[t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20].filter((t) => !!t).reduce((acc, srvRef) => {
|
|
720
|
+
const injectMetadataMap2 = getServiceInjectMetaMapOnPrototype(srvRef);
|
|
721
|
+
applyMixins(Mix, [srvRef], AVOID_MIX_SRV_KEY_SET);
|
|
722
|
+
return [...acc, ...injectMetadataMap2];
|
|
723
|
+
}, [])
|
|
724
|
+
);
|
|
725
|
+
Reflect.defineMetadata("service", false, Mix.prototype);
|
|
726
|
+
Reflect.defineMetadata("inject", injectMetadataMap, Mix.prototype);
|
|
727
|
+
return Mix;
|
|
728
|
+
}
|
|
729
|
+
var LogService = (name) => {
|
|
730
|
+
class LogService2 {
|
|
731
|
+
logger = new Logger(name);
|
|
671
732
|
}
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
else if (injectMeta.type === "Srv") {
|
|
682
|
-
const services = getServiceRefs(injectMeta.name);
|
|
683
|
-
if (!services.length)
|
|
684
|
-
throw new Error(`Service ${injectMeta.name} not found`);
|
|
685
|
-
(0, import_common4.Inject)(services.at(-1))(srvRef.prototype, injectMeta.key);
|
|
686
|
-
} else if (injectMeta.type === "Queue")
|
|
687
|
-
(0, import_common4.Inject)(injectMeta.name)(srvRef.prototype, injectMeta.key);
|
|
688
|
-
else
|
|
689
|
-
(0, import_common4.Inject)(injectMeta.name)(srvRef.prototype, injectMeta.key);
|
|
733
|
+
return LogService2;
|
|
734
|
+
};
|
|
735
|
+
var DbService = (database, sigRef) => {
|
|
736
|
+
const [modelName, className] = [database.refName, capitalize(database.refName)];
|
|
737
|
+
class DbService2 {
|
|
738
|
+
logger = new Logger(`${modelName}Service`);
|
|
739
|
+
__databaseModel;
|
|
740
|
+
async __list(query, queryOption) {
|
|
741
|
+
return await this.__databaseModel.__list(query, queryOption);
|
|
690
742
|
}
|
|
691
|
-
(
|
|
692
|
-
|
|
693
|
-
setServiceDefined(srvRef);
|
|
694
|
-
return srvRef;
|
|
695
|
-
};
|
|
696
|
-
var AVOID_MIX_SRV_KEY_SET = /* @__PURE__ */ new Set(["onModuleInit", "onModuleDestroy"]);
|
|
697
|
-
function MixSrvs(t1, t2, t3, t4, t5, t6, t7, t8, t9, t10, t11, t12, t13, t14, t15, t16, t17, t18, t19, t20) {
|
|
698
|
-
class Mix extends t1 {
|
|
743
|
+
async __listIds(query, queryOption) {
|
|
744
|
+
return await this.__databaseModel.__listIds(query, queryOption);
|
|
699
745
|
}
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
const injectMetadataMap2 = getServiceInjectMetaMapOnPrototype(srvRef);
|
|
703
|
-
applyMixins(Mix, [srvRef], AVOID_MIX_SRV_KEY_SET);
|
|
704
|
-
return [...acc, ...injectMetadataMap2];
|
|
705
|
-
}, [])
|
|
706
|
-
);
|
|
707
|
-
Reflect.defineMetadata("service", false, Mix.prototype);
|
|
708
|
-
Reflect.defineMetadata("inject", injectMetadataMap, Mix.prototype);
|
|
709
|
-
return Mix;
|
|
710
|
-
}
|
|
711
|
-
var LogService = (name) => {
|
|
712
|
-
class LogService2 {
|
|
713
|
-
logger = new Logger(name);
|
|
746
|
+
async __find(query, queryOption) {
|
|
747
|
+
return await this.__databaseModel.__find(query, queryOption);
|
|
714
748
|
}
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
}
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
}
|
|
790
|
-
async [`update${className}`](id, data) {
|
|
791
|
-
const input = await this._preUpdate(id, data);
|
|
792
|
-
const doc = await this.__databaseModel[`update${className}`](id, input);
|
|
793
|
-
return await this._postUpdate(doc);
|
|
794
|
-
}
|
|
795
|
-
async [`remove${className}`](id) {
|
|
796
|
-
await this._preRemove(id);
|
|
797
|
-
const doc = await this.__databaseModel[`remove${className}`](id);
|
|
798
|
-
return await this._postRemove(doc);
|
|
799
|
-
}
|
|
800
|
-
async [`search${className}`](query, queryOption) {
|
|
801
|
-
return await this.__databaseModel[`search${className}`](query, queryOption);
|
|
802
|
-
}
|
|
803
|
-
async [`searchDocs${className}`](query, queryOption) {
|
|
804
|
-
return await this.__databaseModel[`searchDocs${className}`](query, queryOption);
|
|
805
|
-
}
|
|
806
|
-
async [`searchCount${className}`](query) {
|
|
807
|
-
return await this.__databaseModel[`searchCount${className}`](query);
|
|
808
|
-
}
|
|
749
|
+
async __findId(query, queryOption) {
|
|
750
|
+
return await this.__databaseModel.__findId(query, queryOption);
|
|
751
|
+
}
|
|
752
|
+
async __pick(query, queryOption) {
|
|
753
|
+
return await this.__databaseModel.__pick(query, queryOption);
|
|
754
|
+
}
|
|
755
|
+
async __pickId(query, queryOption) {
|
|
756
|
+
return await this.__databaseModel.__pickId(query, queryOption);
|
|
757
|
+
}
|
|
758
|
+
async __exists(query) {
|
|
759
|
+
return await this.__databaseModel.__exists(query);
|
|
760
|
+
}
|
|
761
|
+
async __count(query) {
|
|
762
|
+
return await this.__databaseModel.__count(query);
|
|
763
|
+
}
|
|
764
|
+
async __insight(query) {
|
|
765
|
+
return await this.__databaseModel.__insight(query);
|
|
766
|
+
}
|
|
767
|
+
async __search(searchText, queryOption) {
|
|
768
|
+
return await this.__databaseModel[`search${className}`](searchText, queryOption);
|
|
769
|
+
}
|
|
770
|
+
async __searchDocs(searchText, queryOption) {
|
|
771
|
+
return await this.__databaseModel[`searchDocs${className}`](searchText, queryOption);
|
|
772
|
+
}
|
|
773
|
+
async __searchCount(searchText) {
|
|
774
|
+
return await this.__databaseModel[`searchCount${className}`](searchText);
|
|
775
|
+
}
|
|
776
|
+
async _preCreate(data) {
|
|
777
|
+
return data;
|
|
778
|
+
}
|
|
779
|
+
async _postCreate(doc) {
|
|
780
|
+
return doc;
|
|
781
|
+
}
|
|
782
|
+
async _preUpdate(id, data) {
|
|
783
|
+
return data;
|
|
784
|
+
}
|
|
785
|
+
async _postUpdate(doc) {
|
|
786
|
+
return doc;
|
|
787
|
+
}
|
|
788
|
+
async _preRemove(id) {
|
|
789
|
+
return;
|
|
790
|
+
}
|
|
791
|
+
async _postRemove(doc) {
|
|
792
|
+
return doc;
|
|
793
|
+
}
|
|
794
|
+
async [`get${className}`](id) {
|
|
795
|
+
return await this.__databaseModel[`get${className}`](id);
|
|
796
|
+
}
|
|
797
|
+
async [`load${className}`](id) {
|
|
798
|
+
return await this.__databaseModel[`load${className}`](id);
|
|
799
|
+
}
|
|
800
|
+
async [`load${className}Many`](ids) {
|
|
801
|
+
return await this.__databaseModel[`load${className}Many`](ids);
|
|
802
|
+
}
|
|
803
|
+
async [`create${className}`](data) {
|
|
804
|
+
const input = await this._preCreate(data);
|
|
805
|
+
const doc = await this.__databaseModel[`create${className}`](input);
|
|
806
|
+
return await this._postCreate(doc);
|
|
807
|
+
}
|
|
808
|
+
async [`update${className}`](id, data) {
|
|
809
|
+
const input = await this._preUpdate(id, data);
|
|
810
|
+
const doc = await this.__databaseModel[`update${className}`](id, input);
|
|
811
|
+
return await this._postUpdate(doc);
|
|
812
|
+
}
|
|
813
|
+
async [`remove${className}`](id) {
|
|
814
|
+
await this._preRemove(id);
|
|
815
|
+
const doc = await this.__databaseModel[`remove${className}`](id);
|
|
816
|
+
return await this._postRemove(doc);
|
|
817
|
+
}
|
|
818
|
+
async [`search${className}`](query, queryOption) {
|
|
819
|
+
return await this.__databaseModel[`search${className}`](query, queryOption);
|
|
820
|
+
}
|
|
821
|
+
async [`searchDocs${className}`](query, queryOption) {
|
|
822
|
+
return await this.__databaseModel[`searchDocs${className}`](query, queryOption);
|
|
809
823
|
}
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
824
|
+
async [`searchCount${className}`](query) {
|
|
825
|
+
return await this.__databaseModel[`searchCount${className}`](query);
|
|
826
|
+
}
|
|
827
|
+
}
|
|
828
|
+
__decorateClass([
|
|
829
|
+
Use(`${modelName}Model`)
|
|
830
|
+
], DbService2.prototype, "__databaseModel", 2);
|
|
831
|
+
const getQueryDataFromKey = (queryKey, args) => {
|
|
832
|
+
const lastArg = args.at(-1);
|
|
833
|
+
const hasQueryOption = lastArg && typeof lastArg === "object" && (typeof lastArg.select === "object" || typeof lastArg.skip === "number" || typeof lastArg.limit === "number" || typeof lastArg.sort === "string");
|
|
834
|
+
const queryFn = getFilterQuery(database.Filter, queryKey);
|
|
835
|
+
const query = queryFn(...hasQueryOption ? args.slice(0, -1) : args);
|
|
836
|
+
const queryOption = hasQueryOption ? lastArg : {};
|
|
837
|
+
return { query, queryOption };
|
|
838
|
+
};
|
|
839
|
+
const filterKeyMetaMap = getFilterKeyMetaMapOnPrototype(database.Filter.prototype);
|
|
840
|
+
const queryKeys = [...filterKeyMetaMap.keys()];
|
|
841
|
+
queryKeys.forEach((queryKey) => {
|
|
842
|
+
const queryFn = getFilterQuery(database.Filter, queryKey);
|
|
843
|
+
DbService2.prototype[`list${capitalize(queryKey)}`] = async function(...args) {
|
|
844
|
+
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
845
|
+
return this.__list(query, queryOption);
|
|
846
|
+
};
|
|
847
|
+
DbService2.prototype[`listIds${capitalize(queryKey)}`] = async function(...args) {
|
|
848
|
+
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
849
|
+
return this.__listIds(query, queryOption);
|
|
850
|
+
};
|
|
851
|
+
DbService2.prototype[`find${capitalize(queryKey)}`] = async function(...args) {
|
|
852
|
+
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
853
|
+
return this.__find(query, queryOption);
|
|
854
|
+
};
|
|
855
|
+
DbService2.prototype[`findId${capitalize(queryKey)}`] = async function(...args) {
|
|
856
|
+
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
857
|
+
return this.__findId(query, queryOption);
|
|
858
|
+
};
|
|
859
|
+
DbService2.prototype[`pick${capitalize(queryKey)}`] = async function(...args) {
|
|
860
|
+
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
861
|
+
return this.__pick(query, queryOption);
|
|
862
|
+
};
|
|
863
|
+
DbService2.prototype[`pickId${capitalize(queryKey)}`] = async function(...args) {
|
|
864
|
+
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
865
|
+
return this.__pickId(query, queryOption);
|
|
866
|
+
};
|
|
867
|
+
DbService2.prototype[`exists${capitalize(queryKey)}`] = async function(...args) {
|
|
868
|
+
const query = queryFn(...args);
|
|
869
|
+
return this.__exists(query);
|
|
870
|
+
};
|
|
871
|
+
DbService2.prototype[`count${capitalize(queryKey)}`] = async function(...args) {
|
|
872
|
+
const query = queryFn(...args);
|
|
873
|
+
return this.__count(query);
|
|
874
|
+
};
|
|
875
|
+
DbService2.prototype[`insight${capitalize(queryKey)}`] = async function(...args) {
|
|
876
|
+
const query = queryFn(...args);
|
|
877
|
+
return this.__insight(query);
|
|
878
|
+
};
|
|
879
|
+
});
|
|
880
|
+
Use(`${modelName}Model`)(DbService2.prototype, `${modelName}Model`);
|
|
881
|
+
return DbService2;
|
|
882
|
+
};
|
|
883
|
+
var ExtendedUserService = (database, srvRef, sigRef) => {
|
|
884
|
+
const filterKeyMetaMap = getFilterKeyMetaMapOnPrototype(database.Filter.prototype);
|
|
885
|
+
const queryKeys = [...filterKeyMetaMap.keys()];
|
|
886
|
+
queryKeys.forEach((queryKey) => {
|
|
887
|
+
const queryFn = getFilterQuery(database.Filter, queryKey);
|
|
888
|
+
srvRef.prototype[`list${capitalize(queryKey)}`] = async function(...args) {
|
|
889
|
+
const queryOption = args.at(-1);
|
|
890
|
+
const hasQueryOption = typeof queryOption === "object" && (typeof queryOption.select === "object" || typeof queryOption.skip === "number" || typeof queryOption.limit === "number" || typeof queryOption.sort === "string");
|
|
817
891
|
const query = queryFn(...hasQueryOption ? args.slice(0, -1) : args);
|
|
818
|
-
|
|
819
|
-
return { query, queryOption };
|
|
892
|
+
return this.__list(query, queryOption);
|
|
820
893
|
};
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
835
|
-
return this.__find(query, queryOption);
|
|
836
|
-
};
|
|
837
|
-
DbService2.prototype[`findId${capitalize(queryKey)}`] = async function(...args) {
|
|
838
|
-
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
839
|
-
return this.__findId(query, queryOption);
|
|
840
|
-
};
|
|
841
|
-
DbService2.prototype[`pick${capitalize(queryKey)}`] = async function(...args) {
|
|
842
|
-
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
843
|
-
return this.__pick(query, queryOption);
|
|
844
|
-
};
|
|
845
|
-
DbService2.prototype[`pickId${capitalize(queryKey)}`] = async function(...args) {
|
|
846
|
-
const { query, queryOption } = getQueryDataFromKey(queryKey, args);
|
|
847
|
-
return this.__pickId(query, queryOption);
|
|
848
|
-
};
|
|
849
|
-
DbService2.prototype[`exists${capitalize(queryKey)}`] = async function(...args) {
|
|
850
|
-
const query = queryFn(...args);
|
|
851
|
-
return this.__exists(query);
|
|
852
|
-
};
|
|
853
|
-
DbService2.prototype[`count${capitalize(queryKey)}`] = async function(...args) {
|
|
854
|
-
const query = queryFn(...args);
|
|
855
|
-
return this.__count(query);
|
|
856
|
-
};
|
|
857
|
-
DbService2.prototype[`insight${capitalize(queryKey)}`] = async function(...args) {
|
|
858
|
-
const query = queryFn(...args);
|
|
859
|
-
return this.__insight(query);
|
|
860
|
-
};
|
|
861
|
-
});
|
|
862
|
-
Use(`${modelName}Model`)(DbService2.prototype, `${modelName}Model`);
|
|
863
|
-
return DbService2;
|
|
864
|
-
};
|
|
865
|
-
var ExtendedUserService = (database, srvRef, sigRef) => {
|
|
866
|
-
const filterKeyMetaMap = getFilterKeyMetaMapOnPrototype(database.Filter.prototype);
|
|
867
|
-
const queryKeys = [...filterKeyMetaMap.keys()];
|
|
868
|
-
queryKeys.forEach((queryKey) => {
|
|
869
|
-
const queryFn = getFilterQuery(database.Filter, queryKey);
|
|
870
|
-
srvRef.prototype[`list${capitalize(queryKey)}`] = async function(...args) {
|
|
871
|
-
const queryOption = args.at(-1);
|
|
872
|
-
const hasQueryOption = typeof queryOption === "object" && (typeof queryOption.select === "object" || typeof queryOption.skip === "number" || typeof queryOption.limit === "number" || typeof queryOption.sort === "string");
|
|
873
|
-
const query = queryFn(...hasQueryOption ? args.slice(0, -1) : args);
|
|
874
|
-
return this.__list(query, queryOption);
|
|
875
|
-
};
|
|
876
|
-
srvRef.prototype[`insight${capitalize(queryKey)}`] = async function(...args) {
|
|
877
|
-
const query = queryFn(...args);
|
|
878
|
-
return this.__insight(query);
|
|
879
|
-
};
|
|
880
|
-
});
|
|
881
|
-
return srvRef;
|
|
882
|
-
};
|
|
883
|
-
var ExtendedSummaryService = (database, srvRef, sigRef) => {
|
|
884
|
-
return srvRef;
|
|
885
|
-
};
|
|
886
|
-
var ExtendedSettingService = (database, srvRef, sigRef) => {
|
|
887
|
-
return srvRef;
|
|
888
|
-
};
|
|
889
|
-
})();
|
|
894
|
+
srvRef.prototype[`insight${capitalize(queryKey)}`] = async function(...args) {
|
|
895
|
+
const query = queryFn(...args);
|
|
896
|
+
return this.__insight(query);
|
|
897
|
+
};
|
|
898
|
+
});
|
|
899
|
+
return srvRef;
|
|
900
|
+
};
|
|
901
|
+
var ExtendedSummaryService = (database, srvRef, sigRef) => {
|
|
902
|
+
return srvRef;
|
|
903
|
+
};
|
|
904
|
+
var ExtendedSettingService = (database, srvRef, sigRef) => {
|
|
905
|
+
return srvRef;
|
|
906
|
+
};
|
|
890
907
|
//! Nextjs는 환경변수를 build time에 그냥 하드코딩으로 값을 넣어버림. operationMode같은것들 잘 동작안할 수 있음. 추후 수정 필요.
|