@nhtio/lucid-resourceful 1.20250718.1 → 1.20250718.2
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/{decorator_utils-1yWqd_Gg.cjs → decorator_utils-U_rZo8tv.cjs} +47 -3
- package/decorator_utils-U_rZo8tv.cjs.map +1 -0
- package/{decorator_utils-BUuBwQYK.js → decorator_utils-YSb1EGJ6.js} +50 -4
- package/decorator_utils-YSb1EGJ6.js.map +1 -0
- package/index.cjs +106 -90
- package/index.cjs.map +1 -1
- package/index.mjs +94 -78
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/private/decorators.d.ts +1 -1
- package/private/prepare_consume_chain_builder.d.ts +36 -0
- package/private/types.d.ts +3 -0
- package/utils.cjs +1 -1
- package/utils.mjs +2 -2
- package/decorator_utils-1yWqd_Gg.cjs.map +0 -1
- package/decorator_utils-BUuBwQYK.js.map +0 -1
package/index.mjs
CHANGED
|
@@ -10,7 +10,7 @@ var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot
|
|
|
10
10
|
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
11
11
|
var __privateMethod = (obj, member, method) => (__accessCheck(obj, member, "access private method"), method);
|
|
12
12
|
var _a, _hookHandlers, _cleanupHandlers, _state, _handlersToIgnore, _skipAllHooks, _Runner_instances, filter_fn, exec_fn, _b, _hooks, _c, _d;
|
|
13
|
-
import { I as isObject$1, J as isResourcefulModel, K as DateTime, F as consumeString, u as prepareString, y as consumeBinary, m as prepareBinary, D as consumeNumber, s as prepareNumber, C as consumeInteger, r as prepareInteger, x as consumeBigint, l as prepareBigint, G as consumeUnsignedint, v as prepareUnsignedint, z as consumeBoolean, n as prepareBoolean, E as consumeObject, t as prepareObject, w as consumeArray, p as prepareArray } from "./decorator_utils-
|
|
13
|
+
import { I as isObject$1, J as isResourcefulModel, K as CRUDOperationsEnum, L as operationCRUDToACL, M as ACLOperationsEnum, N as isFunction, O as prepareFields, P as isString$1, Q as DateTime, F as consumeString, u as prepareString, y as consumeBinary, m as prepareBinary, D as consumeNumber, s as prepareNumber, C as consumeInteger, r as prepareInteger, x as consumeBigint, l as prepareBigint, G as consumeUnsignedint, v as prepareUnsignedint, z as consumeBoolean, n as prepareBoolean, E as consumeObject, t as prepareObject, w as consumeArray, p as prepareArray } from "./decorator_utils-YSb1EGJ6.js";
|
|
14
14
|
import { j as joi } from "./index-DDaZ2qr2.js";
|
|
15
15
|
import { parse as parse$2, SyntaxError as SyntaxError$1 } from "liqe";
|
|
16
16
|
import { d as E_LUCENE_SYNTAX_EXCEPTION, e as E_LUCENE_UNEXPECTED_EXCEPTION, f as E_LUCENE_INVALID_TYPE, g as E_INVALID_RESOURCEFUL_MIXIN_OPTIONS, h as E_MISSING_PRIMARY_KEY_EXCEPTION, i as E_FORBIDDEN, j as E_INVALID_COLUMN_ACCESS, k as E_INVALID_RESOUREFUL_INDEX_REQUEST_EXCEPTION, l as E_RECORD_NOT_FOUND_EXCEPTION, m as E_INVALID_PAYLOAD_EXCEPTION, n as E_FORBIDDEN_PAYLOAD_EXCEPTION, o as createError, p as Exception, q as getDefaultExportFromCjs, r as commonjsGlobal, s as index_default, t as defineStaticProperty, u as lodash, v as E_INVALID_RESOURCEFUL_DECORATOR_OPTIONS } from "./errors-B1rr67uM.js";
|
|
@@ -589,43 +589,6 @@ class l {
|
|
|
589
589
|
) : this.e[s] = []), this;
|
|
590
590
|
}
|
|
591
591
|
}
|
|
592
|
-
var CRUDOperationsEnum = /* @__PURE__ */ ((CRUDOperationsEnum2) => {
|
|
593
|
-
CRUDOperationsEnum2["CREATE"] = "create";
|
|
594
|
-
CRUDOperationsEnum2["READ"] = "read";
|
|
595
|
-
CRUDOperationsEnum2["LIST"] = "list";
|
|
596
|
-
CRUDOperationsEnum2["UPDATE"] = "update";
|
|
597
|
-
CRUDOperationsEnum2["DELETE"] = "delete";
|
|
598
|
-
return CRUDOperationsEnum2;
|
|
599
|
-
})(CRUDOperationsEnum || {});
|
|
600
|
-
var ACLOperationsEnum = /* @__PURE__ */ ((ACLOperationsEnum2) => {
|
|
601
|
-
ACLOperationsEnum2["WRITE"] = "write";
|
|
602
|
-
ACLOperationsEnum2["READ"] = "read";
|
|
603
|
-
return ACLOperationsEnum2;
|
|
604
|
-
})(ACLOperationsEnum || {});
|
|
605
|
-
const operationCRUDToACL = (operation) => {
|
|
606
|
-
if (operation === CRUDOperationsEnum.READ || operation === CRUDOperationsEnum.LIST) {
|
|
607
|
-
return ACLOperationsEnum.READ;
|
|
608
|
-
}
|
|
609
|
-
if (operation === CRUDOperationsEnum.CREATE || operation === CRUDOperationsEnum.UPDATE || operation === CRUDOperationsEnum.DELETE) {
|
|
610
|
-
return ACLOperationsEnum.WRITE;
|
|
611
|
-
}
|
|
612
|
-
};
|
|
613
|
-
const isString$1 = (value) => {
|
|
614
|
-
return typeof value === "string";
|
|
615
|
-
};
|
|
616
|
-
const isFunction = (value) => {
|
|
617
|
-
return typeof value === "function";
|
|
618
|
-
};
|
|
619
|
-
const prepareFields = (fields, primaryKey) => {
|
|
620
|
-
const defaultValue = [primaryKey];
|
|
621
|
-
if (Array.isArray(fields)) {
|
|
622
|
-
return fields.length ? fields : defaultValue;
|
|
623
|
-
}
|
|
624
|
-
if (isString$1(fields)) {
|
|
625
|
-
return fields.length ? [fields] : defaultValue;
|
|
626
|
-
}
|
|
627
|
-
return defaultValue;
|
|
628
|
-
};
|
|
629
592
|
const ResourcefulErrorHandlerMethod = ["bubble", "pass", "fail"];
|
|
630
593
|
const getFieldKey = (key, definition) => {
|
|
631
594
|
if (isString$1(definition.serializeAs)) {
|
|
@@ -1859,6 +1822,56 @@ function withResourceful(options = {}) {
|
|
|
1859
1822
|
return ResourcefulModel;
|
|
1860
1823
|
};
|
|
1861
1824
|
}
|
|
1825
|
+
class PrepareConsumeChainBuilder {
|
|
1826
|
+
/**
|
|
1827
|
+
* Creates a chained prepare function that calls default first, then custom.
|
|
1828
|
+
*
|
|
1829
|
+
* @param propertyKey - The property name for error context
|
|
1830
|
+
* @param nullable - Whether the field accepts null values
|
|
1831
|
+
* @param defaultPrepare - The default prepare function from decorator
|
|
1832
|
+
* @param customPrepare - The custom prepare function from options
|
|
1833
|
+
* @returns A chained prepare function or undefined if no functions provided
|
|
1834
|
+
*/
|
|
1835
|
+
static chainPrepare(propertyKey, nullable, defaultPrepare, customPrepare) {
|
|
1836
|
+
if (!defaultPrepare && !customPrepare) {
|
|
1837
|
+
return void 0;
|
|
1838
|
+
}
|
|
1839
|
+
if (!defaultPrepare && customPrepare) {
|
|
1840
|
+
return customPrepare;
|
|
1841
|
+
}
|
|
1842
|
+
if (defaultPrepare && !customPrepare) {
|
|
1843
|
+
return (value) => defaultPrepare(propertyKey, value, nullable);
|
|
1844
|
+
}
|
|
1845
|
+
return (value) => {
|
|
1846
|
+
const defaultResult = defaultPrepare(propertyKey, value, nullable);
|
|
1847
|
+
return customPrepare(defaultResult);
|
|
1848
|
+
};
|
|
1849
|
+
}
|
|
1850
|
+
/**
|
|
1851
|
+
* Creates a chained consume function that calls custom first, then default.
|
|
1852
|
+
*
|
|
1853
|
+
* @param propertyKey - The property name for error context
|
|
1854
|
+
* @param nullable - Whether the field accepts null values
|
|
1855
|
+
* @param defaultConsume - The default consume function from decorator
|
|
1856
|
+
* @param customConsume - The custom consume function from options
|
|
1857
|
+
* @returns A chained consume function or undefined if no functions provided
|
|
1858
|
+
*/
|
|
1859
|
+
static chainConsume(propertyKey, nullable, defaultConsume, customConsume) {
|
|
1860
|
+
if (!defaultConsume && !customConsume) {
|
|
1861
|
+
return void 0;
|
|
1862
|
+
}
|
|
1863
|
+
if (!defaultConsume && customConsume) {
|
|
1864
|
+
return customConsume;
|
|
1865
|
+
}
|
|
1866
|
+
if (defaultConsume && !customConsume) {
|
|
1867
|
+
return (value) => defaultConsume(propertyKey, value, nullable);
|
|
1868
|
+
}
|
|
1869
|
+
return (value) => {
|
|
1870
|
+
const customResult = customConsume(value);
|
|
1871
|
+
return defaultConsume(propertyKey, customResult, nullable);
|
|
1872
|
+
};
|
|
1873
|
+
}
|
|
1874
|
+
}
|
|
1862
1875
|
const E_INVALID_DATE_COLUMN_VALUE = createError('Invalid value for "%s". %s', "E_INVALID_DATE_COLUMN_VALUE", 500);
|
|
1863
1876
|
const E_MISSING_MODEL_ATTRIBUTE = createError('Relation "%s" expects "%s" to exist on "%s" model, but is missing. Did you forget to define the column?', "E_MISSING_MODEL_ATTRIBUTE", 500);
|
|
1864
1877
|
const E_MODEL_DELETED = createError("Cannot mutate delete model instance", "E_MODEL_DELETED", 500);
|
|
@@ -12261,16 +12274,37 @@ const handleResourcefulColumn = (config) => {
|
|
|
12261
12274
|
propertyKey,
|
|
12262
12275
|
decoratorOption,
|
|
12263
12276
|
decoratorOptionsValidationSchema,
|
|
12264
|
-
overrides,
|
|
12265
|
-
lucidDecoratorFunction
|
|
12277
|
+
overrides = {},
|
|
12278
|
+
lucidDecoratorFunction,
|
|
12279
|
+
defaultPrepare,
|
|
12280
|
+
defaultConsume
|
|
12266
12281
|
} = config;
|
|
12267
12282
|
const opts = validateNormalizeAndCastDecoratorOptions(propertyKey, decoratorName, decoratorOptionsValidationSchema, {
|
|
12268
12283
|
...decoratorOption,
|
|
12269
12284
|
propertyKey
|
|
12270
12285
|
});
|
|
12286
|
+
const customPrepare = opts.prepare;
|
|
12287
|
+
const customConsume = opts.consume;
|
|
12288
|
+
const nullable = opts.nullable || false;
|
|
12289
|
+
const chainedPrepare = PrepareConsumeChainBuilder.chainPrepare(
|
|
12290
|
+
propertyKey,
|
|
12291
|
+
nullable,
|
|
12292
|
+
defaultPrepare,
|
|
12293
|
+
customPrepare
|
|
12294
|
+
);
|
|
12295
|
+
const chainedConsume = PrepareConsumeChainBuilder.chainConsume(
|
|
12296
|
+
propertyKey,
|
|
12297
|
+
nullable,
|
|
12298
|
+
defaultConsume,
|
|
12299
|
+
customConsume
|
|
12300
|
+
);
|
|
12271
12301
|
const lucidOptions = extractLucidOptionsForLucidColumnDecorator(
|
|
12272
12302
|
opts,
|
|
12273
|
-
|
|
12303
|
+
{
|
|
12304
|
+
...overrides,
|
|
12305
|
+
...chainedPrepare && { prepare: chainedPrepare },
|
|
12306
|
+
...chainedConsume && { consume: chainedConsume }
|
|
12307
|
+
}
|
|
12274
12308
|
);
|
|
12275
12309
|
lucidDecoratorFunction(lucidOptions)(target, propertyKey);
|
|
12276
12310
|
const map = ensureOwnResourcefulMap(target, "$resourcefulColumns");
|
|
@@ -12318,10 +12352,8 @@ resourcefulColumn.string = function(options = {}) {
|
|
|
12318
12352
|
decoratorOption: options,
|
|
12319
12353
|
decoratorOptionsValidationSchema,
|
|
12320
12354
|
lucidDecoratorFunction: column,
|
|
12321
|
-
|
|
12322
|
-
|
|
12323
|
-
consume: (value) => consumeString(propertyKey, value, options.nullable)
|
|
12324
|
-
}
|
|
12355
|
+
defaultPrepare: prepareString,
|
|
12356
|
+
defaultConsume: consumeString
|
|
12325
12357
|
});
|
|
12326
12358
|
};
|
|
12327
12359
|
};
|
|
@@ -12364,10 +12396,8 @@ resourcefulColumn.binary = function(options = {}) {
|
|
|
12364
12396
|
decoratorOption: options,
|
|
12365
12397
|
decoratorOptionsValidationSchema,
|
|
12366
12398
|
lucidDecoratorFunction: column,
|
|
12367
|
-
|
|
12368
|
-
|
|
12369
|
-
consume: (value) => consumeBinary(propertyKey, value, options.nullable)
|
|
12370
|
-
}
|
|
12399
|
+
defaultPrepare: prepareBinary,
|
|
12400
|
+
defaultConsume: consumeBinary
|
|
12371
12401
|
});
|
|
12372
12402
|
};
|
|
12373
12403
|
};
|
|
@@ -12382,10 +12412,8 @@ resourcefulColumn.number = function(options = {}) {
|
|
|
12382
12412
|
decoratorOption: options,
|
|
12383
12413
|
decoratorOptionsValidationSchema,
|
|
12384
12414
|
lucidDecoratorFunction: column,
|
|
12385
|
-
|
|
12386
|
-
|
|
12387
|
-
consume: (value) => consumeNumber(propertyKey, value, options.nullable)
|
|
12388
|
-
}
|
|
12415
|
+
defaultPrepare: prepareNumber,
|
|
12416
|
+
defaultConsume: consumeNumber
|
|
12389
12417
|
});
|
|
12390
12418
|
};
|
|
12391
12419
|
};
|
|
@@ -12400,10 +12428,8 @@ resourcefulColumn.integer = function(options = {}) {
|
|
|
12400
12428
|
decoratorOption: options,
|
|
12401
12429
|
decoratorOptionsValidationSchema,
|
|
12402
12430
|
lucidDecoratorFunction: column,
|
|
12403
|
-
|
|
12404
|
-
|
|
12405
|
-
consume: (value) => consumeInteger(propertyKey, value, options.nullable)
|
|
12406
|
-
}
|
|
12431
|
+
defaultPrepare: prepareInteger,
|
|
12432
|
+
defaultConsume: consumeInteger
|
|
12407
12433
|
});
|
|
12408
12434
|
};
|
|
12409
12435
|
};
|
|
@@ -12418,10 +12444,8 @@ resourcefulColumn.bigint = function(options = {}) {
|
|
|
12418
12444
|
decoratorOption: options,
|
|
12419
12445
|
decoratorOptionsValidationSchema,
|
|
12420
12446
|
lucidDecoratorFunction: column,
|
|
12421
|
-
|
|
12422
|
-
|
|
12423
|
-
consume: (value) => consumeBigint(propertyKey, value, options.nullable)
|
|
12424
|
-
}
|
|
12447
|
+
defaultPrepare: prepareBigint,
|
|
12448
|
+
defaultConsume: consumeBigint
|
|
12425
12449
|
});
|
|
12426
12450
|
};
|
|
12427
12451
|
};
|
|
@@ -12436,10 +12460,8 @@ resourcefulColumn.unsignedint = function(options = {}) {
|
|
|
12436
12460
|
decoratorOption: options,
|
|
12437
12461
|
decoratorOptionsValidationSchema,
|
|
12438
12462
|
lucidDecoratorFunction: column,
|
|
12439
|
-
|
|
12440
|
-
|
|
12441
|
-
consume: (value) => consumeUnsignedint(propertyKey, value, options.nullable)
|
|
12442
|
-
}
|
|
12463
|
+
defaultPrepare: prepareUnsignedint,
|
|
12464
|
+
defaultConsume: consumeUnsignedint
|
|
12443
12465
|
});
|
|
12444
12466
|
};
|
|
12445
12467
|
};
|
|
@@ -12454,10 +12476,8 @@ resourcefulColumn.boolean = function(options = {}) {
|
|
|
12454
12476
|
decoratorOption: options,
|
|
12455
12477
|
decoratorOptionsValidationSchema,
|
|
12456
12478
|
lucidDecoratorFunction: column,
|
|
12457
|
-
|
|
12458
|
-
|
|
12459
|
-
consume: (value) => consumeBoolean(propertyKey, value, options.nullable)
|
|
12460
|
-
}
|
|
12479
|
+
defaultPrepare: prepareBoolean,
|
|
12480
|
+
defaultConsume: consumeBoolean
|
|
12461
12481
|
});
|
|
12462
12482
|
};
|
|
12463
12483
|
};
|
|
@@ -12472,10 +12492,8 @@ resourcefulColumn.object = function(options = {}) {
|
|
|
12472
12492
|
decoratorOption: options,
|
|
12473
12493
|
decoratorOptionsValidationSchema,
|
|
12474
12494
|
lucidDecoratorFunction: column,
|
|
12475
|
-
|
|
12476
|
-
|
|
12477
|
-
consume: (value) => consumeObject(propertyKey, value, options.nullable)
|
|
12478
|
-
}
|
|
12495
|
+
defaultPrepare: prepareObject,
|
|
12496
|
+
defaultConsume: consumeObject
|
|
12479
12497
|
});
|
|
12480
12498
|
};
|
|
12481
12499
|
};
|
|
@@ -12490,10 +12508,8 @@ resourcefulColumn.array = function(options = {}) {
|
|
|
12490
12508
|
decoratorOption: options,
|
|
12491
12509
|
decoratorOptionsValidationSchema,
|
|
12492
12510
|
lucidDecoratorFunction: column,
|
|
12493
|
-
|
|
12494
|
-
|
|
12495
|
-
consume: (value) => consumeArray(propertyKey, value, options.nullable)
|
|
12496
|
-
}
|
|
12511
|
+
defaultPrepare: prepareArray,
|
|
12512
|
+
defaultConsume: consumeArray
|
|
12497
12513
|
});
|
|
12498
12514
|
};
|
|
12499
12515
|
};
|
|
@@ -12721,7 +12737,7 @@ function resourcefulHasManyThrough(model, options = {}) {
|
|
|
12721
12737
|
map.set(propertyKey, opts);
|
|
12722
12738
|
};
|
|
12723
12739
|
}
|
|
12724
|
-
const version = "1.20250718.
|
|
12740
|
+
const version = "1.20250718.2";
|
|
12725
12741
|
export {
|
|
12726
12742
|
k as definitions,
|
|
12727
12743
|
w as errors,
|