@nhtio/lucid-resourceful 1.20250718.0 → 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 +131 -85
- package/index.cjs.map +1 -1
- package/index.mjs +120 -74
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/private/decorators.d.ts +2 -2
- package/private/prepare_consume_chain_builder.d.ts +36 -0
- package/private/types.d.ts +3 -0
- package/private/utils.d.ts +4 -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,33 +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
592
|
const ResourcefulErrorHandlerMethod = ["bubble", "pass", "fail"];
|
|
620
593
|
const getFieldKey = (key, definition) => {
|
|
621
594
|
if (isString$1(definition.serializeAs)) {
|
|
@@ -1479,9 +1452,7 @@ function withResourceful(options = {}) {
|
|
|
1479
1452
|
if (!isString$1(filter)) {
|
|
1480
1453
|
filter = "";
|
|
1481
1454
|
}
|
|
1482
|
-
|
|
1483
|
-
fields = [primaryKey];
|
|
1484
|
-
}
|
|
1455
|
+
fields = prepareFields(fields, primaryKey);
|
|
1485
1456
|
const { isForbidden, allowedFieldsMap, message } = await this.$resourcefulCheckAccess({
|
|
1486
1457
|
ctx,
|
|
1487
1458
|
app,
|
|
@@ -1851,6 +1822,56 @@ function withResourceful(options = {}) {
|
|
|
1851
1822
|
return ResourcefulModel;
|
|
1852
1823
|
};
|
|
1853
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
|
+
}
|
|
1854
1875
|
const E_INVALID_DATE_COLUMN_VALUE = createError('Invalid value for "%s". %s', "E_INVALID_DATE_COLUMN_VALUE", 500);
|
|
1855
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);
|
|
1856
1877
|
const E_MODEL_DELETED = createError("Cannot mutate delete model instance", "E_MODEL_DELETED", 500);
|
|
@@ -12181,7 +12202,17 @@ const extractLucidOptionsForLucidDecorator = (options, keys, overrides) => {
|
|
|
12181
12202
|
const extractLucidOptionsForLucidColumnDecorator = (options, overrides) => {
|
|
12182
12203
|
return extractLucidOptionsForLucidDecorator(
|
|
12183
12204
|
options,
|
|
12184
|
-
[
|
|
12205
|
+
[
|
|
12206
|
+
"columnName",
|
|
12207
|
+
"serializeAs",
|
|
12208
|
+
"isPrimary",
|
|
12209
|
+
"meta",
|
|
12210
|
+
"serialize",
|
|
12211
|
+
"prepare",
|
|
12212
|
+
"consume",
|
|
12213
|
+
"autoCreate",
|
|
12214
|
+
"autoUpdate"
|
|
12215
|
+
],
|
|
12185
12216
|
overrides
|
|
12186
12217
|
);
|
|
12187
12218
|
};
|
|
@@ -12243,17 +12274,39 @@ const handleResourcefulColumn = (config) => {
|
|
|
12243
12274
|
propertyKey,
|
|
12244
12275
|
decoratorOption,
|
|
12245
12276
|
decoratorOptionsValidationSchema,
|
|
12246
|
-
overrides
|
|
12277
|
+
overrides = {},
|
|
12278
|
+
lucidDecoratorFunction,
|
|
12279
|
+
defaultPrepare,
|
|
12280
|
+
defaultConsume
|
|
12247
12281
|
} = config;
|
|
12248
12282
|
const opts = validateNormalizeAndCastDecoratorOptions(propertyKey, decoratorName, decoratorOptionsValidationSchema, {
|
|
12249
12283
|
...decoratorOption,
|
|
12250
12284
|
propertyKey
|
|
12251
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
|
+
);
|
|
12252
12301
|
const lucidOptions = extractLucidOptionsForLucidColumnDecorator(
|
|
12253
12302
|
opts,
|
|
12254
|
-
|
|
12303
|
+
{
|
|
12304
|
+
...overrides,
|
|
12305
|
+
...chainedPrepare && { prepare: chainedPrepare },
|
|
12306
|
+
...chainedConsume && { consume: chainedConsume }
|
|
12307
|
+
}
|
|
12255
12308
|
);
|
|
12256
|
-
|
|
12309
|
+
lucidDecoratorFunction(lucidOptions)(target, propertyKey);
|
|
12257
12310
|
const map = ensureOwnResourcefulMap(target, "$resourcefulColumns");
|
|
12258
12311
|
map.set(propertyKey, opts);
|
|
12259
12312
|
};
|
|
@@ -12298,10 +12351,9 @@ resourcefulColumn.string = function(options = {}) {
|
|
|
12298
12351
|
propertyKey,
|
|
12299
12352
|
decoratorOption: options,
|
|
12300
12353
|
decoratorOptionsValidationSchema,
|
|
12301
|
-
|
|
12302
|
-
|
|
12303
|
-
|
|
12304
|
-
}
|
|
12354
|
+
lucidDecoratorFunction: column,
|
|
12355
|
+
defaultPrepare: prepareString,
|
|
12356
|
+
defaultConsume: consumeString
|
|
12305
12357
|
});
|
|
12306
12358
|
};
|
|
12307
12359
|
};
|
|
@@ -12314,7 +12366,8 @@ resourcefulColumn.date = function(options = {}) {
|
|
|
12314
12366
|
target,
|
|
12315
12367
|
propertyKey,
|
|
12316
12368
|
decoratorOption: options,
|
|
12317
|
-
decoratorOptionsValidationSchema
|
|
12369
|
+
decoratorOptionsValidationSchema,
|
|
12370
|
+
lucidDecoratorFunction: column.date
|
|
12318
12371
|
});
|
|
12319
12372
|
};
|
|
12320
12373
|
};
|
|
@@ -12327,7 +12380,8 @@ resourcefulColumn.dateTime = function(options = {}) {
|
|
|
12327
12380
|
target,
|
|
12328
12381
|
propertyKey,
|
|
12329
12382
|
decoratorOption: options,
|
|
12330
|
-
decoratorOptionsValidationSchema
|
|
12383
|
+
decoratorOptionsValidationSchema,
|
|
12384
|
+
lucidDecoratorFunction: column.dateTime
|
|
12331
12385
|
});
|
|
12332
12386
|
};
|
|
12333
12387
|
};
|
|
@@ -12341,10 +12395,9 @@ resourcefulColumn.binary = function(options = {}) {
|
|
|
12341
12395
|
propertyKey,
|
|
12342
12396
|
decoratorOption: options,
|
|
12343
12397
|
decoratorOptionsValidationSchema,
|
|
12344
|
-
|
|
12345
|
-
|
|
12346
|
-
|
|
12347
|
-
}
|
|
12398
|
+
lucidDecoratorFunction: column,
|
|
12399
|
+
defaultPrepare: prepareBinary,
|
|
12400
|
+
defaultConsume: consumeBinary
|
|
12348
12401
|
});
|
|
12349
12402
|
};
|
|
12350
12403
|
};
|
|
@@ -12358,10 +12411,9 @@ resourcefulColumn.number = function(options = {}) {
|
|
|
12358
12411
|
propertyKey,
|
|
12359
12412
|
decoratorOption: options,
|
|
12360
12413
|
decoratorOptionsValidationSchema,
|
|
12361
|
-
|
|
12362
|
-
|
|
12363
|
-
|
|
12364
|
-
}
|
|
12414
|
+
lucidDecoratorFunction: column,
|
|
12415
|
+
defaultPrepare: prepareNumber,
|
|
12416
|
+
defaultConsume: consumeNumber
|
|
12365
12417
|
});
|
|
12366
12418
|
};
|
|
12367
12419
|
};
|
|
@@ -12375,10 +12427,9 @@ resourcefulColumn.integer = function(options = {}) {
|
|
|
12375
12427
|
propertyKey,
|
|
12376
12428
|
decoratorOption: options,
|
|
12377
12429
|
decoratorOptionsValidationSchema,
|
|
12378
|
-
|
|
12379
|
-
|
|
12380
|
-
|
|
12381
|
-
}
|
|
12430
|
+
lucidDecoratorFunction: column,
|
|
12431
|
+
defaultPrepare: prepareInteger,
|
|
12432
|
+
defaultConsume: consumeInteger
|
|
12382
12433
|
});
|
|
12383
12434
|
};
|
|
12384
12435
|
};
|
|
@@ -12392,10 +12443,9 @@ resourcefulColumn.bigint = function(options = {}) {
|
|
|
12392
12443
|
propertyKey,
|
|
12393
12444
|
decoratorOption: options,
|
|
12394
12445
|
decoratorOptionsValidationSchema,
|
|
12395
|
-
|
|
12396
|
-
|
|
12397
|
-
|
|
12398
|
-
}
|
|
12446
|
+
lucidDecoratorFunction: column,
|
|
12447
|
+
defaultPrepare: prepareBigint,
|
|
12448
|
+
defaultConsume: consumeBigint
|
|
12399
12449
|
});
|
|
12400
12450
|
};
|
|
12401
12451
|
};
|
|
@@ -12409,10 +12459,9 @@ resourcefulColumn.unsignedint = function(options = {}) {
|
|
|
12409
12459
|
propertyKey,
|
|
12410
12460
|
decoratorOption: options,
|
|
12411
12461
|
decoratorOptionsValidationSchema,
|
|
12412
|
-
|
|
12413
|
-
|
|
12414
|
-
|
|
12415
|
-
}
|
|
12462
|
+
lucidDecoratorFunction: column,
|
|
12463
|
+
defaultPrepare: prepareUnsignedint,
|
|
12464
|
+
defaultConsume: consumeUnsignedint
|
|
12416
12465
|
});
|
|
12417
12466
|
};
|
|
12418
12467
|
};
|
|
@@ -12426,10 +12475,9 @@ resourcefulColumn.boolean = function(options = {}) {
|
|
|
12426
12475
|
propertyKey,
|
|
12427
12476
|
decoratorOption: options,
|
|
12428
12477
|
decoratorOptionsValidationSchema,
|
|
12429
|
-
|
|
12430
|
-
|
|
12431
|
-
|
|
12432
|
-
}
|
|
12478
|
+
lucidDecoratorFunction: column,
|
|
12479
|
+
defaultPrepare: prepareBoolean,
|
|
12480
|
+
defaultConsume: consumeBoolean
|
|
12433
12481
|
});
|
|
12434
12482
|
};
|
|
12435
12483
|
};
|
|
@@ -12443,10 +12491,9 @@ resourcefulColumn.object = function(options = {}) {
|
|
|
12443
12491
|
propertyKey,
|
|
12444
12492
|
decoratorOption: options,
|
|
12445
12493
|
decoratorOptionsValidationSchema,
|
|
12446
|
-
|
|
12447
|
-
|
|
12448
|
-
|
|
12449
|
-
}
|
|
12494
|
+
lucidDecoratorFunction: column,
|
|
12495
|
+
defaultPrepare: prepareObject,
|
|
12496
|
+
defaultConsume: consumeObject
|
|
12450
12497
|
});
|
|
12451
12498
|
};
|
|
12452
12499
|
};
|
|
@@ -12460,10 +12507,9 @@ resourcefulColumn.array = function(options = {}) {
|
|
|
12460
12507
|
propertyKey,
|
|
12461
12508
|
decoratorOption: options,
|
|
12462
12509
|
decoratorOptionsValidationSchema,
|
|
12463
|
-
|
|
12464
|
-
|
|
12465
|
-
|
|
12466
|
-
}
|
|
12510
|
+
lucidDecoratorFunction: column,
|
|
12511
|
+
defaultPrepare: prepareArray,
|
|
12512
|
+
defaultConsume: consumeArray
|
|
12467
12513
|
});
|
|
12468
12514
|
};
|
|
12469
12515
|
};
|
|
@@ -12691,7 +12737,7 @@ function resourcefulHasManyThrough(model, options = {}) {
|
|
|
12691
12737
|
map.set(propertyKey, opts);
|
|
12692
12738
|
};
|
|
12693
12739
|
}
|
|
12694
|
-
const version = "1.20250718.
|
|
12740
|
+
const version = "1.20250718.2";
|
|
12695
12741
|
export {
|
|
12696
12742
|
k as definitions,
|
|
12697
12743
|
w as errors,
|