@akanjs/test 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.
Files changed (2) hide show
  1. package/index.js +593 -589
  2. package/package.json +1 -1
package/index.js CHANGED
@@ -1,37 +1,42 @@
1
- (() => {
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __require = /* @__PURE__ */ ((x) => typeof require !== "undefined" ? require : typeof Proxy !== "undefined" ? new Proxy(x, {
9
- get: (a, b) => (typeof require !== "undefined" ? require : a)[b]
10
- }) : x)(function(x) {
11
- if (typeof require !== "undefined")
12
- return require.apply(this, arguments);
13
- throw Error('Dynamic require of "' + x + '" is not supported');
14
- });
15
- var __copyProps = (to, from, except, desc) => {
16
- if (from && typeof from === "object" || typeof from === "function") {
17
- for (let key of __getOwnPropNames(from))
18
- if (!__hasOwnProp.call(to, key) && key !== except)
19
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
20
- }
21
- return to;
22
- };
23
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
24
- // If the importer is in node compatibility mode or this is not an ESM
25
- // file that has been converted to a CommonJS file using a Babel-
26
- // compatible transform (i.e. "__esModule" has not been set), then set
27
- // "default" to the CommonJS "module.exports" for node compatibility.
28
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
29
- mod
30
- ));
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
+
29
+ // pkgs/@akanjs/test/index.ts
30
+ var test_exports = {};
31
+ __export(test_exports, {
32
+ sample: () => sample,
33
+ sampleOf: () => sampleOf
34
+ });
35
+ module.exports = __toCommonJS(test_exports);
31
36
 
32
- // pkgs/@akanjs/base/src/base.ts
33
- var version = "0.9.0";
34
- var logo = `
37
+ // pkgs/@akanjs/base/src/base.ts
38
+ var version = "0.9.0";
39
+ var logo = `
35
40
  _ _ _
36
41
  / \\ | | ____ _ _ __ (_)___
37
42
  / _ \\ | |/ / _' | '_ \\ | / __|
@@ -43,584 +48,583 @@
43
48
 
44
49
  `;
45
50
 
46
- // pkgs/@akanjs/base/src/baseEnv.ts
47
- var appName = process.env.NEXT_PUBLIC_APP_NAME ?? "unknown";
48
- var repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? "unknown";
49
- var serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "unknown";
50
- if (appName === "unknown")
51
- throw new Error("environment variable NEXT_PUBLIC_APP_NAME is required");
52
- if (repoName === "unknown")
53
- throw new Error("environment variable NEXT_PUBLIC_REPO_NAME is required");
54
- if (serveDomain === "unknown")
55
- throw new Error("environment variable NEXT_PUBLIC_SERVE_DOMAIN is required");
56
- var environment = process.env.NEXT_PUBLIC_ENV ?? "debug";
57
- var operationType = typeof window !== "undefined" ? "client" : process.env.NEXT_RUNTIME ? "client" : "server";
58
- var operationMode = process.env.NEXT_PUBLIC_OPERATION_MODE ?? "cloud";
59
- var networkType = process.env.NEXT_PUBLIC_NETWORK_TYPE ?? (environment === "main" ? "mainnet" : environment === "develop" ? "testnet" : "debugnet");
60
- var tunnelUsername = process.env.SSU_TUNNEL_USERNAME ?? "root";
61
- var tunnelPassword = process.env.SSU_TUNNEL_PASSWORD ?? repoName;
62
- var baseEnv = {
63
- repoName,
64
- serveDomain,
65
- appName,
66
- environment,
67
- operationType,
68
- operationMode,
69
- networkType,
70
- tunnelUsername,
71
- tunnelPassword
72
- };
73
- var side = typeof window === "undefined" ? "server" : "client";
74
- var renderMode = process.env.RENDER_ENV ?? "ssr";
75
- var clientHost = process.env.NEXT_PUBLIC_CLIENT_HOST ?? (operationMode === "local" || side === "server" ? "localhost" : window.location.hostname);
76
- var clientPort = parseInt(
77
- process.env.NEXT_PUBLIC_CLIENT_PORT ?? (operationMode === "local" ? renderMode === "ssr" ? "4200" : "4201" : "443")
78
- );
79
- var clientHttpProtocol = side === "client" ? window.location.protocol : clientHost === "localhost" ? "http:" : "https:";
80
- var clientHttpUri = `${clientHttpProtocol}//${clientHost}${clientPort === 443 ? "" : `:${clientPort}`}`;
81
- 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");
82
- var serverPort = parseInt(
83
- process.env.SERVER_PORT ?? (operationMode === "local" || side === "server" ? "8080" : "443")
84
- );
85
- var serverHttpProtocol = side === "client" ? window.location.protocol : "http:";
86
- var serverHttpUri = `${serverHttpProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}/backend`;
87
- var serverGraphqlUri = `${serverHttpUri}/graphql`;
88
- var serverWsProtocol = serverHttpProtocol === "http:" ? "ws:" : "wss:";
89
- var serverWsUri = `${serverWsProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}`;
90
- var baseClientEnv = {
91
- ...baseEnv,
92
- side,
93
- renderMode,
94
- websocket: true,
95
- clientHost,
96
- clientPort,
97
- clientHttpProtocol,
98
- clientHttpUri,
99
- serverHost,
100
- serverPort,
101
- serverHttpProtocol,
102
- serverHttpUri,
103
- serverGraphqlUri,
104
- serverWsProtocol,
105
- serverWsUri
106
- };
51
+ // pkgs/@akanjs/base/src/baseEnv.ts
52
+ var appName = process.env.NEXT_PUBLIC_APP_NAME ?? "unknown";
53
+ var repoName = process.env.NEXT_PUBLIC_REPO_NAME ?? "unknown";
54
+ var serveDomain = process.env.NEXT_PUBLIC_SERVE_DOMAIN ?? "unknown";
55
+ if (appName === "unknown")
56
+ throw new Error("environment variable NEXT_PUBLIC_APP_NAME is required");
57
+ if (repoName === "unknown")
58
+ throw new Error("environment variable NEXT_PUBLIC_REPO_NAME is required");
59
+ if (serveDomain === "unknown")
60
+ throw new Error("environment variable NEXT_PUBLIC_SERVE_DOMAIN is required");
61
+ var environment = process.env.NEXT_PUBLIC_ENV ?? "debug";
62
+ var operationType = typeof window !== "undefined" ? "client" : process.env.NEXT_RUNTIME ? "client" : "server";
63
+ var operationMode = process.env.NEXT_PUBLIC_OPERATION_MODE ?? "cloud";
64
+ var networkType = process.env.NEXT_PUBLIC_NETWORK_TYPE ?? (environment === "main" ? "mainnet" : environment === "develop" ? "testnet" : "debugnet");
65
+ var tunnelUsername = process.env.SSU_TUNNEL_USERNAME ?? "root";
66
+ var tunnelPassword = process.env.SSU_TUNNEL_PASSWORD ?? repoName;
67
+ var baseEnv = {
68
+ repoName,
69
+ serveDomain,
70
+ appName,
71
+ environment,
72
+ operationType,
73
+ operationMode,
74
+ networkType,
75
+ tunnelUsername,
76
+ tunnelPassword
77
+ };
78
+ var side = typeof window === "undefined" ? "server" : "client";
79
+ var renderMode = process.env.RENDER_ENV ?? "ssr";
80
+ var clientHost = process.env.NEXT_PUBLIC_CLIENT_HOST ?? (operationMode === "local" || side === "server" ? "localhost" : window.location.hostname);
81
+ var clientPort = parseInt(
82
+ process.env.NEXT_PUBLIC_CLIENT_PORT ?? (operationMode === "local" ? renderMode === "ssr" ? "4200" : "4201" : "443")
83
+ );
84
+ var clientHttpProtocol = side === "client" ? window.location.protocol : clientHost === "localhost" ? "http:" : "https:";
85
+ var clientHttpUri = `${clientHttpProtocol}//${clientHost}${clientPort === 443 ? "" : `:${clientPort}`}`;
86
+ 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");
87
+ var serverPort = parseInt(
88
+ process.env.SERVER_PORT ?? (operationMode === "local" || side === "server" ? "8080" : "443")
89
+ );
90
+ var serverHttpProtocol = side === "client" ? window.location.protocol : "http:";
91
+ var serverHttpUri = `${serverHttpProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}/backend`;
92
+ var serverGraphqlUri = `${serverHttpUri}/graphql`;
93
+ var serverWsProtocol = serverHttpProtocol === "http:" ? "ws:" : "wss:";
94
+ var serverWsUri = `${serverWsProtocol}//${serverHost}${serverPort === 443 ? "" : `:${serverPort}`}`;
95
+ var baseClientEnv = {
96
+ ...baseEnv,
97
+ side,
98
+ renderMode,
99
+ websocket: true,
100
+ clientHost,
101
+ clientPort,
102
+ clientHttpProtocol,
103
+ clientHttpUri,
104
+ serverHost,
105
+ serverPort,
106
+ serverHttpProtocol,
107
+ serverHttpUri,
108
+ serverGraphqlUri,
109
+ serverWsProtocol,
110
+ serverWsUri
111
+ };
107
112
 
108
- // pkgs/@akanjs/base/src/scalar.ts
109
- var import_dayjs = __toESM(__require("dayjs"));
110
- var dayjs = import_dayjs.default;
111
- var Int = class {
112
- __Scalar__;
113
- };
114
- var Upload = class {
115
- __Scalar__;
116
- filename;
117
- mimetype;
118
- encoding;
119
- createReadStream;
120
- };
121
- var Float = class {
122
- __Scalar__;
123
- };
124
- var ID = class {
125
- __Scalar__;
126
- };
127
- var JSON = class {
128
- __Scalar__;
129
- };
130
- var getNonArrayModel = (arraiedModel) => {
131
- let arrDepth = 0;
132
- let target = arraiedModel;
133
- while (Array.isArray(target)) {
134
- target = target[0];
135
- arrDepth++;
136
- }
137
- return [target, arrDepth];
138
- };
139
- var scalarSet = /* @__PURE__ */ new Set([String, Boolean, Date, ID, Int, Float, Upload, JSON, Map]);
140
- var scalarNameMap = /* @__PURE__ */ new Map([
141
- [ID, "ID"],
142
- [Int, "Int"],
143
- [Float, "Float"],
144
- [String, "String"],
145
- [Boolean, "Boolean"],
146
- [Date, "Date"],
147
- [Upload, "Upload"],
148
- [JSON, "JSON"],
149
- [Map, "Map"]
150
- ]);
151
- var scalarArgMap = /* @__PURE__ */ new Map([
152
- [ID, null],
153
- [String, ""],
154
- [Boolean, false],
155
- [Date, dayjs(/* @__PURE__ */ new Date(-1))],
156
- [Int, 0],
157
- [Float, 0],
158
- [JSON, {}],
159
- [Map, {}]
160
- ]);
161
- var scalarDefaultMap = /* @__PURE__ */ new Map([
162
- [ID, null],
163
- [String, ""],
164
- [Boolean, false],
165
- [Date, dayjs(/* @__PURE__ */ new Date(-1))],
166
- [Int, 0],
167
- [Float, 0],
168
- [JSON, {}]
169
- ]);
170
- var isGqlScalar = (modelRef) => scalarSet.has(modelRef);
171
- var isGqlMap = (modelRef) => modelRef === Map;
113
+ // pkgs/@akanjs/base/src/scalar.ts
114
+ var import_dayjs = __toESM(require("dayjs"));
115
+ var dayjs = import_dayjs.default;
116
+ var Int = class {
117
+ __Scalar__;
118
+ };
119
+ var Upload = class {
120
+ __Scalar__;
121
+ filename;
122
+ mimetype;
123
+ encoding;
124
+ createReadStream;
125
+ };
126
+ var Float = class {
127
+ __Scalar__;
128
+ };
129
+ var ID = class {
130
+ __Scalar__;
131
+ };
132
+ var JSON = class {
133
+ __Scalar__;
134
+ };
135
+ var getNonArrayModel = (arraiedModel) => {
136
+ let arrDepth = 0;
137
+ let target = arraiedModel;
138
+ while (Array.isArray(target)) {
139
+ target = target[0];
140
+ arrDepth++;
141
+ }
142
+ return [target, arrDepth];
143
+ };
144
+ var scalarSet = /* @__PURE__ */ new Set([String, Boolean, Date, ID, Int, Float, Upload, JSON, Map]);
145
+ var scalarNameMap = /* @__PURE__ */ new Map([
146
+ [ID, "ID"],
147
+ [Int, "Int"],
148
+ [Float, "Float"],
149
+ [String, "String"],
150
+ [Boolean, "Boolean"],
151
+ [Date, "Date"],
152
+ [Upload, "Upload"],
153
+ [JSON, "JSON"],
154
+ [Map, "Map"]
155
+ ]);
156
+ var scalarArgMap = /* @__PURE__ */ new Map([
157
+ [ID, null],
158
+ [String, ""],
159
+ [Boolean, false],
160
+ [Date, dayjs(/* @__PURE__ */ new Date(-1))],
161
+ [Int, 0],
162
+ [Float, 0],
163
+ [JSON, {}],
164
+ [Map, {}]
165
+ ]);
166
+ var scalarDefaultMap = /* @__PURE__ */ new Map([
167
+ [ID, null],
168
+ [String, ""],
169
+ [Boolean, false],
170
+ [Date, dayjs(/* @__PURE__ */ new Date(-1))],
171
+ [Int, 0],
172
+ [Float, 0],
173
+ [JSON, {}]
174
+ ]);
175
+ var isGqlScalar = (modelRef) => scalarSet.has(modelRef);
176
+ var isGqlMap = (modelRef) => modelRef === Map;
172
177
 
173
- // pkgs/@akanjs/common/src/isDayjs.ts
174
- var import_dayjs2 = __require("dayjs");
178
+ // pkgs/@akanjs/common/src/isDayjs.ts
179
+ var import_dayjs2 = require("dayjs");
175
180
 
176
- // pkgs/@akanjs/common/src/isQueryEqual.ts
177
- var import_dayjs3 = __toESM(__require("dayjs"));
181
+ // pkgs/@akanjs/common/src/isQueryEqual.ts
182
+ var import_dayjs3 = __toESM(require("dayjs"));
178
183
 
179
- // pkgs/@akanjs/common/src/isValidDate.ts
180
- var import_dayjs4 = __toESM(__require("dayjs"));
181
- var import_customParseFormat = __toESM(__require("dayjs/plugin/customParseFormat"));
182
- import_dayjs4.default.extend(import_customParseFormat.default);
184
+ // pkgs/@akanjs/common/src/isValidDate.ts
185
+ var import_dayjs4 = __toESM(require("dayjs"));
186
+ var import_customParseFormat = __toESM(require("dayjs/plugin/customParseFormat"));
187
+ import_dayjs4.default.extend(import_customParseFormat.default);
183
188
 
184
- // pkgs/@akanjs/common/src/randomPick.ts
185
- var randomPick = (arr) => arr[Math.floor(Math.random() * arr.length)];
189
+ // pkgs/@akanjs/common/src/randomPick.ts
190
+ var randomPick = (arr) => arr[Math.floor(Math.random() * arr.length)];
186
191
 
187
- // pkgs/@akanjs/common/src/randomPicks.ts
188
- var randomPicks = (arr, count = 1, allowDuplicate = false) => {
189
- if (!allowDuplicate && arr.length <= count)
190
- return arr;
191
- const idxs = [];
192
- let pickIdx;
193
- for (let i = 0; i < count; i++) {
194
- do {
195
- pickIdx = Math.floor(Math.random() * arr.length);
196
- } while (!allowDuplicate && idxs.includes(pickIdx));
197
- idxs.push(pickIdx);
198
- }
199
- return idxs.map((idx) => arr[idx]);
200
- };
192
+ // pkgs/@akanjs/common/src/randomPicks.ts
193
+ var randomPicks = (arr, count = 1, allowDuplicate = false) => {
194
+ if (!allowDuplicate && arr.length <= count)
195
+ return arr;
196
+ const idxs = [];
197
+ let pickIdx;
198
+ for (let i = 0; i < count; i++) {
199
+ do {
200
+ pickIdx = Math.floor(Math.random() * arr.length);
201
+ } while (!allowDuplicate && idxs.includes(pickIdx));
202
+ idxs.push(pickIdx);
203
+ }
204
+ return idxs.map((idx) => arr[idx]);
205
+ };
201
206
 
202
- // pkgs/@akanjs/common/src/pluralize.ts
203
- var import_pluralize = __toESM(__require("pluralize"));
207
+ // pkgs/@akanjs/common/src/pluralize.ts
208
+ var import_pluralize = __toESM(require("pluralize"));
204
209
 
205
- // pkgs/@akanjs/common/src/Logger.ts
206
- var import_dayjs5 = __toESM(__require("dayjs"));
207
- var logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
208
- var clc = {
209
- bold: (text) => `\x1B[1m${text}\x1B[0m`,
210
- green: (text) => `\x1B[32m${text}\x1B[39m`,
211
- yellow: (text) => `\x1B[33m${text}\x1B[39m`,
212
- red: (text) => `\x1B[31m${text}\x1B[39m`,
213
- magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
214
- cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
215
- };
216
- var colorizeMap = {
217
- trace: clc.bold,
218
- verbose: clc.cyanBright,
219
- debug: clc.magentaBright,
220
- log: clc.green,
221
- info: clc.green,
222
- warn: clc.yellow,
223
- error: clc.red
224
- };
225
- var Logger = class _Logger {
226
- static #ignoreCtxSet = /* @__PURE__ */ new Set([
227
- "InstanceLoader",
228
- "RoutesResolver",
229
- "RouterExplorer",
230
- "NestFactory",
231
- "WebSocketsController",
232
- "GraphQLModule",
233
- "NestApplication"
234
- ]);
235
- static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
236
- static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
237
- static #startAt = (0, import_dayjs5.default)();
238
- static setLevel(level) {
239
- this.level = level;
240
- this.#levelIdx = logLevels.findIndex((l) => l === level);
241
- }
242
- name;
243
- constructor(name) {
244
- this.name = name;
245
- }
246
- trace(msg, context = "") {
247
- if (_Logger.#levelIdx <= 0)
248
- _Logger.#printMessages(this.name ?? "App", msg, context, "trace");
249
- }
250
- verbose(msg, context = "") {
251
- if (_Logger.#levelIdx <= 1)
252
- _Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
253
- }
254
- debug(msg, context = "") {
255
- if (_Logger.#levelIdx <= 2)
256
- _Logger.#printMessages(this.name ?? "App", msg, context, "debug");
257
- }
258
- log(msg, context = "") {
259
- if (_Logger.#levelIdx <= 3)
260
- _Logger.#printMessages(this.name ?? "App", msg, context, "log");
261
- }
262
- info(msg, context = "") {
263
- if (_Logger.#levelIdx <= 4)
264
- _Logger.#printMessages(this.name ?? "App", msg, context, "info");
265
- }
266
- warn(msg, context = "") {
267
- if (_Logger.#levelIdx <= 5)
268
- _Logger.#printMessages(this.name ?? "App", msg, context, "warn");
269
- }
270
- error(msg, context = "") {
271
- if (_Logger.#levelIdx <= 6)
272
- _Logger.#printMessages(this.name ?? "App", msg, context, "error");
273
- }
274
- raw(msg, method) {
275
- _Logger.rawLog(msg, method);
276
- }
277
- rawLog(msg, method) {
278
- _Logger.rawLog(msg, method);
279
- }
280
- static trace(msg, context = "") {
281
- if (_Logger.#levelIdx <= 0)
282
- _Logger.#printMessages("App", msg, context, "trace");
283
- }
284
- static verbose(msg, context = "") {
285
- if (_Logger.#levelIdx <= 1)
286
- _Logger.#printMessages("App", msg, context, "verbose");
287
- }
288
- static debug(msg, context = "") {
289
- if (_Logger.#levelIdx <= 2)
290
- _Logger.#printMessages("App", msg, context, "debug");
291
- }
292
- static log(msg, context = "") {
293
- if (_Logger.#levelIdx <= 3)
294
- _Logger.#printMessages("App", msg, context, "log");
295
- }
296
- static info(msg, context = "") {
297
- if (_Logger.#levelIdx <= 4)
298
- _Logger.#printMessages("App", msg, context, "info");
299
- }
300
- static warn(msg, context = "") {
301
- if (_Logger.#levelIdx <= 5)
302
- _Logger.#printMessages("App", msg, context, "warn");
303
- }
304
- static error(msg, context = "") {
305
- if (_Logger.#levelIdx <= 6)
306
- _Logger.#printMessages("App", msg, context, "error");
307
- }
308
- static #colorize(msg, logLevel) {
309
- return colorizeMap[logLevel](msg);
310
- }
311
- static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
312
- if (this.#ignoreCtxSet.has(context))
313
- return;
314
- const now = (0, import_dayjs5.default)();
315
- const processMsg = this.#colorize(
316
- `[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
317
- logLevel
318
- );
319
- const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
320
- const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
321
- const contextMsg = context ? clc.yellow(`[${context}] `) : "";
322
- const contentMsg = this.#colorize(content, logLevel);
323
- const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
324
- if (typeof window === "undefined")
325
- process[writeStreamType].write(
326
- `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
210
+ // pkgs/@akanjs/common/src/Logger.ts
211
+ var import_dayjs5 = __toESM(require("dayjs"));
212
+ var logLevels = ["trace", "verbose", "debug", "log", "info", "warn", "error"];
213
+ var clc = {
214
+ bold: (text) => `\x1B[1m${text}\x1B[0m`,
215
+ green: (text) => `\x1B[32m${text}\x1B[39m`,
216
+ yellow: (text) => `\x1B[33m${text}\x1B[39m`,
217
+ red: (text) => `\x1B[31m${text}\x1B[39m`,
218
+ magentaBright: (text) => `\x1B[95m${text}\x1B[39m`,
219
+ cyanBright: (text) => `\x1B[96m${text}\x1B[39m`
220
+ };
221
+ var colorizeMap = {
222
+ trace: clc.bold,
223
+ verbose: clc.cyanBright,
224
+ debug: clc.magentaBright,
225
+ log: clc.green,
226
+ info: clc.green,
227
+ warn: clc.yellow,
228
+ error: clc.red
229
+ };
230
+ var Logger = class _Logger {
231
+ static #ignoreCtxSet = /* @__PURE__ */ new Set([
232
+ "InstanceLoader",
233
+ "RoutesResolver",
234
+ "RouterExplorer",
235
+ "NestFactory",
236
+ "WebSocketsController",
237
+ "GraphQLModule",
238
+ "NestApplication"
239
+ ]);
240
+ static level = process.env.NEXT_PUBLIC_LOG_LEVEL ?? "log";
241
+ static #levelIdx = logLevels.findIndex((l) => l === process.env.NEXT_PUBLIC_LOG_LEVEL);
242
+ static #startAt = (0, import_dayjs5.default)();
243
+ static setLevel(level) {
244
+ this.level = level;
245
+ this.#levelIdx = logLevels.findIndex((l) => l === level);
246
+ }
247
+ name;
248
+ constructor(name) {
249
+ this.name = name;
250
+ }
251
+ trace(msg, context = "") {
252
+ if (_Logger.#levelIdx <= 0)
253
+ _Logger.#printMessages(this.name ?? "App", msg, context, "trace");
254
+ }
255
+ verbose(msg, context = "") {
256
+ if (_Logger.#levelIdx <= 1)
257
+ _Logger.#printMessages(this.name ?? "App", msg, context, "verbose");
258
+ }
259
+ debug(msg, context = "") {
260
+ if (_Logger.#levelIdx <= 2)
261
+ _Logger.#printMessages(this.name ?? "App", msg, context, "debug");
262
+ }
263
+ log(msg, context = "") {
264
+ if (_Logger.#levelIdx <= 3)
265
+ _Logger.#printMessages(this.name ?? "App", msg, context, "log");
266
+ }
267
+ info(msg, context = "") {
268
+ if (_Logger.#levelIdx <= 4)
269
+ _Logger.#printMessages(this.name ?? "App", msg, context, "info");
270
+ }
271
+ warn(msg, context = "") {
272
+ if (_Logger.#levelIdx <= 5)
273
+ _Logger.#printMessages(this.name ?? "App", msg, context, "warn");
274
+ }
275
+ error(msg, context = "") {
276
+ if (_Logger.#levelIdx <= 6)
277
+ _Logger.#printMessages(this.name ?? "App", msg, context, "error");
278
+ }
279
+ raw(msg, method) {
280
+ _Logger.rawLog(msg, method);
281
+ }
282
+ rawLog(msg, method) {
283
+ _Logger.rawLog(msg, method);
284
+ }
285
+ static trace(msg, context = "") {
286
+ if (_Logger.#levelIdx <= 0)
287
+ _Logger.#printMessages("App", msg, context, "trace");
288
+ }
289
+ static verbose(msg, context = "") {
290
+ if (_Logger.#levelIdx <= 1)
291
+ _Logger.#printMessages("App", msg, context, "verbose");
292
+ }
293
+ static debug(msg, context = "") {
294
+ if (_Logger.#levelIdx <= 2)
295
+ _Logger.#printMessages("App", msg, context, "debug");
296
+ }
297
+ static log(msg, context = "") {
298
+ if (_Logger.#levelIdx <= 3)
299
+ _Logger.#printMessages("App", msg, context, "log");
300
+ }
301
+ static info(msg, context = "") {
302
+ if (_Logger.#levelIdx <= 4)
303
+ _Logger.#printMessages("App", msg, context, "info");
304
+ }
305
+ static warn(msg, context = "") {
306
+ if (_Logger.#levelIdx <= 5)
307
+ _Logger.#printMessages("App", msg, context, "warn");
308
+ }
309
+ static error(msg, context = "") {
310
+ if (_Logger.#levelIdx <= 6)
311
+ _Logger.#printMessages("App", msg, context, "error");
312
+ }
313
+ static #colorize(msg, logLevel) {
314
+ return colorizeMap[logLevel](msg);
315
+ }
316
+ static #printMessages(name, content, context, logLevel, writeStreamType = logLevel === "error" ? "stderr" : "stdout") {
317
+ if (this.#ignoreCtxSet.has(context))
318
+ return;
319
+ const now = (0, import_dayjs5.default)();
320
+ const processMsg = this.#colorize(
321
+ `[${name ?? "App"}] ${global.process?.pid ?? "window"} -`,
322
+ logLevel
323
+ );
324
+ const timestampMsg = now.format("MM/DD/YYYY, HH:mm:ss A");
325
+ const logLevelMsg = this.#colorize(logLevel.toUpperCase().padStart(7, " "), logLevel);
326
+ const contextMsg = context ? clc.yellow(`[${context}] `) : "";
327
+ const contentMsg = this.#colorize(content, logLevel);
328
+ const timeDiffMsg = clc.yellow(`+${now.diff(_Logger.#startAt, "ms")}ms`);
329
+ if (typeof window === "undefined")
330
+ process[writeStreamType].write(
331
+ `${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
327
332
  `
328
- );
329
- else
330
- console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
333
+ );
334
+ else
335
+ console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
331
336
  `);
332
- }
333
- static rawLog(msg, method) {
334
- this.raw(`${msg}
337
+ }
338
+ static rawLog(msg, method) {
339
+ this.raw(`${msg}
335
340
  `, method);
336
- }
337
- static raw(msg, method) {
338
- if (typeof window === "undefined" && method !== "console" && global.process)
339
- global.process.stdout.write(msg);
340
- else
341
- console.log(msg);
342
- }
343
- };
341
+ }
342
+ static raw(msg, method) {
343
+ if (typeof window === "undefined" && method !== "console" && global.process)
344
+ global.process.stdout.write(msg);
345
+ else
346
+ console.log(msg);
347
+ }
348
+ };
344
349
 
345
- // pkgs/@akanjs/constant/src/scalar.ts
346
- var import_reflect_metadata = __require("reflect-metadata");
347
- var scalarExampleMap = /* @__PURE__ */ new Map([
348
- [ID, "1234567890abcdef12345678"],
349
- [Int, 0],
350
- [Float, 0],
351
- [String, "String"],
352
- [Boolean, true],
353
- [Date, (/* @__PURE__ */ new Date()).toISOString()],
354
- [Upload, "FileUpload"],
355
- [JSON, {}],
356
- [Map, {}]
357
- ]);
358
- var getClassMeta = (modelRef) => {
359
- const [target] = getNonArrayModel(modelRef);
360
- const classMeta = Reflect.getMetadata("class", target.prototype);
361
- if (!classMeta)
362
- throw new Error(`No ClassMeta for this target ${target.name}`);
363
- return classMeta;
364
- };
365
- var getFieldMetas = (modelRef) => {
366
- const [target] = getNonArrayModel(modelRef);
367
- const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
368
- const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
369
- return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
370
- };
371
- var getFieldMetaMapOnPrototype = (prototype) => {
372
- const metadataMap = Reflect.getMetadata("fields", prototype) ?? /* @__PURE__ */ new Map();
373
- return new Map(metadataMap);
374
- };
375
- var setFieldMetaMapOnPrototype = (prototype, metadataMap) => {
376
- Reflect.defineMetadata("fields", new Map(metadataMap), prototype);
377
- };
350
+ // pkgs/@akanjs/constant/src/scalar.ts
351
+ var import_reflect_metadata = require("reflect-metadata");
352
+ var scalarExampleMap = /* @__PURE__ */ new Map([
353
+ [ID, "1234567890abcdef12345678"],
354
+ [Int, 0],
355
+ [Float, 0],
356
+ [String, "String"],
357
+ [Boolean, true],
358
+ [Date, (/* @__PURE__ */ new Date()).toISOString()],
359
+ [Upload, "FileUpload"],
360
+ [JSON, {}],
361
+ [Map, {}]
362
+ ]);
363
+ var getClassMeta = (modelRef) => {
364
+ const [target] = getNonArrayModel(modelRef);
365
+ const classMeta = Reflect.getMetadata("class", target.prototype);
366
+ if (!classMeta)
367
+ throw new Error(`No ClassMeta for this target ${target.name}`);
368
+ return classMeta;
369
+ };
370
+ var getFieldMetas = (modelRef) => {
371
+ const [target] = getNonArrayModel(modelRef);
372
+ const metadataMap = Reflect.getMetadata("fields", target.prototype) ?? /* @__PURE__ */ new Map();
373
+ const keySortMap = { id: -1, createdAt: 1, updatedAt: 2, removedAt: 3 };
374
+ return [...metadataMap.values()].sort((a, b) => (keySortMap[a.key] ?? 0) - (keySortMap[b.key] ?? 0));
375
+ };
376
+ var getFieldMetaMapOnPrototype = (prototype) => {
377
+ const metadataMap = Reflect.getMetadata("fields", prototype) ?? /* @__PURE__ */ new Map();
378
+ return new Map(metadataMap);
379
+ };
380
+ var setFieldMetaMapOnPrototype = (prototype, metadataMap) => {
381
+ Reflect.defineMetadata("fields", new Map(metadataMap), prototype);
382
+ };
378
383
 
379
- // pkgs/@akanjs/constant/src/fieldMeta.ts
380
- var applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
381
- const isArray = arrDepth > 0;
382
- const isClass = !isGqlScalar(modelRef);
383
- const isMap = isGqlMap(modelRef);
384
- const { refName, type } = isClass ? getClassMeta(modelRef) : { refName: "", type: "scalar" };
385
- const name = isClass ? refName : scalarNameMap.get(modelRef) ?? "Unknown";
386
- if (isMap && !option.of)
387
- throw new Error("Map type must have 'of' option");
388
- return (prototype, key) => {
389
- const metadata = {
390
- nullable: option.nullable ?? false,
391
- ref: option.ref,
392
- refPath: option.refPath,
393
- refType: option.refType,
394
- default: option.default ?? (isArray ? [] : null),
395
- type: option.type,
396
- fieldType: option.fieldType ?? "property",
397
- immutable: option.immutable ?? false,
398
- min: option.min,
399
- max: option.max,
400
- enum: option.enum,
401
- select: option.select ?? true,
402
- minlength: option.minlength,
403
- maxlength: option.maxlength,
404
- query: option.query,
405
- accumulate: option.accumulate,
406
- example: option.example,
407
- validate: option.validate,
408
- key,
409
- name,
410
- isClass,
411
- isScalar: type === "scalar",
412
- modelRef,
413
- arrDepth,
414
- isArray,
415
- optArrDepth: optionArrDepth,
416
- isMap,
417
- of: option.of,
418
- text: option.text
419
- };
420
- const metadataMap = getFieldMetaMapOnPrototype(prototype);
421
- metadataMap.set(key, metadata);
422
- setFieldMetaMapOnPrototype(prototype, metadataMap);
384
+ // pkgs/@akanjs/constant/src/fieldMeta.ts
385
+ var applyFieldMeta = (modelRef, arrDepth, option, optionArrDepth) => {
386
+ const isArray = arrDepth > 0;
387
+ const isClass = !isGqlScalar(modelRef);
388
+ const isMap = isGqlMap(modelRef);
389
+ const { refName, type } = isClass ? getClassMeta(modelRef) : { refName: "", type: "scalar" };
390
+ const name = isClass ? refName : scalarNameMap.get(modelRef) ?? "Unknown";
391
+ if (isMap && !option.of)
392
+ throw new Error("Map type must have 'of' option");
393
+ return (prototype, key) => {
394
+ const metadata = {
395
+ nullable: option.nullable ?? false,
396
+ ref: option.ref,
397
+ refPath: option.refPath,
398
+ refType: option.refType,
399
+ default: option.default ?? (isArray ? [] : null),
400
+ type: option.type,
401
+ fieldType: option.fieldType ?? "property",
402
+ immutable: option.immutable ?? false,
403
+ min: option.min,
404
+ max: option.max,
405
+ enum: option.enum,
406
+ select: option.select ?? true,
407
+ minlength: option.minlength,
408
+ maxlength: option.maxlength,
409
+ query: option.query,
410
+ accumulate: option.accumulate,
411
+ example: option.example,
412
+ validate: option.validate,
413
+ key,
414
+ name,
415
+ isClass,
416
+ isScalar: type === "scalar",
417
+ modelRef,
418
+ arrDepth,
419
+ isArray,
420
+ optArrDepth: optionArrDepth,
421
+ isMap,
422
+ of: option.of,
423
+ text: option.text
423
424
  };
424
- };
425
- var makeField = (customOption) => (returns, fieldOption) => {
426
- const [modelRef, arrDepth] = getNonArrayModel(returns());
427
- if (!fieldOption)
428
- return applyFieldMeta(modelRef, arrDepth, { ...customOption }, arrDepth);
429
- const [opt, optArrDepth] = getNonArrayModel(fieldOption);
430
- return applyFieldMeta(modelRef, arrDepth, { ...opt, ...customOption }, optArrDepth);
431
- };
432
- var Field = {
433
- Prop: makeField({ fieldType: "property" }),
434
- Hidden: makeField({ fieldType: "hidden", nullable: true }),
435
- Secret: makeField({ fieldType: "hidden", select: false, nullable: true }),
436
- Resolve: makeField({ fieldType: "resolve" })
437
- };
425
+ const metadataMap = getFieldMetaMapOnPrototype(prototype);
426
+ metadataMap.set(key, metadata);
427
+ setFieldMetaMapOnPrototype(prototype, metadataMap);
428
+ };
429
+ };
430
+ var makeField = (customOption) => (returns, fieldOption) => {
431
+ const [modelRef, arrDepth] = getNonArrayModel(returns());
432
+ if (!fieldOption)
433
+ return applyFieldMeta(modelRef, arrDepth, { ...customOption }, arrDepth);
434
+ const [opt, optArrDepth] = getNonArrayModel(fieldOption);
435
+ return applyFieldMeta(modelRef, arrDepth, { ...opt, ...customOption }, optArrDepth);
436
+ };
437
+ var Field = {
438
+ Prop: makeField({ fieldType: "property" }),
439
+ Hidden: makeField({ fieldType: "hidden", nullable: true }),
440
+ Secret: makeField({ fieldType: "hidden", select: false, nullable: true }),
441
+ Resolve: makeField({ fieldType: "resolve" })
442
+ };
438
443
 
439
- // pkgs/@akanjs/constant/src/constantDecorator.ts
440
- var import_reflect_metadata2 = __require("reflect-metadata");
444
+ // pkgs/@akanjs/constant/src/constantDecorator.ts
445
+ var import_reflect_metadata2 = require("reflect-metadata");
441
446
 
442
- // pkgs/@akanjs/constant/src/filterMeta.ts
443
- var setFilterMeta = (filterRef, filterMeta) => {
444
- const existingFilterMeta = Reflect.getMetadata("filter", filterRef.prototype);
445
- if (existingFilterMeta)
446
- Object.assign(filterMeta.sort, existingFilterMeta.sort);
447
- Reflect.defineMetadata("filter", filterMeta, filterRef.prototype);
448
- };
449
- var getFilterKeyMetaMapOnPrototype = (prototype) => {
450
- const metadataMap = Reflect.getMetadata("filterKey", prototype) ?? /* @__PURE__ */ new Map();
451
- return new Map(metadataMap);
452
- };
453
- var setFilterKeyMetaMapOnPrototype = (prototype, metadataMap) => {
454
- Reflect.defineMetadata("filterKey", new Map(metadataMap), prototype);
455
- };
456
- var applyFilterKeyMeta = (option) => {
457
- return (prototype, key, descriptor) => {
458
- const metadata = { key, ...option, descriptor };
459
- const metadataMap = getFilterKeyMetaMapOnPrototype(prototype);
460
- metadataMap.set(key, metadata);
461
- setFilterKeyMetaMapOnPrototype(prototype, metadataMap);
462
- };
463
- };
464
- var makeFilter = (customOption) => (fieldOption) => {
465
- return applyFilterKeyMeta({ ...customOption, ...fieldOption });
466
- };
467
- var getFilterArgMetasOnPrototype = (prototype, key) => {
468
- const filterArgMetas = Reflect.getMetadata("filterArg", prototype, key) ?? [];
469
- return filterArgMetas;
470
- };
471
- var setFilterArgMetasOnPrototype = (prototype, key, filterArgMetas) => {
472
- Reflect.defineMetadata("filterArg", filterArgMetas, prototype, key);
473
- };
474
- var applyFilterArgMeta = (name, returns, argOption) => {
475
- return (prototype, key, idx) => {
476
- const [modelRef, arrDepth] = getNonArrayModel(returns());
477
- const [opt, optArrDepth] = getNonArrayModel(argOption ?? {});
478
- const filterArgMeta = { name, ...opt, modelRef, arrDepth, isArray: arrDepth > 0, optArrDepth };
479
- const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
480
- filterArgMetas[idx] = filterArgMeta;
481
- setFilterArgMetasOnPrototype(prototype, key, filterArgMetas);
482
- };
483
- };
484
- var Filter = {
485
- Mongo: makeFilter({ type: "mongo" }),
486
- // Meili: makeFilter({ fieldType: "hidden", nullable: true }),
487
- Arg: applyFilterArgMeta
488
- };
447
+ // pkgs/@akanjs/constant/src/filterMeta.ts
448
+ var setFilterMeta = (filterRef, filterMeta) => {
449
+ const existingFilterMeta = Reflect.getMetadata("filter", filterRef.prototype);
450
+ if (existingFilterMeta)
451
+ Object.assign(filterMeta.sort, existingFilterMeta.sort);
452
+ Reflect.defineMetadata("filter", filterMeta, filterRef.prototype);
453
+ };
454
+ var getFilterKeyMetaMapOnPrototype = (prototype) => {
455
+ const metadataMap = Reflect.getMetadata("filterKey", prototype) ?? /* @__PURE__ */ new Map();
456
+ return new Map(metadataMap);
457
+ };
458
+ var setFilterKeyMetaMapOnPrototype = (prototype, metadataMap) => {
459
+ Reflect.defineMetadata("filterKey", new Map(metadataMap), prototype);
460
+ };
461
+ var applyFilterKeyMeta = (option) => {
462
+ return (prototype, key, descriptor) => {
463
+ const metadata = { key, ...option, descriptor };
464
+ const metadataMap = getFilterKeyMetaMapOnPrototype(prototype);
465
+ metadataMap.set(key, metadata);
466
+ setFilterKeyMetaMapOnPrototype(prototype, metadataMap);
467
+ };
468
+ };
469
+ var makeFilter = (customOption) => (fieldOption) => {
470
+ return applyFilterKeyMeta({ ...customOption, ...fieldOption });
471
+ };
472
+ var getFilterArgMetasOnPrototype = (prototype, key) => {
473
+ const filterArgMetas = Reflect.getMetadata("filterArg", prototype, key) ?? [];
474
+ return filterArgMetas;
475
+ };
476
+ var setFilterArgMetasOnPrototype = (prototype, key, filterArgMetas) => {
477
+ Reflect.defineMetadata("filterArg", filterArgMetas, prototype, key);
478
+ };
479
+ var applyFilterArgMeta = (name, returns, argOption) => {
480
+ return (prototype, key, idx) => {
481
+ const [modelRef, arrDepth] = getNonArrayModel(returns());
482
+ const [opt, optArrDepth] = getNonArrayModel(argOption ?? {});
483
+ const filterArgMeta = { name, ...opt, modelRef, arrDepth, isArray: arrDepth > 0, optArrDepth };
484
+ const filterArgMetas = getFilterArgMetasOnPrototype(prototype, key);
485
+ filterArgMetas[idx] = filterArgMeta;
486
+ setFilterArgMetasOnPrototype(prototype, key, filterArgMetas);
487
+ };
488
+ };
489
+ var Filter = {
490
+ Mongo: makeFilter({ type: "mongo" }),
491
+ // Meili: makeFilter({ fieldType: "hidden", nullable: true }),
492
+ Arg: applyFilterArgMeta
493
+ };
489
494
 
490
- // pkgs/@akanjs/constant/src/baseGql.ts
491
- var import_reflect_metadata3 = __require("reflect-metadata");
492
- var defaultFieldMeta = {
493
- fieldType: "property",
494
- immutable: false,
495
- select: true,
496
- isClass: false,
497
- isScalar: true,
498
- nullable: false,
499
- isArray: false,
500
- arrDepth: 0,
501
- optArrDepth: 0,
502
- default: null,
503
- isMap: false
504
- };
505
- var idFieldMeta = { ...defaultFieldMeta, key: "id", name: "ID", modelRef: ID };
506
- var createdAtFieldMeta = { ...defaultFieldMeta, key: "createdAt", name: "Date", modelRef: Date };
507
- var updatedAtFieldMeta = { ...defaultFieldMeta, key: "updatedAt", name: "Date", modelRef: Date };
508
- var removedAtFieldMeta = {
509
- ...defaultFieldMeta,
510
- key: "removedAt",
511
- name: "Date",
512
- modelRef: Date,
513
- nullable: true,
514
- default: null
515
- };
495
+ // pkgs/@akanjs/constant/src/baseGql.ts
496
+ var import_reflect_metadata3 = require("reflect-metadata");
497
+ var defaultFieldMeta = {
498
+ fieldType: "property",
499
+ immutable: false,
500
+ select: true,
501
+ isClass: false,
502
+ isScalar: true,
503
+ nullable: false,
504
+ isArray: false,
505
+ arrDepth: 0,
506
+ optArrDepth: 0,
507
+ default: null,
508
+ isMap: false
509
+ };
510
+ var idFieldMeta = { ...defaultFieldMeta, key: "id", name: "ID", modelRef: ID };
511
+ var createdAtFieldMeta = { ...defaultFieldMeta, key: "createdAt", name: "Date", modelRef: Date };
512
+ var updatedAtFieldMeta = { ...defaultFieldMeta, key: "updatedAt", name: "Date", modelRef: Date };
513
+ var removedAtFieldMeta = {
514
+ ...defaultFieldMeta,
515
+ key: "removedAt",
516
+ name: "Date",
517
+ modelRef: Date,
518
+ nullable: true,
519
+ default: null
520
+ };
516
521
 
517
- // pkgs/@akanjs/constant/src/classMeta.ts
518
- var import_reflect_metadata4 = __require("reflect-metadata");
519
- var InputModelStorage = class {
520
- };
521
- var LightModelStorage = class {
522
- };
523
- var FullModelStorage = class {
524
- };
525
- var ScalarModelStorage = class {
526
- };
527
- var FilterModelStorage = class {
528
- };
529
- var hasTextField = (modelRef) => {
530
- const fieldMetas = getFieldMetas(modelRef);
531
- return fieldMetas.some(
532
- (fieldMeta) => !!fieldMeta.text || fieldMeta.isScalar && fieldMeta.isClass && fieldMeta.select && hasTextField(fieldMeta.modelRef)
533
- );
534
- };
535
- var applyClassMeta = (type, modelType, storage) => {
536
- return function(refName) {
537
- return function(target) {
538
- const modelRef = target;
539
- const classMeta = { refName, type, modelType, modelRef, hasTextField: hasTextField(modelRef) };
540
- Reflect.defineMetadata("class", classMeta, modelRef.prototype);
541
- Reflect.defineMetadata(refName, modelRef, storage.prototype);
542
- };
522
+ // pkgs/@akanjs/constant/src/classMeta.ts
523
+ var import_reflect_metadata4 = require("reflect-metadata");
524
+ var InputModelStorage = class {
525
+ };
526
+ var LightModelStorage = class {
527
+ };
528
+ var FullModelStorage = class {
529
+ };
530
+ var ScalarModelStorage = class {
531
+ };
532
+ var FilterModelStorage = class {
533
+ };
534
+ var hasTextField = (modelRef) => {
535
+ const fieldMetas = getFieldMetas(modelRef);
536
+ return fieldMetas.some(
537
+ (fieldMeta) => !!fieldMeta.text || fieldMeta.isScalar && fieldMeta.isClass && fieldMeta.select && hasTextField(fieldMeta.modelRef)
538
+ );
539
+ };
540
+ var applyClassMeta = (type, modelType, storage) => {
541
+ return function(refName) {
542
+ return function(target) {
543
+ const modelRef = target;
544
+ const classMeta = { refName, type, modelType, modelRef, hasTextField: hasTextField(modelRef) };
545
+ Reflect.defineMetadata("class", classMeta, modelRef.prototype);
546
+ Reflect.defineMetadata(refName, modelRef, storage.prototype);
543
547
  };
544
548
  };
545
- var applyFilterMeta = (storage) => {
546
- return function(refName) {
547
- return function(target) {
548
- const modelRef = target;
549
- setFilterMeta(modelRef, { refName, sort: {} });
550
- Reflect.defineMetadata(refName, modelRef, storage.prototype);
551
- };
549
+ };
550
+ var applyFilterMeta = (storage) => {
551
+ return function(refName) {
552
+ return function(target) {
553
+ const modelRef = target;
554
+ setFilterMeta(modelRef, { refName, sort: {} });
555
+ Reflect.defineMetadata(refName, modelRef, storage.prototype);
552
556
  };
553
557
  };
554
- var Model = {
555
- Light: applyClassMeta("light", "data", LightModelStorage),
556
- Object: applyClassMeta("full", "ephemeral", FullModelStorage),
557
- Full: applyClassMeta("full", "data", FullModelStorage),
558
- Input: applyClassMeta("input", "data", InputModelStorage),
559
- Scalar: applyClassMeta("scalar", "data", ScalarModelStorage),
560
- Summary: applyClassMeta("scalar", "summary", ScalarModelStorage),
561
- Insight: applyClassMeta("scalar", "insight", ScalarModelStorage),
562
- Filter: applyFilterMeta(FilterModelStorage)
563
- };
558
+ };
559
+ var Model = {
560
+ Light: applyClassMeta("light", "data", LightModelStorage),
561
+ Object: applyClassMeta("full", "ephemeral", FullModelStorage),
562
+ Full: applyClassMeta("full", "data", FullModelStorage),
563
+ Input: applyClassMeta("input", "data", InputModelStorage),
564
+ Scalar: applyClassMeta("scalar", "data", ScalarModelStorage),
565
+ Summary: applyClassMeta("scalar", "summary", ScalarModelStorage),
566
+ Insight: applyClassMeta("scalar", "insight", ScalarModelStorage),
567
+ Filter: applyFilterMeta(FilterModelStorage)
568
+ };
564
569
 
565
- // pkgs/@akanjs/test/src/sample.ts
566
- var import_chance = __toESM(__require("chance"));
567
- var chance = new import_chance.default();
568
- var sample = Object.assign(chance, {
569
- dayjs: (opt) => dayjs(chance.date({ ...opt, min: opt?.min?.toDate(), max: opt?.max?.toDate() })),
570
- pick: randomPick,
571
- picks: randomPicks
572
- });
570
+ // pkgs/@akanjs/test/src/sample.ts
571
+ var import_chance = __toESM(require("chance"));
572
+ var chance = new import_chance.default();
573
+ var sample = Object.assign(chance, {
574
+ dayjs: (opt) => dayjs(chance.date({ ...opt, min: opt?.min?.toDate(), max: opt?.max?.toDate() })),
575
+ pick: randomPick,
576
+ picks: randomPicks
577
+ });
573
578
 
574
- // pkgs/@akanjs/test/src/sampleOf.ts
575
- var getFieldTypeExample = {
576
- email: () => sample.email(),
577
- password: () => sample.string({ length: 8 }),
578
- url: () => sample.url()
579
- };
580
- var scalarSampleMap = /* @__PURE__ */ new Map([
581
- [ID, () => sample.hash({ length: 24 })],
582
- [Int, () => sample.integer({ min: -1e4, max: 1e4 })],
583
- [Float, () => sample.floating({ min: -1e4, max: 1e4 })],
584
- [String, () => sample.string({ length: 100 })],
585
- [Boolean, () => sample.bool()],
586
- [Date, () => sample.dayjs()],
587
- [Upload, () => "FileUpload"],
588
- [JSON, () => ({})]
589
- ]);
590
- var getScalarSample = (ref, fieldMeta) => {
591
- if (fieldMeta.type) {
592
- return getFieldTypeExample[fieldMeta.type]();
593
- } else if (typeof fieldMeta.min === "number") {
594
- return fieldMeta.min;
595
- } else if (typeof fieldMeta.max === "number") {
596
- return fieldMeta.max;
597
- } else {
598
- return scalarSampleMap.get(ref)?.() ?? null;
599
- }
600
- };
601
- var makeSample = (fieldMeta) => {
602
- if (fieldMeta.default)
603
- return typeof fieldMeta.default === "function" ? fieldMeta.default() : fieldMeta.default;
604
- else if (fieldMeta.enum)
605
- return randomPick([...fieldMeta.enum.values]);
606
- if (isGqlScalar(fieldMeta.modelRef))
607
- return getScalarSample(fieldMeta.modelRef, fieldMeta);
608
- return Object.fromEntries(
609
- getFieldMetas(fieldMeta.modelRef).map(
610
- (fieldMeta2) => [
611
- fieldMeta2.key,
612
- fieldMeta2.arrDepth ? [] : fieldMeta2.isClass && !fieldMeta2.isScalar ? null : makeSample(fieldMeta2)
613
- ]
614
- )
615
- );
616
- };
617
- var sampleOf = (modelRef) => {
618
- return Object.fromEntries(
619
- getFieldMetas(modelRef).map((fieldMeta) => [
620
- fieldMeta.key,
621
- fieldMeta.arrDepth ? [] : fieldMeta.isClass && !fieldMeta.isScalar ? null : makeSample(fieldMeta)
622
- ])
623
- );
624
- };
625
- })();
579
+ // pkgs/@akanjs/test/src/sampleOf.ts
580
+ var getFieldTypeExample = {
581
+ email: () => sample.email(),
582
+ password: () => sample.string({ length: 8 }),
583
+ url: () => sample.url()
584
+ };
585
+ var scalarSampleMap = /* @__PURE__ */ new Map([
586
+ [ID, () => sample.hash({ length: 24 })],
587
+ [Int, () => sample.integer({ min: -1e4, max: 1e4 })],
588
+ [Float, () => sample.floating({ min: -1e4, max: 1e4 })],
589
+ [String, () => sample.string({ length: 100 })],
590
+ [Boolean, () => sample.bool()],
591
+ [Date, () => sample.dayjs()],
592
+ [Upload, () => "FileUpload"],
593
+ [JSON, () => ({})]
594
+ ]);
595
+ var getScalarSample = (ref, fieldMeta) => {
596
+ if (fieldMeta.type) {
597
+ return getFieldTypeExample[fieldMeta.type]();
598
+ } else if (typeof fieldMeta.min === "number") {
599
+ return fieldMeta.min;
600
+ } else if (typeof fieldMeta.max === "number") {
601
+ return fieldMeta.max;
602
+ } else {
603
+ return scalarSampleMap.get(ref)?.() ?? null;
604
+ }
605
+ };
606
+ var makeSample = (fieldMeta) => {
607
+ if (fieldMeta.default)
608
+ return typeof fieldMeta.default === "function" ? fieldMeta.default() : fieldMeta.default;
609
+ else if (fieldMeta.enum)
610
+ return randomPick([...fieldMeta.enum.values]);
611
+ if (isGqlScalar(fieldMeta.modelRef))
612
+ return getScalarSample(fieldMeta.modelRef, fieldMeta);
613
+ return Object.fromEntries(
614
+ getFieldMetas(fieldMeta.modelRef).map(
615
+ (fieldMeta2) => [
616
+ fieldMeta2.key,
617
+ fieldMeta2.arrDepth ? [] : fieldMeta2.isClass && !fieldMeta2.isScalar ? null : makeSample(fieldMeta2)
618
+ ]
619
+ )
620
+ );
621
+ };
622
+ var sampleOf = (modelRef) => {
623
+ return Object.fromEntries(
624
+ getFieldMetas(modelRef).map((fieldMeta) => [
625
+ fieldMeta.key,
626
+ fieldMeta.arrDepth ? [] : fieldMeta.isClass && !fieldMeta.isScalar ? null : makeSample(fieldMeta)
627
+ ])
628
+ );
629
+ };
626
630
  //! Nextjs는 환경변수를 build time에 그냥 하드코딩으로 값을 넣어버림. operationMode같은것들 잘 동작안할 수 있음. 추후 수정 필요.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@akanjs/test",
3
- "version": "0.0.44",
3
+ "version": "0.0.45",
4
4
  "type": "commonjs",
5
5
  "publishConfig": {
6
6
  "access": "public"