@akanjs/test 0.0.45 → 0.0.46
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 +18 -545
- package/package.json +2 -5
package/index.js
CHANGED
|
@@ -34,546 +34,20 @@ __export(test_exports, {
|
|
|
34
34
|
});
|
|
35
35
|
module.exports = __toCommonJS(test_exports);
|
|
36
36
|
|
|
37
|
-
// pkgs/@akanjs/
|
|
38
|
-
var
|
|
39
|
-
var
|
|
40
|
-
|
|
41
|
-
/ \\ | | ____ _ _ __ (_)___
|
|
42
|
-
/ _ \\ | |/ / _' | '_ \\ | / __|
|
|
43
|
-
/ ___ \\| < (_| | | | |_ | \\__ \\
|
|
44
|
-
/_/ \\_\\_|\\_\\__,_|_| |_(_)/ |___/
|
|
45
|
-
|__/ ver ${version}
|
|
46
|
-
? See more details on docs https://www.akanjs.com/docs
|
|
47
|
-
\u2605 Star Akanjs on GitHub https://github.com/aka-bassman/akanjs
|
|
48
|
-
|
|
49
|
-
`;
|
|
50
|
-
|
|
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
|
-
};
|
|
112
|
-
|
|
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;
|
|
177
|
-
|
|
178
|
-
// pkgs/@akanjs/common/src/isDayjs.ts
|
|
179
|
-
var import_dayjs2 = require("dayjs");
|
|
180
|
-
|
|
181
|
-
// pkgs/@akanjs/common/src/isQueryEqual.ts
|
|
182
|
-
var import_dayjs3 = __toESM(require("dayjs"));
|
|
183
|
-
|
|
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);
|
|
188
|
-
|
|
189
|
-
// pkgs/@akanjs/common/src/randomPick.ts
|
|
190
|
-
var randomPick = (arr) => arr[Math.floor(Math.random() * arr.length)];
|
|
191
|
-
|
|
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
|
-
};
|
|
206
|
-
|
|
207
|
-
// pkgs/@akanjs/common/src/pluralize.ts
|
|
208
|
-
var import_pluralize = __toESM(require("pluralize"));
|
|
209
|
-
|
|
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}
|
|
332
|
-
`
|
|
333
|
-
);
|
|
334
|
-
else
|
|
335
|
-
console.log(`${processMsg} ${timestampMsg} ${logLevelMsg} ${contextMsg} ${contentMsg} ${timeDiffMsg}
|
|
336
|
-
`);
|
|
337
|
-
}
|
|
338
|
-
static rawLog(msg, method) {
|
|
339
|
-
this.raw(`${msg}
|
|
340
|
-
`, method);
|
|
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
|
-
};
|
|
349
|
-
|
|
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
|
-
};
|
|
383
|
-
|
|
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
|
|
424
|
-
};
|
|
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
|
-
};
|
|
443
|
-
|
|
444
|
-
// pkgs/@akanjs/constant/src/constantDecorator.ts
|
|
445
|
-
var import_reflect_metadata2 = require("reflect-metadata");
|
|
446
|
-
|
|
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
|
-
};
|
|
494
|
-
|
|
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
|
-
};
|
|
521
|
-
|
|
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);
|
|
547
|
-
};
|
|
548
|
-
};
|
|
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);
|
|
556
|
-
};
|
|
557
|
-
};
|
|
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
|
-
};
|
|
37
|
+
// pkgs/@akanjs/test/src/sampleOf.ts
|
|
38
|
+
var import_base2 = require("@akanjs/base");
|
|
39
|
+
var import_common2 = require("@akanjs/common");
|
|
40
|
+
var import_constant = require("@akanjs/constant");
|
|
569
41
|
|
|
570
42
|
// pkgs/@akanjs/test/src/sample.ts
|
|
43
|
+
var import_base = require("@akanjs/base");
|
|
44
|
+
var import_common = require("@akanjs/common");
|
|
571
45
|
var import_chance = __toESM(require("chance"));
|
|
572
46
|
var chance = new import_chance.default();
|
|
573
47
|
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
|
|
48
|
+
dayjs: (opt) => (0, import_base.dayjs)(chance.date({ ...opt, min: opt?.min?.toDate(), max: opt?.max?.toDate() })),
|
|
49
|
+
pick: import_common.randomPick,
|
|
50
|
+
picks: import_common.randomPicks
|
|
577
51
|
});
|
|
578
52
|
|
|
579
53
|
// pkgs/@akanjs/test/src/sampleOf.ts
|
|
@@ -583,14 +57,14 @@ var getFieldTypeExample = {
|
|
|
583
57
|
url: () => sample.url()
|
|
584
58
|
};
|
|
585
59
|
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 })],
|
|
60
|
+
[import_base2.ID, () => sample.hash({ length: 24 })],
|
|
61
|
+
[import_base2.Int, () => sample.integer({ min: -1e4, max: 1e4 })],
|
|
62
|
+
[import_base2.Float, () => sample.floating({ min: -1e4, max: 1e4 })],
|
|
589
63
|
[String, () => sample.string({ length: 100 })],
|
|
590
64
|
[Boolean, () => sample.bool()],
|
|
591
65
|
[Date, () => sample.dayjs()],
|
|
592
|
-
[Upload, () => "FileUpload"],
|
|
593
|
-
[JSON, () => ({})]
|
|
66
|
+
[import_base2.Upload, () => "FileUpload"],
|
|
67
|
+
[import_base2.JSON, () => ({})]
|
|
594
68
|
]);
|
|
595
69
|
var getScalarSample = (ref, fieldMeta) => {
|
|
596
70
|
if (fieldMeta.type) {
|
|
@@ -607,11 +81,11 @@ var makeSample = (fieldMeta) => {
|
|
|
607
81
|
if (fieldMeta.default)
|
|
608
82
|
return typeof fieldMeta.default === "function" ? fieldMeta.default() : fieldMeta.default;
|
|
609
83
|
else if (fieldMeta.enum)
|
|
610
|
-
return randomPick([...fieldMeta.enum.values]);
|
|
611
|
-
if (isGqlScalar(fieldMeta.modelRef))
|
|
84
|
+
return (0, import_common2.randomPick)([...fieldMeta.enum.values]);
|
|
85
|
+
if ((0, import_base2.isGqlScalar)(fieldMeta.modelRef))
|
|
612
86
|
return getScalarSample(fieldMeta.modelRef, fieldMeta);
|
|
613
87
|
return Object.fromEntries(
|
|
614
|
-
getFieldMetas(fieldMeta.modelRef).map(
|
|
88
|
+
(0, import_constant.getFieldMetas)(fieldMeta.modelRef).map(
|
|
615
89
|
(fieldMeta2) => [
|
|
616
90
|
fieldMeta2.key,
|
|
617
91
|
fieldMeta2.arrDepth ? [] : fieldMeta2.isClass && !fieldMeta2.isScalar ? null : makeSample(fieldMeta2)
|
|
@@ -621,10 +95,9 @@ var makeSample = (fieldMeta) => {
|
|
|
621
95
|
};
|
|
622
96
|
var sampleOf = (modelRef) => {
|
|
623
97
|
return Object.fromEntries(
|
|
624
|
-
getFieldMetas(modelRef).map((fieldMeta) => [
|
|
98
|
+
(0, import_constant.getFieldMetas)(modelRef).map((fieldMeta) => [
|
|
625
99
|
fieldMeta.key,
|
|
626
100
|
fieldMeta.arrDepth ? [] : fieldMeta.isClass && !fieldMeta.isScalar ? null : makeSample(fieldMeta)
|
|
627
101
|
])
|
|
628
102
|
);
|
|
629
103
|
};
|
|
630
|
-
//! Nextjs는 환경변수를 build time에 그냥 하드코딩으로 값을 넣어버림. operationMode같은것들 잘 동작안할 수 있음. 추후 수정 필요.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@akanjs/test",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.46",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -15,9 +15,6 @@
|
|
|
15
15
|
"node": ">=22"
|
|
16
16
|
},
|
|
17
17
|
"dependencies": {
|
|
18
|
-
"chance": "^1.1.12"
|
|
19
|
-
"dayjs": "^1.11.13",
|
|
20
|
-
"pluralize": "^8.0.0",
|
|
21
|
-
"reflect-metadata": "^0.2.2"
|
|
18
|
+
"chance": "^1.1.12"
|
|
22
19
|
}
|
|
23
20
|
}
|