@arkstack/common 0.18.9 → 0.18.11

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.
@@ -2,8 +2,8 @@ import { ChannelOptions, Cipher, CipherOptions, Codec, DeriveOptions, DerivedKey
2
2
  import { NodeCipher } from "@arkstack/encryption/node";
3
3
  import { JitiOptions, JitiResolveOptions } from "jiti";
4
4
  import { TOTP } from "otpauth";
5
- import { Model, ModelStatic, RegisteredModelClass, RegisteredModelName, RelatedModelClass } from "arkormx";
6
5
  import { ChalkInstance } from "chalk";
6
+ import { Model, ModelStatic, RegisteredModelClass, RegisteredModelName, RelatedModelClass } from "arkormx";
7
7
  //#region src/Logger.d.ts
8
8
  declare class Console {
9
9
  static log: (...args: any[]) => string | void;
@@ -41,6 +41,22 @@ declare class Logger {
41
41
  */
42
42
  static twoColumnDetail(name: string, value: string, log?: true, spacer?: string): void;
43
43
  static twoColumnDetail(name: string, value: string, log?: false, spacer?: string): [string, string, string];
44
+ /**
45
+ * Convert absolute paths under current working directory into relative display paths.
46
+ *
47
+ * @param filePath
48
+ * @returns
49
+ */
50
+ static formatPathForLog(filePath: string): string;
51
+ /**
52
+ * Utility to format a value for logging, converting absolute paths under current
53
+ * working directory into relative display paths.
54
+ *
55
+ * @param name
56
+ * @param value
57
+ * @returns
58
+ */
59
+ static splitLogger(name: string, value: string): string;
44
60
  /**
45
61
  * Logs the message in two columns
46
62
  *
@@ -583,6 +599,15 @@ declare class Hash {
583
599
  type AbstractModelConstructor<TModel = unknown> = abstract new (attributes?: Record<string, unknown>) => TModel;
584
600
  type ModelConstructor<TModel extends Model = Model> = AbstractModelConstructor<TModel> & Pick<ModelStatic<TModel>, keyof ModelStatic<TModel>>;
585
601
  interface ModelRegistry {}
602
+ type ModelResolver = (modelName: string) => RelatedModelClass;
603
+ /**
604
+ * Configure the synchronous model resolver used by {@link getModel}.
605
+ *
606
+ * Database integrations should call this during module initialization. Keeping
607
+ * the resolver injectable lets `@arkstack/common` remain usable without loading
608
+ * a specific ORM at runtime.
609
+ */
610
+ declare const setModelResolver: (resolver: ModelResolver) => void;
586
611
  /**
587
612
  * Checks and asserts if target is a class
588
613
  *
@@ -630,16 +655,14 @@ declare const resolvePagination: (query: {
630
655
  /**
631
656
  * Synchronously resolve an application model by name.
632
657
  *
633
- * Registered models are returned first. If a model has not been registered yet,
634
- * ArkORM loads it from the configured models paths, registers it, and returns
635
- * the matching constructor.
658
+ * The configured database integration resolves and, when supported, loads the
659
+ * requested model.
636
660
  *
637
661
  * @param modelName
638
- * @alias {@link getArkormxModel}
639
662
  * @returns
640
663
  */
641
- declare function getModel$1<TName extends RegisteredModelName>(modelName: TName): RegisteredModelClass<TName>;
642
- declare function getModel$1<TModel extends RelatedModelClass = RelatedModelClass>(modelName: string): TModel;
664
+ declare function getModel<TName extends RegisteredModelName>(modelName: TName): RegisteredModelClass<TName>;
665
+ declare function getModel<TModel extends RelatedModelClass = RelatedModelClass>(modelName: string): TModel;
643
666
  /**
644
667
  * Synchronously import an application model by name.
645
668
  *
@@ -647,8 +670,7 @@ declare function getModel$1<TModel extends RelatedModelClass = RelatedModelClass
647
670
  * Without a registry entry, pass the class type explicitly: `getModel<typeof User>('User')`.
648
671
  *
649
672
  * @param modelName
650
- * @alias {@link getArkormxModel}
651
- * @deprecated 0.17.27 - Use {@link getModel} or {@link getArkormxModel}
673
+ * @deprecated 0.17.27 - Use {@link getModel}
652
674
  */
653
675
  declare function getModelSync<TName extends RegisteredModelName>(modelName: TName): RegisteredModelClass<TName>;
654
676
  declare function getModelSync<TModel extends RelatedModelClass = RelatedModelClass>(modelName: string): TModel;
@@ -684,4 +706,4 @@ declare const abortIf: <T>(boolean: T, message?: string, code?: number) => asser
684
706
  */
685
707
  declare const assertFound: <T>(value: T | null | undefined, message: string, code?: number) => asserts value is T;
686
708
  //#endregion
687
- export { HookRegistry as $, SerializedKeyPair as A, DotPathValue as B, FingerprintOptions as C, NodeCipher as D, Keys as E, Choices as F, FileImporter as G, EnvLookup as H, Concrete as I, HookArgs as J, GlobalConfig as K, ConfigRegistry as L, ArkstackErrorPayload as M, ArkstackErrorShape as N, SealedBox as O, Choice as P, HookPositions as Q, ConfigShape as R, EncryptionKey as S, KeyPair as T, EnvRegistry as U, EnvKey as V, EnvReturn as W, HookName as X, HookFor as Y, HookPos as Z, CipherOptions as _, abortIf as a, PaginationOptions as at, DerivedKey as b, getModelSync as c, PublishEntry as ct, normalizePositiveInteger as d, UnionToIntersection as dt, IHook as et, perPage as f, Logger as ft, Cipher as g, ChannelOptions as h, abort as i, MergedConfig as it, AppConfig as j, SecureChannel as k, initializeGlobalContext as l, PublishFilter as lt, Hash as m, ModelConstructor as n, LoggerLog as nt, assertFound as o, Primitive as ot, resolvePagination as p, GlobalEnv as q, ModelRegistry as r, LoggerParseSignature as rt, getModel$1 as s, PublishConfirmation as st, AbstractModelConstructor as t, LoggerChalk as tt, isClass as u, PublishGroup as ut, Codec as v, KeyInput as w, Encryption as x, DeriveOptions as y, DotPath as z };
709
+ export { HookPos as $, SealedBox as A, ConfigShape as B, Encryption as C, KeyPair as D, KeyInput as E, ArkstackErrorShape as F, EnvRegistry as G, DotPathValue as H, Choice as I, GlobalConfig as J, EnvReturn as K, Choices as L, SerializedKeyPair as M, AppConfig as N, Keys as O, ArkstackErrorPayload as P, HookName as Q, Concrete as R, DerivedKey as S, FingerprintOptions as T, EnvKey as U, DotPath as V, EnvLookup as W, HookArgs as X, GlobalEnv as Y, HookFor as Z, ChannelOptions as _, abort as a, LoggerParseSignature as at, Codec as b, getModel as c, Primitive as ct, isClass as d, PublishFilter as dt, HookPositions as et, normalizePositiveInteger as f, PublishGroup as ft, Hash as g, setModelResolver as h, ModelResolver as i, LoggerLog as it, SecureChannel as j, NodeCipher as k, getModelSync as l, PublishConfirmation as lt, resolvePagination as m, Logger as mt, ModelConstructor as n, IHook as nt, abortIf as o, MergedConfig as ot, perPage as p, UnionToIntersection as pt, FileImporter as q, ModelRegistry as r, LoggerChalk as rt, assertFound as s, PaginationOptions as st, AbstractModelConstructor as t, HookRegistry as tt, initializeGlobalContext as u, PublishEntry as ut, Cipher as v, EncryptionKey as w, DeriveOptions as x, CipherOptions as y, ConfigRegistry as z };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./app.d.ts" />
2
- import { $ as HookRegistry, A as SerializedKeyPair, B as DotPathValue, C as FingerprintOptions, D as NodeCipher, E as Keys, F as Choices, G as FileImporter, H as EnvLookup, I as Concrete, J as HookArgs, K as GlobalConfig, L as ConfigRegistry, M as ArkstackErrorPayload, N as ArkstackErrorShape, O as SealedBox, P as Choice, Q as HookPositions, R as ConfigShape, S as EncryptionKey, T as KeyPair, U as EnvRegistry, V as EnvKey, W as EnvReturn, X as HookName, Y as HookFor, Z as HookPos, _ as CipherOptions, a as abortIf, at as PaginationOptions, b as DerivedKey, c as getModelSync, ct as PublishEntry, d as normalizePositiveInteger, dt as UnionToIntersection, et as IHook, f as perPage, ft as Logger, g as Cipher, h as ChannelOptions, i as abort, it as MergedConfig, j as AppConfig, k as SecureChannel, l as initializeGlobalContext, lt as PublishFilter, m as Hash, n as ModelConstructor, nt as LoggerLog, o as assertFound, ot as Primitive, p as resolvePagination, q as GlobalEnv, r as ModelRegistry, rt as LoggerParseSignature, s as getModel, st as PublishConfirmation, t as AbstractModelConstructor, tt as LoggerChalk, u as isClass, ut as PublishGroup, v as Codec, w as KeyInput, x as Encryption, y as DeriveOptions, z as DotPath } from "./helpers-DgIgQLDu.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-CWLBYxS-.js";
3
3
  import { Arkstack } from "@arkstack/contract";
4
4
  import { ForkOptions } from "node:child_process";
5
5
  import pino from "pino";
@@ -533,4 +533,4 @@ declare const devServer: (options: DevServerRunnerOptions) => {
533
533
  closeWatcher(): Promise<void>;
534
534
  };
535
535
  //#endregion
536
- export { AbstractModelConstructor, AppConfig, AppException, ArkstackErrorPayload, ArkstackErrorShape, CONFIG_KEY, type ChannelOptions, Choice, Choices, Cipher, type CipherOptions, Codec, Concrete, ConfigLoader, ConfigRegistry, ConfigShape, type DeriveOptions, type DerivedKey, DevServerRunnerOptions, DotPath, DotPathValue, Encryption, EncryptionKey, EnvKey, EnvLoader, EnvLookup, EnvRegistry, EnvReturn, ErrorHandler, Exception, FileImporter, type FingerprintOptions, GlobalConfig, GlobalEnv, Hash, Hook, HookArgs, HookFor, HookName, HookPos, HookPositions, HookRegistry, IHook, type KeyInput, KeyPair, Keys, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, MergedConfig, ModelConstructor, ModelRegistry, NodeCipher, PaginationOptions, Primitive, PublishConfirmation, PublishEntry, PublishFilter, PublishGroup, Publisher, RequestException, SealedBox, SecureChannel, type SerializedKeyPair, TlsCredentials, UnionToIntersection, abort, abortIf, appKey, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, configLoader, createErrorPayload, devServer, devTlsCredentials, discoverCommands, env, envLoader, getErrorLogger, getModel, getModelSync, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, localNetworkAddress, logUnhandledError, nodeEnv, normalizePositiveInteger, normalizeStatusCode, outputDir, perPage, rebuildOutput, renderError, resolvePagination, resolveRuntimeDir, resolveRuntimeModule, serializeError, shouldHideStack, shouldLogError, toErrorShape, toOutputPath };
536
+ export { AbstractModelConstructor, AppConfig, AppException, ArkstackErrorPayload, ArkstackErrorShape, CONFIG_KEY, type ChannelOptions, Choice, Choices, Cipher, type CipherOptions, Codec, Concrete, ConfigLoader, ConfigRegistry, ConfigShape, type DeriveOptions, type DerivedKey, DevServerRunnerOptions, DotPath, DotPathValue, Encryption, EncryptionKey, EnvKey, EnvLoader, EnvLookup, EnvRegistry, EnvReturn, ErrorHandler, Exception, FileImporter, type FingerprintOptions, GlobalConfig, GlobalEnv, Hash, Hook, HookArgs, HookFor, HookName, HookPos, HookPositions, HookRegistry, IHook, type KeyInput, KeyPair, Keys, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, MergedConfig, ModelConstructor, ModelRegistry, ModelResolver, NodeCipher, PaginationOptions, Primitive, PublishConfirmation, PublishEntry, PublishFilter, PublishGroup, Publisher, RequestException, SealedBox, SecureChannel, type SerializedKeyPair, TlsCredentials, UnionToIntersection, abort, abortIf, appKey, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, configLoader, createErrorPayload, devServer, devTlsCredentials, discoverCommands, env, envLoader, getErrorLogger, getModel, getModelSync, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, localNetworkAddress, logUnhandledError, nodeEnv, normalizePositiveInteger, normalizeStatusCode, outputDir, perPage, rebuildOutput, renderError, resolvePagination, resolveRuntimeDir, resolveRuntimeModule, serializeError, setModelResolver, shouldHideStack, shouldLogError, toErrorShape, toOutputPath };
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
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 { C as Encryption, D as NodeCipher, E as Keys, O as SealedBox, S as Codec, T as KeyPair, _ as RequestException, b as Hash, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, k as SecureChannel, l as assertFound, m as normalizePositiveInteger, p as isClass, s as abort, u as getModel, v as AppException, w as EncryptionKey, x as Cipher, y as Exception } from "./utils-4xEVrT0Z.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-DbBtlcTv.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";
@@ -336,6 +336,30 @@ var Logger = class Logger {
336
336
  value
337
337
  ];
338
338
  }
339
+ /**
340
+ * Convert absolute paths under current working directory into relative display paths.
341
+ *
342
+ * @param filePath
343
+ * @returns
344
+ */
345
+ static formatPathForLog(filePath) {
346
+ const relPath = path.relative(process.cwd(), filePath);
347
+ if (!relPath) return ".";
348
+ if (relPath.startsWith("..")) return filePath;
349
+ return relPath;
350
+ }
351
+ /**
352
+ * Utility to format a value for logging, converting absolute paths under current
353
+ * working directory into relative display paths.
354
+ *
355
+ * @param name
356
+ * @param value
357
+ * @returns
358
+ */
359
+ static splitLogger(name, value) {
360
+ value = value.includes(process.cwd()) ? this.formatPathForLog(value) : value;
361
+ return this.twoColumnDetail(name + " ", " " + value, false).join("");
362
+ }
339
363
  static describe(name, desc, width = 50, log = true) {
340
364
  width = Math.max(width, 30);
341
365
  const dots = Math.max(width - name.replace(/\x1b\[\d+m/g, "").length, 0);
@@ -660,4 +684,4 @@ const devServer = (options) => {
660
684
  };
661
685
  };
662
686
  //#endregion
663
- export { AppException, CONFIG_KEY, Cipher, Codec, ConfigLoader, Encryption, EncryptionKey, EnvLoader, ErrorHandler, Exception, Hash, Hook, KeyPair, Keys, Logger, NodeCipher, Publisher, RequestException, SealedBox, SecureChannel, abort, abortIf, appKey, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, configLoader, createErrorPayload, devServer, devTlsCredentials, discoverCommands, env, envLoader, getErrorLogger, getModel, getModelSync, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, localNetworkAddress, logUnhandledError, nodeEnv, normalizePositiveInteger, normalizeStatusCode, outputDir, perPage, rebuildOutput, renderError, resolvePagination, resolveRuntimeDir, resolveRuntimeModule, serializeError, shouldHideStack, shouldLogError, toErrorShape, toOutputPath };
687
+ export { AppException, CONFIG_KEY, Cipher, Codec, ConfigLoader, Encryption, EncryptionKey, EnvLoader, ErrorHandler, Exception, Hash, Hook, KeyPair, Keys, Logger, NodeCipher, Publisher, RequestException, SealedBox, SecureChannel, abort, abortIf, appKey, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, configLoader, createErrorPayload, devServer, devTlsCredentials, discoverCommands, env, envLoader, getErrorLogger, getModel, getModelSync, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, localNetworkAddress, logUnhandledError, nodeEnv, normalizePositiveInteger, normalizeStatusCode, outputDir, perPage, rebuildOutput, renderError, resolvePagination, resolveRuntimeDir, resolveRuntimeModule, serializeError, setModelResolver, shouldHideStack, shouldLogError, toErrorShape, toOutputPath };
@@ -1,4 +1,4 @@
1
- import { A as SerializedKeyPair, C as FingerprintOptions, D as NodeCipher, E as Keys, O as SealedBox, S as EncryptionKey, T as KeyPair, _ as CipherOptions, a as abortIf, b as DerivedKey, c as getModelSync, d as normalizePositiveInteger, f as perPage, g as Cipher, h as ChannelOptions, i as abort, k as SecureChannel, l as initializeGlobalContext, m as Hash, n as ModelConstructor, o as assertFound, p as resolvePagination, r as ModelRegistry, s as getModel, t as AbstractModelConstructor, u as isClass, v as Codec, w as KeyInput, x as Encryption, y as DeriveOptions } from "../helpers-DgIgQLDu.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-CWLBYxS-.js";
2
2
  import { Model } from "arkormx";
3
3
  //#region src/utils/traits.d.ts
4
4
  declare const crc32: (str: string) => number;
@@ -184,4 +184,4 @@ type Derived<T extends (Trait | TypeFactory<Trait> | Cons)> = T extends TypeFact
184
184
  */
185
185
  declare function uses<T extends (Trait | TypeFactory<Trait> | Cons)>(instance: unknown, trait: T): instance is Derived<T>;
186
186
  //#endregion
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, NodeCipher, SealedBox, SecureChannel, type SerializedKeyPair, Trait, abort, abortIf, assertFound, callTraitMethods, crc32, getModel, getModelSync, getTraitMethods, initializeGlobalContext, isClass, normalizePositiveInteger, perPage, resolvePagination, trait, use, uses };
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 };
@@ -1,2 +1,2 @@
1
- import { C as Encryption, D as NodeCipher, E as Keys, O as SealedBox, S as Codec, T as KeyPair, a as use, b as Hash, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, i as trait, k as SecureChannel, l as assertFound, m as normalizePositiveInteger, n as crc32, o as uses, p as isClass, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, w as EncryptionKey, x as Cipher } from "../utils-4xEVrT0Z.js";
2
- export { Cipher, Codec, Encryption, EncryptionKey, Hash, KeyPair, Keys, NodeCipher, SealedBox, SecureChannel, abort, abortIf, assertFound, callTraitMethods, crc32, getModel, getModelSync, getTraitMethods, initializeGlobalContext, isClass, normalizePositiveInteger, perPage, resolvePagination, trait, use, uses };
1
+ import { A as SecureChannel, C as Codec, D as Keys, E as KeyPair, O as NodeCipher, S as Cipher, T as EncryptionKey, _ as setModelResolver, a as use, c as abortIf, d as getModelSync, f as initializeGlobalContext, g as resolvePagination, h as perPage, i as trait, k as SealedBox, l as assertFound, m as normalizePositiveInteger, n as crc32, o as uses, p as isClass, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, w as Encryption, x as Hash } from "../utils-DbBtlcTv.js";
2
+ export { Cipher, Codec, Encryption, EncryptionKey, Hash, KeyPair, Keys, NodeCipher, SealedBox, SecureChannel, abort, abortIf, assertFound, callTraitMethods, crc32, getModel, getModelSync, getTraitMethods, initializeGlobalContext, isClass, normalizePositiveInteger, perPage, resolvePagination, setModelResolver, trait, use, uses };
@@ -3,7 +3,6 @@ import { Cipher, Codec, EncryptionKey, KeyPair, Keys, SealedBox, SecureChannel }
3
3
  import { NodeCipher } from "@arkstack/encryption/node";
4
4
  import { Secret, TOTP } from "otpauth";
5
5
  import { compare, genSalt, hash } from "bcryptjs";
6
- import { getModel } from "arkormx";
7
6
  //#region src/utils/encryption.ts
8
7
  /**
9
8
  * Application facing encryption, bound to the app key.
@@ -329,6 +328,17 @@ var RequestException = class RequestException extends AppException {
329
328
  };
330
329
  //#endregion
331
330
  //#region src/utils/helpers.ts
331
+ let modelResolver;
332
+ /**
333
+ * Configure the synchronous model resolver used by {@link getModel}.
334
+ *
335
+ * Database integrations should call this during module initialization. Keeping
336
+ * the resolver injectable lets `@arkstack/common` remain usable without loading
337
+ * a specific ORM at runtime.
338
+ */
339
+ const setModelResolver = (resolver) => {
340
+ modelResolver = resolver;
341
+ };
332
342
  /**
333
343
  * Checks and asserts if target is a class
334
344
  *
@@ -369,8 +379,9 @@ const resolvePagination = (query, defaults) => {
369
379
  perPage: perPage(query, defaults)
370
380
  };
371
381
  };
372
- function getModel$1(modelName) {
373
- return getModel(modelName);
382
+ function getModel(modelName) {
383
+ if (!modelResolver) throw new Error(`No model resolver has been configured. Load your database integration before resolving "${modelName}".`);
384
+ return modelResolver(modelName);
374
385
  }
375
386
  function getModelSync(modelName) {
376
387
  return getModel(modelName);
@@ -633,4 +644,4 @@ function uses(instance, trait) {
633
644
  return false;
634
645
  }
635
646
  //#endregion
636
- export { Encryption as C, NodeCipher as D, Keys as E, SealedBox as O, Codec as S, KeyPair as T, RequestException as _, use as a, Hash as b, abortIf as c, getModelSync as d, initializeGlobalContext as f, resolvePagination as g, perPage as h, trait as i, SecureChannel as k, assertFound as l, normalizePositiveInteger as m, crc32 as n, uses as o, isClass as p, getTraitMethods as r, abort as s, callTraitMethods as t, getModel$1 as u, AppException as v, EncryptionKey as w, Cipher as x, Exception as y };
647
+ export { SecureChannel as A, Codec as C, Keys as D, KeyPair as E, NodeCipher as O, Cipher as S, EncryptionKey as T, setModelResolver as _, use as a, Exception as b, abortIf as c, getModelSync as d, initializeGlobalContext as f, resolvePagination as g, perPage as h, trait as i, SealedBox as k, assertFound as l, normalizePositiveInteger as m, crc32 as n, uses as o, isClass as p, getTraitMethods as r, abort as s, callTraitMethods as t, getModel as u, RequestException as v, Encryption as w, Hash as x, AppException as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/common",
3
- "version": "0.18.9",
3
+ "version": "0.18.11",
4
4
  "type": "module",
5
5
  "description": "Core utilities, primitives, and shared infrastructure for the Arkstack ecosystem.",
6
6
  "homepage": "https://arkstack.toneflix.net",
@@ -43,13 +43,13 @@
43
43
  "otpauth": "^9.5.1",
44
44
  "pino": "^10.3.1",
45
45
  "selfsigned": "^2.4.1",
46
- "@arkstack/encryption": "^0.18.9"
46
+ "@arkstack/encryption": "^0.18.11"
47
47
  },
48
48
  "peerDependencies": {
49
49
  "@h3ravel/support": "^2.2.7",
50
50
  "arkormx": "^2.12.8",
51
- "@arkstack/contract": "^0.18.9",
52
- "@arkstack/foundry": "^0.18.9"
51
+ "@arkstack/contract": "^0.18.11",
52
+ "@arkstack/foundry": "^0.18.11"
53
53
  },
54
54
  "optionalDependencies": {
55
55
  "@faker-js/faker": "^10.4.0"