@nhtio/lucid-resourceful 0.1.0-master-71781cfd → 0.1.0-master-3ec631a4

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.
Files changed (47) hide show
  1. package/{definitions-DgI468dW.cjs → data_type_schemas-BqeljaQB.cjs} +21 -177
  2. package/data_type_schemas-BqeljaQB.cjs.map +1 -0
  3. package/data_type_schemas-Cpco9Zba.js +225 -0
  4. package/data_type_schemas-Cpco9Zba.js.map +1 -0
  5. package/{decorator_utils-U_rZo8tv.cjs → decorator_utils-DSvYjLYD.cjs} +204 -60
  6. package/decorator_utils-DSvYjLYD.cjs.map +1 -0
  7. package/{decorator_utils-YSb1EGJ6.js → decorator_utils-gyymixlk.js} +207 -65
  8. package/decorator_utils-gyymixlk.js.map +1 -0
  9. package/definitions-DcB6B_4d.js +174 -0
  10. package/definitions-DcB6B_4d.js.map +1 -0
  11. package/definitions-DjQRkCeH.cjs +173 -0
  12. package/definitions-DjQRkCeH.cjs.map +1 -0
  13. package/definitions.cjs +1 -1
  14. package/definitions.mjs +11 -11
  15. package/{errors-B1rr67uM.js → errors-C-x5_jRE.js} +162 -27
  16. package/errors-C-x5_jRE.js.map +1 -0
  17. package/{errors-D8jb9VxY.cjs → errors-CNwuNhBV.cjs} +138 -5
  18. package/errors-CNwuNhBV.cjs.map +1 -0
  19. package/errors.cjs +5 -1
  20. package/errors.cjs.map +1 -1
  21. package/errors.d.ts +24 -2
  22. package/errors.mjs +19 -15
  23. package/index.cjs +1380 -652
  24. package/index.cjs.map +1 -1
  25. package/index.mjs +1624 -896
  26. package/index.mjs.map +1 -1
  27. package/joi.cjs +1854 -3368
  28. package/joi.cjs.map +1 -1
  29. package/joi.mjs +1857 -3371
  30. package/joi.mjs.map +1 -1
  31. package/package.json +1 -1
  32. package/private/decorators.d.ts +8 -8
  33. package/private/lucene_to_lucid_translator.d.ts +21 -175
  34. package/private/mixin.d.ts +68 -5
  35. package/private/services/open_api_schema_service.d.ts +111 -0
  36. package/private/type_guards.d.ts +62 -0
  37. package/private/types.d.ts +1 -1
  38. package/private/utils.d.ts +24 -0
  39. package/utils.cjs +1 -1
  40. package/utils.mjs +2 -2
  41. package/decorator_utils-U_rZo8tv.cjs.map +0 -1
  42. package/decorator_utils-YSb1EGJ6.js.map +0 -1
  43. package/definitions-B88XBTUF.js +0 -381
  44. package/definitions-B88XBTUF.js.map +0 -1
  45. package/definitions-DgI468dW.cjs.map +0 -1
  46. package/errors-B1rr67uM.js.map +0 -1
  47. package/errors-D8jb9VxY.cjs.map +0 -1
@@ -1,4 +1,7 @@
1
- import { a as E_UNCASTABLE, b as E_INVALID_PREPARED_VALUE, c as E_INVALID_CONSUMED_VALUE } from "./errors-B1rr67uM.js";
1
+ import { s as stripUndefinedValuesFromObject, a as E_UNCASTABLE, b as E_INVALID_PREPARED_VALUE, c as E_INVALID_CONSUMED_VALUE, i as isString$1 } from "./errors-C-x5_jRE.js";
2
+ import { types } from "node:util";
3
+ import { joi as zu } from "./joi.mjs";
4
+ import { R as ResourcefulStringTypeSchema, a as ResourcefulDateTypeSchema, b as ResourcefulDateTimeTypeSchema, c as ResourcefulBinaryTypeSchema, d as ResourcefulNumberTypeSchema, e as ResourcefulIntegerTypeSchema, f as ResourcefulBigintTypeSchema, g as ResourcefulUnsignedIntegerTypeSchema, h as ResourcefulBooleanTypeSchema, i as ResourcefulObjectTypeSchema, j as ResourcefulArrayTypeSchema } from "./data_type_schemas-Cpco9Zba.js";
2
5
  class LuxonError extends Error {
3
6
  }
4
7
  class InvalidDateTimeError extends LuxonError {
@@ -1095,7 +1098,7 @@ function normalizeZone(input, defaultZone2) {
1095
1098
  return defaultZone2;
1096
1099
  } else if (input instanceof Zone) {
1097
1100
  return input;
1098
- } else if (isString$1(input)) {
1101
+ } else if (isString(input)) {
1099
1102
  const lowered = input.toLowerCase();
1100
1103
  if (lowered === "default") return defaultZone2;
1101
1104
  else if (lowered === "local" || lowered === "system") return SystemZone.instance;
@@ -1491,7 +1494,7 @@ function isNumber(o) {
1491
1494
  function isInteger(o) {
1492
1495
  return typeof o === "number" && o % 1 === 0;
1493
1496
  }
1494
- function isString$1(o) {
1497
+ function isString(o) {
1495
1498
  return typeof o === "string";
1496
1499
  }
1497
1500
  function isDate(o) {
@@ -6387,8 +6390,168 @@ const isInstanceOf = (value, type, ctor) => {
6387
6390
  };
6388
6391
  const isResourcefulModel = (value) => {
6389
6392
  if (!isObject(value) && !(typeof value === "function")) return false;
6390
- const proto = Object.getPrototypeOf(value);
6391
- return (isObject(proto) || typeof proto === "function") && "$resourcefulName" in proto && "string" === typeof proto.$resourcefulName && "$resourcefulColumns" in proto && proto.$resourcefulColumns instanceof Map && "$resourcefulRelationships" in proto && proto.$resourcefulRelationships instanceof Map && "$resourcefulComputedAccessors" in proto && proto.$resourcefulComputedAccessors instanceof Map;
6393
+ if (typeof value === "function") {
6394
+ return "$resourcefulName" in value && "string" === typeof value.$resourcefulName && "$resourcefulColumns" in value && value.$resourcefulColumns instanceof Map && "$resourcefulRelationships" in value && value.$resourcefulRelationships instanceof Map && "$resourcefulComputedAccessors" in value && value.$resourcefulComputedAccessors instanceof Map;
6395
+ }
6396
+ /* istanbul ignore if -- @preserve */
6397
+ if ("constructor" in value) {
6398
+ const constructor = value.constructor;
6399
+ /* istanbul ignore if -- @preserve */
6400
+ if (!constructor || typeof constructor !== "function") return false;
6401
+ return isResourcefulModel(constructor);
6402
+ }
6403
+ /* istanbul ignore next -- @preserve */
6404
+ if (types.isProxy(value)) {
6405
+ const proto = Object.getPrototypeOf(value);
6406
+ return isResourcefulModel(proto);
6407
+ }
6408
+ /* istanbul ignore next -- @preserve */
6409
+ return false;
6410
+ };
6411
+ const BaseDataTypeSchemaFactory = (name, type) => {
6412
+ return zu.object({
6413
+ type: zu.string().allow(type).required(),
6414
+ name: zu.string().allow(name).optional(),
6415
+ schema: zu.object({
6416
+ _cache: zu.required(),
6417
+ _flags: zu.object().unknown(true).required(),
6418
+ _ids: zu.object({
6419
+ _byId: zu.object().instance(Map).required(),
6420
+ _byKey: zu.object().instance(Map).required(),
6421
+ _schemaChain: zu.boolean().required()
6422
+ }).unknown(true).required(),
6423
+ _invalids: zu.required(),
6424
+ _preferences: zu.required(),
6425
+ _refs: zu.object().unknown(true).required(),
6426
+ _rules: zu.array().items(zu.any()).required(),
6427
+ _singleRules: zu.object().instance(Map).required(),
6428
+ _valids: zu.required(),
6429
+ $: zu.required(),
6430
+ $_root: zu.required(),
6431
+ $_super: zu.required(),
6432
+ $_temp: zu.required(),
6433
+ $_terms: zu.required(),
6434
+ ruleset: zu.func().required(),
6435
+ type: zu.string().required()
6436
+ }).unknown(true).optional()
6437
+ }).unknown(true);
6438
+ };
6439
+ const getDataTypeSchemaResults = (value, name, type, schema) => {
6440
+ if (!isObject(value)) return false;
6441
+ if (value.type !== type) return false;
6442
+ const base = BaseDataTypeSchemaFactory(name, type);
6443
+ const { error: errorFromSchema } = schema.validate(
6444
+ stripUndefinedValuesFromObject({
6445
+ ...value,
6446
+ type: void 0,
6447
+ name: void 0,
6448
+ schema: void 0
6449
+ })
6450
+ );
6451
+ const { error: errorFromBase } = base.validate({
6452
+ type: value.type,
6453
+ name: value.name,
6454
+ schema: value.schema
6455
+ });
6456
+ return "undefined" === typeof errorFromSchema && "undefined" === typeof errorFromBase;
6457
+ };
6458
+ const isResourcefulStringType = (value) => {
6459
+ return getDataTypeSchemaResults(
6460
+ value,
6461
+ "ResourcefulStringType",
6462
+ "string",
6463
+ ResourcefulStringTypeSchema()
6464
+ );
6465
+ };
6466
+ const isResourcefulDateType = (value) => {
6467
+ return getDataTypeSchemaResults(
6468
+ value,
6469
+ "ResourcefulDateType",
6470
+ "string",
6471
+ ResourcefulDateTypeSchema().append({
6472
+ format: zu.string().valid("date").required()
6473
+ })
6474
+ );
6475
+ };
6476
+ const isResourcefulDateTimeType = (value) => {
6477
+ return getDataTypeSchemaResults(
6478
+ value,
6479
+ "ResourcefulDateTimeType",
6480
+ "string",
6481
+ ResourcefulDateTimeTypeSchema().append({
6482
+ format: zu.string().valid("date-time").required()
6483
+ })
6484
+ );
6485
+ };
6486
+ const isResourcefulBinaryType = (value) => {
6487
+ return getDataTypeSchemaResults(
6488
+ value,
6489
+ "ResourcefulBinaryType",
6490
+ "string",
6491
+ ResourcefulBinaryTypeSchema().append({
6492
+ format: zu.string().valid("binary").required()
6493
+ })
6494
+ );
6495
+ };
6496
+ const isResourcefulNumberType = (value) => {
6497
+ return getDataTypeSchemaResults(
6498
+ value,
6499
+ "ResourcefulNumberType",
6500
+ "number",
6501
+ ResourcefulNumberTypeSchema()
6502
+ );
6503
+ };
6504
+ const isResourcefulIntegerType = (value) => {
6505
+ return getDataTypeSchemaResults(
6506
+ value,
6507
+ "ResourcefulIntegerType",
6508
+ "integer",
6509
+ ResourcefulIntegerTypeSchema().append({
6510
+ format: zu.string().valid("int32").required()
6511
+ })
6512
+ );
6513
+ };
6514
+ const isResourcefulBigintType = (value) => {
6515
+ return getDataTypeSchemaResults(
6516
+ value,
6517
+ "ResourcefulBigintType",
6518
+ "integer",
6519
+ ResourcefulBigintTypeSchema().append({
6520
+ format: zu.string().valid("int64").required()
6521
+ })
6522
+ );
6523
+ };
6524
+ const isResourcefulUnsignedIntegerType = (value) => {
6525
+ return getDataTypeSchemaResults(
6526
+ value,
6527
+ "ResourcefulUnsignedIntegerType",
6528
+ "integer",
6529
+ ResourcefulUnsignedIntegerTypeSchema()
6530
+ );
6531
+ };
6532
+ const isResourcefulBooleanType = (value) => {
6533
+ return getDataTypeSchemaResults(
6534
+ value,
6535
+ "ResourcefulBooleanType",
6536
+ "boolean",
6537
+ ResourcefulBooleanTypeSchema()
6538
+ );
6539
+ };
6540
+ const isResourcefulObjectType = (value) => {
6541
+ return getDataTypeSchemaResults(
6542
+ value,
6543
+ "ResourcefulObjectType",
6544
+ "object",
6545
+ ResourcefulObjectTypeSchema()
6546
+ );
6547
+ };
6548
+ const isResourcefulArrayType = (value) => {
6549
+ return getDataTypeSchemaResults(
6550
+ value,
6551
+ "ResourcefulArrayType",
6552
+ "array",
6553
+ ResourcefulArrayTypeSchema()
6554
+ );
6392
6555
  };
6393
6556
  const type_guards = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
6394
6557
  __proto__: null,
@@ -6397,45 +6560,19 @@ const type_guards = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineP
6397
6560
  isLucidBinaryValue,
6398
6561
  isLuxonDateTime,
6399
6562
  isObject,
6400
- isResourcefulModel
6563
+ isResourcefulArrayType,
6564
+ isResourcefulBigintType,
6565
+ isResourcefulBinaryType,
6566
+ isResourcefulBooleanType,
6567
+ isResourcefulDateTimeType,
6568
+ isResourcefulDateType,
6569
+ isResourcefulIntegerType,
6570
+ isResourcefulModel,
6571
+ isResourcefulNumberType,
6572
+ isResourcefulObjectType,
6573
+ isResourcefulStringType,
6574
+ isResourcefulUnsignedIntegerType
6401
6575
  }, Symbol.toStringTag, { value: "Module" }));
6402
- var CRUDOperationsEnum = /* @__PURE__ */ ((CRUDOperationsEnum2) => {
6403
- CRUDOperationsEnum2["CREATE"] = "create";
6404
- CRUDOperationsEnum2["READ"] = "read";
6405
- CRUDOperationsEnum2["LIST"] = "list";
6406
- CRUDOperationsEnum2["UPDATE"] = "update";
6407
- CRUDOperationsEnum2["DELETE"] = "delete";
6408
- return CRUDOperationsEnum2;
6409
- })(CRUDOperationsEnum || {});
6410
- var ACLOperationsEnum = /* @__PURE__ */ ((ACLOperationsEnum2) => {
6411
- ACLOperationsEnum2["WRITE"] = "write";
6412
- ACLOperationsEnum2["READ"] = "read";
6413
- return ACLOperationsEnum2;
6414
- })(ACLOperationsEnum || {});
6415
- const operationCRUDToACL = (operation) => {
6416
- if (operation === CRUDOperationsEnum.READ || operation === CRUDOperationsEnum.LIST) {
6417
- return ACLOperationsEnum.READ;
6418
- }
6419
- if (operation === CRUDOperationsEnum.CREATE || operation === CRUDOperationsEnum.UPDATE || operation === CRUDOperationsEnum.DELETE) {
6420
- return ACLOperationsEnum.WRITE;
6421
- }
6422
- };
6423
- const isString = (value) => {
6424
- return typeof value === "string";
6425
- };
6426
- const isFunction = (value) => {
6427
- return typeof value === "function";
6428
- };
6429
- const prepareFields = (fields, primaryKey) => {
6430
- const defaultValue = [primaryKey];
6431
- if (Array.isArray(fields)) {
6432
- return fields.length ? fields : defaultValue;
6433
- }
6434
- if (isString(fields)) {
6435
- return fields.length ? [fields] : defaultValue;
6436
- }
6437
- return defaultValue;
6438
- };
6439
6576
  const castValueAsString = (value) => {
6440
6577
  if ("string" === typeof value) return value;
6441
6578
  if ("number" === typeof value) return value.toString();
@@ -6675,7 +6812,7 @@ function consumeString(key, value, nullable = false) {
6675
6812
  if (true === nullable) {
6676
6813
  return null;
6677
6814
  }
6678
- throw new E_INVALID_CONSUMED_VALUE([key, "String"]);
6815
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "String"]);
6679
6816
  }
6680
6817
  }
6681
6818
  function consumeDate(key, value, nullable = false) {
@@ -6686,7 +6823,7 @@ function consumeDate(key, value, nullable = false) {
6686
6823
  if (true === nullable) {
6687
6824
  return null;
6688
6825
  }
6689
- throw new E_INVALID_CONSUMED_VALUE([key, "Date"]);
6826
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "Date"]);
6690
6827
  }
6691
6828
  }
6692
6829
  function consumeDateTime(key, value, nullable = false) {
@@ -6697,7 +6834,7 @@ function consumeDateTime(key, value, nullable = false) {
6697
6834
  if (true === nullable) {
6698
6835
  return null;
6699
6836
  }
6700
- throw new E_INVALID_CONSUMED_VALUE([key, "DateTime"]);
6837
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "DateTime"]);
6701
6838
  }
6702
6839
  }
6703
6840
  function consumeBinary(key, value, nullable = false) {
@@ -6708,7 +6845,7 @@ function consumeBinary(key, value, nullable = false) {
6708
6845
  if (true === nullable) {
6709
6846
  return null;
6710
6847
  }
6711
- throw new E_INVALID_CONSUMED_VALUE([key, "Binary"]);
6848
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "Binary"]);
6712
6849
  }
6713
6850
  }
6714
6851
  function consumeNumber(key, value, nullable = false) {
@@ -6719,7 +6856,7 @@ function consumeNumber(key, value, nullable = false) {
6719
6856
  if (true === nullable) {
6720
6857
  return null;
6721
6858
  }
6722
- throw new E_INVALID_CONSUMED_VALUE([key, "Number"]);
6859
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "Number"]);
6723
6860
  }
6724
6861
  }
6725
6862
  function consumeInteger(key, value, nullable = false) {
@@ -6730,7 +6867,7 @@ function consumeInteger(key, value, nullable = false) {
6730
6867
  if (true === nullable) {
6731
6868
  return null;
6732
6869
  }
6733
- throw new E_INVALID_CONSUMED_VALUE([key, "Integer"]);
6870
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "Integer"]);
6734
6871
  }
6735
6872
  }
6736
6873
  function consumeBigint(key, value, nullable = false) {
@@ -6741,7 +6878,7 @@ function consumeBigint(key, value, nullable = false) {
6741
6878
  if (true === nullable) {
6742
6879
  return null;
6743
6880
  }
6744
- throw new E_INVALID_CONSUMED_VALUE([key, "Bigint"]);
6881
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "Bigint"]);
6745
6882
  }
6746
6883
  }
6747
6884
  function consumeUnsignedint(key, value, nullable = false) {
@@ -6752,7 +6889,7 @@ function consumeUnsignedint(key, value, nullable = false) {
6752
6889
  if (true === nullable) {
6753
6890
  return null;
6754
6891
  }
6755
- throw new E_INVALID_CONSUMED_VALUE([key, "Unsignedint"]);
6892
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "Unsignedint"]);
6756
6893
  }
6757
6894
  }
6758
6895
  function consumeBoolean(key, value, nullable = false) {
@@ -6763,13 +6900,13 @@ function consumeBoolean(key, value, nullable = false) {
6763
6900
  if (true === nullable) {
6764
6901
  return null;
6765
6902
  }
6766
- throw new E_INVALID_CONSUMED_VALUE([key, "Boolean"]);
6903
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "Boolean"]);
6767
6904
  }
6768
6905
  }
6769
6906
  function consumeObject(key, value, nullable = false) {
6770
6907
  if (value === null && nullable === true) return null;
6771
6908
  try {
6772
- if (isString(value)) {
6909
+ if (isString$1(value)) {
6773
6910
  value = JSON.parse(value);
6774
6911
  }
6775
6912
  return castValueAsObject(value);
@@ -6777,7 +6914,7 @@ function consumeObject(key, value, nullable = false) {
6777
6914
  if (true === nullable) {
6778
6915
  return null;
6779
6916
  }
6780
- throw new E_INVALID_CONSUMED_VALUE([key, "Object"]);
6917
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "Object"]);
6781
6918
  }
6782
6919
  }
6783
6920
  function consumeArray(key, value, nullable = false) {
@@ -6788,7 +6925,7 @@ function consumeArray(key, value, nullable = false) {
6788
6925
  if (true === nullable) {
6789
6926
  return null;
6790
6927
  }
6791
- throw new E_INVALID_CONSUMED_VALUE([key, "Array"]);
6928
+ throw new E_INVALID_CONSUMED_VALUE([key, value, "Array"]);
6792
6929
  }
6793
6930
  }
6794
6931
  export {
@@ -6800,15 +6937,20 @@ export {
6800
6937
  consumeString as F,
6801
6938
  consumeUnsignedint as G,
6802
6939
  type_guards as H,
6803
- isObject as I,
6804
- isResourcefulModel as J,
6805
- CRUDOperationsEnum as K,
6806
- operationCRUDToACL as L,
6807
- ACLOperationsEnum as M,
6808
- isFunction as N,
6809
- prepareFields as O,
6810
- isString as P,
6811
- DateTime as Q,
6940
+ isResourcefulModel as I,
6941
+ isResourcefulArrayType as J,
6942
+ isResourcefulObjectType as K,
6943
+ isObject as L,
6944
+ isResourcefulBooleanType as M,
6945
+ isResourcefulNumberType as N,
6946
+ isResourcefulUnsignedIntegerType as O,
6947
+ isResourcefulBigintType as P,
6948
+ isResourcefulIntegerType as Q,
6949
+ isResourcefulStringType as R,
6950
+ isResourcefulBinaryType as S,
6951
+ isResourcefulDateTimeType as T,
6952
+ isResourcefulDateType as U,
6953
+ DateTime as V,
6812
6954
  castValueAsBigint as a,
6813
6955
  castValueAsBinary as b,
6814
6956
  castValueAsArray as c,
@@ -6836,4 +6978,4 @@ export {
6836
6978
  consumeBinary as y,
6837
6979
  consumeBoolean as z
6838
6980
  };
6839
- //# sourceMappingURL=decorator_utils-YSb1EGJ6.js.map
6981
+ //# sourceMappingURL=decorator_utils-gyymixlk.js.map