@arkstack/common 0.12.9 → 0.12.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.
@@ -43,6 +43,13 @@ type AbstractModelConstructor<TModel = unknown> = abstract new (attributes?: Rec
43
43
  type ModelConstructor<TModel extends Model = Model> = AbstractModelConstructor<TModel> & Pick<ModelStatic<TModel>, keyof ModelStatic<TModel>>;
44
44
  interface ModelRegistry {}
45
45
  type ModelName = Extract<keyof ModelRegistry, string>;
46
+ /**
47
+ * Checks and asserts if target is a class
48
+ *
49
+ * @param target
50
+ * @returns
51
+ */
52
+ declare const isClass: <T = unknown>(target: unknown) => target is new (...args: any[]) => T;
46
53
  /**
47
54
  * Determine the number of items to return per page based on the provided query parameters.
48
55
  *
@@ -99,4 +106,4 @@ declare const abortIf: <T>(boolean: T, message?: string, code?: number) => asser
99
106
  */
100
107
  declare const assertFound: <T>(value: T | null | undefined, message: string, code?: number) => asserts value is T;
101
108
  //#endregion
102
- export { abortIf as a, initializeGlobalContext as c, Encryption as d, abort as i, perPage as l, ModelConstructor as n, assertFound as o, ModelRegistry as r, getModel as s, AbstractModelConstructor as t, Hash as u };
109
+ export { abortIf as a, initializeGlobalContext as c, Hash as d, Encryption as f, abort as i, isClass as l, ModelConstructor as n, assertFound as o, ModelRegistry as r, getModel as s, AbstractModelConstructor as t, perPage as u };
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  /// <reference path="./app.d.ts" />
2
- import { a as abortIf, c as initializeGlobalContext, d as Encryption, i as abort, l as perPage, n as ModelConstructor, o as assertFound, r as ModelRegistry, s as getModel, t as AbstractModelConstructor, u as Hash } from "./helpers-DALo42cp.js";
2
+ import { a as abortIf, c as initializeGlobalContext, d as Hash, f as Encryption, i as abort, l as isClass, n as ModelConstructor, o as assertFound, r as ModelRegistry, s as getModel, t as AbstractModelConstructor, u as perPage } from "./helpers-CfQxt_q2.js";
3
3
  import { JitiOptions, JitiResolveOptions } from "jiti";
4
4
  import { Arkstack } from "@arkstack/contract";
5
5
  import pino from "pino";
@@ -432,4 +432,4 @@ declare class Hook {
432
432
  static clear: () => void;
433
433
  }
434
434
  //#endregion
435
- export { AbstractModelConstructor, AppException, ArkstackErrorPayload, ArkstackErrorShape, CONFIG_KEY, ConfigRegistry, ConfigShape, DotPath, DotPathValue, Encryption, EnvRegistry, ErrorHandler, Exception, FileImporter, GlobalConfig, GlobalEnv, Hash, Hook, HookArgs, HookFor, HookName, HookPos, HookPositions, HookRegistry, IHook, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, MergedConfig, ModelConstructor, ModelRegistry, Primitive, RequestException, UnionToIntersection, abort, abortIf, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, createErrorPayload, env, getErrorLogger, getModel, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isModelNotFoundError, isValidationError, loadPrototypes, logUnhandledError, nodeEnv, normalizeStatusCode, outputDir, perPage, renderError, serializeError, shouldHideStack, shouldLogError, toErrorShape };
435
+ export { AbstractModelConstructor, AppException, ArkstackErrorPayload, ArkstackErrorShape, CONFIG_KEY, ConfigRegistry, ConfigShape, DotPath, DotPathValue, Encryption, EnvRegistry, ErrorHandler, Exception, FileImporter, GlobalConfig, GlobalEnv, Hash, Hook, HookArgs, HookFor, HookName, HookPos, HookPositions, HookRegistry, IHook, Logger, LoggerChalk, LoggerLog, LoggerParseSignature, MergedConfig, ModelConstructor, ModelRegistry, Primitive, RequestException, UnionToIntersection, abort, abortIf, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, createErrorPayload, env, getErrorLogger, getModel, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, logUnhandledError, nodeEnv, normalizeStatusCode, outputDir, perPage, renderError, serializeError, shouldHideStack, shouldLogError, toErrorShape };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { C as outputDir, S as nodeEnv, _ as appUrl, a as abort, b as importFile, c as getModel, d as RequestException, f as AppException, g as CONFIG_KEY, h as Encryption, l as initializeGlobalContext, m as Hash, o as abortIf, p as Exception, s as assertFound, u as perPage, v as config, x as interopDefault, y as env } from "./utils-D_dikzz8.js";
1
+ import { C as nodeEnv, S as interopDefault, _ as CONFIG_KEY, a as abort, b as env, c as getModel, d as perPage, f as RequestException, g as Encryption, h as Hash, l as initializeGlobalContext, m as Exception, o as abortIf, p as AppException, s as assertFound, u as isClass, v as appUrl, w as outputDir, x as importFile, y as config } from "./utils-CMuDt6cA.js";
2
2
  import { Hook as Hook$1 } from "@arkstack/foundry";
3
3
  import { str } from "@h3ravel/support";
4
4
  import { Arkstack } from "@arkstack/contract";
@@ -481,4 +481,4 @@ var Hook = class {
481
481
  };
482
482
  };
483
483
  //#endregion
484
- export { AppException, CONFIG_KEY, Encryption, ErrorHandler, Exception, Hash, Hook, Logger, RequestException, abort, abortIf, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, createErrorPayload, env, getErrorLogger, getModel, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isModelNotFoundError, isValidationError, loadPrototypes, logUnhandledError, nodeEnv, normalizeStatusCode, outputDir, perPage, renderError, serializeError, shouldHideStack, shouldLogError, toErrorShape };
484
+ export { AppException, CONFIG_KEY, Encryption, ErrorHandler, Exception, Hash, Hook, Logger, RequestException, abort, abortIf, appUrl, assertFound, bindGracefulShutdown, bootWithDetectedPort, config, createErrorPayload, env, getErrorLogger, getModel, getPrimaryError, getValidationErrors, importFile, initializeGlobalContext, interopDefault, isClass, isModelNotFoundError, isValidationError, loadPrototypes, logUnhandledError, nodeEnv, normalizeStatusCode, outputDir, perPage, renderError, serializeError, shouldHideStack, shouldLogError, toErrorShape };
@@ -1,4 +1,4 @@
1
- import { a as abortIf, c as initializeGlobalContext, d as Encryption, i as abort, l as perPage, n as ModelConstructor, o as assertFound, r as ModelRegistry, s as getModel, t as AbstractModelConstructor, u as Hash } from "../helpers-DALo42cp.js";
1
+ import { a as abortIf, c as initializeGlobalContext, d as Hash, f as Encryption, i as abort, l as isClass, n as ModelConstructor, o as assertFound, r as ModelRegistry, s as getModel, t as AbstractModelConstructor, u as perPage } from "../helpers-CfQxt_q2.js";
2
2
  import { Model } from "arkormx";
3
3
 
4
4
  //#region src/utils/traits.d.ts
@@ -158,4 +158,4 @@ type Derived<T extends (Trait | TypeFactory<Trait> | Cons)> = T extends TypeFact
158
158
  */
159
159
  declare function uses<T extends (Trait | TypeFactory<Trait> | Cons)>(instance: unknown, trait: T): instance is Derived<T>;
160
160
  //#endregion
161
- export { AbstractModelConstructor, Derived, Encryption, Hash, ModelConstructor, ModelRegistry, Trait, abort, abortIf, assertFound, crc32, getModel, initializeGlobalContext, perPage, trait, use, uses };
161
+ export { AbstractModelConstructor, Derived, Encryption, Hash, ModelConstructor, ModelRegistry, Trait, abort, abortIf, assertFound, crc32, getModel, initializeGlobalContext, isClass, perPage, trait, use, uses };
@@ -1,2 +1,2 @@
1
- import { a as abort, c as getModel, h as Encryption, i as uses, l as initializeGlobalContext, m as Hash, n as trait, o as abortIf, r as use, s as assertFound, t as crc32, u as perPage } from "../utils-D_dikzz8.js";
2
- export { Encryption, Hash, abort, abortIf, assertFound, crc32, getModel, initializeGlobalContext, perPage, trait, use, uses };
1
+ import { a as abort, c as getModel, d as perPage, g as Encryption, h as Hash, i as uses, l as initializeGlobalContext, n as trait, o as abortIf, r as use, s as assertFound, t as crc32, u as isClass } from "../utils-CMuDt6cA.js";
2
+ export { Encryption, Hash, abort, abortIf, assertFound, crc32, getModel, initializeGlobalContext, isClass, perPage, trait, use, uses };
@@ -293,6 +293,15 @@ var RequestException = class RequestException extends AppException {
293
293
  //#endregion
294
294
  //#region src/utils/helpers.ts
295
295
  /**
296
+ * Checks and asserts if target is a class
297
+ *
298
+ * @param target
299
+ * @returns
300
+ */
301
+ const isClass = (target) => {
302
+ return typeof target === "function" && /^class\s/.test(Function.prototype.toString.call(target));
303
+ };
304
+ /**
296
305
  * Determine the number of items to return per page based on the provided query parameters.
297
306
  *
298
307
  * @param query
@@ -489,4 +498,4 @@ function uses(instance, trait) {
489
498
  return false;
490
499
  }
491
500
  //#endregion
492
- export { outputDir as C, nodeEnv as S, appUrl as _, abort as a, importFile as b, getModel as c, RequestException as d, AppException as f, CONFIG_KEY as g, Encryption as h, uses as i, initializeGlobalContext as l, Hash as m, trait as n, abortIf as o, Exception as p, use as r, assertFound as s, crc32 as t, perPage as u, config as v, interopDefault as x, env as y };
501
+ export { nodeEnv as C, interopDefault as S, CONFIG_KEY as _, abort as a, env as b, getModel as c, perPage as d, RequestException as f, Encryption as g, Hash as h, uses as i, initializeGlobalContext as l, Exception as m, trait as n, abortIf as o, AppException as p, use as r, assertFound as s, crc32 as t, isClass as u, appUrl as v, outputDir as w, importFile as x, config as y };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arkstack/common",
3
- "version": "0.12.9",
3
+ "version": "0.12.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",
@@ -42,8 +42,8 @@
42
42
  "peerDependencies": {
43
43
  "@h3ravel/support": "^0.15.11",
44
44
  "arkormx": "^ 2.4.1",
45
- "@arkstack/foundry": "^0.12.9",
46
- "@arkstack/contract": "^0.12.9"
45
+ "@arkstack/foundry": "^0.12.11",
46
+ "@arkstack/contract": "^0.12.11"
47
47
  },
48
48
  "scripts": {
49
49
  "build": "tsdown --config-loader unrun",