@nhtio/lucid-resourceful 1.20250718.0 → 1.20250718.1
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/index.cjs +39 -9
- package/index.cjs.map +1 -1
- package/index.mjs +39 -9
- package/index.mjs.map +1 -1
- package/package.json +1 -1
- package/private/decorators.d.ts +1 -1
- package/private/utils.d.ts +4 -0
package/index.cjs
CHANGED
|
@@ -616,6 +616,16 @@ const isString$1 = (value) => {
|
|
|
616
616
|
const isFunction = (value) => {
|
|
617
617
|
return typeof value === "function";
|
|
618
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
|
+
};
|
|
619
629
|
const ResourcefulErrorHandlerMethod = ["bubble", "pass", "fail"];
|
|
620
630
|
const getFieldKey = (key, definition) => {
|
|
621
631
|
if (isString$1(definition.serializeAs)) {
|
|
@@ -1479,9 +1489,7 @@ function withResourceful(options = {}) {
|
|
|
1479
1489
|
if (!isString$1(filter)) {
|
|
1480
1490
|
filter = "";
|
|
1481
1491
|
}
|
|
1482
|
-
|
|
1483
|
-
fields = [primaryKey];
|
|
1484
|
-
}
|
|
1492
|
+
fields = prepareFields(fields, primaryKey);
|
|
1485
1493
|
const { isForbidden, allowedFieldsMap, message } = await this.$resourcefulCheckAccess({
|
|
1486
1494
|
ctx,
|
|
1487
1495
|
app,
|
|
@@ -12181,7 +12189,17 @@ const extractLucidOptionsForLucidDecorator = (options, keys, overrides) => {
|
|
|
12181
12189
|
const extractLucidOptionsForLucidColumnDecorator = (options, overrides) => {
|
|
12182
12190
|
return extractLucidOptionsForLucidDecorator(
|
|
12183
12191
|
options,
|
|
12184
|
-
[
|
|
12192
|
+
[
|
|
12193
|
+
"columnName",
|
|
12194
|
+
"serializeAs",
|
|
12195
|
+
"isPrimary",
|
|
12196
|
+
"meta",
|
|
12197
|
+
"serialize",
|
|
12198
|
+
"prepare",
|
|
12199
|
+
"consume",
|
|
12200
|
+
"autoCreate",
|
|
12201
|
+
"autoUpdate"
|
|
12202
|
+
],
|
|
12185
12203
|
overrides
|
|
12186
12204
|
);
|
|
12187
12205
|
};
|
|
@@ -12243,7 +12261,8 @@ const handleResourcefulColumn = (config) => {
|
|
|
12243
12261
|
propertyKey,
|
|
12244
12262
|
decoratorOption,
|
|
12245
12263
|
decoratorOptionsValidationSchema,
|
|
12246
|
-
overrides
|
|
12264
|
+
overrides,
|
|
12265
|
+
lucidDecoratorFunction
|
|
12247
12266
|
} = config;
|
|
12248
12267
|
const opts = validateNormalizeAndCastDecoratorOptions(propertyKey, decoratorName, decoratorOptionsValidationSchema, {
|
|
12249
12268
|
...decoratorOption,
|
|
@@ -12253,7 +12272,7 @@ const handleResourcefulColumn = (config) => {
|
|
|
12253
12272
|
opts,
|
|
12254
12273
|
overrides
|
|
12255
12274
|
);
|
|
12256
|
-
|
|
12275
|
+
lucidDecoratorFunction(lucidOptions)(target, propertyKey);
|
|
12257
12276
|
const map = ensureOwnResourcefulMap(target, "$resourcefulColumns");
|
|
12258
12277
|
map.set(propertyKey, opts);
|
|
12259
12278
|
};
|
|
@@ -12298,6 +12317,7 @@ resourcefulColumn.string = function(options = {}) {
|
|
|
12298
12317
|
propertyKey,
|
|
12299
12318
|
decoratorOption: options,
|
|
12300
12319
|
decoratorOptionsValidationSchema,
|
|
12320
|
+
lucidDecoratorFunction: column,
|
|
12301
12321
|
overrides: {
|
|
12302
12322
|
prepare: (value) => decorator_utils.prepareString(propertyKey, value, options.nullable),
|
|
12303
12323
|
consume: (value) => decorator_utils.consumeString(propertyKey, value, options.nullable)
|
|
@@ -12314,7 +12334,8 @@ resourcefulColumn.date = function(options = {}) {
|
|
|
12314
12334
|
target,
|
|
12315
12335
|
propertyKey,
|
|
12316
12336
|
decoratorOption: options,
|
|
12317
|
-
decoratorOptionsValidationSchema
|
|
12337
|
+
decoratorOptionsValidationSchema,
|
|
12338
|
+
lucidDecoratorFunction: column.date
|
|
12318
12339
|
});
|
|
12319
12340
|
};
|
|
12320
12341
|
};
|
|
@@ -12327,7 +12348,8 @@ resourcefulColumn.dateTime = function(options = {}) {
|
|
|
12327
12348
|
target,
|
|
12328
12349
|
propertyKey,
|
|
12329
12350
|
decoratorOption: options,
|
|
12330
|
-
decoratorOptionsValidationSchema
|
|
12351
|
+
decoratorOptionsValidationSchema,
|
|
12352
|
+
lucidDecoratorFunction: column.dateTime
|
|
12331
12353
|
});
|
|
12332
12354
|
};
|
|
12333
12355
|
};
|
|
@@ -12341,6 +12363,7 @@ resourcefulColumn.binary = function(options = {}) {
|
|
|
12341
12363
|
propertyKey,
|
|
12342
12364
|
decoratorOption: options,
|
|
12343
12365
|
decoratorOptionsValidationSchema,
|
|
12366
|
+
lucidDecoratorFunction: column,
|
|
12344
12367
|
overrides: {
|
|
12345
12368
|
prepare: (value) => decorator_utils.prepareBinary(propertyKey, value, options.nullable),
|
|
12346
12369
|
consume: (value) => decorator_utils.consumeBinary(propertyKey, value, options.nullable)
|
|
@@ -12358,6 +12381,7 @@ resourcefulColumn.number = function(options = {}) {
|
|
|
12358
12381
|
propertyKey,
|
|
12359
12382
|
decoratorOption: options,
|
|
12360
12383
|
decoratorOptionsValidationSchema,
|
|
12384
|
+
lucidDecoratorFunction: column,
|
|
12361
12385
|
overrides: {
|
|
12362
12386
|
prepare: (value) => decorator_utils.prepareNumber(propertyKey, value, options.nullable),
|
|
12363
12387
|
consume: (value) => decorator_utils.consumeNumber(propertyKey, value, options.nullable)
|
|
@@ -12375,6 +12399,7 @@ resourcefulColumn.integer = function(options = {}) {
|
|
|
12375
12399
|
propertyKey,
|
|
12376
12400
|
decoratorOption: options,
|
|
12377
12401
|
decoratorOptionsValidationSchema,
|
|
12402
|
+
lucidDecoratorFunction: column,
|
|
12378
12403
|
overrides: {
|
|
12379
12404
|
prepare: (value) => decorator_utils.prepareInteger(propertyKey, value, options.nullable),
|
|
12380
12405
|
consume: (value) => decorator_utils.consumeInteger(propertyKey, value, options.nullable)
|
|
@@ -12392,6 +12417,7 @@ resourcefulColumn.bigint = function(options = {}) {
|
|
|
12392
12417
|
propertyKey,
|
|
12393
12418
|
decoratorOption: options,
|
|
12394
12419
|
decoratorOptionsValidationSchema,
|
|
12420
|
+
lucidDecoratorFunction: column,
|
|
12395
12421
|
overrides: {
|
|
12396
12422
|
prepare: (value) => decorator_utils.prepareBigint(propertyKey, value, options.nullable),
|
|
12397
12423
|
consume: (value) => decorator_utils.consumeBigint(propertyKey, value, options.nullable)
|
|
@@ -12409,6 +12435,7 @@ resourcefulColumn.unsignedint = function(options = {}) {
|
|
|
12409
12435
|
propertyKey,
|
|
12410
12436
|
decoratorOption: options,
|
|
12411
12437
|
decoratorOptionsValidationSchema,
|
|
12438
|
+
lucidDecoratorFunction: column,
|
|
12412
12439
|
overrides: {
|
|
12413
12440
|
prepare: (value) => decorator_utils.prepareUnsignedint(propertyKey, value, options.nullable),
|
|
12414
12441
|
consume: (value) => decorator_utils.consumeUnsignedint(propertyKey, value, options.nullable)
|
|
@@ -12426,6 +12453,7 @@ resourcefulColumn.boolean = function(options = {}) {
|
|
|
12426
12453
|
propertyKey,
|
|
12427
12454
|
decoratorOption: options,
|
|
12428
12455
|
decoratorOptionsValidationSchema,
|
|
12456
|
+
lucidDecoratorFunction: column,
|
|
12429
12457
|
overrides: {
|
|
12430
12458
|
prepare: (value) => decorator_utils.prepareBoolean(propertyKey, value, options.nullable),
|
|
12431
12459
|
consume: (value) => decorator_utils.consumeBoolean(propertyKey, value, options.nullable)
|
|
@@ -12443,6 +12471,7 @@ resourcefulColumn.object = function(options = {}) {
|
|
|
12443
12471
|
propertyKey,
|
|
12444
12472
|
decoratorOption: options,
|
|
12445
12473
|
decoratorOptionsValidationSchema,
|
|
12474
|
+
lucidDecoratorFunction: column,
|
|
12446
12475
|
overrides: {
|
|
12447
12476
|
prepare: (value) => decorator_utils.prepareObject(propertyKey, value, options.nullable),
|
|
12448
12477
|
consume: (value) => decorator_utils.consumeObject(propertyKey, value, options.nullable)
|
|
@@ -12460,6 +12489,7 @@ resourcefulColumn.array = function(options = {}) {
|
|
|
12460
12489
|
propertyKey,
|
|
12461
12490
|
decoratorOption: options,
|
|
12462
12491
|
decoratorOptionsValidationSchema,
|
|
12492
|
+
lucidDecoratorFunction: column,
|
|
12463
12493
|
overrides: {
|
|
12464
12494
|
prepare: (value) => decorator_utils.prepareArray(propertyKey, value, options.nullable),
|
|
12465
12495
|
consume: (value) => decorator_utils.consumeArray(propertyKey, value, options.nullable)
|
|
@@ -12691,7 +12721,7 @@ function resourcefulHasManyThrough(model, options = {}) {
|
|
|
12691
12721
|
map.set(propertyKey, opts);
|
|
12692
12722
|
};
|
|
12693
12723
|
}
|
|
12694
|
-
const version = "1.20250718.
|
|
12724
|
+
const version = "1.20250718.1";
|
|
12695
12725
|
exports.errors = errors.errors;
|
|
12696
12726
|
exports.definitions = definitions.definitions;
|
|
12697
12727
|
exports.resourcefulBelongsTo = resourcefulBelongsTo;
|