@nhtio/lucid-resourceful 1.20250718.2 → 1.20250724.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/{definitions-B66EPk0H.js → definitions-B88XBTUF.js} +119 -119
- package/{definitions-B66EPk0H.js.map → definitions-B88XBTUF.js.map} +1 -1
- package/{definitions-BrN-oCRI.cjs → definitions-DgI468dW.cjs} +119 -119
- package/{definitions-BrN-oCRI.cjs.map → definitions-DgI468dW.cjs.map} +1 -1
- package/definitions.cjs +1 -1
- package/definitions.mjs +1 -1
- package/index.cjs +304 -290
- package/index.cjs.map +1 -1
- package/index.mjs +291 -277
- package/index.mjs.map +1 -1
- package/joi.cjs +12389 -2
- package/joi.cjs.map +1 -1
- package/joi.mjs +12391 -2
- package/joi.mjs.map +1 -1
- package/package.json +1 -1
- package/private/joi/index.d.ts +3 -65
- package/private/mixin.d.ts +4 -1
- package/index-Cv6KC1rC.cjs +0 -670
- package/index-Cv6KC1rC.cjs.map +0 -1
- package/index-DDaZ2qr2.js +0 -671
- package/index-DDaZ2qr2.js.map +0 -1
- package/private/joi/bigint.d.ts +0 -85
package/index.mjs
CHANGED
|
@@ -11,12 +11,12 @@ var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "
|
|
|
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
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
|
-
import {
|
|
14
|
+
import { joi as Q_ } from "./joi.mjs";
|
|
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";
|
|
17
17
|
import { w } from "./errors-B1rr67uM.js";
|
|
18
|
-
import { R as ResourcefulArrayType, a as ResourcefulObjectType, b as ResourcefulBooleanType, c as ResourcefulUnsignedIntegerType, d as ResourcefulBigintType, e as ResourcefulIntegerType, f as ResourcefulNumberType, g as ResourcefulBinaryType, h as ResourcefulDateTimeType, i as ResourcefulDateType, j as ResourcefulStringType } from "./definitions-
|
|
19
|
-
import { k } from "./definitions-
|
|
18
|
+
import { R as ResourcefulArrayType, a as ResourcefulObjectType, b as ResourcefulBooleanType, c as ResourcefulUnsignedIntegerType, d as ResourcefulBigintType, e as ResourcefulIntegerType, f as ResourcefulNumberType, g as ResourcefulBinaryType, h as ResourcefulDateTimeType, i as ResourcefulDateType, j as ResourcefulStringType } from "./definitions-B88XBTUF.js";
|
|
19
|
+
import { k } from "./definitions-B88XBTUF.js";
|
|
20
20
|
import require$$0, { debuglog } from "util";
|
|
21
21
|
import "node:path";
|
|
22
22
|
import "node:url";
|
|
@@ -598,31 +598,31 @@ const getFieldKey = (key, definition) => {
|
|
|
598
598
|
};
|
|
599
599
|
function withResourceful(options = {}) {
|
|
600
600
|
return (superclass) => {
|
|
601
|
-
const optionsSchema =
|
|
602
|
-
name:
|
|
603
|
-
readRequiredForWrite:
|
|
604
|
-
accessControlFilters:
|
|
605
|
-
list:
|
|
606
|
-
create:
|
|
607
|
-
read:
|
|
608
|
-
update:
|
|
609
|
-
delete:
|
|
601
|
+
const optionsSchema = Q_.object({
|
|
602
|
+
name: Q_.string().default(superclass.name),
|
|
603
|
+
readRequiredForWrite: Q_.boolean().default(false),
|
|
604
|
+
accessControlFilters: Q_.object({
|
|
605
|
+
list: Q_.array().items(Q_.function()).default([]),
|
|
606
|
+
create: Q_.array().items(Q_.function()).default([]),
|
|
607
|
+
read: Q_.array().items(Q_.function()).default([]),
|
|
608
|
+
update: Q_.array().items(Q_.function()).default([]),
|
|
609
|
+
delete: Q_.array().items(Q_.function()).default([])
|
|
610
610
|
}).default({}),
|
|
611
|
-
onACLError:
|
|
612
|
-
onValidationScopeError:
|
|
613
|
-
queryScopeCallbacks:
|
|
614
|
-
list:
|
|
615
|
-
access:
|
|
611
|
+
onACLError: Q_.string().valid(...ResourcefulErrorHandlerMethod).default("throw"),
|
|
612
|
+
onValidationScopeError: Q_.string().valid(...ResourcefulErrorHandlerMethod).default("throw"),
|
|
613
|
+
queryScopeCallbacks: Q_.object({
|
|
614
|
+
list: Q_.array().items(Q_.function()).default([]),
|
|
615
|
+
access: Q_.array().items(Q_.function()).default([])
|
|
616
616
|
}).default({}),
|
|
617
|
-
description:
|
|
618
|
-
externalDocs:
|
|
619
|
-
description:
|
|
620
|
-
url:
|
|
617
|
+
description: Q_.string().optional(),
|
|
618
|
+
externalDocs: Q_.object({
|
|
619
|
+
description: Q_.string().optional(),
|
|
620
|
+
url: Q_.string().uri().required()
|
|
621
621
|
}).optional(),
|
|
622
|
-
example:
|
|
623
|
-
advanced:
|
|
624
|
-
propertyEvaluationConcurrency:
|
|
625
|
-
aclEvaluationConcurrency:
|
|
622
|
+
example: Q_.string().optional(),
|
|
623
|
+
advanced: Q_.object({
|
|
624
|
+
propertyEvaluationConcurrency: Q_.number().integer().min(1).default(10),
|
|
625
|
+
aclEvaluationConcurrency: Q_.number().integer().min(1).default(2)
|
|
626
626
|
}).default({
|
|
627
627
|
propertyEvaluationConcurrency: 10,
|
|
628
628
|
aclEvaluationConcurrency: 2
|
|
@@ -763,7 +763,7 @@ function withResourceful(options = {}) {
|
|
|
763
763
|
"relationship"
|
|
764
764
|
),
|
|
765
765
|
kind: "relationship",
|
|
766
|
-
validator:
|
|
766
|
+
validator: Q_.forbidden(),
|
|
767
767
|
relatedModel: relationshipDefinition.relatedModel
|
|
768
768
|
};
|
|
769
769
|
if (!resourcefulModelRelationshipMetaSchema.canRead && !resourcefulModelRelationshipMetaSchema.canWrite)
|
|
@@ -778,7 +778,7 @@ function withResourceful(options = {}) {
|
|
|
778
778
|
}
|
|
779
779
|
static $getPropertyValidator(ctx, app, key, datatype, nullable, validationScopes, kind, writable = false) {
|
|
780
780
|
if ("relationship" === kind || "computedAccessor" === kind && !writable) {
|
|
781
|
-
return
|
|
781
|
+
return Q_.any().forbidden();
|
|
782
782
|
}
|
|
783
783
|
const baseValidator = this.$getPropertyBaseValidator(datatype, nullable, kind, writable);
|
|
784
784
|
if (Array.isArray(validationScopes) && validationScopes.length > 0) {
|
|
@@ -800,7 +800,7 @@ function withResourceful(options = {}) {
|
|
|
800
800
|
case "pass":
|
|
801
801
|
break;
|
|
802
802
|
case "fail":
|
|
803
|
-
return
|
|
803
|
+
return Q_.any().forbidden();
|
|
804
804
|
}
|
|
805
805
|
}
|
|
806
806
|
});
|
|
@@ -809,13 +809,13 @@ function withResourceful(options = {}) {
|
|
|
809
809
|
}
|
|
810
810
|
static $getPropertyBaseValidator(datatype, nullable, kind, writable = false) {
|
|
811
811
|
if ("relationship" === kind || "computedAccessor" === kind && !writable) {
|
|
812
|
-
return
|
|
812
|
+
return Q_.any().forbidden();
|
|
813
813
|
}
|
|
814
814
|
nullable = nullable || "boolean" === typeof datatype.nullable && datatype.nullable;
|
|
815
815
|
switch (true) {
|
|
816
816
|
case datatype instanceof ResourcefulStringType: {
|
|
817
817
|
const d = datatype;
|
|
818
|
-
const r =
|
|
818
|
+
const r = Q_.string().min(d.minLength).max(d.maxLength);
|
|
819
819
|
if (d.pattern) {
|
|
820
820
|
r.pattern(new RegExp(d.pattern));
|
|
821
821
|
}
|
|
@@ -828,14 +828,14 @@ function withResourceful(options = {}) {
|
|
|
828
828
|
return r;
|
|
829
829
|
}
|
|
830
830
|
case datatype instanceof ResourcefulDateType: {
|
|
831
|
-
const r =
|
|
831
|
+
const r = Q_.date().iso();
|
|
832
832
|
if (nullable) {
|
|
833
833
|
r.allow(null);
|
|
834
834
|
}
|
|
835
835
|
return r;
|
|
836
836
|
}
|
|
837
837
|
case datatype instanceof ResourcefulDateTimeType: {
|
|
838
|
-
const r =
|
|
838
|
+
const r = Q_.date().iso();
|
|
839
839
|
if (nullable) {
|
|
840
840
|
r.allow(null);
|
|
841
841
|
}
|
|
@@ -843,7 +843,7 @@ function withResourceful(options = {}) {
|
|
|
843
843
|
}
|
|
844
844
|
case datatype instanceof ResourcefulBinaryType: {
|
|
845
845
|
const d = datatype;
|
|
846
|
-
const r =
|
|
846
|
+
const r = Q_.string();
|
|
847
847
|
if (nullable) {
|
|
848
848
|
r.allow(null);
|
|
849
849
|
}
|
|
@@ -857,7 +857,7 @@ function withResourceful(options = {}) {
|
|
|
857
857
|
}
|
|
858
858
|
case datatype instanceof ResourcefulNumberType: {
|
|
859
859
|
const d = datatype;
|
|
860
|
-
const r =
|
|
860
|
+
const r = Q_.number();
|
|
861
861
|
if (nullable) {
|
|
862
862
|
r.allow(null);
|
|
863
863
|
}
|
|
@@ -876,7 +876,7 @@ function withResourceful(options = {}) {
|
|
|
876
876
|
}
|
|
877
877
|
case datatype instanceof ResourcefulIntegerType: {
|
|
878
878
|
const d = datatype;
|
|
879
|
-
const r =
|
|
879
|
+
const r = Q_.number();
|
|
880
880
|
if (nullable) {
|
|
881
881
|
r.allow(null);
|
|
882
882
|
}
|
|
@@ -895,7 +895,7 @@ function withResourceful(options = {}) {
|
|
|
895
895
|
}
|
|
896
896
|
case datatype instanceof ResourcefulBigintType: {
|
|
897
897
|
const d = datatype;
|
|
898
|
-
const r =
|
|
898
|
+
const r = Q_.bigint();
|
|
899
899
|
if (nullable) {
|
|
900
900
|
r.allow(null);
|
|
901
901
|
}
|
|
@@ -914,7 +914,7 @@ function withResourceful(options = {}) {
|
|
|
914
914
|
}
|
|
915
915
|
case datatype instanceof ResourcefulUnsignedIntegerType: {
|
|
916
916
|
const d = datatype;
|
|
917
|
-
const r =
|
|
917
|
+
const r = Q_.number().unsafe();
|
|
918
918
|
if (nullable) {
|
|
919
919
|
r.allow(null);
|
|
920
920
|
}
|
|
@@ -932,7 +932,7 @@ function withResourceful(options = {}) {
|
|
|
932
932
|
return r;
|
|
933
933
|
}
|
|
934
934
|
case datatype instanceof ResourcefulBooleanType: {
|
|
935
|
-
const r =
|
|
935
|
+
const r = Q_.boolean();
|
|
936
936
|
if (nullable) {
|
|
937
937
|
r.allow(null);
|
|
938
938
|
}
|
|
@@ -952,7 +952,7 @@ function withResourceful(options = {}) {
|
|
|
952
952
|
!(item.readOnly || false)
|
|
953
953
|
)
|
|
954
954
|
);
|
|
955
|
-
propValidator =
|
|
955
|
+
propValidator = Q_.alternatives().try(...alternatives);
|
|
956
956
|
} else if ("allOf" in propDef) {
|
|
957
957
|
const schemas = propDef.allOf.map(
|
|
958
958
|
(item) => this.$getPropertyBaseValidator(
|
|
@@ -962,7 +962,7 @@ function withResourceful(options = {}) {
|
|
|
962
962
|
!(item.readOnly || false)
|
|
963
963
|
)
|
|
964
964
|
);
|
|
965
|
-
propValidator = schemas.reduce((acc, schema) => acc.concat(schema),
|
|
965
|
+
propValidator = schemas.reduce((acc, schema) => acc.concat(schema), Q_.any());
|
|
966
966
|
} else if ("anyOf" in propDef) {
|
|
967
967
|
const alternatives = propDef.anyOf.map(
|
|
968
968
|
(item) => this.$getPropertyBaseValidator(
|
|
@@ -972,7 +972,7 @@ function withResourceful(options = {}) {
|
|
|
972
972
|
!(item.readOnly || false)
|
|
973
973
|
)
|
|
974
974
|
);
|
|
975
|
-
propValidator =
|
|
975
|
+
propValidator = Q_.alternatives().try(...alternatives);
|
|
976
976
|
} else if ("not" in propDef) {
|
|
977
977
|
const notSchemas = propDef.not.map(
|
|
978
978
|
(item) => this.$getPropertyBaseValidator(
|
|
@@ -982,7 +982,7 @@ function withResourceful(options = {}) {
|
|
|
982
982
|
!(item.readOnly || false)
|
|
983
983
|
)
|
|
984
984
|
);
|
|
985
|
-
propValidator =
|
|
985
|
+
propValidator = Q_.any().not(...notSchemas);
|
|
986
986
|
} else {
|
|
987
987
|
propValidator = this.$getPropertyBaseValidator(
|
|
988
988
|
propDef,
|
|
@@ -996,7 +996,7 @@ function withResourceful(options = {}) {
|
|
|
996
996
|
}
|
|
997
997
|
objectSchema[propKey] = propValidator;
|
|
998
998
|
});
|
|
999
|
-
const r =
|
|
999
|
+
const r = Q_.object(objectSchema);
|
|
1000
1000
|
if (nullable) {
|
|
1001
1001
|
r.allow(null);
|
|
1002
1002
|
}
|
|
@@ -1009,7 +1009,7 @@ function withResourceful(options = {}) {
|
|
|
1009
1009
|
if (isObject$1(d.additionalProperties)) {
|
|
1010
1010
|
const additionalPropertiesType = d.additionalProperties;
|
|
1011
1011
|
r.pattern(
|
|
1012
|
-
|
|
1012
|
+
Q_.string(),
|
|
1013
1013
|
this.$getPropertyBaseValidator(
|
|
1014
1014
|
additionalPropertiesType,
|
|
1015
1015
|
additionalPropertiesType.nullable || false,
|
|
@@ -1024,7 +1024,7 @@ function withResourceful(options = {}) {
|
|
|
1024
1024
|
}
|
|
1025
1025
|
case datatype instanceof ResourcefulArrayType: {
|
|
1026
1026
|
const d = datatype;
|
|
1027
|
-
const r =
|
|
1027
|
+
const r = Q_.array();
|
|
1028
1028
|
if (nullable) {
|
|
1029
1029
|
r.allow(null);
|
|
1030
1030
|
}
|
|
@@ -1038,7 +1038,7 @@ function withResourceful(options = {}) {
|
|
|
1038
1038
|
!(item.readOnly || false)
|
|
1039
1039
|
)
|
|
1040
1040
|
);
|
|
1041
|
-
itemValidator =
|
|
1041
|
+
itemValidator = Q_.alternatives().try(...alternatives);
|
|
1042
1042
|
} else if ("allOf" in d.items) {
|
|
1043
1043
|
const schemas = d.items.allOf.map(
|
|
1044
1044
|
(item) => this.$getPropertyBaseValidator(
|
|
@@ -1048,7 +1048,7 @@ function withResourceful(options = {}) {
|
|
|
1048
1048
|
!(item.readOnly || false)
|
|
1049
1049
|
)
|
|
1050
1050
|
);
|
|
1051
|
-
itemValidator = schemas.reduce((acc, schema) => acc.concat(schema),
|
|
1051
|
+
itemValidator = schemas.reduce((acc, schema) => acc.concat(schema), Q_.any());
|
|
1052
1052
|
} else if ("anyOf" in d.items) {
|
|
1053
1053
|
const alternatives = d.items.anyOf.map(
|
|
1054
1054
|
(item) => this.$getPropertyBaseValidator(
|
|
@@ -1058,7 +1058,7 @@ function withResourceful(options = {}) {
|
|
|
1058
1058
|
!(item.readOnly || false)
|
|
1059
1059
|
)
|
|
1060
1060
|
);
|
|
1061
|
-
itemValidator =
|
|
1061
|
+
itemValidator = Q_.alternatives().try(...alternatives);
|
|
1062
1062
|
} else if ("not" in d.items) {
|
|
1063
1063
|
const notSchemas = d.items.not.map(
|
|
1064
1064
|
(item) => this.$getPropertyBaseValidator(
|
|
@@ -1068,7 +1068,7 @@ function withResourceful(options = {}) {
|
|
|
1068
1068
|
!(item.readOnly || false)
|
|
1069
1069
|
)
|
|
1070
1070
|
);
|
|
1071
|
-
itemValidator =
|
|
1071
|
+
itemValidator = Q_.any().not(...notSchemas);
|
|
1072
1072
|
} else {
|
|
1073
1073
|
itemValidator = this.$getPropertyBaseValidator(
|
|
1074
1074
|
d.items,
|
|
@@ -1090,7 +1090,7 @@ function withResourceful(options = {}) {
|
|
|
1090
1090
|
return r;
|
|
1091
1091
|
}
|
|
1092
1092
|
default:
|
|
1093
|
-
return
|
|
1093
|
+
return Q_.any().forbidden();
|
|
1094
1094
|
}
|
|
1095
1095
|
}
|
|
1096
1096
|
static async $getPropertyCanReadWrite(ctx, app, key, lucidDefinition, readAclFilters = [], writeAclFilters = [], kind, writable = false) {
|
|
@@ -1147,6 +1147,13 @@ function withResourceful(options = {}) {
|
|
|
1147
1147
|
};
|
|
1148
1148
|
Object.entries(resourcefulModelMetaSchema.properties).forEach(
|
|
1149
1149
|
([propertyKey, propertyMeta]) => {
|
|
1150
|
+
const resolvedColumnName = getFieldKey(
|
|
1151
|
+
propertyKey,
|
|
1152
|
+
propertyMeta.lucidDefinitions
|
|
1153
|
+
);
|
|
1154
|
+
if (null === resolvedColumnName) {
|
|
1155
|
+
return;
|
|
1156
|
+
}
|
|
1150
1157
|
switch (propertyMeta.kind) {
|
|
1151
1158
|
case "column": {
|
|
1152
1159
|
ret.properties[propertyKey] = this.$resourcefulModelColumnMetaToOpenApiSchema(
|
|
@@ -1192,7 +1199,6 @@ function withResourceful(options = {}) {
|
|
|
1192
1199
|
}
|
|
1193
1200
|
static $resourcefulModelColumnMetaToOpenApiSchema(propertyKey, propertyMeta) {
|
|
1194
1201
|
const ret = stripUndefinedValuesFromObject({
|
|
1195
|
-
type: propertyMeta.definition.type,
|
|
1196
1202
|
items: propertyMeta.definition.items,
|
|
1197
1203
|
title: getFieldKey(propertyKey, propertyMeta.lucidDefinitions) || propertyKey,
|
|
1198
1204
|
description: propertyMeta.definition.description,
|
|
@@ -1223,13 +1229,13 @@ function withResourceful(options = {}) {
|
|
|
1223
1229
|
readOnly: propertyMeta.canRead && !propertyMeta.canWrite,
|
|
1224
1230
|
writeOnly: !propertyMeta.canRead && propertyMeta.canWrite,
|
|
1225
1231
|
externalDocs: propertyMeta.definition.externalDocs,
|
|
1226
|
-
example: propertyMeta.definition.example
|
|
1232
|
+
example: propertyMeta.definition.example,
|
|
1233
|
+
...propertyMeta.definition.type
|
|
1227
1234
|
});
|
|
1228
1235
|
return ret;
|
|
1229
1236
|
}
|
|
1230
1237
|
static $resourcefulModelComputedAccessorMetaToOpenApiSchema(propertyKey, propertyMeta) {
|
|
1231
1238
|
const ret = stripUndefinedValuesFromObject({
|
|
1232
|
-
type: propertyMeta.definition.type,
|
|
1233
1239
|
items: propertyMeta.definition.items,
|
|
1234
1240
|
title: getFieldKey(propertyKey, propertyMeta.lucidDefinitions) || propertyKey,
|
|
1235
1241
|
description: propertyMeta.definition.description,
|
|
@@ -1260,7 +1266,8 @@ function withResourceful(options = {}) {
|
|
|
1260
1266
|
readOnly: propertyMeta.canRead && !propertyMeta.canWrite,
|
|
1261
1267
|
writeOnly: !propertyMeta.canRead && propertyMeta.canWrite,
|
|
1262
1268
|
externalDocs: propertyMeta.definition.externalDocs,
|
|
1263
|
-
example: propertyMeta.definition.example
|
|
1269
|
+
example: propertyMeta.definition.example,
|
|
1270
|
+
...propertyMeta.definition.type
|
|
1264
1271
|
});
|
|
1265
1272
|
return ret;
|
|
1266
1273
|
}
|
|
@@ -1443,7 +1450,7 @@ function withResourceful(options = {}) {
|
|
|
1443
1450
|
static $resourcefulGetQueryBuilder() {
|
|
1444
1451
|
return this.$adapter.modelConstructorClient(this).query().from(this.table);
|
|
1445
1452
|
}
|
|
1446
|
-
static async $onResourcefulIndex(filter, page, perPage, fields, ctx, app, hooks = []) {
|
|
1453
|
+
static async $onResourcefulIndex(filter, page, perPage, fields, sort, ctx, app, hooks = []) {
|
|
1447
1454
|
var _a2;
|
|
1448
1455
|
const primaryKey = this.$getPrivateKeyAttribute();
|
|
1449
1456
|
if (!primaryKey) {
|
|
@@ -1465,11 +1472,11 @@ function withResourceful(options = {}) {
|
|
|
1465
1472
|
if (possibleFields.length === 0) {
|
|
1466
1473
|
throw new E_INVALID_COLUMN_ACCESS("No fields available for access");
|
|
1467
1474
|
}
|
|
1468
|
-
const schema =
|
|
1469
|
-
filter:
|
|
1470
|
-
page:
|
|
1471
|
-
perPage:
|
|
1472
|
-
fields:
|
|
1475
|
+
const schema = Q_.object({
|
|
1476
|
+
filter: Q_.string().allow("").required(),
|
|
1477
|
+
page: Q_.number().integer().min(1).required(),
|
|
1478
|
+
perPage: Q_.number().integer().min(1).max(100).required(),
|
|
1479
|
+
fields: Q_.array().items(Q_.string().valid(...possibleFields)).required()
|
|
1473
1480
|
});
|
|
1474
1481
|
const { error: methodValidationError, value: validatedMethodOptions } = schema.validate(
|
|
1475
1482
|
{
|
|
@@ -1499,11 +1506,18 @@ function withResourceful(options = {}) {
|
|
|
1499
1506
|
]) {
|
|
1500
1507
|
await scopeCallback(ctx, app, query);
|
|
1501
1508
|
}
|
|
1502
|
-
const columnsToSelect = validatedMethodOptions.fields.filter((field) => allowedFieldsMap.has(field)).map((field) => this.$keys.serializedToColumns.get(field));
|
|
1509
|
+
const columnsToSelect = validatedMethodOptions.fields.filter((field) => allowedFieldsMap.has(field)).map((field) => this.$keys.serializedToColumns.get(field)).filter((column2) => !!column2);
|
|
1503
1510
|
const countQuery = query.clone();
|
|
1504
1511
|
const recordsQuery = query.clone();
|
|
1505
1512
|
countQuery.count("*", "total");
|
|
1506
1513
|
recordsQuery.select(columnsToSelect).forPage(validatedMethodOptions.page, validatedMethodOptions.perPage);
|
|
1514
|
+
if (Array.isArray(sort) && sort.length > 0) {
|
|
1515
|
+
sort.forEach(([field, direction]) => {
|
|
1516
|
+
if (allowedFieldsMap.has(field)) {
|
|
1517
|
+
recordsQuery.orderBy(field, direction);
|
|
1518
|
+
}
|
|
1519
|
+
});
|
|
1520
|
+
}
|
|
1507
1521
|
const countQueryQuery = countQuery.toQuery();
|
|
1508
1522
|
const recordsQueryQuery = recordsQuery.toQuery();
|
|
1509
1523
|
const [countResults, rawRecords] = await Promise.all([countQuery, recordsQuery]);
|
|
@@ -11800,25 +11814,25 @@ const validateNormalizeAndCastDecoratorOptions = (fieldName, decoratorName, sche
|
|
|
11800
11814
|
}
|
|
11801
11815
|
return value;
|
|
11802
11816
|
};
|
|
11803
|
-
const resourcefulPropertyDefinitionSchema =
|
|
11804
|
-
propertyKey:
|
|
11805
|
-
readAccessControlFilters:
|
|
11806
|
-
writeAccessControlFilters:
|
|
11807
|
-
nullable:
|
|
11808
|
-
description:
|
|
11809
|
-
default:
|
|
11810
|
-
externalDocs:
|
|
11811
|
-
description:
|
|
11812
|
-
url:
|
|
11817
|
+
const resourcefulPropertyDefinitionSchema = Q_.object({
|
|
11818
|
+
propertyKey: Q_.string().default(""),
|
|
11819
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
11820
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
11821
|
+
nullable: Q_.boolean().default(false),
|
|
11822
|
+
description: Q_.string().optional(),
|
|
11823
|
+
default: Q_.any().optional(),
|
|
11824
|
+
externalDocs: Q_.object({
|
|
11825
|
+
description: Q_.string().optional(),
|
|
11826
|
+
url: Q_.string().uri().required()
|
|
11813
11827
|
}).optional(),
|
|
11814
|
-
example:
|
|
11815
|
-
deprecated:
|
|
11828
|
+
example: Q_.string().optional(),
|
|
11829
|
+
deprecated: Q_.boolean().default(false)
|
|
11816
11830
|
});
|
|
11817
11831
|
const joiInstanceCheckerAlternativesFactory = (Ctor, CtorName) => {
|
|
11818
11832
|
return [
|
|
11819
|
-
|
|
11820
|
-
|
|
11821
|
-
|
|
11833
|
+
Q_.object().instance(Ctor),
|
|
11834
|
+
Q_.function().instance(Ctor),
|
|
11835
|
+
Q_.custom((value, helpers) => {
|
|
11822
11836
|
if (isObject$1(value) && value.constructor.name === CtorName) {
|
|
11823
11837
|
return value;
|
|
11824
11838
|
}
|
|
@@ -11826,7 +11840,7 @@ const joiInstanceCheckerAlternativesFactory = (Ctor, CtorName) => {
|
|
|
11826
11840
|
})
|
|
11827
11841
|
];
|
|
11828
11842
|
};
|
|
11829
|
-
const resourcefulDataTypeSchema =
|
|
11843
|
+
const resourcefulDataTypeSchema = Q_.alternatives(
|
|
11830
11844
|
...joiInstanceCheckerAlternativesFactory(ResourcefulStringType, "ResourcefulStringType"),
|
|
11831
11845
|
...joiInstanceCheckerAlternativesFactory(ResourcefulDateType, "ResourcefulDateType"),
|
|
11832
11846
|
...joiInstanceCheckerAlternativesFactory(ResourcefulDateTimeType, "ResourcefulDateTimeType"),
|
|
@@ -11845,95 +11859,95 @@ const resourcefulDataTypeSchema = joi.alternatives(
|
|
|
11845
11859
|
const localResourcefulPropertyDefinitionSchema = resourcefulPropertyDefinitionSchema.keys({
|
|
11846
11860
|
type: resourcefulDataTypeSchema.required()
|
|
11847
11861
|
});
|
|
11848
|
-
const resourcefulColumnOptionsSchema =
|
|
11862
|
+
const resourcefulColumnOptionsSchema = Q_.object({
|
|
11849
11863
|
// Lucid ColumnOptions (partial)
|
|
11850
|
-
columnName:
|
|
11851
|
-
serializeAs:
|
|
11852
|
-
serialize:
|
|
11853
|
-
consume:
|
|
11854
|
-
prepare:
|
|
11855
|
-
meta:
|
|
11856
|
-
isPrimary:
|
|
11857
|
-
hasDefaultValue:
|
|
11864
|
+
columnName: Q_.string().optional(),
|
|
11865
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
11866
|
+
serialize: Q_.function().optional(),
|
|
11867
|
+
consume: Q_.function().optional(),
|
|
11868
|
+
prepare: Q_.function().optional(),
|
|
11869
|
+
meta: Q_.object().optional(),
|
|
11870
|
+
isPrimary: Q_.boolean().default(false),
|
|
11871
|
+
hasDefaultValue: Q_.boolean().default(false),
|
|
11858
11872
|
// Resourceful options
|
|
11859
|
-
propertyKey:
|
|
11860
|
-
readAccessControlFilters:
|
|
11861
|
-
writeAccessControlFilters:
|
|
11862
|
-
nullable:
|
|
11863
|
-
description:
|
|
11864
|
-
default:
|
|
11865
|
-
externalDocs:
|
|
11866
|
-
description:
|
|
11867
|
-
url:
|
|
11873
|
+
propertyKey: Q_.string().default(""),
|
|
11874
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
11875
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
11876
|
+
nullable: Q_.boolean().default(false),
|
|
11877
|
+
description: Q_.string().optional(),
|
|
11878
|
+
default: Q_.any().optional(),
|
|
11879
|
+
externalDocs: Q_.object({
|
|
11880
|
+
description: Q_.string().optional(),
|
|
11881
|
+
url: Q_.string().uri().required()
|
|
11868
11882
|
}).optional(),
|
|
11869
|
-
example:
|
|
11870
|
-
deprecated:
|
|
11883
|
+
example: Q_.string().optional(),
|
|
11884
|
+
deprecated: Q_.boolean().default(false),
|
|
11871
11885
|
type: resourcefulDataTypeSchema.required()
|
|
11872
11886
|
});
|
|
11873
|
-
const dataTypeColumnOptionsSchema =
|
|
11887
|
+
const dataTypeColumnOptionsSchema = Q_.object({
|
|
11874
11888
|
// Lucid ColumnOptions (partial) - excluding 'prepare' and 'consume'
|
|
11875
|
-
columnName:
|
|
11876
|
-
serializeAs:
|
|
11877
|
-
serialize:
|
|
11878
|
-
meta:
|
|
11879
|
-
isPrimary:
|
|
11880
|
-
hasDefaultValue:
|
|
11889
|
+
columnName: Q_.string().optional(),
|
|
11890
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
11891
|
+
serialize: Q_.function().optional(),
|
|
11892
|
+
meta: Q_.object().optional(),
|
|
11893
|
+
isPrimary: Q_.boolean().default(false),
|
|
11894
|
+
hasDefaultValue: Q_.boolean().default(false),
|
|
11881
11895
|
// Resourceful options
|
|
11882
|
-
propertyKey:
|
|
11883
|
-
readAccessControlFilters:
|
|
11884
|
-
writeAccessControlFilters:
|
|
11885
|
-
nullable:
|
|
11886
|
-
description:
|
|
11887
|
-
default:
|
|
11888
|
-
externalDocs:
|
|
11889
|
-
description:
|
|
11890
|
-
url:
|
|
11896
|
+
propertyKey: Q_.string().default(""),
|
|
11897
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
11898
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
11899
|
+
nullable: Q_.boolean().default(false),
|
|
11900
|
+
description: Q_.string().optional(),
|
|
11901
|
+
default: Q_.any().optional(),
|
|
11902
|
+
externalDocs: Q_.object({
|
|
11903
|
+
description: Q_.string().optional(),
|
|
11904
|
+
url: Q_.string().uri().required()
|
|
11891
11905
|
}).optional(),
|
|
11892
|
-
example:
|
|
11893
|
-
deprecated:
|
|
11906
|
+
example: Q_.string().optional(),
|
|
11907
|
+
deprecated: Q_.boolean().default(false),
|
|
11894
11908
|
type: resourcefulDataTypeSchema.optional()
|
|
11895
11909
|
});
|
|
11896
11910
|
const baseDateColumnOptionsSchema = dataTypeColumnOptionsSchema.keys({
|
|
11897
|
-
autoCreate:
|
|
11898
|
-
autoUpdate:
|
|
11911
|
+
autoCreate: Q_.boolean().default(false),
|
|
11912
|
+
autoUpdate: Q_.boolean().default(false)
|
|
11899
11913
|
});
|
|
11900
11914
|
const stringColumnOptionsSchema = dataTypeColumnOptionsSchema.keys({
|
|
11901
|
-
type:
|
|
11915
|
+
type: Q_.alternatives(
|
|
11902
11916
|
...joiInstanceCheckerAlternativesFactory(ResourcefulStringType, "ResourcefulStringType")
|
|
11903
11917
|
).default(() => new ResourcefulStringType())
|
|
11904
11918
|
});
|
|
11905
11919
|
const dateColumnOptionsSchema = baseDateColumnOptionsSchema.keys({
|
|
11906
|
-
type:
|
|
11920
|
+
type: Q_.alternatives(
|
|
11907
11921
|
...joiInstanceCheckerAlternativesFactory(ResourcefulDateType, "ResourcefulDateType")
|
|
11908
11922
|
).default(() => new ResourcefulDateType())
|
|
11909
11923
|
});
|
|
11910
11924
|
const dateTimeColumnOptionsSchema = baseDateColumnOptionsSchema.keys({
|
|
11911
|
-
type:
|
|
11925
|
+
type: Q_.alternatives(
|
|
11912
11926
|
...joiInstanceCheckerAlternativesFactory(ResourcefulDateTimeType, "ResourcefulDateTimeType")
|
|
11913
11927
|
).default(() => new ResourcefulDateTimeType())
|
|
11914
11928
|
});
|
|
11915
11929
|
const binaryColumnOptionsSchema = dataTypeColumnOptionsSchema.keys({
|
|
11916
|
-
type:
|
|
11930
|
+
type: Q_.alternatives(
|
|
11917
11931
|
...joiInstanceCheckerAlternativesFactory(ResourcefulBinaryType, "ResourcefulBinaryType")
|
|
11918
11932
|
).default(() => new ResourcefulBinaryType())
|
|
11919
11933
|
});
|
|
11920
11934
|
const numberColumnOptionsSchema = dataTypeColumnOptionsSchema.keys({
|
|
11921
|
-
type:
|
|
11935
|
+
type: Q_.alternatives(
|
|
11922
11936
|
...joiInstanceCheckerAlternativesFactory(ResourcefulNumberType, "ResourcefulNumberType")
|
|
11923
11937
|
).default(() => new ResourcefulNumberType())
|
|
11924
11938
|
});
|
|
11925
11939
|
const integerColumnOptionsSchema = dataTypeColumnOptionsSchema.keys({
|
|
11926
|
-
type:
|
|
11940
|
+
type: Q_.alternatives(
|
|
11927
11941
|
...joiInstanceCheckerAlternativesFactory(ResourcefulIntegerType, "ResourcefulIntegerType")
|
|
11928
11942
|
).default(() => new ResourcefulIntegerType())
|
|
11929
11943
|
});
|
|
11930
11944
|
const bigintColumnOptionsSchema = dataTypeColumnOptionsSchema.keys({
|
|
11931
|
-
type:
|
|
11945
|
+
type: Q_.alternatives(
|
|
11932
11946
|
...joiInstanceCheckerAlternativesFactory(ResourcefulBigintType, "ResourcefulBigintType")
|
|
11933
11947
|
).default(() => new ResourcefulBigintType())
|
|
11934
11948
|
});
|
|
11935
11949
|
const unsignedIntegerColumnOptionsSchema = dataTypeColumnOptionsSchema.keys({
|
|
11936
|
-
type:
|
|
11950
|
+
type: Q_.alternatives(
|
|
11937
11951
|
...joiInstanceCheckerAlternativesFactory(
|
|
11938
11952
|
ResourcefulUnsignedIntegerType,
|
|
11939
11953
|
"ResourcefulUnsignedIntegerType"
|
|
@@ -11941,148 +11955,148 @@ const unsignedIntegerColumnOptionsSchema = dataTypeColumnOptionsSchema.keys({
|
|
|
11941
11955
|
).default(() => new ResourcefulUnsignedIntegerType())
|
|
11942
11956
|
});
|
|
11943
11957
|
const booleanColumnOptionsSchema = dataTypeColumnOptionsSchema.keys({
|
|
11944
|
-
type:
|
|
11958
|
+
type: Q_.alternatives(
|
|
11945
11959
|
...joiInstanceCheckerAlternativesFactory(ResourcefulBooleanType, "ResourcefulBooleanType")
|
|
11946
11960
|
).default(() => new ResourcefulBooleanType())
|
|
11947
11961
|
});
|
|
11948
|
-
const objectColumnOptionsSchema =
|
|
11962
|
+
const objectColumnOptionsSchema = Q_.object({
|
|
11949
11963
|
// Lucid ColumnOptions (full)
|
|
11950
|
-
columnName:
|
|
11951
|
-
serializeAs:
|
|
11952
|
-
serialize:
|
|
11953
|
-
consume:
|
|
11954
|
-
prepare:
|
|
11955
|
-
meta:
|
|
11956
|
-
isPrimary:
|
|
11957
|
-
hasDefaultValue:
|
|
11964
|
+
columnName: Q_.string().optional(),
|
|
11965
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
11966
|
+
serialize: Q_.function().optional(),
|
|
11967
|
+
consume: Q_.function().optional(),
|
|
11968
|
+
prepare: Q_.function().optional(),
|
|
11969
|
+
meta: Q_.object().optional(),
|
|
11970
|
+
isPrimary: Q_.boolean().default(false),
|
|
11971
|
+
hasDefaultValue: Q_.boolean().default(false),
|
|
11958
11972
|
// Resourceful options
|
|
11959
|
-
propertyKey:
|
|
11960
|
-
readAccessControlFilters:
|
|
11961
|
-
writeAccessControlFilters:
|
|
11962
|
-
nullable:
|
|
11963
|
-
description:
|
|
11964
|
-
default:
|
|
11965
|
-
externalDocs:
|
|
11966
|
-
description:
|
|
11967
|
-
url:
|
|
11973
|
+
propertyKey: Q_.string().default(""),
|
|
11974
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
11975
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
11976
|
+
nullable: Q_.boolean().default(false),
|
|
11977
|
+
description: Q_.string().optional(),
|
|
11978
|
+
default: Q_.any().optional(),
|
|
11979
|
+
externalDocs: Q_.object({
|
|
11980
|
+
description: Q_.string().optional(),
|
|
11981
|
+
url: Q_.string().uri().required()
|
|
11968
11982
|
}).optional(),
|
|
11969
|
-
example:
|
|
11970
|
-
deprecated:
|
|
11971
|
-
type:
|
|
11983
|
+
example: Q_.string().optional(),
|
|
11984
|
+
deprecated: Q_.boolean().default(false),
|
|
11985
|
+
type: Q_.alternatives(
|
|
11972
11986
|
...joiInstanceCheckerAlternativesFactory(ResourcefulObjectType, "ResourcefulObjectType")
|
|
11973
11987
|
).default(() => new ResourcefulObjectType())
|
|
11974
11988
|
});
|
|
11975
|
-
const arrayColumnOptionsSchema =
|
|
11989
|
+
const arrayColumnOptionsSchema = Q_.object({
|
|
11976
11990
|
// Lucid ColumnOptions (full)
|
|
11977
|
-
columnName:
|
|
11978
|
-
serializeAs:
|
|
11979
|
-
serialize:
|
|
11980
|
-
consume:
|
|
11981
|
-
prepare:
|
|
11982
|
-
meta:
|
|
11983
|
-
isPrimary:
|
|
11984
|
-
hasDefaultValue:
|
|
11991
|
+
columnName: Q_.string().optional(),
|
|
11992
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
11993
|
+
serialize: Q_.function().optional(),
|
|
11994
|
+
consume: Q_.function().optional(),
|
|
11995
|
+
prepare: Q_.function().optional(),
|
|
11996
|
+
meta: Q_.object().optional(),
|
|
11997
|
+
isPrimary: Q_.boolean().default(false),
|
|
11998
|
+
hasDefaultValue: Q_.boolean().default(false),
|
|
11985
11999
|
// Resourceful options
|
|
11986
|
-
propertyKey:
|
|
11987
|
-
readAccessControlFilters:
|
|
11988
|
-
writeAccessControlFilters:
|
|
11989
|
-
nullable:
|
|
11990
|
-
description:
|
|
11991
|
-
default:
|
|
11992
|
-
externalDocs:
|
|
11993
|
-
description:
|
|
11994
|
-
url:
|
|
12000
|
+
propertyKey: Q_.string().default(""),
|
|
12001
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12002
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12003
|
+
nullable: Q_.boolean().default(false),
|
|
12004
|
+
description: Q_.string().optional(),
|
|
12005
|
+
default: Q_.any().optional(),
|
|
12006
|
+
externalDocs: Q_.object({
|
|
12007
|
+
description: Q_.string().optional(),
|
|
12008
|
+
url: Q_.string().uri().required()
|
|
11995
12009
|
}).optional(),
|
|
11996
|
-
example:
|
|
11997
|
-
deprecated:
|
|
11998
|
-
type:
|
|
12010
|
+
example: Q_.string().optional(),
|
|
12011
|
+
deprecated: Q_.boolean().default(false),
|
|
12012
|
+
type: Q_.alternatives(
|
|
11999
12013
|
...joiInstanceCheckerAlternativesFactory(ResourcefulArrayType, "ResourcefulArrayType")
|
|
12000
12014
|
).default(() => new ResourcefulArrayType())
|
|
12001
12015
|
});
|
|
12002
12016
|
localResourcefulPropertyDefinitionSchema.append({
|
|
12003
|
-
writable:
|
|
12017
|
+
writable: Q_.boolean().default(false)
|
|
12004
12018
|
});
|
|
12005
|
-
const resourcefulComputedOptionsSchema =
|
|
12019
|
+
const resourcefulComputedOptionsSchema = Q_.object({
|
|
12006
12020
|
// Lucid ComputedOptions (partial)
|
|
12007
|
-
serializeAs:
|
|
12008
|
-
serialize:
|
|
12009
|
-
meta:
|
|
12021
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
12022
|
+
serialize: Q_.function().optional(),
|
|
12023
|
+
meta: Q_.object().optional(),
|
|
12010
12024
|
// Resourceful options
|
|
12011
|
-
propertyKey:
|
|
12012
|
-
readAccessControlFilters:
|
|
12013
|
-
writeAccessControlFilters:
|
|
12014
|
-
nullable:
|
|
12015
|
-
description:
|
|
12016
|
-
default:
|
|
12017
|
-
externalDocs:
|
|
12018
|
-
description:
|
|
12019
|
-
url:
|
|
12025
|
+
propertyKey: Q_.string().default(""),
|
|
12026
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12027
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12028
|
+
nullable: Q_.boolean().default(false),
|
|
12029
|
+
description: Q_.string().optional(),
|
|
12030
|
+
default: Q_.any().optional(),
|
|
12031
|
+
externalDocs: Q_.object({
|
|
12032
|
+
description: Q_.string().optional(),
|
|
12033
|
+
url: Q_.string().uri().required()
|
|
12020
12034
|
}).optional(),
|
|
12021
|
-
example:
|
|
12022
|
-
deprecated:
|
|
12035
|
+
example: Q_.string().optional(),
|
|
12036
|
+
deprecated: Q_.boolean().default(false),
|
|
12023
12037
|
type: resourcefulDataTypeSchema.required()
|
|
12024
12038
|
});
|
|
12025
|
-
const dataTypeComputedOptionsSchema =
|
|
12039
|
+
const dataTypeComputedOptionsSchema = Q_.object({
|
|
12026
12040
|
// Lucid ComputedOptions (partial) - excluding 'prepare' and 'consume'
|
|
12027
|
-
serializeAs:
|
|
12028
|
-
serialize:
|
|
12029
|
-
meta:
|
|
12041
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
12042
|
+
serialize: Q_.function().optional(),
|
|
12043
|
+
meta: Q_.object().optional(),
|
|
12030
12044
|
// Resourceful options
|
|
12031
|
-
propertyKey:
|
|
12032
|
-
readAccessControlFilters:
|
|
12033
|
-
writeAccessControlFilters:
|
|
12034
|
-
nullable:
|
|
12035
|
-
description:
|
|
12036
|
-
default:
|
|
12037
|
-
externalDocs:
|
|
12038
|
-
description:
|
|
12039
|
-
url:
|
|
12045
|
+
propertyKey: Q_.string().default(""),
|
|
12046
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12047
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12048
|
+
nullable: Q_.boolean().default(false),
|
|
12049
|
+
description: Q_.string().optional(),
|
|
12050
|
+
default: Q_.any().optional(),
|
|
12051
|
+
externalDocs: Q_.object({
|
|
12052
|
+
description: Q_.string().optional(),
|
|
12053
|
+
url: Q_.string().uri().required()
|
|
12040
12054
|
}).optional(),
|
|
12041
|
-
example:
|
|
12042
|
-
deprecated:
|
|
12055
|
+
example: Q_.string().optional(),
|
|
12056
|
+
deprecated: Q_.boolean().default(false),
|
|
12043
12057
|
type: resourcefulDataTypeSchema.optional()
|
|
12044
12058
|
});
|
|
12045
12059
|
const baseDateComputedOptionsSchema = dataTypeComputedOptionsSchema.keys({
|
|
12046
|
-
autoCreate:
|
|
12047
|
-
autoUpdate:
|
|
12060
|
+
autoCreate: Q_.boolean().default(false),
|
|
12061
|
+
autoUpdate: Q_.boolean().default(false)
|
|
12048
12062
|
});
|
|
12049
12063
|
const stringComputedOptionsSchema = dataTypeComputedOptionsSchema.keys({
|
|
12050
|
-
type:
|
|
12064
|
+
type: Q_.alternatives(
|
|
12051
12065
|
...joiInstanceCheckerAlternativesFactory(ResourcefulStringType, "ResourcefulStringType")
|
|
12052
12066
|
).default(() => new ResourcefulStringType())
|
|
12053
12067
|
});
|
|
12054
12068
|
const dateComputedOptionsSchema = baseDateComputedOptionsSchema.keys({
|
|
12055
|
-
type:
|
|
12069
|
+
type: Q_.alternatives(
|
|
12056
12070
|
...joiInstanceCheckerAlternativesFactory(ResourcefulDateType, "ResourcefulDateType")
|
|
12057
12071
|
).default(() => new ResourcefulDateType())
|
|
12058
12072
|
});
|
|
12059
12073
|
const dateTimeComputedOptionsSchema = baseDateComputedOptionsSchema.keys({
|
|
12060
|
-
type:
|
|
12074
|
+
type: Q_.alternatives(
|
|
12061
12075
|
...joiInstanceCheckerAlternativesFactory(ResourcefulDateTimeType, "ResourcefulDateTimeType")
|
|
12062
12076
|
).default(() => new ResourcefulDateTimeType())
|
|
12063
12077
|
});
|
|
12064
12078
|
const binaryComputedOptionsSchema = dataTypeComputedOptionsSchema.keys({
|
|
12065
|
-
type:
|
|
12079
|
+
type: Q_.alternatives(
|
|
12066
12080
|
...joiInstanceCheckerAlternativesFactory(ResourcefulBinaryType, "ResourcefulBinaryType")
|
|
12067
12081
|
).default(() => new ResourcefulBinaryType())
|
|
12068
12082
|
});
|
|
12069
12083
|
const numberComputedOptionsSchema = dataTypeComputedOptionsSchema.keys({
|
|
12070
|
-
type:
|
|
12084
|
+
type: Q_.alternatives(
|
|
12071
12085
|
...joiInstanceCheckerAlternativesFactory(ResourcefulNumberType, "ResourcefulNumberType")
|
|
12072
12086
|
).default(() => new ResourcefulNumberType())
|
|
12073
12087
|
});
|
|
12074
12088
|
const integerComputedOptionsSchema = dataTypeComputedOptionsSchema.keys({
|
|
12075
|
-
type:
|
|
12089
|
+
type: Q_.alternatives(
|
|
12076
12090
|
...joiInstanceCheckerAlternativesFactory(ResourcefulIntegerType, "ResourcefulIntegerType")
|
|
12077
12091
|
).default(() => new ResourcefulIntegerType())
|
|
12078
12092
|
});
|
|
12079
12093
|
const bigintComputedOptionsSchema = dataTypeComputedOptionsSchema.keys({
|
|
12080
|
-
type:
|
|
12094
|
+
type: Q_.alternatives(
|
|
12081
12095
|
...joiInstanceCheckerAlternativesFactory(ResourcefulBigintType, "ResourcefulBigintType")
|
|
12082
12096
|
).default(() => new ResourcefulBigintType())
|
|
12083
12097
|
});
|
|
12084
12098
|
const unsignedIntegerComputedOptionsSchema = dataTypeComputedOptionsSchema.keys({
|
|
12085
|
-
type:
|
|
12099
|
+
type: Q_.alternatives(
|
|
12086
12100
|
...joiInstanceCheckerAlternativesFactory(
|
|
12087
12101
|
ResourcefulUnsignedIntegerType,
|
|
12088
12102
|
"ResourcefulUnsignedIntegerType"
|
|
@@ -12090,99 +12104,99 @@ const unsignedIntegerComputedOptionsSchema = dataTypeComputedOptionsSchema.keys(
|
|
|
12090
12104
|
).default(() => new ResourcefulUnsignedIntegerType())
|
|
12091
12105
|
});
|
|
12092
12106
|
const booleanComputedOptionsSchema = dataTypeComputedOptionsSchema.keys({
|
|
12093
|
-
type:
|
|
12107
|
+
type: Q_.alternatives(
|
|
12094
12108
|
...joiInstanceCheckerAlternativesFactory(ResourcefulBooleanType, "ResourcefulBooleanType")
|
|
12095
12109
|
).default(() => new ResourcefulBooleanType())
|
|
12096
12110
|
});
|
|
12097
|
-
const objectComputedOptionsSchema =
|
|
12111
|
+
const objectComputedOptionsSchema = Q_.object({
|
|
12098
12112
|
// Lucid ComputedOptions (full)
|
|
12099
|
-
serializeAs:
|
|
12100
|
-
serialize:
|
|
12101
|
-
meta:
|
|
12113
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
12114
|
+
serialize: Q_.function().optional(),
|
|
12115
|
+
meta: Q_.object().optional(),
|
|
12102
12116
|
// Resourceful options
|
|
12103
|
-
propertyKey:
|
|
12104
|
-
readAccessControlFilters:
|
|
12105
|
-
writeAccessControlFilters:
|
|
12106
|
-
nullable:
|
|
12107
|
-
description:
|
|
12108
|
-
default:
|
|
12109
|
-
externalDocs:
|
|
12110
|
-
description:
|
|
12111
|
-
url:
|
|
12117
|
+
propertyKey: Q_.string().default(""),
|
|
12118
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12119
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12120
|
+
nullable: Q_.boolean().default(false),
|
|
12121
|
+
description: Q_.string().optional(),
|
|
12122
|
+
default: Q_.any().optional(),
|
|
12123
|
+
externalDocs: Q_.object({
|
|
12124
|
+
description: Q_.string().optional(),
|
|
12125
|
+
url: Q_.string().uri().required()
|
|
12112
12126
|
}).optional(),
|
|
12113
|
-
example:
|
|
12114
|
-
deprecated:
|
|
12115
|
-
type:
|
|
12127
|
+
example: Q_.string().optional(),
|
|
12128
|
+
deprecated: Q_.boolean().default(false),
|
|
12129
|
+
type: Q_.alternatives(
|
|
12116
12130
|
...joiInstanceCheckerAlternativesFactory(ResourcefulObjectType, "ResourcefulObjectType")
|
|
12117
12131
|
).default(() => new ResourcefulObjectType())
|
|
12118
12132
|
});
|
|
12119
|
-
const arrayComputedOptionsSchema =
|
|
12133
|
+
const arrayComputedOptionsSchema = Q_.object({
|
|
12120
12134
|
// Lucid ComputedOptions (full)
|
|
12121
|
-
serializeAs:
|
|
12122
|
-
serialize:
|
|
12123
|
-
meta:
|
|
12135
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
12136
|
+
serialize: Q_.function().optional(),
|
|
12137
|
+
meta: Q_.object().optional(),
|
|
12124
12138
|
// Resourceful options
|
|
12125
|
-
propertyKey:
|
|
12126
|
-
readAccessControlFilters:
|
|
12127
|
-
writeAccessControlFilters:
|
|
12128
|
-
nullable:
|
|
12129
|
-
description:
|
|
12130
|
-
default:
|
|
12131
|
-
externalDocs:
|
|
12132
|
-
description:
|
|
12133
|
-
url:
|
|
12139
|
+
propertyKey: Q_.string().default(""),
|
|
12140
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12141
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12142
|
+
nullable: Q_.boolean().default(false),
|
|
12143
|
+
description: Q_.string().optional(),
|
|
12144
|
+
default: Q_.any().optional(),
|
|
12145
|
+
externalDocs: Q_.object({
|
|
12146
|
+
description: Q_.string().optional(),
|
|
12147
|
+
url: Q_.string().uri().required()
|
|
12134
12148
|
}).optional(),
|
|
12135
|
-
example:
|
|
12136
|
-
deprecated:
|
|
12137
|
-
type:
|
|
12149
|
+
example: Q_.string().optional(),
|
|
12150
|
+
deprecated: Q_.boolean().default(false),
|
|
12151
|
+
type: Q_.alternatives(
|
|
12138
12152
|
...joiInstanceCheckerAlternativesFactory(ResourcefulArrayType, "ResourcefulArrayType")
|
|
12139
12153
|
).default(() => new ResourcefulArrayType())
|
|
12140
12154
|
});
|
|
12141
|
-
const resourcefulRelationshipOptionsSchema =
|
|
12155
|
+
const resourcefulRelationshipOptionsSchema = Q_.object({
|
|
12142
12156
|
// Resourceful options
|
|
12143
|
-
propertyKey:
|
|
12144
|
-
readAccessControlFilters:
|
|
12145
|
-
writeAccessControlFilters:
|
|
12146
|
-
nullable:
|
|
12147
|
-
description:
|
|
12148
|
-
default:
|
|
12149
|
-
externalDocs:
|
|
12150
|
-
description:
|
|
12151
|
-
url:
|
|
12157
|
+
propertyKey: Q_.string().default(""),
|
|
12158
|
+
readAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12159
|
+
writeAccessControlFilters: Q_.array().items(Q_.function()).default([]),
|
|
12160
|
+
nullable: Q_.boolean().default(false),
|
|
12161
|
+
description: Q_.string().optional(),
|
|
12162
|
+
default: Q_.any().optional(),
|
|
12163
|
+
externalDocs: Q_.object({
|
|
12164
|
+
description: Q_.string().optional(),
|
|
12165
|
+
url: Q_.string().uri().required()
|
|
12152
12166
|
}).optional(),
|
|
12153
|
-
example:
|
|
12154
|
-
deprecated:
|
|
12167
|
+
example: Q_.string().optional(),
|
|
12168
|
+
deprecated: Q_.boolean().default(false)
|
|
12155
12169
|
});
|
|
12156
12170
|
const relationOptionsSchema = resourcefulRelationshipOptionsSchema.keys({
|
|
12157
12171
|
// Lucid RelationOptions
|
|
12158
|
-
localKey:
|
|
12159
|
-
foreignKey:
|
|
12160
|
-
serializeAs:
|
|
12161
|
-
onQuery:
|
|
12162
|
-
relatedModel:
|
|
12172
|
+
localKey: Q_.string().optional(),
|
|
12173
|
+
foreignKey: Q_.string().optional(),
|
|
12174
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
12175
|
+
onQuery: Q_.function().optional(),
|
|
12176
|
+
relatedModel: Q_.function()
|
|
12163
12177
|
});
|
|
12164
12178
|
const manyToManyRelationOptionsSchema = resourcefulRelationshipOptionsSchema.keys({
|
|
12165
12179
|
// Lucid ManyToManyRelationOptions
|
|
12166
|
-
localKey:
|
|
12167
|
-
relatedKey:
|
|
12168
|
-
pivotForeignKey:
|
|
12169
|
-
pivotRelatedForeignKey:
|
|
12170
|
-
pivotTable:
|
|
12171
|
-
pivotTimestamps:
|
|
12172
|
-
pivotColumns:
|
|
12173
|
-
serializeAs:
|
|
12174
|
-
onQuery:
|
|
12175
|
-
relatedModel:
|
|
12180
|
+
localKey: Q_.string().optional(),
|
|
12181
|
+
relatedKey: Q_.string().optional(),
|
|
12182
|
+
pivotForeignKey: Q_.string().optional(),
|
|
12183
|
+
pivotRelatedForeignKey: Q_.string().optional(),
|
|
12184
|
+
pivotTable: Q_.string().optional(),
|
|
12185
|
+
pivotTimestamps: Q_.boolean().optional(),
|
|
12186
|
+
pivotColumns: Q_.array().items(Q_.string()).optional(),
|
|
12187
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
12188
|
+
onQuery: Q_.function().optional(),
|
|
12189
|
+
relatedModel: Q_.function()
|
|
12176
12190
|
});
|
|
12177
12191
|
const hasManyThroughRelationOptionsSchema = resourcefulRelationshipOptionsSchema.keys({
|
|
12178
12192
|
// Lucid HasManyThroughRelationOptions (ThroughRelationOptions without throughModel)
|
|
12179
|
-
localKey:
|
|
12180
|
-
foreignKey:
|
|
12181
|
-
throughLocalKey:
|
|
12182
|
-
throughForeignKey:
|
|
12183
|
-
serializeAs:
|
|
12184
|
-
onQuery:
|
|
12185
|
-
relatedModel:
|
|
12193
|
+
localKey: Q_.string().optional(),
|
|
12194
|
+
foreignKey: Q_.string().optional(),
|
|
12195
|
+
throughLocalKey: Q_.string().optional(),
|
|
12196
|
+
throughForeignKey: Q_.string().optional(),
|
|
12197
|
+
serializeAs: Q_.alternatives().try(Q_.string(), Q_.valid(null)).optional(),
|
|
12198
|
+
onQuery: Q_.function().optional(),
|
|
12199
|
+
relatedModel: Q_.function()
|
|
12186
12200
|
});
|
|
12187
12201
|
const extractLucidOptionsForLucidDecorator = (options, keys, overrides) => {
|
|
12188
12202
|
const extracted = {};
|
|
@@ -12737,7 +12751,7 @@ function resourcefulHasManyThrough(model, options = {}) {
|
|
|
12737
12751
|
map.set(propertyKey, opts);
|
|
12738
12752
|
};
|
|
12739
12753
|
}
|
|
12740
|
-
const version = "1.
|
|
12754
|
+
const version = "1.20250724.1";
|
|
12741
12755
|
export {
|
|
12742
12756
|
k as definitions,
|
|
12743
12757
|
w as errors,
|