@arkstack/common 0.19.2 → 0.19.3

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/dist/app.d.ts CHANGED
@@ -1,12 +1,12 @@
1
1
  import type { GlobalConfig, GlobalEnv } from '.'
2
2
 
3
3
  interface Stubs {
4
- api: string;
5
- model: string;
6
- resource: string;
7
- controller: string;
8
- collection: string;
9
- apiResource: string;
4
+ api: string
5
+ model: string
6
+ resource: string
7
+ controller: string
8
+ collection: string
9
+ apiResource: string
10
10
  }
11
11
 
12
12
  declare global {
@@ -15,71 +15,60 @@ declare global {
15
15
 
16
16
  /**
17
17
  * Thows to abort the current request
18
- *
19
- * @param message
20
- * @param code
18
+ *
19
+ * @param message
20
+ * @param code
21
21
  * @throws {RequestException}
22
22
  */
23
- function abort (
24
- message?: string,
25
- code?: number
26
- ): void
23
+ function abort(message?: string, code?: number): void
27
24
 
28
25
  /**
29
- * Asserts that a boolean condition is true.
30
- *
31
- * @param boolean
32
- * @param message
33
- * @param code
26
+ * Asserts that a boolean condition is true.
27
+ *
28
+ * @param boolean
29
+ * @param message
30
+ * @param code
34
31
  * @throws {RequestException} Throws if the boolean condition is true.
35
32
  */
36
- function abortIf<T> (
37
- boolean: T,
38
- message?: string,
39
- code?: number,
40
- ): asserts boolean is T
33
+ function abortIf<T>(boolean: T, message?: string, code?: number): asserts boolean is T
41
34
 
42
35
  /**
43
- * Asserts that a value is not null or undefined.
44
- *
45
- * @param value
46
- * @param message
47
- * @param code
36
+ * Asserts that a value is not null or undefined.
37
+ *
38
+ * @param value
39
+ * @param message
40
+ * @param code
48
41
  * @throws {RequestException} Throws if the value is null or undefined.
49
42
  */
50
- function assertFound<T> (
51
- value: T | null | undefined,
52
- message: string,
53
- code: number = 404,
54
- ): asserts value is T
43
+ function assertFound<T>(value: T | null | undefined, message: string, code: number = 404): asserts value is T
55
44
 
56
45
  interface String {
57
46
  /**
58
47
  * Converts the string to title case.
59
48
  */
60
- titleCase (): string;
49
+ titleCase(): string
61
50
  /**
62
51
  * Converts the string to camel case.
63
52
  */
64
- camelCase (): string;
53
+ camelCase(): string
65
54
  /**
66
55
  * Converts the string to pascal case.
67
56
  */
68
- pascalCase (): string;
57
+ pascalCase(): string
69
58
  /**
70
59
  * Truncates the string to a specified length while preserving words
71
60
  * and adds a suffix if necessary.
72
- *
61
+ *
73
62
  * @param len Length of the string
74
63
  * @param suffix Suffix to add to the string
75
64
  */
76
- truncate (len: number, suffix?: string): string;
65
+ truncate(len: number, suffix?: string): string
77
66
  }
78
67
  }
79
68
 
80
69
  declare module 'resora' {
81
70
  interface Config {
82
- stubs: Stubs;
71
+ stubs: Stubs
83
72
  }
84
73
 
85
74
  interface ResoraConfig {
@@ -87,4 +76,4 @@ declare module 'resora' {
87
76
  }
88
77
  }
89
78
 
90
- export { }
79
+ export {}
@@ -3085,7 +3085,7 @@ function mergeDeep(target, source) {
3085
3085
  });
3086
3086
  import_dayjs_min.default.extend(import_customParseFormat.default);
3087
3087
  //#endregion
3088
- //#region ../http/dist/redirect-g4KUj_g-.js
3088
+ //#region ../http/dist/redirect-D4Oybkdd.js
3089
3089
  const unwrapRequestSource = (source) => {
3090
3090
  if (source.original) return unwrapRequestSource(source.original);
3091
3091
  if (source.headers) return source;
@@ -3139,7 +3139,7 @@ const setFallbackRequest = (request) => {
3139
3139
  };
3140
3140
  /**
3141
3141
  * Represents an HTTP request, providing a consistent interface for accessing request data.
3142
- *
3142
+ *
3143
3143
  * @author 3m1n3nc3
3144
3144
  */
3145
3145
  var Request$1 = class Request$1 extends Request {
@@ -3280,7 +3280,7 @@ const setFallbackResponse = (response) => {
3280
3280
  };
3281
3281
  /**
3282
3282
  * Represents an HTTP response, providing a consistent interface for accessing response data.
3283
- *
3283
+ *
3284
3284
  * @author 3m1n3nc3
3285
3285
  */
3286
3286
  var Response$1 = class Response$1 extends Response {
package/dist/faker.js CHANGED
@@ -1,4 +1,4 @@
1
- import { g as configLoader } from "./system-BH1phDBR.js";
1
+ import { g as configLoader } from "./system-DzAzwH__.js";
2
2
  import * as fakerLocales from "@faker-js/faker";
3
3
  import { Faker } from "@faker-js/faker";
4
4
  import { pictwoImage } from "@pictwo/faker";
@@ -184,9 +184,9 @@ interface EnvRegistry {
184
184
  APP_DEBUG: boolean;
185
185
  APP_SECURE: boolean;
186
186
  APP_TIMEZONE: string;
187
- APP_LOCALE: typeof locales[number];
188
- APP_FALLBACK_LOCALE: typeof locales[number];
189
- APP_FAKER_LOCALE: typeof locales[number];
187
+ APP_LOCALE: (typeof locales)[number];
188
+ APP_FALLBACK_LOCALE: (typeof locales)[number];
189
+ APP_FAKER_LOCALE: (typeof locales)[number];
190
190
  NODE_ENV: 'development' | 'production' | 'test';
191
191
  PORT: number;
192
192
  HOST: string;
@@ -247,9 +247,9 @@ interface AppConfig {
247
247
  frontend_url: string;
248
248
  debug: boolean;
249
249
  timezone: string;
250
- locale: typeof locales[number];
251
- fallback_locale: typeof locales[number];
252
- faker_locale: typeof locales[number];
250
+ locale: (typeof locales)[number];
251
+ fallback_locale: (typeof locales)[number];
252
+ faker_locale: (typeof locales)[number];
253
253
  }
254
254
  /**
255
255
  * Known environment variable names.
@@ -299,7 +299,7 @@ interface LoggerLog {
299
299
  */
300
300
  type EnvReturn<X, K extends string, D> = [X] extends [never] ? [D] extends [undefined] ? EnvLookup<K> : EnvLookup<K> | D : [D] extends [undefined] ? X : X | D;
301
301
  interface GlobalEnv {
302
- <X = never, D = undefined, K extends (keyof EnvRegistry | (string & {})) = keyof EnvRegistry>(env: K, defaultValue?: D): EnvReturn<X, K, D>;
302
+ <X = never, D = undefined, K extends keyof EnvRegistry | (string & {}) = keyof EnvRegistry>(env: K, defaultValue?: D): EnvReturn<X, K, D>;
303
303
  }
304
304
  type ConfigShape = keyof ConfigRegistry extends never ? Record<string, any> : ConfigRegistry;
305
305
  interface GlobalConfig {
@@ -311,9 +311,9 @@ interface GlobalConfig {
311
311
  interface FileImporter {
312
312
  <T = unknown>(filePath: string): Promise<T>;
313
313
  <T = unknown>(filePath: string, userOptions?: JitiOptions | undefined): Promise<T>;
314
- <T = unknown>(filePath: string, userOptions?: JitiOptions | undefined, resolveOptions?: (JitiResolveOptions & {
314
+ <T = unknown>(filePath: string, userOptions?: JitiOptions | undefined, resolveOptions?: JitiResolveOptions & {
315
315
  default?: true;
316
- })): Promise<T>;
316
+ }): Promise<T>;
317
317
  }
318
318
  type ArkstackErrorShape = Error & {
319
319
  cause?: unknown;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./app.d.ts" />
2
- import { $ as HookPos, A as SealedBox, B as ConfigShape, C as Encryption, D as KeyPair, E as KeyInput, F as ArkstackErrorShape, G as EnvRegistry, H as DotPathValue, I as Choice, J as GlobalConfig, K as EnvReturn, L as Choices, M as SerializedKeyPair, N as AppConfig, O as Keys, P as ArkstackErrorPayload, Q as HookName, R as Concrete, S as DerivedKey, T as FingerprintOptions, U as EnvKey, V as DotPath, W as EnvLookup, X as HookArgs, Y as GlobalEnv, Z as HookFor, _ as ChannelOptions, a as abort, at as LoggerParseSignature, b as Codec, c as getModel, ct as Primitive, d as isClass, dt as PublishFilter, et as HookPositions, f as normalizePositiveInteger, ft as PublishGroup, g as Hash, h as setModelResolver, i as ModelResolver, it as LoggerLog, j as SecureChannel, k as NodeCipher, l as getModelSync, lt as PublishConfirmation, m as resolvePagination, mt as Logger, n as ModelConstructor, nt as IHook, o as abortIf, ot as MergedConfig, p as perPage, pt as UnionToIntersection, q as FileImporter, r as ModelRegistry, rt as LoggerChalk, s as assertFound, st as PaginationOptions, t as AbstractModelConstructor, tt as HookRegistry, u as initializeGlobalContext, ut as PublishEntry, v as Cipher, w as EncryptionKey, x as DeriveOptions, y as CipherOptions, z as ConfigRegistry } from "./helpers-O3ZUac1k.js";
2
+ import { $ as HookPos, A as SealedBox, B as ConfigShape, C as Encryption, D as KeyPair, E as KeyInput, F as ArkstackErrorShape, G as EnvRegistry, H as DotPathValue, I as Choice, J as GlobalConfig, K as EnvReturn, L as Choices, M as SerializedKeyPair, N as AppConfig, O as Keys, P as ArkstackErrorPayload, Q as HookName, R as Concrete, S as DerivedKey, T as FingerprintOptions, U as EnvKey, V as DotPath, W as EnvLookup, X as HookArgs, Y as GlobalEnv, Z as HookFor, _ as ChannelOptions, a as abort, at as LoggerParseSignature, b as Codec, c as getModel, ct as Primitive, d as isClass, dt as PublishFilter, et as HookPositions, f as normalizePositiveInteger, ft as PublishGroup, g as Hash, h as setModelResolver, i as ModelResolver, it as LoggerLog, j as SecureChannel, k as NodeCipher, l as getModelSync, lt as PublishConfirmation, m as resolvePagination, mt as Logger, n as ModelConstructor, nt as IHook, o as abortIf, ot as MergedConfig, p as perPage, pt as UnionToIntersection, q as FileImporter, r as ModelRegistry, rt as LoggerChalk, s as assertFound, st as PaginationOptions, t as AbstractModelConstructor, tt as HookRegistry, u as initializeGlobalContext, ut as PublishEntry, v as Cipher, w as EncryptionKey, x as DeriveOptions, y as CipherOptions, z as ConfigRegistry } from "./helpers-DpnBcrO9.js";
3
3
  import { Arkstack } from "@arkstack/contract";
4
4
  import { ForkOptions } from "node:child_process";
5
5
  import pino from "pino";
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { _ as EnvLoader, a as env, c as nodeEnv, d as resolveRuntimeDir, f as resolveRuntimeModule, g as configLoader, h as ConfigLoader, i as discoverCommands, l as outputDir, m as CONFIG_KEY, n as appUrl, o as importFile, p as toOutputPath, r as config, s as interopDefault, t as appKey, u as rebuildOutput, v as envLoader } from "./system-BH1phDBR.js";
2
- import { A as SecureChannel, C as Codec, D as Keys, E as KeyPair, O as NodeCipher, S as Cipher, T as EncryptionKey, _ as setModelResolver, b as Exception, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, k as SealedBox, l as assertFound, m as normalizePositiveInteger, p as isClass, s as abort, u as getModel, v as RequestException, w as Encryption, x as Hash, y as AppException } from "./utils-CvlK2sYM.js";
1
+ import { _ as EnvLoader, a as env, c as nodeEnv, d as resolveRuntimeDir, f as resolveRuntimeModule, g as configLoader, h as ConfigLoader, i as discoverCommands, l as outputDir, m as CONFIG_KEY, n as appUrl, o as importFile, p as toOutputPath, r as config, s as interopDefault, t as appKey, u as rebuildOutput, v as envLoader } from "./system-DzAzwH__.js";
2
+ import { A as SecureChannel, C as Codec, D as Keys, E as KeyPair, O as NodeCipher, S as Cipher, T as EncryptionKey, _ as setModelResolver, b as Exception, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, k as SealedBox, l as assertFound, m as normalizePositiveInteger, p as isClass, s as abort, u as getModel, v as RequestException, w as Encryption, x as Hash, y as AppException } from "./utils-DwfM0lt4.js";
3
3
  import { Hook as Hook$1 } from "@arkstack/foundry";
4
4
  import { Arkstack } from "@arkstack/contract";
5
5
  import { str } from "@h3ravel/support";
@@ -27,13 +27,13 @@ const bindGracefulShutdown = (shutdown, defer) => {
27
27
  //#endregion
28
28
  //#region src/network.ts
29
29
  /**
30
- * Boots the app using an available port close to the requested port
30
+ * Boots the app using an available port close to the requested port
31
31
  *when requested port is not available
32
- *
33
- * @param boot
34
- * @param preferredPort
35
- * @param app
36
- * @param defer
32
+ *
33
+ * @param boot
34
+ * @param preferredPort
35
+ * @param app
36
+ * @param defer
37
37
  */
38
38
  const bootWithDetectedPort = async (boot, preferredPort = 3e3, app, defer) => {
39
39
  const port = await detect(preferredPort);
@@ -227,14 +227,14 @@ const CONFIRMATION_REGISTRY_KEY = Symbol.for("arkstack.confirmables");
227
227
  * shared instance even across duplicated module copies.
228
228
  */
229
229
  var Publisher = class {
230
- /**
231
- * The shared, global-symbol-backed registry of publishable groups confirmations.
230
+ /**
231
+ * The shared, global-symbol-backed registry of publishable groups confirmations.
232
232
  */
233
233
  static get confirmations() {
234
234
  return globalThis[CONFIRMATION_REGISTRY_KEY] ??= [];
235
235
  }
236
- /**
237
- * The shared, global-symbol-backed registry of publishable groups.
236
+ /**
237
+ * The shared, global-symbol-backed registry of publishable groups.
238
238
  */
239
239
  static get registry() {
240
240
  return globalThis[REGISTRY_KEY] ??= [];
@@ -274,10 +274,10 @@ var Publisher = class {
274
274
  this.registry.length = 0;
275
275
  this.confirmations.length = 0;
276
276
  }
277
- /**
278
- * Ask to confirm what tag needs to be published.
279
- *
280
- * @param confirmation
277
+ /**
278
+ * Ask to confirm what tag needs to be published.
279
+ *
280
+ * @param confirmation
281
281
  */
282
282
  static confirm(confirmation) {
283
283
  this.confirmations.push(...Array.isArray(confirmation) ? confirmation : [confirmation]);
@@ -372,12 +372,12 @@ var Logger = class Logger {
372
372
  }
373
373
  /**
374
374
  * Logs the message in two columns but allways passing status
375
- *
376
- * @param name
377
- * @param value
378
- * @param status
379
- * @param exit
380
- * @param preserveCol
375
+ *
376
+ * @param name
377
+ * @param value
378
+ * @param status
379
+ * @param exit
380
+ * @param preserveCol
381
381
  */
382
382
  static split(name, value, status, exit = false, preserveCol = false, spacer = ".") {
383
383
  status ??= "info";
@@ -392,11 +392,11 @@ var Logger = class Logger {
392
392
  }
393
393
  /**
394
394
  * Wraps text with chalk
395
- *
396
- * @param txt
397
- * @param color
398
- * @param preserveCol
399
- * @returns
395
+ *
396
+ * @param txt
397
+ * @param color
398
+ * @param preserveCol
399
+ * @returns
400
400
  */
401
401
  static textFormat(txt, color, preserveCol = false) {
402
402
  if (txt instanceof Error) {
@@ -418,10 +418,10 @@ var Logger = class Logger {
418
418
  }
419
419
  /**
420
420
  * Logs a success message
421
- *
422
- * @param msg
423
- * @param exit
424
- * @param preserveCol
421
+ *
422
+ * @param msg
423
+ * @param exit
424
+ * @param preserveCol
425
425
  */
426
426
  static success(msg, exit = false, preserveCol = false) {
427
427
  if (!this.shouldSuppressOutput("success")) console.log(chalk.green("✓"), this.textFormat(msg, chalk.bgGreen, preserveCol));
@@ -429,10 +429,10 @@ var Logger = class Logger {
429
429
  }
430
430
  /**
431
431
  * Logs an informational message
432
- *
433
- * @param msg
434
- * @param exit
435
- * @param preserveCol
432
+ *
433
+ * @param msg
434
+ * @param exit
435
+ * @param preserveCol
436
436
  */
437
437
  static info(msg, exit = false, preserveCol = false) {
438
438
  if (!this.shouldSuppressOutput("info")) console.log(chalk.blue("ℹ"), this.textFormat(msg, chalk.bgBlue, preserveCol));
@@ -440,10 +440,10 @@ var Logger = class Logger {
440
440
  }
441
441
  /**
442
442
  * Logs an error message
443
- *
444
- * @param msg
445
- * @param exit
446
- * @param preserveCol
443
+ *
444
+ * @param msg
445
+ * @param exit
446
+ * @param preserveCol
447
447
  */
448
448
  static error(msg, exit = true, preserveCol = false) {
449
449
  if (!this.shouldSuppressOutput("error")) if (msg instanceof Error) {
@@ -454,10 +454,10 @@ var Logger = class Logger {
454
454
  }
455
455
  /**
456
456
  * Logs a warning message
457
- *
458
- * @param msg
459
- * @param exit
460
- * @param preserveCol
457
+ *
458
+ * @param msg
459
+ * @param exit
460
+ * @param preserveCol
461
461
  */
462
462
  static warn(msg, exit = false, preserveCol = false) {
463
463
  if (!this.shouldSuppressOutput("warn")) console.warn(chalk.yellow("⚠"), this.textFormat(msg, chalk.bgYellow, preserveCol));
@@ -465,10 +465,10 @@ var Logger = class Logger {
465
465
  }
466
466
  /**
467
467
  * Logs a debug message (only shown with verbosity >= 3)
468
- *
469
- * @param msg
470
- * @param exit
471
- * @param preserveCol
468
+ *
469
+ * @param msg
470
+ * @param exit
471
+ * @param preserveCol
472
472
  */
473
473
  static debug(msg, exit = false, preserveCol = false) {
474
474
  if (!this.shouldSuppressOutput("debug")) if (Array.isArray(msg)) for (let i = 0; i < msg.length; i++) console.log(chalk.gray("🐛"), chalk.bgGray(i + 1), this.textFormat(msg[i], chalk.bgGray, preserveCol));
@@ -499,8 +499,8 @@ var Logger = class Logger {
499
499
  }
500
500
  /**
501
501
  * Ouput formater object or format the output
502
- *
503
- * @returns
502
+ *
503
+ * @returns
504
504
  */
505
505
  static log = ((config, joiner, log = true, sc) => {
506
506
  if (typeof config === "string") {
@@ -512,8 +512,8 @@ var Logger = class Logger {
512
512
  });
513
513
  /**
514
514
  * A simple console like output logger
515
- *
516
- * @returns
515
+ *
516
+ * @returns
517
517
  */
518
518
  static console() {
519
519
  return Console;
@@ -525,9 +525,9 @@ var Hook = class {
525
525
  static hooks = /* @__PURE__ */ new Map();
526
526
  /**
527
527
  * Hooks define code that should run within defined boundaries to add extra functionalities.
528
- *
529
- * @param name
530
- * @param value
528
+ *
529
+ * @param name
530
+ * @param value
531
531
  */
532
532
  static set(name, hook) {
533
533
  const oldhook = this.hooks.get(name) ?? {};
@@ -538,8 +538,8 @@ var Hook = class {
538
538
  }
539
539
  /**
540
540
  * Check if a hook is defined by name
541
- *
542
- * @param name
541
+ *
542
+ * @param name
543
543
  */
544
544
  static has(name, pos) {
545
545
  if (pos && this.hooks.has(name)) return Boolean(this.get(name, pos));
@@ -556,8 +556,8 @@ var Hook = class {
556
556
  }
557
557
  /**
558
558
  * Retrieve all defined hooks
559
- *
560
- * @param name
559
+ *
560
+ * @param name
561
561
  */
562
562
  static getAll = () => {
563
563
  const hooks = {};
@@ -566,8 +566,8 @@ var Hook = class {
566
566
  };
567
567
  /**
568
568
  * Remove the defined hook
569
- *
570
- * @param name
569
+ *
570
+ * @param name
571
571
  */
572
572
  static unset(name, pos) {
573
573
  if (name && this.hooks.has(name)) {
@@ -25,8 +25,8 @@ var EnvLoader = class {
25
25
  loaded = false;
26
26
  /**
27
27
  * Load the `.env` file once.
28
- *
29
- * @returns
28
+ *
29
+ * @returns
30
30
  */
31
31
  ensureLoaded() {
32
32
  if (this.loaded) return;
@@ -89,7 +89,7 @@ var EnvLoader = class {
89
89
  return Number.isFinite(parsed) && String(parsed) === value;
90
90
  }
91
91
  };
92
- /**
92
+ /**
93
93
  * Shared environment loader backing {@link env}.
94
94
  */
95
95
  const envLoader = new EnvLoader();
@@ -105,7 +105,7 @@ globalThis[CONFIG_KEY] = {};
105
105
  * merged in at runtime.
106
106
  */
107
107
  var ConfigLoader = class {
108
- /**
108
+ /**
109
109
  * The cached config store, shared across instances via a global symbol.
110
110
  */
111
111
  get store() {
@@ -114,7 +114,7 @@ var ConfigLoader = class {
114
114
  set store(value) {
115
115
  globalThis[CONFIG_KEY] = value;
116
116
  }
117
- /**
117
+ /**
118
118
  * Read and cache config modules from the config directory on first use.
119
119
  */
120
120
  load() {
@@ -181,7 +181,7 @@ var ConfigLoader = class {
181
181
  return this.store;
182
182
  }
183
183
  };
184
- /**
184
+ /**
185
185
  * Shared config loader backing {@link config}.
186
186
  */
187
187
  const configLoader = new ConfigLoader();
@@ -289,21 +289,21 @@ const OUTPUT_EXTENSIONS = [
289
289
  ".cjs",
290
290
  ".ts"
291
291
  ];
292
- /**
293
- * Strip a trailing known source/compiled extension from a path.
294
- *
295
- * @param value
296
- * @returns
292
+ /**
293
+ * Strip a trailing known source/compiled extension from a path.
294
+ *
295
+ * @param value
296
+ * @returns
297
297
  */
298
298
  const stripKnownExtension = (value) => value.replace(/\.(ts|tsx|mts|cts|js|mjs|cjs)$/i, "");
299
299
  /**
300
300
  * Build the list of concrete file candidates for a base path. Any existing
301
301
  * source/compiled extension is dropped first so the correct runtime extension
302
302
  * can be tried (e.g. a `.ts` source maps to a `.js` candidate under `dist`).
303
- *
304
- * @param base
305
- * @param extensions
306
- * @returns
303
+ *
304
+ * @param base
305
+ * @param extensions
306
+ * @returns
307
307
  */
308
308
  const moduleCandidates = (base, extensions) => {
309
309
  const bare = stripKnownExtension(base);
@@ -406,11 +406,11 @@ const rebuildOutput = async () => {
406
406
  });
407
407
  };
408
408
  /**
409
- *
409
+ *
410
410
  * Dynamically imports a file at the given path with full TypeScript support,
411
- * including `tsconfig.json` path aliases.
411
+ * including `tsconfig.json` path aliases.
412
412
  *
413
- * @param filePath - The path to the file to import.
413
+ * @param filePath - The path to the file to import.
414
414
  * @returns The imported module typed as `T`.
415
415
  *
416
416
  * @example
@@ -1,4 +1,4 @@
1
- import { A as SealedBox, C as Encryption, D as KeyPair, E as KeyInput, M as SerializedKeyPair, O as Keys, S as DerivedKey, T as FingerprintOptions, _ as ChannelOptions, a as abort, b as Codec, c as getModel, d as isClass, f as normalizePositiveInteger, g as Hash, h as setModelResolver, i as ModelResolver, j as SecureChannel, k as NodeCipher, l as getModelSync, m as resolvePagination, n as ModelConstructor, o as abortIf, p as perPage, r as ModelRegistry, s as assertFound, t as AbstractModelConstructor, u as initializeGlobalContext, v as Cipher, w as EncryptionKey, x as DeriveOptions, y as CipherOptions } from "../helpers-O3ZUac1k.js";
1
+ import { A as SealedBox, C as Encryption, D as KeyPair, E as KeyInput, M as SerializedKeyPair, O as Keys, S as DerivedKey, T as FingerprintOptions, _ as ChannelOptions, a as abort, b as Codec, c as getModel, d as isClass, f as normalizePositiveInteger, g as Hash, h as setModelResolver, i as ModelResolver, j as SecureChannel, k as NodeCipher, l as getModelSync, m as resolvePagination, n as ModelConstructor, o as abortIf, p as perPage, r as ModelRegistry, s as assertFound, t as AbstractModelConstructor, u as initializeGlobalContext, v as Cipher, w as EncryptionKey, x as DeriveOptions, y as CipherOptions } from "../helpers-DpnBcrO9.js";
2
2
  import { Model } from "arkormx";
3
3
  //#region src/utils/traits.d.ts
4
4
  declare const crc32: (str: string) => number;
@@ -38,7 +38,7 @@ type Explode<T = any> = { [P in keyof T]: T[P]; };
38
38
  /**
39
39
  * utility type: convert two arrays of types into an array of union types
40
40
  */
41
- type MixParams<T1 extends any[], T2 extends any[]> = T1 extends [] ? (T2 extends [] ? [] : T2) : (T2 extends [] ? T1 : (T1 extends [infer H1, ...infer R1] ? (T2 extends [infer H2, ...infer R2] ? [H1 & H2, ...MixParams<R1, R2>] : []) : []));
41
+ type MixParams<T1 extends any[], T2 extends any[]> = T1 extends [] ? T2 extends [] ? [] : T2 : T2 extends [] ? T1 : T1 extends [infer H1, ...infer R1] ? T2 extends [infer H2, ...infer R2] ? [H1 & H2, ...MixParams<R1, R2>] : [] : [];
42
42
  /**
43
43
  * API: trait type
44
44
  */
@@ -74,7 +74,7 @@ type ExtractSuperTrait<T extends Trait> = T extends Trait<TraitDefTypeT, infer S
74
74
  /**
75
75
  * utility type: derive type constructor: merge two constructors
76
76
  */
77
- type DeriveTraitsConsConsMerge<A extends Cons, B extends Cons> = A extends (new (...args: infer ArgsA) => infer RetA) ? (B extends (new (...args: infer ArgsB) => infer RetB) ? (new (...args: MixParams<ArgsA, ArgsB>) => RetA & RetB) : never) : never;
77
+ type DeriveTraitsConsConsMerge<A extends Cons, B extends Cons> = A extends (new (...args: infer ArgsA) => infer RetA) ? B extends (new (...args: infer ArgsB) => infer RetB) ? new (...args: MixParams<ArgsA, ArgsB>) => RetA & RetB : never : never;
78
78
  /**
79
79
  * utility type: derive type constructor: extract plain constructor
80
80
  */
@@ -83,7 +83,7 @@ type DeriveTraitsConsDirectBase<T extends DirectBase> = T extends Model ? new (.
83
83
  /**
84
84
  * utility type: derive type constructor: from trait parts
85
85
  */
86
- type DeriveTraitsConsTraitParts<C extends Cons, ST extends ((Trait | TypeFactory<Trait>)[] | undefined)> = ST extends undefined ? DeriveTraitsConsCons<C> : ST extends [] ? DeriveTraitsConsCons<C> : DeriveTraitsConsConsMerge<DeriveTraitsConsCons<C>, DeriveTraitsConsAll<ST>>;
86
+ type DeriveTraitsConsTraitParts<C extends Cons, ST extends (Trait | TypeFactory<Trait>)[] | undefined> = ST extends undefined ? DeriveTraitsConsCons<C> : ST extends [] ? DeriveTraitsConsCons<C> : DeriveTraitsConsConsMerge<DeriveTraitsConsCons<C>, DeriveTraitsConsAll<ST>>;
87
87
  /**
88
88
  * utility type: derive type constructor: from single trait
89
89
  */
@@ -91,15 +91,15 @@ type DeriveTraitsConsTrait<T extends Trait> = DeriveTraitsConsTraitParts<Extract
91
91
  /**
92
92
  * utility type: derive type constructor: from single trait or trait factory
93
93
  */
94
- type DeriveTraitsConsOne<T extends (Trait | TypeFactory<Trait>)> = T extends Trait ? DeriveTraitsConsTrait<T> : T extends TypeFactory<Trait> ? DeriveTraitsConsTrait<ReturnType<T>> : never;
94
+ type DeriveTraitsConsOne<T extends Trait | TypeFactory<Trait>> = T extends Trait ? DeriveTraitsConsTrait<T> : T extends TypeFactory<Trait> ? DeriveTraitsConsTrait<ReturnType<T>> : never;
95
95
  /**
96
96
  * utility type: derive type constructor: from one or more traits or trait factories
97
97
  */
98
- type DeriveTraitsConsAll<T extends (((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase]) | undefined)> = T extends [infer Only extends DirectBase] ? DeriveTraitsConsDirectBase<Only> : T extends [...infer Others extends (Trait | TypeFactory<Trait>)[], infer Last extends DirectBase] ? (Others extends [] ? DeriveTraitsConsDirectBase<Last> : DeriveTraitsConsConsMerge<DeriveTraitsConsAll<Others>, /* RECURSION */ DeriveTraitsConsDirectBase<Last>>) : T extends (Trait | TypeFactory<Trait>)[] ? (T extends [infer First extends (Trait | TypeFactory<Trait>)] ? (DeriveTraitsConsOne<First>) : (T extends [infer First extends (Trait | TypeFactory<Trait>), ...infer Rest extends (Trait | TypeFactory<Trait>)[]] ? (DeriveTraitsConsConsMerge<DeriveTraitsConsOne<First>, DeriveTraitsConsAll<Rest>>) : never)) : never;
98
+ type DeriveTraitsConsAll<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase]) | undefined> = T extends [infer Only extends DirectBase] ? DeriveTraitsConsDirectBase<Only> : T extends [...infer Others extends (Trait | TypeFactory<Trait>)[], infer Last extends DirectBase] ? Others extends [] ? DeriveTraitsConsDirectBase<Last> : DeriveTraitsConsConsMerge<DeriveTraitsConsAll<Others>, DeriveTraitsConsDirectBase<Last>> : T extends (Trait | TypeFactory<Trait>)[] ? T extends [infer First extends Trait | TypeFactory<Trait>] ? DeriveTraitsConsOne<First> : T extends [infer First extends Trait | TypeFactory<Trait>, ...infer Rest extends (Trait | TypeFactory<Trait>)[]] ? DeriveTraitsConsConsMerge<DeriveTraitsConsOne<First>, DeriveTraitsConsAll<Rest>> : never : never;
99
99
  /**
100
100
  * utility type: derive type constructor
101
101
  */
102
- type DeriveTraitsCons<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase])> = DeriveTraitsConsAll<T>;
102
+ type DeriveTraitsCons<T extends (Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase]> = DeriveTraitsConsAll<T>;
103
103
  /**
104
104
  * utility type: derive type statics: merge two objects with statics
105
105
  */
@@ -112,7 +112,7 @@ type DeriveTraitsStatsDirectBase<T extends DirectBase> = T extends Model ? objec
112
112
  /**
113
113
  * utility type: derive type statics: from trait parts
114
114
  */
115
- type DeriveTraitsStatsTraitParts<C extends Cons, ST extends ((Trait | TypeFactory<Trait>)[] | undefined)> = ST extends undefined ? DeriveTraitsStatsCons<C> : ST extends [] ? DeriveTraitsStatsCons<C> : DeriveTraitsStatsConsMerge<DeriveTraitsStatsCons<C>, DeriveTraitsStatsAll<ST>>;
115
+ type DeriveTraitsStatsTraitParts<C extends Cons, ST extends (Trait | TypeFactory<Trait>)[] | undefined> = ST extends undefined ? DeriveTraitsStatsCons<C> : ST extends [] ? DeriveTraitsStatsCons<C> : DeriveTraitsStatsConsMerge<DeriveTraitsStatsCons<C>, DeriveTraitsStatsAll<ST>>;
116
116
  /**
117
117
  * utility type: derive type statics: from single trait
118
118
  */
@@ -120,24 +120,24 @@ type DeriveTraitsStatsTrait<T extends Trait> = DeriveTraitsStatsTraitParts<Extra
120
120
  /**
121
121
  * utility type: derive type statics: from single trait or trait factory
122
122
  */
123
- type DeriveTraitsStatsOne<T extends (Trait | TypeFactory<Trait>)> = T extends Trait ? DeriveTraitsStatsTrait<T> : T extends TypeFactory<Trait> ? DeriveTraitsStatsTrait<ReturnType<T>> : never;
123
+ type DeriveTraitsStatsOne<T extends Trait | TypeFactory<Trait>> = T extends Trait ? DeriveTraitsStatsTrait<T> : T extends TypeFactory<Trait> ? DeriveTraitsStatsTrait<ReturnType<T>> : never;
124
124
  /**
125
125
  * utility type: derive type statics: from one or more traits or trait factories
126
126
  */
127
- type DeriveTraitsStatsAll<T extends (((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase]) | undefined)> = T extends [infer Only extends DirectBase] ? DeriveTraitsStatsDirectBase<Only> : T extends [...infer Others extends (Trait | TypeFactory<Trait>)[], infer Last extends DirectBase] ? (Others extends [] ? DeriveTraitsStatsDirectBase<Last> : DeriveTraitsStatsConsMerge<DeriveTraitsStatsAll<Others>, /* RECURSION */ DeriveTraitsStatsDirectBase<Last>>) : T extends (Trait | TypeFactory<Trait>)[] ? (T extends [infer First extends (Trait | TypeFactory<Trait>)] ? (DeriveTraitsStatsOne<First>) : (T extends [infer First extends (Trait | TypeFactory<Trait>), ...infer Rest extends (Trait | TypeFactory<Trait>)[]] ? (DeriveTraitsStatsConsMerge<DeriveTraitsStatsOne<First>, DeriveTraitsStatsAll<Rest>>) : never)) : never;
127
+ type DeriveTraitsStatsAll<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase]) | undefined> = T extends [infer Only extends DirectBase] ? DeriveTraitsStatsDirectBase<Only> : T extends [...infer Others extends (Trait | TypeFactory<Trait>)[], infer Last extends DirectBase] ? Others extends [] ? DeriveTraitsStatsDirectBase<Last> : DeriveTraitsStatsConsMerge<DeriveTraitsStatsAll<Others>, DeriveTraitsStatsDirectBase<Last>> : T extends (Trait | TypeFactory<Trait>)[] ? T extends [infer First extends Trait | TypeFactory<Trait>] ? DeriveTraitsStatsOne<First> : T extends [infer First extends Trait | TypeFactory<Trait>, ...infer Rest extends (Trait | TypeFactory<Trait>)[]] ? DeriveTraitsStatsConsMerge<DeriveTraitsStatsOne<First>, DeriveTraitsStatsAll<Rest>> : never : never;
128
128
  /**
129
129
  * utility type: derive type statics
130
130
  */
131
- type DeriveTraitsStats<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase])> = DeriveTraitsStatsAll<T>;
131
+ type DeriveTraitsStats<T extends (Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase]> = DeriveTraitsStatsAll<T>;
132
132
  /**
133
133
  * utility type: derive type from one or more traits or trait type factories
134
134
  */
135
- type DeriveTraits<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase])> = DeriveTraitsCons<T> & DeriveTraitsStats<T>;
135
+ type DeriveTraits<T extends (Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase]> = DeriveTraitsCons<T> & DeriveTraitsStats<T>;
136
136
  type TraitMethodHelpers = {
137
137
  getTraitMethods: <T extends TraitMethod = TraitMethod>(name: PropertyKey) => T[];
138
138
  callTraitMethods: <T = any>(name: PropertyKey, ...args: any[]) => T[];
139
139
  };
140
- type DeriveTraitsWithMethodHelpers<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase])> = DeriveTraits<T> extends (new (...args: infer Args) => infer Instance) ? (new (...args: Args) => Instance & TraitMethodHelpers) & Omit<DeriveTraits<T>, 'prototype'> & TraitMethodHelpers : never;
140
+ type DeriveTraitsWithMethodHelpers<T extends (Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase]> = DeriveTraits<T> extends (new (...args: infer Args) => infer Instance) ? (new (...args: Args) => Instance & TraitMethodHelpers) & Omit<DeriveTraits<T>, 'prototype'> & TraitMethodHelpers : never;
141
141
  type TraitMethod = (...args: any[]) => any;
142
142
  /**
143
143
  * Return every trait implementation for a method, bound to the supplied
@@ -158,7 +158,7 @@ declare const getTraitMethods: <T extends TraitMethod = TraitMethod>(target: obj
158
158
  * @returns
159
159
  */
160
160
  declare const callTraitMethods: <T = any>(target: object | Cons, name: PropertyKey, ...args: any[]) => T[];
161
- type UsableTraits = ([Trait | TypeFactory<Trait>, ...(Trait | TypeFactory<Trait>)[]] | [...(Trait | TypeFactory<Trait>)[], DirectBase]);
161
+ type UsableTraits = [Trait | TypeFactory<Trait>, ...(Trait | TypeFactory<Trait>)[]] | [...(Trait | TypeFactory<Trait>)[], DirectBase];
162
162
  /**
163
163
  * API: derive a class from one or more traits or trait type factories
164
164
  *
@@ -174,7 +174,7 @@ type DerivedType<T extends Trait> = InstanceType<ExtractFactory<T>>;
174
174
  /**
175
175
  * internal type: implements trait type or trait type factory
176
176
  */
177
- type Derived<T extends (Trait | TypeFactory<Trait> | Cons)> = T extends TypeFactory<Trait> ? DerivedType<ReturnType<T>> : T extends Trait ? DerivedType<T> : T extends Cons ? T : never;
177
+ type Derived<T extends Trait | TypeFactory<Trait> | Cons> = T extends TypeFactory<Trait> ? DerivedType<ReturnType<T>> : T extends Trait ? DerivedType<T> : T extends Cons ? T : never;
178
178
  /**
179
179
  * API: type guard for checking whether class instance is derived from a trait
180
180
  *
@@ -182,6 +182,6 @@ type Derived<T extends (Trait | TypeFactory<Trait> | Cons)> = T extends TypeFact
182
182
  * @param trait
183
183
  * @returns
184
184
  */
185
- declare function uses<T extends (Trait | TypeFactory<Trait> | Cons)>(instance: unknown, trait: T): instance is Derived<T>;
185
+ declare function uses<T extends Trait | TypeFactory<Trait> | Cons>(instance: unknown, trait: T): instance is Derived<T>;
186
186
  //#endregion
187
187
  export { AbstractModelConstructor, type ChannelOptions, Cipher, type CipherOptions, Codec, type DeriveOptions, Derived, type DerivedKey, Encryption, EncryptionKey, type FingerprintOptions, Hash, type KeyInput, KeyPair, Keys, ModelConstructor, ModelRegistry, ModelResolver, NodeCipher, SealedBox, SecureChannel, type SerializedKeyPair, Trait, abort, abortIf, assertFound, callTraitMethods, crc32, getModel, getModelSync, getTraitMethods, initializeGlobalContext, isClass, normalizePositiveInteger, perPage, resolvePagination, setModelResolver, trait, use, uses };