@arkstack/common 0.12.17 → 0.12.19
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/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { C as importFile, E as outputDir, S as env, T as nodeEnv, _ as Hash, b as appUrl, c as abortIf, d as initializeGlobalContext, f as isClass, g as Exception, h as AppException, l as assertFound, m as RequestException, p as perPage, s as abort, u as getModel, v as Encryption, w as interopDefault, x as config, y as CONFIG_KEY } from "./utils-
|
|
1
|
+
import { C as importFile, E as outputDir, S as env, T as nodeEnv, _ as Hash, b as appUrl, c as abortIf, d as initializeGlobalContext, f as isClass, g as Exception, h as AppException, l as assertFound, m as RequestException, p as perPage, s as abort, u as getModel, v as Encryption, w as interopDefault, x as config, y as CONFIG_KEY } from "./utils-Y1a3rhA3.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";
|
package/dist/utils/index.d.ts
CHANGED
|
@@ -134,6 +134,11 @@ type DeriveTraitsStats<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait |
|
|
|
134
134
|
* utility type: derive type from one or more traits or trait type factories
|
|
135
135
|
*/
|
|
136
136
|
type DeriveTraits<T extends ((Trait | TypeFactory<Trait>)[] | [...(Trait | TypeFactory<Trait>)[], DirectBase])> = DeriveTraitsCons<T> & DeriveTraitsStats<T>;
|
|
137
|
+
type TraitMethodHelpers = {
|
|
138
|
+
getTraitMethods: <T extends TraitMethod = TraitMethod>(name: PropertyKey) => T[];
|
|
139
|
+
callTraitMethods: <T = any>(name: PropertyKey, ...args: any[]) => T[];
|
|
140
|
+
};
|
|
141
|
+
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;
|
|
137
142
|
type TraitMethod = (...args: any[]) => any;
|
|
138
143
|
/**
|
|
139
144
|
* Return every trait implementation for a method, bound to the supplied
|
|
@@ -154,13 +159,15 @@ declare const getTraitMethods: <T extends TraitMethod = TraitMethod>(target: obj
|
|
|
154
159
|
* @returns
|
|
155
160
|
*/
|
|
156
161
|
declare const callTraitMethods: <T = any>(target: object | Cons, name: PropertyKey, ...args: any[]) => T[];
|
|
162
|
+
type UsableTraits = ([Trait | TypeFactory<Trait>, ...(Trait | TypeFactory<Trait>)[]] | [...(Trait | TypeFactory<Trait>)[], DirectBase]);
|
|
157
163
|
/**
|
|
158
164
|
* API: derive a class from one or more traits or trait type factories
|
|
159
165
|
*
|
|
160
166
|
* @param traits
|
|
161
167
|
* @returns
|
|
162
168
|
*/
|
|
163
|
-
declare function use<T extends
|
|
169
|
+
declare function use<T extends UsableTraits>(withMethodHelpers: true, ...traits: T): DeriveTraitsWithMethodHelpers<T>;
|
|
170
|
+
declare function use<T extends UsableTraits>(...traits: T): DeriveTraits<T>;
|
|
164
171
|
/**
|
|
165
172
|
* internal type: implements trait type
|
|
166
173
|
*/
|
package/dist/utils/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { _ as Hash, a as use, c as abortIf, d as initializeGlobalContext, f as isClass, i as trait, l as assertFound, n as crc32, o as uses, p as perPage, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, v as Encryption } from "../utils-
|
|
1
|
+
import { _ as Hash, a as use, c as abortIf, d as initializeGlobalContext, f as isClass, i as trait, l as assertFound, n as crc32, o as uses, p as perPage, r as getTraitMethods, s as abort, t as callTraitMethods, u as getModel, v as Encryption } from "../utils-Y1a3rhA3.js";
|
|
2
2
|
export { Encryption, Hash, abort, abortIf, assertFound, callTraitMethods, crc32, getModel, getTraitMethods, initializeGlobalContext, isClass, perPage, trait, use, uses };
|
|
@@ -523,13 +523,9 @@ const deriveTrait = (trait$, baseClass, derived) => {
|
|
|
523
523
|
* @returns
|
|
524
524
|
*/
|
|
525
525
|
const reverseTraitList = (traits) => traits.slice().reverse();
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
* @param traits
|
|
530
|
-
* @returns
|
|
531
|
-
*/
|
|
532
|
-
function use(...traits) {
|
|
526
|
+
function use(...args) {
|
|
527
|
+
const withMethodHelpers = args[0] === true;
|
|
528
|
+
const traits = withMethodHelpers ? args.slice(1) : args;
|
|
533
529
|
if (traits.length === 0) throw new Error("invalid number of parameters (expected one or more traits)");
|
|
534
530
|
let classInstance;
|
|
535
531
|
let lot;
|
|
@@ -546,6 +542,20 @@ function use(...traits) {
|
|
|
546
542
|
}
|
|
547
543
|
const derived = /* @__PURE__ */ new Map();
|
|
548
544
|
for (const trait of reverseTraitList(lot)) classInstance = deriveTrait(trait, classInstance, derived);
|
|
545
|
+
if (withMethodHelpers) classInstance = class TraitMethodEnabled extends classInstance {
|
|
546
|
+
getTraitMethods(name) {
|
|
547
|
+
return getTraitMethods(this, name);
|
|
548
|
+
}
|
|
549
|
+
callTraitMethods(name, ...args) {
|
|
550
|
+
return callTraitMethods(this, name, ...args);
|
|
551
|
+
}
|
|
552
|
+
static getTraitMethods(name) {
|
|
553
|
+
return getTraitMethods(this, name);
|
|
554
|
+
}
|
|
555
|
+
static callTraitMethods(name, ...args) {
|
|
556
|
+
return callTraitMethods(this, name, ...args);
|
|
557
|
+
}
|
|
558
|
+
};
|
|
549
559
|
return classInstance;
|
|
550
560
|
}
|
|
551
561
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@arkstack/common",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Core utilities, primitives, and shared infrastructure for the Arkstack ecosystem.",
|
|
6
6
|
"homepage": "https://arkstack.toneflix.net",
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
43
|
"@h3ravel/support": "^0.15.11",
|
|
44
|
-
"arkormx": "^2.5.
|
|
45
|
-
"@arkstack/foundry": "^0.12.
|
|
46
|
-
"@arkstack/contract": "^0.12.
|
|
44
|
+
"arkormx": "^2.5.3",
|
|
45
|
+
"@arkstack/foundry": "^0.12.19",
|
|
46
|
+
"@arkstack/contract": "^0.12.19"
|
|
47
47
|
},
|
|
48
48
|
"scripts": {
|
|
49
49
|
"build": "tsdown --config-loader unrun",
|