@routier/core 0.2.0 → 0.2.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.
Files changed (85) hide show
  1. package/dist/assertions/index.d.ts +30 -0
  2. package/dist/assertions/index.js +88 -4
  3. package/dist/assertions/index.js.map +1 -1
  4. package/dist/capabilities/index.js +25 -16
  5. package/dist/capabilities/index.js.map +1 -1
  6. package/dist/codegen/blocks.test.d.ts +1 -0
  7. package/dist/codegen/handlers/SetHandlerBuilder.d.ts +4 -0
  8. package/dist/codegen/handlers/index.d.ts +1 -0
  9. package/dist/codegen/handlers/serialize/SerializeComputedHandler.d.ts +6 -0
  10. package/dist/codegen/handlers/set/SetComplexHandler.d.ts +6 -0
  11. package/dist/codegen/index.js +1 -0
  12. package/dist/codegen/index.js.map +1 -1
  13. package/dist/codegen/utils.test.d.ts +1 -0
  14. package/dist/collections/Changes.d.ts +2 -2
  15. package/dist/collections/IdSet.test.d.ts +1 -0
  16. package/dist/collections/TagCollection.contract.test.d.ts +1 -0
  17. package/dist/collections/TagCollection.d.ts +7 -7
  18. package/dist/collections/index.js +1 -1
  19. package/dist/collections/index.js.map +1 -1
  20. package/dist/expressions/constants.d.ts +2 -0
  21. package/dist/expressions/index.d.ts +2 -0
  22. package/dist/expressions/index.js +401 -34
  23. package/dist/expressions/index.js.map +1 -1
  24. package/dist/expressions/sql.d.ts +28 -0
  25. package/dist/expressions/sql.test.d.ts +1 -0
  26. package/dist/expressions/utils.d.ts +1 -2
  27. package/dist/index.js +1669 -610
  28. package/dist/index.js.map +1 -1
  29. package/dist/performance/index.js +18 -7
  30. package/dist/performance/index.js.map +1 -1
  31. package/dist/pipeline/index.js +18 -7
  32. package/dist/pipeline/index.js.map +1 -1
  33. package/dist/plugins/index.d.ts +0 -1
  34. package/dist/plugins/index.js +126 -694
  35. package/dist/plugins/index.js.map +1 -1
  36. package/dist/plugins/query/Query.test.d.ts +1 -0
  37. package/dist/plugins/query/QueryOptionsCollection.d.ts +1 -0
  38. package/dist/plugins/translators/SqlTranslator.test.d.ts +1 -0
  39. package/dist/plugins/translators/TranslatedArrayValue.d.ts +3 -1
  40. package/dist/plugins/translators/TranslatedGroupValue.d.ts +3 -1
  41. package/dist/plugins/translators/TranslatedSingleValue.d.ts +3 -1
  42. package/dist/plugins/translators/TranslatedValues.test.d.ts +1 -0
  43. package/dist/plugins/translators/types.d.ts +8 -1
  44. package/dist/plugins/types.d.ts +6 -10
  45. package/dist/results/Result.d.ts +2 -2
  46. package/dist/results/Result.test.d.ts +1 -0
  47. package/dist/results/index.js.map +1 -1
  48. package/dist/results/utils.test.d.ts +1 -0
  49. package/dist/schema/PropertyInfo.d.ts +5 -1
  50. package/dist/schema/SchemaDefinition.d.ts +29 -1
  51. package/dist/schema/communication/broadcast.test.d.ts +1 -0
  52. package/dist/schema/index.d.ts +2 -0
  53. package/dist/schema/index.js +1151 -132
  54. package/dist/schema/index.js.map +1 -1
  55. package/dist/schema/property/base/SchemaBase.d.ts +3 -1
  56. package/dist/schema/property/modifiers/SchemaDeserialize.d.ts +5 -1
  57. package/dist/schema/property/modifiers/SchemaForeignKey.d.ts +15 -0
  58. package/dist/schema/property/modifiers/SchemaKey.d.ts +2 -0
  59. package/dist/schema/property/modifiers/SchemaNullable.d.ts +5 -1
  60. package/dist/schema/property/modifiers/SchemaOptional.d.ts +3 -1
  61. package/dist/schema/property/modifiers/SchemaTag.d.ts +27 -0
  62. package/dist/schema/property/modifiers/SchemaTracked.d.ts +5 -1
  63. package/dist/schema/property/modifiers/index.d.ts +2 -0
  64. package/dist/schema/property/types/SchemaArray.d.ts +2 -0
  65. package/dist/schema/property/types/SchemaBoolean.d.ts +2 -0
  66. package/dist/schema/property/types/SchemaDate.d.ts +2 -0
  67. package/dist/schema/property/types/SchemaNumber.d.ts +5 -1
  68. package/dist/schema/property/types/SchemaObject.d.ts +2 -0
  69. package/dist/schema/property/types/SchemaString.d.ts +5 -1
  70. package/dist/schema/types.d.ts +37 -27
  71. package/dist/schema/utils/standardJsonSchema.d.ts +90 -0
  72. package/dist/schema/utils/standardJsonSchema.test.d.ts +1 -0
  73. package/dist/utilities/functions.d.ts +1 -1
  74. package/dist/utilities/index.js +153 -15
  75. package/dist/utilities/index.js.map +1 -1
  76. package/dist/utilities/runtime.test.d.ts +1 -0
  77. package/dist/utilities/uuid.test.d.ts +1 -0
  78. package/package.json +2 -2
  79. package/readme.md +1 -1
  80. package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +0 -23
  81. package/dist/plugins/replication/ReplicationDbPlugin.d.ts +0 -22
  82. package/dist/plugins/replication/index.d.ts +0 -3
  83. package/dist/plugins/replication/types.d.ts +0 -5
  84. package/dist/schema/testSchemas.test.d.ts +0 -314
  85. /package/dist/{pipeline/WorkPipeline.test.d.ts → codegen/SlotPath.test.d.ts} +0 -0
@@ -78,6 +78,7 @@ class Block {
78
78
  return this._lines.find(w => typeof w !== "string" && w.name === name);
79
79
  }
80
80
  const split = name.match(/(\[[^\]]+\]|[^.]+)/g);
81
+ // oxlint-disable-next-line no-this-alias
81
82
  let result = this;
82
83
  for (const item of split) {
83
84
  const found = result._lines.find(w => typeof w !== "string" && w.name === item);
@@ -832,11 +833,13 @@ __webpack_require__.r(__webpack_exports__);
832
833
  __webpack_require__.d(__webpack_exports__, {
833
834
  SerializeHandlerBuilder: () => (SerializeHandlerBuilder)
834
835
  });
835
- /* import */ var _serialize_SerializeDateHandler__rspack_import_2 = __webpack_require__("./src/codegen/handlers/serialize/SerializeDateHandler.ts");
836
- /* import */ var _serialize_SerializeObjectHandler__rspack_import_4 = __webpack_require__("./src/codegen/handlers/serialize/SerializeObjectHandler.ts");
837
- /* import */ var _serialize_SerializeValueHandler__rspack_import_3 = __webpack_require__("./src/codegen/handlers/serialize/SerializeValueHandler.ts");
836
+ /* import */ var _serialize_SerializeDateHandler__rspack_import_3 = __webpack_require__("./src/codegen/handlers/serialize/SerializeDateHandler.ts");
837
+ /* import */ var _serialize_SerializeObjectHandler__rspack_import_5 = __webpack_require__("./src/codegen/handlers/serialize/SerializeObjectHandler.ts");
838
+ /* import */ var _serialize_SerializeValueHandler__rspack_import_4 = __webpack_require__("./src/codegen/handlers/serialize/SerializeValueHandler.ts");
838
839
  /* import */ var _serialize_SerializeSerializerHandler__rspack_import_0 = __webpack_require__("./src/codegen/handlers/serialize/SerializeSerializerHandler.ts");
839
- /* import */ var _serialize_SerializeFunctionHandler__rspack_import_1 = __webpack_require__("./src/codegen/handlers/serialize/SerializeFunctionHandler.ts");
840
+ /* import */ var _serialize_SerializeFunctionHandler__rspack_import_2 = __webpack_require__("./src/codegen/handlers/serialize/SerializeFunctionHandler.ts");
841
+ /* import */ var _serialize_SerializeComputedHandler__rspack_import_1 = __webpack_require__("./src/codegen/handlers/serialize/SerializeComputedHandler.ts");
842
+
840
843
 
841
844
 
842
845
 
@@ -847,10 +850,27 @@ class SerializeHandlerBuilder {
847
850
  build() {
848
851
  const handler = new _serialize_SerializeSerializerHandler__rspack_import_0.SerializeSerializerHandler();
849
852
  handler
850
- .setNext(new _serialize_SerializeFunctionHandler__rspack_import_1.SerializeFunctionHandler())
851
- .setNext(new _serialize_SerializeDateHandler__rspack_import_2.SerializeDateHandler())
852
- .setNext(new _serialize_SerializeValueHandler__rspack_import_3.SerializeValueHandler())
853
- .setNext(new _serialize_SerializeObjectHandler__rspack_import_4.SerializeObjectHandler());
853
+ .setNext(new _serialize_SerializeComputedHandler__rspack_import_1.SerializeComputedHandler())
854
+ .setNext(new _serialize_SerializeFunctionHandler__rspack_import_2.SerializeFunctionHandler())
855
+ .setNext(new _serialize_SerializeDateHandler__rspack_import_3.SerializeDateHandler())
856
+ .setNext(new _serialize_SerializeValueHandler__rspack_import_4.SerializeValueHandler())
857
+ .setNext(new _serialize_SerializeObjectHandler__rspack_import_5.SerializeObjectHandler());
858
+ return handler;
859
+ }
860
+ }
861
+
862
+
863
+ },
864
+ "./src/codegen/handlers/SetHandlerBuilder.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
865
+ __webpack_require__.r(__webpack_exports__);
866
+ __webpack_require__.d(__webpack_exports__, {
867
+ SetHandlerBuilder: () => (SetHandlerBuilder)
868
+ });
869
+ /* import */ var _set_SetComplexHandler__rspack_import_0 = __webpack_require__("./src/codegen/handlers/set/SetComplexHandler.ts");
870
+
871
+ class SetHandlerBuilder {
872
+ build() {
873
+ const handler = new _set_SetComplexHandler__rspack_import_0.SetComplexHandler();
854
874
  return handler;
855
875
  }
856
876
  }
@@ -2147,6 +2167,27 @@ class PrepareValueHandler extends _types__rspack_import_0.PropertyInfoHandler {
2147
2167
  }
2148
2168
 
2149
2169
 
2170
+ },
2171
+ "./src/codegen/handlers/serialize/SerializeComputedHandler.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2172
+ __webpack_require__.r(__webpack_exports__);
2173
+ __webpack_require__.d(__webpack_exports__, {
2174
+ SerializeComputedHandler: () => (SerializeComputedHandler)
2175
+ });
2176
+ /* import */ var _types__rspack_import_0 = __webpack_require__("./src/codegen/handlers/types.ts");
2177
+ /* import */ var _schema__rspack_import_1 = __webpack_require__("./src/schema/types.ts");
2178
+
2179
+
2180
+ class SerializeComputedHandler extends _types__rspack_import_0.PropertyInfoHandler {
2181
+ handle(property, builder) {
2182
+ if (property.type === _schema__rspack_import_1.SchemaTypes.Computed && property.isUnmapped === true) {
2183
+ // Do not serialize computed properties that are unmapped
2184
+ return builder;
2185
+ }
2186
+ return super.handle(property, builder);
2187
+ }
2188
+ }
2189
+
2190
+
2150
2191
  },
2151
2192
  "./src/codegen/handlers/serialize/SerializeDateHandler.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2152
2193
  __webpack_require__.r(__webpack_exports__);
@@ -2171,7 +2212,7 @@ class SerializeDateHandler extends _types__rspack_import_0.PropertyInfoHandler {
2171
2212
  const entityAssignmentPath = property.getAssignmentPath({
2172
2213
  parent: "result"
2173
2214
  });
2174
- const assignment = `${property.name}: ${entitySelectorPath} instanceof Date ? ${entitySelectorPath}.toISOString() : ${entitySelectorPath}`;
2215
+ const _assignment = `${property.name}: ${entitySelectorPath} instanceof Date ? ${entitySelectorPath}.toISOString() : ${entitySelectorPath}`;
2175
2216
  // if it is nullable or optional, assign in an if block, otherwise we
2176
2217
  // could unintentionally assign null/undefined to a property that does not exist
2177
2218
  if (property.isOptional || property.isNullable) {
@@ -2310,7 +2351,9 @@ class SerializeValueHandler extends _types__rspack_import_0.PropertyInfoHandler
2310
2351
  }
2311
2352
  const parentSelectPath = ["entity", ...property.getParentPathArray()].join(".");
2312
2353
  const parentAssignPath = ["result", ...property.getParentPathArray()].join(".");
2313
- const ifSlot = slot.if(`Object.hasOwn(${parentSelectPath}, "${property.name}")`);
2354
+ // We need to handle serializing delta changes in getChanges, there is the possibility that child objects are null
2355
+ // and we need to handle that scenario
2356
+ const ifSlot = slot.if(`${parentSelectPath} != null && Object.hasOwn(${parentSelectPath}, "${property.name}")`);
2314
2357
  if (property.parent.isNullable || property.parent.isOptional) {
2315
2358
  // Do this for nullable/optional parents. Parent will be null if its nullable/optional
2316
2359
  const conditionallyCreateParent = new _blocks__rspack_import_2.IfBuilder(`${parentAssignPath} == null`).appendBody(`${parentAssignPath} = {}`);
@@ -2324,6 +2367,39 @@ class SerializeValueHandler extends _types__rspack_import_0.PropertyInfoHandler
2324
2367
  }
2325
2368
 
2326
2369
 
2370
+ },
2371
+ "./src/codegen/handlers/set/SetComplexHandler.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2372
+ __webpack_require__.r(__webpack_exports__);
2373
+ __webpack_require__.d(__webpack_exports__, {
2374
+ SetComplexHandler: () => (SetComplexHandler)
2375
+ });
2376
+ /* import */ var _types__rspack_import_1 = __webpack_require__("./src/codegen/handlers/types.ts");
2377
+ /* import */ var _schema_types__rspack_import_0 = __webpack_require__("./src/schema/types.ts");
2378
+
2379
+
2380
+ const allowedTypes = new Set([
2381
+ _schema_types__rspack_import_0.SchemaTypes.Array,
2382
+ _schema_types__rspack_import_0.SchemaTypes.Boolean,
2383
+ _schema_types__rspack_import_0.SchemaTypes.Date,
2384
+ _schema_types__rspack_import_0.SchemaTypes.Number,
2385
+ _schema_types__rspack_import_0.SchemaTypes.Object,
2386
+ _schema_types__rspack_import_0.SchemaTypes.String
2387
+ ]);
2388
+ class SetComplexHandler extends _types__rspack_import_1.PropertyInfoHandler {
2389
+ handle(property, builder) {
2390
+ if (allowedTypes.has(property.type)) {
2391
+ const selectorPath = property.getSelectrorPath({ parent: "source", assignmentType: "FORCE_NULLABLE_OR_OPTIONAL" });
2392
+ const slot = builder.get("assignments");
2393
+ const entitySelectorPath = property.getAssignmentPath({ parent: "source" });
2394
+ const enrichedAssignmentPath = property.getAssignmentPath({ parent: "destination" });
2395
+ slot.if(`${selectorPath} != null`).appendBody(`${enrichedAssignmentPath} = ${entitySelectorPath}`);
2396
+ return builder;
2397
+ }
2398
+ return super.handle(property, builder);
2399
+ }
2400
+ }
2401
+
2402
+
2327
2403
  },
2328
2404
  "./src/codegen/handlers/strip/StripIdentityHandler.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
2329
2405
  __webpack_require__.r(__webpack_exports__);
@@ -2692,6 +2768,8 @@ class PropertyInfo {
2692
2768
  isOptional;
2693
2769
  /** Whether the property is a key. */
2694
2770
  isKey;
2771
+ /** Foreign key schema and property */
2772
+ foreignKeyDefinition;
2695
2773
  /** Whether the property is an identity property. */
2696
2774
  isIdentity;
2697
2775
  /** Whether the property is readonly. */
@@ -2720,6 +2798,8 @@ class PropertyInfo {
2720
2798
  innerSchema;
2721
2799
  /** Literal values allowed for this property. */
2722
2800
  literals;
2801
+ /** Tags passed from the schema */
2802
+ tags;
2723
2803
  /** The parent property, if any. */
2724
2804
  parent;
2725
2805
  // Cached computed values for performance
@@ -2747,6 +2827,8 @@ class PropertyInfo {
2747
2827
  this.isDistinct = schema.isDistict;
2748
2828
  this.indexes = schema.indexes;
2749
2829
  this.from = schema.fromPropertyName;
2830
+ this.tags = schema.tags;
2831
+ this.foreignKeyDefinition = schema.foreignKeyDefinition;
2750
2832
  this.defaultValue = schema.defaultValue;
2751
2833
  this.valueSerializer = schema.valueSerializer;
2752
2834
  this.valueDeserializer = schema.valueDeserializer;
@@ -2766,6 +2848,7 @@ class PropertyInfo {
2766
2848
  return this._levelCache;
2767
2849
  }
2768
2850
  let level = 0;
2851
+ // oxlint-disable-next-line no-this-alias
2769
2852
  let current = this;
2770
2853
  while (current) {
2771
2854
  if (current.parent == null) {
@@ -2789,6 +2872,7 @@ class PropertyInfo {
2789
2872
  return this._propertyChainCache;
2790
2873
  }
2791
2874
  const chain = [];
2875
+ // oxlint-disable-next-line no-this-alias
2792
2876
  let current = this;
2793
2877
  while (current) {
2794
2878
  chain.unshift(current);
@@ -3006,30 +3090,34 @@ __webpack_require__.r(__webpack_exports__);
3006
3090
  __webpack_require__.d(__webpack_exports__, {
3007
3091
  SchemaDefinition: () => (SchemaDefinition)
3008
3092
  });
3009
- /* import */ var _table_SchemaFunction__rspack_import_3 = __webpack_require__("./src/schema/table/SchemaFunction.ts");
3010
- /* import */ var _table_SchemaComputed__rspack_import_4 = __webpack_require__("./src/schema/table/SchemaComputed.ts");
3093
+ /* import */ var _table_SchemaFunction__rspack_import_4 = __webpack_require__("./src/schema/table/SchemaFunction.ts");
3094
+ /* import */ var _table_SchemaComputed__rspack_import_5 = __webpack_require__("./src/schema/table/SchemaComputed.ts");
3011
3095
  /* import */ var _property_base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
3012
- /* import */ var _PropertyInfo__rspack_import_5 = __webpack_require__("./src/schema/PropertyInfo.ts");
3013
- /* import */ var _codegen__rspack_import_20 = __webpack_require__("./src/codegen/blocks.ts");
3014
- /* import */ var _codegen_handlers_EnrichmentHandlerBuilder__rspack_import_6 = __webpack_require__("./src/codegen/handlers/EnrichmentHandlerBuilder.ts");
3015
- /* import */ var _codegen_handlers_MergeHandlerBuilder__rspack_import_7 = __webpack_require__("./src/codegen/handlers/MergeHandlerBuilder.ts");
3016
- /* import */ var _codegen_handlers_PrepareHandlerBuilder__rspack_import_8 = __webpack_require__("./src/codegen/handlers/PrepareHandlerBuilder.ts");
3017
- /* import */ var _codegen_handlers_StripHandlerBuilder__rspack_import_9 = __webpack_require__("./src/codegen/handlers/StripHandlerBuilder.ts");
3018
- /* import */ var _codegen_handlers_CloneHandlerBuilder__rspack_import_10 = __webpack_require__("./src/codegen/handlers/CloneHandlerBuilder.ts");
3019
- /* import */ var _codegen_handlers_CompareHandlerBuilder__rspack_import_11 = __webpack_require__("./src/codegen/handlers/CompareHandlerBuilder.ts");
3020
- /* import */ var _codegen_handlers_DeserializeHandlerBuilder__rspack_import_12 = __webpack_require__("./src/codegen/handlers/DeserializeHandlerBuilder.ts");
3021
- /* import */ var _codegen_handlers_HashTypeHandlerBuilder__rspack_import_13 = __webpack_require__("./src/codegen/handlers/HashTypeHandlerBuilder.ts");
3022
- /* import */ var _codegen_handlers_IdSelectorHandlerBuilder__rspack_import_14 = __webpack_require__("./src/codegen/handlers/IdSelectorHandlerBuilder.ts");
3023
- /* import */ var _codegen_handlers_HashHandlerBuilder__rspack_import_15 = __webpack_require__("./src/codegen/handlers/HashHandlerBuilder.ts");
3024
- /* import */ var _codegen_handlers_EnableChangeTrackingHandlerBuilder__rspack_import_16 = __webpack_require__("./src/codegen/handlers/EnableChangeTrackingHandlerBuilder.ts");
3025
- /* import */ var _codegen_handlers_FreezeHandlerBuilder__rspack_import_17 = __webpack_require__("./src/codegen/handlers/FreezeHandlerBuilder.ts");
3026
- /* import */ var _errors_SchemaError__rspack_import_23 = __webpack_require__("./src/errors/SchemaError.ts");
3027
- /* import */ var _codegen_handlers_SerializeHandlerBuilder__rspack_import_18 = __webpack_require__("./src/codegen/handlers/SerializeHandlerBuilder.ts");
3028
- /* import */ var _utilities__rspack_import_2 = __webpack_require__("./src/utilities/logger.ts");
3029
- /* import */ var _utilities__rspack_import_21 = __webpack_require__("./src/utilities/strings.ts");
3096
+ /* import */ var _PropertyInfo__rspack_import_6 = __webpack_require__("./src/schema/PropertyInfo.ts");
3097
+ /* import */ var _codegen__rspack_import_22 = __webpack_require__("./src/codegen/blocks.ts");
3098
+ /* import */ var _codegen_handlers_EnrichmentHandlerBuilder__rspack_import_7 = __webpack_require__("./src/codegen/handlers/EnrichmentHandlerBuilder.ts");
3099
+ /* import */ var _codegen_handlers_MergeHandlerBuilder__rspack_import_8 = __webpack_require__("./src/codegen/handlers/MergeHandlerBuilder.ts");
3100
+ /* import */ var _codegen_handlers_PrepareHandlerBuilder__rspack_import_9 = __webpack_require__("./src/codegen/handlers/PrepareHandlerBuilder.ts");
3101
+ /* import */ var _codegen_handlers_StripHandlerBuilder__rspack_import_10 = __webpack_require__("./src/codegen/handlers/StripHandlerBuilder.ts");
3102
+ /* import */ var _codegen_handlers_CloneHandlerBuilder__rspack_import_11 = __webpack_require__("./src/codegen/handlers/CloneHandlerBuilder.ts");
3103
+ /* import */ var _codegen_handlers_CompareHandlerBuilder__rspack_import_12 = __webpack_require__("./src/codegen/handlers/CompareHandlerBuilder.ts");
3104
+ /* import */ var _codegen_handlers_DeserializeHandlerBuilder__rspack_import_13 = __webpack_require__("./src/codegen/handlers/DeserializeHandlerBuilder.ts");
3105
+ /* import */ var _codegen_handlers_HashTypeHandlerBuilder__rspack_import_14 = __webpack_require__("./src/codegen/handlers/HashTypeHandlerBuilder.ts");
3106
+ /* import */ var _codegen_handlers_IdSelectorHandlerBuilder__rspack_import_15 = __webpack_require__("./src/codegen/handlers/IdSelectorHandlerBuilder.ts");
3107
+ /* import */ var _codegen_handlers_HashHandlerBuilder__rspack_import_16 = __webpack_require__("./src/codegen/handlers/HashHandlerBuilder.ts");
3108
+ /* import */ var _codegen_handlers_EnableChangeTrackingHandlerBuilder__rspack_import_17 = __webpack_require__("./src/codegen/handlers/EnableChangeTrackingHandlerBuilder.ts");
3109
+ /* import */ var _codegen_handlers_FreezeHandlerBuilder__rspack_import_18 = __webpack_require__("./src/codegen/handlers/FreezeHandlerBuilder.ts");
3110
+ /* import */ var _errors_SchemaError__rspack_import_25 = __webpack_require__("./src/errors/SchemaError.ts");
3111
+ /* import */ var _codegen_handlers_SerializeHandlerBuilder__rspack_import_19 = __webpack_require__("./src/codegen/handlers/SerializeHandlerBuilder.ts");
3112
+ /* import */ var _utilities__rspack_import_3 = __webpack_require__("./src/utilities/logger.ts");
3113
+ /* import */ var _utilities__rspack_import_23 = __webpack_require__("./src/utilities/strings.ts");
3030
3114
  /* import */ var _types__rspack_import_1 = __webpack_require__("./src/schema/types.ts");
3031
- /* import */ var _communication_broadcast__rspack_import_22 = __webpack_require__("./src/schema/communication/broadcast.ts");
3032
- /* import */ var _codegen_handlers_CompareIdsHandlerBuilder__rspack_import_19 = __webpack_require__("./src/codegen/handlers/CompareIdsHandlerBuilder.ts");
3115
+ /* import */ var _communication_broadcast__rspack_import_24 = __webpack_require__("./src/schema/communication/broadcast.ts");
3116
+ /* import */ var _codegen_handlers_CompareIdsHandlerBuilder__rspack_import_20 = __webpack_require__("./src/codegen/handlers/CompareIdsHandlerBuilder.ts");
3117
+ /* import */ var _utils_standardJsonSchema__rspack_import_2 = __webpack_require__("./src/schema/utils/standardJsonSchema.ts");
3118
+ /* import */ var _codegen_handlers__rspack_import_21 = __webpack_require__("./src/codegen/handlers/SetHandlerBuilder.ts");
3119
+
3120
+
3033
3121
 
3034
3122
 
3035
3123
 
@@ -3130,13 +3218,45 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3130
3218
  this.isNullable = false;
3131
3219
  this.isOptional = false;
3132
3220
  }
3221
+ /**
3222
+ * Creates a SchemaDefinition from a JSON string containing a JSON Schema.
3223
+ * Parses the JSON string, rehydrates the schema structure, and compiles it.
3224
+ *
3225
+ * @param jsonString - The JSON string containing the JSON Schema (typically from `schema['~standard'].jsonSchema.input()` or `output()`)
3226
+ * @param collectionName - Optional collection name override (if not present in JSON Schema metadata)
3227
+ * @returns A compiled schema ready to use
3228
+ * @throws Error if the JSON string is invalid or doesn't contain a valid JSON Schema
3229
+ *
3230
+ * @example
3231
+ * ```typescript
3232
+ * // Serialize a schema to JSON
3233
+ * const jsonSchema = mySchema['~standard'].jsonSchema.input({ target: 'draft-2020-12' });
3234
+ * const jsonString = JSON.stringify(jsonSchema);
3235
+ *
3236
+ * // Rehydrate from JSON string
3237
+ * const rehydratedSchema = SchemaDefinition.fromJson(jsonString);
3238
+ * // Schema is already compiled and ready to use
3239
+ * ```
3240
+ */
3241
+ static fromJson(jsonString, collectionName) {
3242
+ const schemaDefinition = (0,_utils_standardJsonSchema__rspack_import_2.rehydrateSchemaFromJsonString)(jsonString, collectionName);
3243
+ return schemaDefinition.compile();
3244
+ }
3245
+ /**
3246
+ * Standard JSON Schema V1 implementation.
3247
+ * Provides JSON Schema conversion for Routier schemas.
3248
+ */
3249
+ get '~standard'() {
3250
+ const schema = this.compile();
3251
+ return (0,_utils_standardJsonSchema__rspack_import_2.createStandardJsonSchemaProps)(schema);
3252
+ }
3133
3253
  createReturnFunction(builder) {
3134
3254
  const body = builder.toString();
3135
3255
  try {
3136
3256
  return Function(`return ${body}`);
3137
3257
  }
3138
3258
  catch (e) {
3139
- _utilities__rspack_import_2.logger.error(`Error compiling schema function. Function Body: ${body}`);
3259
+ _utilities__rspack_import_3.logger.error(`Error compiling schema function. Function Body: ${body}`);
3140
3260
  throw e;
3141
3261
  }
3142
3262
  }
@@ -3146,14 +3266,14 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3146
3266
  return Function(...fnArgs, body);
3147
3267
  }
3148
3268
  catch (e) {
3149
- _utilities__rspack_import_2.logger.error(`Error compiling schema function. Function Body: ${body}`);
3269
+ _utilities__rspack_import_3.logger.error(`Error compiling schema function. Function Body: ${body}`);
3150
3270
  throw e;
3151
3271
  }
3152
3272
  }
3153
3273
  modify(builder) {
3154
3274
  const b = {
3155
- function: (fn, injected) => new _table_SchemaFunction__rspack_import_3.SchemaFunction(fn, injected),
3156
- computed: (fn, injected) => new _table_SchemaComputed__rspack_import_4.SchemaComputed(fn, injected)
3275
+ function: (fn, injected) => new _table_SchemaFunction__rspack_import_4.SchemaFunction(fn, injected),
3276
+ computed: (fn, injected) => new _table_SchemaComputed__rspack_import_5.SchemaComputed(fn, injected)
3157
3277
  };
3158
3278
  const r = builder(b);
3159
3279
  return new SchemaDefinition(this.collectionName, { ...this.instance, ...r });
@@ -3181,7 +3301,7 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3181
3301
  ? null
3182
3302
  : item.parents[item.parents.length - 1].propertyInfo;
3183
3303
  if (propertyInstance.type === _types__rspack_import_1.SchemaTypes.Object) {
3184
- const propertyInfo = new _PropertyInfo__rspack_import_5.PropertyInfo(propertyInstance, key, previousParent);
3304
+ const propertyInfo = new _PropertyInfo__rspack_import_6.PropertyInfo(propertyInstance, key, previousParent);
3185
3305
  explore.push({
3186
3306
  path: [item.path, key].filter((w) => w != null).join("."),
3187
3307
  instance: propertyInstance.instance,
@@ -3198,7 +3318,7 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3198
3318
  previousParent.children.push(propertyInfo);
3199
3319
  continue;
3200
3320
  }
3201
- const childPrimitivePropertyInfo = new _PropertyInfo__rspack_import_5.PropertyInfo(item.instance[key], key, previousParent);
3321
+ const childPrimitivePropertyInfo = new _PropertyInfo__rspack_import_6.PropertyInfo(item.instance[key], key, previousParent);
3202
3322
  if (previousParent === null) {
3203
3323
  properties.push(childPrimitivePropertyInfo);
3204
3324
  continue;
@@ -3217,25 +3337,25 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3217
3337
  recursiveCallback(prop);
3218
3338
  }
3219
3339
  }
3220
- compile() {
3340
+ compile(metadata) {
3221
3341
  try {
3222
- const schema = this;
3223
3342
  const properties = [];
3224
3343
  const propertyMap = new Map();
3225
- const enrichmentHandlerBuilder = new _codegen_handlers_EnrichmentHandlerBuilder__rspack_import_6.EnrichmentHandlerBuilder();
3226
- const mergeHandlerFactory = new _codegen_handlers_MergeHandlerBuilder__rspack_import_7.MergeHandlerBuilder();
3227
- const prepareHandlerBuilder = new _codegen_handlers_PrepareHandlerBuilder__rspack_import_8.PrepareHandlerBuilder();
3228
- const stripHandlerBuilder = new _codegen_handlers_StripHandlerBuilder__rspack_import_9.StripHandlerBuilder();
3229
- const cloneHandlerBuilder = new _codegen_handlers_CloneHandlerBuilder__rspack_import_10.CloneHandlerBuilder();
3230
- const compareHandlerBuilder = new _codegen_handlers_CompareHandlerBuilder__rspack_import_11.CompareHandlerBuilder();
3231
- const deserializeHandlerBuilder = new _codegen_handlers_DeserializeHandlerBuilder__rspack_import_12.DeserializeHandlerBuilder();
3232
- const hashTypeHandlerBuilder = new _codegen_handlers_HashTypeHandlerBuilder__rspack_import_13.HashTypeHandlerBuilder();
3233
- const idSelectorHandlerBuilder = new _codegen_handlers_IdSelectorHandlerBuilder__rspack_import_14.IdSelectorHandlerBuilder();
3234
- const hashHandlerBuilder = new _codegen_handlers_HashHandlerBuilder__rspack_import_15.HashHandlerBuilder();
3235
- const enableChangeTrackingHandlerBuilder = new _codegen_handlers_EnableChangeTrackingHandlerBuilder__rspack_import_16.EnableChangeTrackingHandlerBuilder();
3236
- const freezeHandlerBuilder = new _codegen_handlers_FreezeHandlerBuilder__rspack_import_17.FreezeHandlerBuilder();
3237
- const serializeHandlerBuilder = new _codegen_handlers_SerializeHandlerBuilder__rspack_import_18.SerializeHandlerBuilder();
3238
- const compareIdsHandlerBuilder = new _codegen_handlers_CompareIdsHandlerBuilder__rspack_import_19.CompareIdsHandlerBuilder();
3344
+ const enrichmentHandlerBuilder = new _codegen_handlers_EnrichmentHandlerBuilder__rspack_import_7.EnrichmentHandlerBuilder();
3345
+ const mergeHandlerFactory = new _codegen_handlers_MergeHandlerBuilder__rspack_import_8.MergeHandlerBuilder();
3346
+ const prepareHandlerBuilder = new _codegen_handlers_PrepareHandlerBuilder__rspack_import_9.PrepareHandlerBuilder();
3347
+ const stripHandlerBuilder = new _codegen_handlers_StripHandlerBuilder__rspack_import_10.StripHandlerBuilder();
3348
+ const cloneHandlerBuilder = new _codegen_handlers_CloneHandlerBuilder__rspack_import_11.CloneHandlerBuilder();
3349
+ const compareHandlerBuilder = new _codegen_handlers_CompareHandlerBuilder__rspack_import_12.CompareHandlerBuilder();
3350
+ const deserializeHandlerBuilder = new _codegen_handlers_DeserializeHandlerBuilder__rspack_import_13.DeserializeHandlerBuilder();
3351
+ const hashTypeHandlerBuilder = new _codegen_handlers_HashTypeHandlerBuilder__rspack_import_14.HashTypeHandlerBuilder();
3352
+ const idSelectorHandlerBuilder = new _codegen_handlers_IdSelectorHandlerBuilder__rspack_import_15.IdSelectorHandlerBuilder();
3353
+ const hashHandlerBuilder = new _codegen_handlers_HashHandlerBuilder__rspack_import_16.HashHandlerBuilder();
3354
+ const enableChangeTrackingHandlerBuilder = new _codegen_handlers_EnableChangeTrackingHandlerBuilder__rspack_import_17.EnableChangeTrackingHandlerBuilder();
3355
+ const freezeHandlerBuilder = new _codegen_handlers_FreezeHandlerBuilder__rspack_import_18.FreezeHandlerBuilder();
3356
+ const serializeHandlerBuilder = new _codegen_handlers_SerializeHandlerBuilder__rspack_import_19.SerializeHandlerBuilder();
3357
+ const compareIdsHandlerBuilder = new _codegen_handlers_CompareIdsHandlerBuilder__rspack_import_20.CompareIdsHandlerBuilder();
3358
+ const setHandlerBuilder = new _codegen_handlers__rspack_import_21.SetHandlerBuilder();
3239
3359
  const enricher = enrichmentHandlerBuilder.build();
3240
3360
  const merge = mergeHandlerFactory.build();
3241
3361
  const prepare = prepareHandlerBuilder.build();
@@ -3250,15 +3370,16 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3250
3370
  const freezeHandler = freezeHandlerBuilder.build();
3251
3371
  const serializeHandler = serializeHandlerBuilder.build();
3252
3372
  const compareIdsHandler = compareIdsHandlerBuilder.build();
3253
- const changeTrackingCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3373
+ const setHandlerHanlder = setHandlerBuilder.build();
3374
+ const changeTrackingCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3254
3375
  changeTrackingCodeBuilder.raw(`${createChangeTracker.toString()}`);
3255
3376
  changeTrackingCodeBuilder.slot("declarations").variable("enableChangeTracking").value('createChangeTracker()');
3256
3377
  changeTrackingCodeBuilder.slot("assignment");
3257
3378
  changeTrackingCodeBuilder.slot("return").raw('\treturn enableChangeTracking(entity);');
3258
- const freezeCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3379
+ const freezeCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3259
3380
  freezeCodeBuilder.slot("assignment");
3260
3381
  freezeCodeBuilder.slot("return").raw('\treturn Object.freeze(entity);');
3261
- const enricherCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3382
+ const enricherCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3262
3383
  const enricherFunctionRoot = enricherCodeBuilder.factory("factory", { name: "factory" }).parameters({ name: "collectionName", value: this.collectionName });
3263
3384
  enricherFunctionRoot.slot("changeTracker").raw(`${createChangeTracker.toString()}`);
3264
3385
  enricherFunctionRoot.slot("changeTrackerFunction").raw(`\tconst changeTracker = createChangeTracker();`);
@@ -3273,13 +3394,16 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3273
3394
  enricherFunctionBody.slot("ifs");
3274
3395
  enricherFunctionBody.slot("tracking").if('changeTrackingType === "immutable"', { name: "freeze" });
3275
3396
  enricherFunctionBody.slot("return").raw('\treturn enableChangeTracking(enriched);');
3276
- const preprocessCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3397
+ const preprocessCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3277
3398
  preprocessCodeBuilder.slot("main");
3278
3399
  preprocessCodeBuilder.slot("return").raw(` return result;`);
3279
- const postprocessCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3400
+ const postprocessCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3280
3401
  postprocessCodeBuilder.slot("main");
3281
3402
  postprocessCodeBuilder.slot("return").raw(` return result;`);
3282
- const mergeCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3403
+ const setCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3404
+ setCodeBuilder.slot("assignments");
3405
+ setCodeBuilder.slot("ifs");
3406
+ const mergeCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3283
3407
  const mergeFunctionRoot = mergeCodeBuilder.factory("factory", { name: "factory" }).parameters({ name: "collectionName", value: this.collectionName });
3284
3408
  const mergeFunctionBody = mergeFunctionRoot.function(undefined, { name: "function" }).parameters("destination", "source").return();
3285
3409
  const pauseFunctionBody = mergeFunctionBody.function("pause")
@@ -3298,43 +3422,43 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3298
3422
  unpause();
3299
3423
 
3300
3424
  return destination;`);
3301
- const prepareCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3425
+ const prepareCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3302
3426
  prepareCodeBuilder.slot("result");
3303
3427
  prepareCodeBuilder.slot("assignments");
3304
3428
  prepareCodeBuilder.slot("return").raw(` return result;`);
3305
- const stripCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3429
+ const stripCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3306
3430
  stripCodeBuilder.slot("result");
3307
3431
  stripCodeBuilder.slot("return").raw(` return result;`);
3308
- const cloneCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3432
+ const cloneCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3309
3433
  cloneCodeBuilder.slot("result").raw("const result = {};");
3310
3434
  ;
3311
3435
  cloneCodeBuilder.slot("assignments");
3312
3436
  cloneCodeBuilder.slot("if");
3313
3437
  cloneCodeBuilder.slot("return").raw(` return result;`);
3314
- const compareCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3438
+ const compareCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3315
3439
  compareCodeBuilder.slot("result");
3316
3440
  compareCodeBuilder.slot("return").raw(` return result;`);
3317
- const compareIdsCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3441
+ const compareIdsCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3318
3442
  compareIdsCodeBuilder.slot("ifs");
3319
3443
  compareIdsCodeBuilder.slot("return").raw(` return true;`);
3320
- const deserializeCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3444
+ const deserializeCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3321
3445
  deserializeCodeBuilder.slot("functions");
3322
3446
  deserializeCodeBuilder.slot("result");
3323
3447
  deserializeCodeBuilder.slot("if");
3324
3448
  deserializeCodeBuilder.slot("return").raw(` return entity;`);
3325
- const serializeCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3449
+ const serializeCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3326
3450
  serializeCodeBuilder.slot("result").raw("const result = {};");
3327
3451
  serializeCodeBuilder.slot("assignments");
3328
3452
  serializeCodeBuilder.slot("functions");
3329
3453
  serializeCodeBuilder.slot("if");
3330
3454
  serializeCodeBuilder.slot("return").raw(` return result;`);
3331
- const idSelectorCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3455
+ const idSelectorCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3332
3456
  idSelectorCodeBuilder.slot("result");
3333
3457
  idSelectorCodeBuilder.slot("return").raw(` return result;`);
3334
- const hashTypeCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3458
+ const hashTypeCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3335
3459
  hashTypeCodeBuilder.slot("ifs");
3336
3460
  hashTypeCodeBuilder.slot("return").raw(` return "Ids";`);
3337
- const hashCodeBuilder = new _codegen__rspack_import_20.CodeBuilder();
3461
+ const hashCodeBuilder = new _codegen__rspack_import_22.CodeBuilder();
3338
3462
  hashCodeBuilder.slot("functions").raw(`
3339
3463
  function stringifyDate(d) {
3340
3464
 
@@ -3363,7 +3487,7 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3363
3487
  let hashType = _types__rspack_import_1.HashType.Ids;
3364
3488
  let hasIdentities = false;
3365
3489
  let hasIdentityKeys = false;
3366
- this._iterate(schema, (property) => {
3490
+ this._iterate(this, (property) => {
3367
3491
  properties.push(property);
3368
3492
  propertyMap.set(property.id, property);
3369
3493
  allPropertyNamesAndPaths.push(property.getSelectrorPath({ parent: "entity" }));
@@ -3390,6 +3514,7 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3390
3514
  enableChangeTrackingHandler.handle(property, changeTrackingCodeBuilder);
3391
3515
  freezeHandler.handle(property, freezeCodeBuilder);
3392
3516
  compareIdsHandler.handle(property, compareIdsCodeBuilder);
3517
+ setHandlerHanlder.handle(property, setCodeBuilder);
3393
3518
  });
3394
3519
  if (idProperties.length === 0) {
3395
3520
  throw new Error(`Schema must have a key. Use .key() to mark a property as a key. Collection Name: ${this.collectionName}`);
@@ -3402,7 +3527,7 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3402
3527
  enricherFunctionBody.get("append").insert(deserializeCodeBuilder.get("functions"));
3403
3528
  enricherFunctionBody.get("append").insert(deserializeCodeBuilder.get("result"));
3404
3529
  enricherFunctionBody.get("append").insert(deserializeCodeBuilder.get("if"));
3405
- enricherFunctionRoot.replace("function", new _codegen__rspack_import_20.FunctionBuilder(undefined).parameters("unserialized", "changeTrackingType").return());
3530
+ enricherFunctionRoot.replace("function", new _codegen__rspack_import_22.FunctionBuilder(undefined).parameters("unserialized", "changeTrackingType").return());
3406
3531
  const postProcessGenerator = this.createReturnFunction(enricherCodeBuilder);
3407
3532
  const postProcessParams = enricherFunctionRoot.getParameters();
3408
3533
  // Combine prepare and serialize
@@ -3424,6 +3549,7 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3424
3549
  const freezeFunction = this.createFunction(freezeCodeBuilder, "entity");
3425
3550
  const compareIdsFunction = this.createFunction(compareIdsCodeBuilder, "a", "b");
3426
3551
  const preprocessFunction = this.createFunction(preprocessCodeBuilder, "entity");
3552
+ const setFunction = this.createFunction(setCodeBuilder, "destination", "source");
3427
3553
  const enricherFactoryFunction = enrichGenerator();
3428
3554
  const postProcessFactoryFunction = postProcessGenerator();
3429
3555
  const mergeFactoryFunction = mergeGenerator();
@@ -3438,7 +3564,7 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3438
3564
  return getIdsFunction(entity)[0];
3439
3565
  };
3440
3566
  const getProperty = (id) => propertyMap.get(id);
3441
- const id = (0,_utilities__rspack_import_21.hash)([...allPropertyNamesAndPaths, this.collectionName].join(","));
3567
+ const id = (0,_utilities__rspack_import_23.hash)([...allPropertyNamesAndPaths, this.collectionName].join(","));
3442
3568
  // memoize this by the validProperties
3443
3569
  // TODO: See if we can generate a function to do this and eliminate loops
3444
3570
  const deserializePartial = (item, properties) => {
@@ -3456,6 +3582,7 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3456
3582
  const result = {
3457
3583
  preprocess: preprocessFunction,
3458
3584
  postprocess: postProcessFunction,
3585
+ set: setFunction,
3459
3586
  getId,
3460
3587
  getProperty,
3461
3588
  properties,
@@ -3532,13 +3659,22 @@ class SchemaDefinition extends _property_base_SchemaBase__rspack_import_0.Schema
3532
3659
  return indexes;
3533
3660
  }
3534
3661
  };
3535
- return {
3536
- createSubscription: (signal) => new _communication_broadcast__rspack_import_22.SchemaSubscription(result, signal),
3662
+ if (metadata != null) {
3663
+ const compiledSchemaWithMetadata = {
3664
+ ...result,
3665
+ createSubscription: (signal) => new _communication_broadcast__rspack_import_24.SchemaSubscription(result, signal),
3666
+ metadata
3667
+ };
3668
+ return compiledSchemaWithMetadata;
3669
+ }
3670
+ const compiledSchema = {
3671
+ createSubscription: (signal) => new _communication_broadcast__rspack_import_24.SchemaSubscription(result, signal),
3537
3672
  ...result
3538
3673
  };
3674
+ return compiledSchema;
3539
3675
  }
3540
3676
  catch (e) {
3541
- throw new _errors_SchemaError__rspack_import_23.SchemaError(e, `Error compiling schema for collection: ${this.collectionName}`);
3677
+ throw new _errors_SchemaError__rspack_import_25.SchemaError(e, `Error compiling schema for collection: ${this.collectionName}`);
3542
3678
  }
3543
3679
  }
3544
3680
  }
@@ -3571,7 +3707,7 @@ const s = {
3571
3707
  date: () => new _property_types_SchemaDate__rspack_import_3.SchemaDate(),
3572
3708
  array: (schema) => new _property_types_SchemaArray__rspack_import_4.SchemaArray(schema),
3573
3709
  object: (schema) => new _property_types_SchemaObject__rspack_import_5.SchemaObject(schema),
3574
- define: (collectionName, schema) => new _SchemaDefinition__rspack_import_6.SchemaDefinition(collectionName, schema)
3710
+ define: (collectionName, schema) => new _SchemaDefinition__rspack_import_6.SchemaDefinition(collectionName, schema),
3575
3711
  };
3576
3712
 
3577
3713
 
@@ -3660,10 +3796,10 @@ class SchemaSubscription {
3660
3796
  const regisry = getChannelRegistry(this.schema.id);
3661
3797
  // cannot send raw data, needs to be preprocessed
3662
3798
  const preprocessedChanges = {
3663
- adds: new Array(changes.adds.length),
3664
- removals: new Array(changes.removals.length),
3665
- unknown: new Array(changes.unknown.length),
3666
- updates: new Array(changes.updates.length),
3799
+ adds: Array.from({ length: changes.adds.length }),
3800
+ removals: Array.from({ length: changes.removals.length }),
3801
+ unknown: Array.from({ length: changes.unknown.length }),
3802
+ updates: Array.from({ length: changes.updates.length }),
3667
3803
  };
3668
3804
  for (let i = 0, length = changes.adds.length; i < length; i++) {
3669
3805
  preprocessedChanges.adds[i] = this.schema.preprocess(changes.adds[i]);
@@ -3696,10 +3832,10 @@ class SchemaSubscription {
3696
3832
  }
3697
3833
  // Changes were preprocessed before they were sent, need to postprocess them
3698
3834
  const postProcessedChanges = {
3699
- adds: new Array(data.adds.length),
3700
- removals: new Array(data.removals.length),
3701
- unknown: new Array(data.unknown.length),
3702
- updates: new Array(data.updates.length),
3835
+ adds: Array.from({ length: data.adds.length }),
3836
+ removals: Array.from({ length: data.removals.length }),
3837
+ unknown: Array.from({ length: data.unknown.length }),
3838
+ updates: Array.from({ length: data.updates.length }),
3703
3839
  };
3704
3840
  for (let i = 0, length = data.adds.length; i < length; i++) {
3705
3841
  postProcessedChanges.adds[i] = this.schema.preprocess(data.adds[i]);
@@ -3744,6 +3880,8 @@ class SchemaBase {
3744
3880
  isDistict = false;
3745
3881
  indexes = [];
3746
3882
  fromPropertyName = null;
3883
+ foreignKeyDefinition = null;
3884
+ tags = [];
3747
3885
  injected = null;
3748
3886
  defaultValue = null;
3749
3887
  valueSerializer = null;
@@ -3767,6 +3905,7 @@ class SchemaBase {
3767
3905
  this.injected = entity.injected;
3768
3906
  this.indexes = entity.indexes;
3769
3907
  this.fromPropertyName = entity.fromPropertyName;
3908
+ this.tags = entity.tags;
3770
3909
  }
3771
3910
  if (literals) {
3772
3911
  this.literals = literals;
@@ -3791,10 +3930,12 @@ __webpack_require__.r(__webpack_exports__);
3791
3930
  __webpack_require__.d(__webpack_exports__, {
3792
3931
  SchemaDefault: () => (SchemaDefault)
3793
3932
  });
3933
+ /* import */ var _utilities__rspack_import_1 = __webpack_require__("./src/utilities/logger.ts");
3794
3934
  /* import */ var _base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
3795
- /* import */ var _SchemaDeserialize__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaDeserialize.ts");
3796
- /* import */ var _SchemaFrom__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
3797
- /* import */ var _SchemaSerialize__rspack_import_1 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
3935
+ /* import */ var _SchemaDeserialize__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaDeserialize.ts");
3936
+ /* import */ var _SchemaFrom__rspack_import_4 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
3937
+ /* import */ var _SchemaSerialize__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
3938
+
3798
3939
 
3799
3940
 
3800
3941
 
@@ -3804,18 +3945,21 @@ class SchemaDefault extends _base_SchemaBase__rspack_import_0.SchemaBase {
3804
3945
  _schemaDefault = true;
3805
3946
  constructor(defaultValue, injected, current) {
3806
3947
  super(current);
3948
+ if (defaultValue == null) {
3949
+ _utilities__rspack_import_1.logger.warn("Do not use `.default(null)` in your schema, please use `.default(() => null)`");
3950
+ }
3807
3951
  this.instance = current.instance;
3808
3952
  this.injected = injected;
3809
3953
  this.defaultValue = defaultValue;
3810
3954
  }
3811
3955
  serialize(serializer) {
3812
- return new _SchemaSerialize__rspack_import_1.SchemaSerialize(serializer, this);
3956
+ return new _SchemaSerialize__rspack_import_2.SchemaSerialize(serializer, this);
3813
3957
  }
3814
3958
  deserialize(deserializer) {
3815
- return new _SchemaDeserialize__rspack_import_2.SchemaDeserialize(deserializer, this);
3959
+ return new _SchemaDeserialize__rspack_import_3.SchemaDeserialize(deserializer, this);
3816
3960
  }
3817
3961
  from(propertyName) {
3818
- return new _SchemaFrom__rspack_import_3.SchemaFrom(propertyName, this);
3962
+ return new _SchemaFrom__rspack_import_4.SchemaFrom(propertyName, this);
3819
3963
  }
3820
3964
  }
3821
3965
 
@@ -3827,11 +3971,15 @@ __webpack_require__.d(__webpack_exports__, {
3827
3971
  SchemaDeserialize: () => (SchemaDeserialize)
3828
3972
  });
3829
3973
  /* import */ var _base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
3974
+ /* import */ var _SchemaDefault__rspack_import_4 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
3830
3975
  /* import */ var _SchemaFrom__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
3976
+ /* import */ var _SchemaOptional__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaOptional.ts");
3831
3977
  /* import */ var _SchemaSerialize__rspack_import_1 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
3832
3978
 
3833
3979
 
3834
3980
 
3981
+
3982
+
3835
3983
  class SchemaDeserialize extends _base_SchemaBase__rspack_import_0.SchemaBase {
3836
3984
  instance;
3837
3985
  _schemaDeserialize = true;
@@ -3846,6 +3994,12 @@ class SchemaDeserialize extends _base_SchemaBase__rspack_import_0.SchemaBase {
3846
3994
  from(propertyName) {
3847
3995
  return new _SchemaFrom__rspack_import_2.SchemaFrom(propertyName, this);
3848
3996
  }
3997
+ optional() {
3998
+ return new _SchemaOptional__rspack_import_3.SchemaOptional(this);
3999
+ }
4000
+ default(value, injected) {
4001
+ return new _SchemaDefault__rspack_import_4.SchemaDefault(value, injected, this);
4002
+ }
3849
4003
  }
3850
4004
 
3851
4005
 
@@ -3868,6 +4022,48 @@ class SchemaDistinct extends _base_SchemaBase__rspack_import_0.SchemaBase {
3868
4022
  }
3869
4023
 
3870
4024
 
4025
+ },
4026
+ "./src/schema/property/modifiers/SchemaForeignKey.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4027
+ __webpack_require__.r(__webpack_exports__);
4028
+ __webpack_require__.d(__webpack_exports__, {
4029
+ SchemaForeignKey: () => (SchemaForeignKey)
4030
+ });
4031
+ /* import */ var _base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
4032
+ /* import */ var _SchemaIdentity__rspack_import_1 = __webpack_require__("./src/schema/property/modifiers/SchemaIdentity.ts");
4033
+ /* import */ var _SchemaDefault__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
4034
+ /* import */ var _SchemaFrom__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
4035
+ /* import */ var _SchemaTag__rspack_import_4 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4036
+
4037
+
4038
+
4039
+
4040
+
4041
+ class SchemaForeignKey extends _base_SchemaBase__rspack_import_0.SchemaBase {
4042
+ instance;
4043
+ _schemaForeignKey = true;
4044
+ constructor(current, relatingSchema, property) {
4045
+ super(current);
4046
+ this.instance = current.instance;
4047
+ this.foreignKeyDefinition = {
4048
+ schema: relatingSchema,
4049
+ property: relatingSchema.getProperty(String(property))
4050
+ };
4051
+ }
4052
+ identity() {
4053
+ return new _SchemaIdentity__rspack_import_1.SchemaIdentity(this);
4054
+ }
4055
+ default(value, injected) {
4056
+ return new _SchemaDefault__rspack_import_2.SchemaDefault(value, injected, this);
4057
+ }
4058
+ from(propertyName) {
4059
+ return new _SchemaFrom__rspack_import_3.SchemaFrom(propertyName, this);
4060
+ }
4061
+ tag(...tags) {
4062
+ return new _SchemaTag__rspack_import_4.SchemaTag(tags, this);
4063
+ }
4064
+ }
4065
+
4066
+
3871
4067
  },
3872
4068
  "./src/schema/property/modifiers/SchemaFrom.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3873
4069
  __webpack_require__.r(__webpack_exports__);
@@ -4020,6 +4216,8 @@ __webpack_require__.d(__webpack_exports__, {
4020
4216
  /* import */ var _SchemaIdentity__rspack_import_1 = __webpack_require__("./src/schema/property/modifiers/SchemaIdentity.ts");
4021
4217
  /* import */ var _SchemaDefault__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
4022
4218
  /* import */ var _SchemaFrom__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
4219
+ /* import */ var _SchemaTag__rspack_import_4 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4220
+
4023
4221
 
4024
4222
 
4025
4223
 
@@ -4041,6 +4239,9 @@ class SchemaKey extends _base_SchemaBase__rspack_import_0.SchemaBase {
4041
4239
  from(propertyName) {
4042
4240
  return new _SchemaFrom__rspack_import_3.SchemaFrom(propertyName, this);
4043
4241
  }
4242
+ tag(...tags) {
4243
+ return new _SchemaTag__rspack_import_4.SchemaTag(tags, this);
4244
+ }
4044
4245
  }
4045
4246
 
4046
4247
 
@@ -4051,9 +4252,13 @@ __webpack_require__.d(__webpack_exports__, {
4051
4252
  SchemaNullable: () => (SchemaNullable)
4052
4253
  });
4053
4254
  /* import */ var _base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
4255
+ /* import */ var _SchemaDefault__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
4256
+ /* import */ var _SchemaDeserialize__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaDeserialize.ts");
4054
4257
  /* import */ var _SchemaOptional__rspack_import_1 = __webpack_require__("./src/schema/property/modifiers/SchemaOptional.ts");
4055
4258
 
4056
4259
 
4260
+
4261
+
4057
4262
  class SchemaNullable extends _base_SchemaBase__rspack_import_0.SchemaBase {
4058
4263
  instance;
4059
4264
  _schemaNullable = true;
@@ -4065,6 +4270,12 @@ class SchemaNullable extends _base_SchemaBase__rspack_import_0.SchemaBase {
4065
4270
  optional() {
4066
4271
  return new _SchemaOptional__rspack_import_1.SchemaOptional(this);
4067
4272
  }
4273
+ default(value, injected) {
4274
+ return new _SchemaDefault__rspack_import_2.SchemaDefault(value, injected, this);
4275
+ }
4276
+ deserialize(deserializer) {
4277
+ return new _SchemaDeserialize__rspack_import_3.SchemaDeserialize(deserializer, this);
4278
+ }
4068
4279
  }
4069
4280
 
4070
4281
 
@@ -4075,9 +4286,11 @@ __webpack_require__.d(__webpack_exports__, {
4075
4286
  SchemaOptional: () => (SchemaOptional)
4076
4287
  });
4077
4288
  /* import */ var _base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
4289
+ /* import */ var _SchemaDeserialize__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaDeserialize.ts");
4078
4290
  /* import */ var _SchemaNullable__rspack_import_1 = __webpack_require__("./src/schema/property/modifiers/SchemaNullable.ts");
4079
4291
 
4080
4292
 
4293
+
4081
4294
  class SchemaOptional extends _base_SchemaBase__rspack_import_0.SchemaBase {
4082
4295
  instance;
4083
4296
  _schemaOptional = true;
@@ -4089,6 +4302,9 @@ class SchemaOptional extends _base_SchemaBase__rspack_import_0.SchemaBase {
4089
4302
  nullable() {
4090
4303
  return new _SchemaNullable__rspack_import_1.SchemaNullable(this);
4091
4304
  }
4305
+ deserialize(deserializer) {
4306
+ return new _SchemaDeserialize__rspack_import_2.SchemaDeserialize(deserializer, this);
4307
+ }
4092
4308
  }
4093
4309
 
4094
4310
 
@@ -4155,6 +4371,75 @@ class SchemaSerialize extends _base_SchemaBase__rspack_import_0.SchemaBase {
4155
4371
  }
4156
4372
 
4157
4373
 
4374
+ },
4375
+ "./src/schema/property/modifiers/SchemaTag.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4376
+ __webpack_require__.r(__webpack_exports__);
4377
+ __webpack_require__.d(__webpack_exports__, {
4378
+ SchemaTag: () => (SchemaTag)
4379
+ });
4380
+ /* import */ var _base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
4381
+ /* import */ var _types__rspack_import_8 = __webpack_require__("./src/schema/property/types/SchemaArray.ts");
4382
+ /* import */ var _SchemaDefault__rspack_import_4 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
4383
+ /* import */ var _SchemaDeserialize__rspack_import_6 = __webpack_require__("./src/schema/property/modifiers/SchemaDeserialize.ts");
4384
+ /* import */ var _SchemaDistinct__rspack_import_10 = __webpack_require__("./src/schema/property/modifiers/SchemaDistinct.ts");
4385
+ /* import */ var _SchemaFrom__rspack_import_1 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
4386
+ /* import */ var _SchemaIndex__rspack_import_9 = __webpack_require__("./src/schema/property/modifiers/SchemaIndex.ts");
4387
+ /* import */ var _SchemaNullable__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaNullable.ts");
4388
+ /* import */ var _SchemaOptional__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaOptional.ts");
4389
+ /* import */ var _SchemaReadonly__rspack_import_5 = __webpack_require__("./src/schema/property/modifiers/SchemaReadonly.ts");
4390
+ /* import */ var _SchemaSerialize__rspack_import_7 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
4391
+
4392
+
4393
+
4394
+
4395
+
4396
+
4397
+
4398
+
4399
+
4400
+
4401
+
4402
+ class SchemaTag extends _base_SchemaBase__rspack_import_0.SchemaBase {
4403
+ instance;
4404
+ _schemaTag = true;
4405
+ constructor(tags, current) {
4406
+ super(current);
4407
+ this.tags = tags;
4408
+ this.instance = current.instance;
4409
+ }
4410
+ from(propertyName) {
4411
+ return new _SchemaFrom__rspack_import_1.SchemaFrom(propertyName, this);
4412
+ }
4413
+ optional() {
4414
+ return new _SchemaOptional__rspack_import_2.SchemaOptional(this);
4415
+ }
4416
+ nullable() {
4417
+ return new _SchemaNullable__rspack_import_3.SchemaNullable(this);
4418
+ }
4419
+ default(value, injected) {
4420
+ return new _SchemaDefault__rspack_import_4.SchemaDefault(value, injected, this);
4421
+ }
4422
+ readonly() {
4423
+ return new _SchemaReadonly__rspack_import_5.SchemaReadonly(this);
4424
+ }
4425
+ deserialize(deserializer) {
4426
+ return new _SchemaDeserialize__rspack_import_6.SchemaDeserialize(deserializer, this);
4427
+ }
4428
+ serialize(serializer) {
4429
+ return new _SchemaSerialize__rspack_import_7.SchemaSerialize(serializer, this);
4430
+ }
4431
+ array() {
4432
+ return new _types__rspack_import_8.SchemaArray(this);
4433
+ }
4434
+ index(...indexes) {
4435
+ return new _SchemaIndex__rspack_import_9.SchemaIndex(this, ...indexes);
4436
+ }
4437
+ distinct() {
4438
+ return new _SchemaDistinct__rspack_import_10.SchemaDistinct(this);
4439
+ }
4440
+ }
4441
+
4442
+
4158
4443
  },
4159
4444
  "./src/schema/property/modifiers/SchemaTracked.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4160
4445
  __webpack_require__.r(__webpack_exports__);
@@ -4162,7 +4447,11 @@ __webpack_require__.d(__webpack_exports__, {
4162
4447
  SchemaTracked: () => (SchemaTracked)
4163
4448
  });
4164
4449
  /* import */ var _base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
4450
+ /* import */ var _SchemaForeignKey__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaForeignKey.ts");
4165
4451
  /* import */ var _SchemaKey__rspack_import_1 = __webpack_require__("./src/schema/property/modifiers/SchemaKey.ts");
4452
+ /* import */ var _SchemaTag__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4453
+
4454
+
4166
4455
 
4167
4456
 
4168
4457
  class SchemaTracked extends _base_SchemaBase__rspack_import_0.SchemaBase {
@@ -4176,6 +4465,12 @@ class SchemaTracked extends _base_SchemaBase__rspack_import_0.SchemaBase {
4176
4465
  key() {
4177
4466
  return new _SchemaKey__rspack_import_1.SchemaKey(this);
4178
4467
  }
4468
+ foreignKey(relatingSchema, property) {
4469
+ return new _SchemaForeignKey__rspack_import_2.SchemaForeignKey(this, relatingSchema, property);
4470
+ }
4471
+ tag(...tags) {
4472
+ return new _SchemaTag__rspack_import_3.SchemaTag(tags, this);
4473
+ }
4179
4474
  }
4180
4475
 
4181
4476
 
@@ -4186,6 +4481,7 @@ __webpack_require__.d(__webpack_exports__, {
4186
4481
  SchemaDefault: () => (/* reexport safe */ _SchemaDefault__rspack_import_0.SchemaDefault),
4187
4482
  SchemaDeserialize: () => (/* reexport safe */ _SchemaDeserialize__rspack_import_1.SchemaDeserialize),
4188
4483
  SchemaDistinct: () => (/* reexport safe */ _SchemaDistinct__rspack_import_2.SchemaDistinct),
4484
+ SchemaForeignKey: () => (/* reexport safe */ _SchemaForeignKey__rspack_import_13.SchemaForeignKey),
4189
4485
  SchemaFrom: () => (/* reexport safe */ _SchemaFrom__rspack_import_11.SchemaFrom),
4190
4486
  SchemaIdentity: () => (/* reexport safe */ _SchemaIdentity__rspack_import_3.SchemaIdentity),
4191
4487
  SchemaIndex: () => (/* reexport safe */ _SchemaIndex__rspack_import_4.SchemaIndex),
@@ -4194,6 +4490,7 @@ __webpack_require__.d(__webpack_exports__, {
4194
4490
  SchemaOptional: () => (/* reexport safe */ _SchemaOptional__rspack_import_7.SchemaOptional),
4195
4491
  SchemaReadonly: () => (/* reexport safe */ _SchemaReadonly__rspack_import_8.SchemaReadonly),
4196
4492
  SchemaSerialize: () => (/* reexport safe */ _SchemaSerialize__rspack_import_9.SchemaSerialize),
4493
+ SchemaTag: () => (/* reexport safe */ _SchemaTag__rspack_import_12.SchemaTag),
4197
4494
  SchemaTracked: () => (/* reexport safe */ _SchemaTracked__rspack_import_10.SchemaTracked)
4198
4495
  });
4199
4496
  /* import */ var _SchemaDefault__rspack_import_0 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
@@ -4208,6 +4505,10 @@ __webpack_require__.d(__webpack_exports__, {
4208
4505
  /* import */ var _SchemaSerialize__rspack_import_9 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
4209
4506
  /* import */ var _SchemaTracked__rspack_import_10 = __webpack_require__("./src/schema/property/modifiers/SchemaTracked.ts");
4210
4507
  /* import */ var _SchemaFrom__rspack_import_11 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
4508
+ /* import */ var _SchemaTag__rspack_import_12 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4509
+ /* import */ var _SchemaForeignKey__rspack_import_13 = __webpack_require__("./src/schema/property/modifiers/SchemaForeignKey.ts");
4510
+
4511
+
4211
4512
 
4212
4513
 
4213
4514
 
@@ -4237,6 +4538,8 @@ __webpack_require__.d(__webpack_exports__, {
4237
4538
  /* import */ var _modifiers_SchemaIndex__rspack_import_8 = __webpack_require__("./src/schema/property/modifiers/SchemaIndex.ts");
4238
4539
  /* import */ var _types__rspack_import_1 = __webpack_require__("./src/schema/types.ts");
4239
4540
  /* import */ var _modifiers_SchemaFrom__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
4541
+ /* import */ var _modifiers_SchemaTag__rspack_import_9 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4542
+
4240
4543
 
4241
4544
 
4242
4545
 
@@ -4276,6 +4579,9 @@ class SchemaArray extends _base_SchemaBase__rspack_import_0.SchemaBase {
4276
4579
  index(...indexes) {
4277
4580
  return new _modifiers_SchemaIndex__rspack_import_8.SchemaIndex(this, ...indexes);
4278
4581
  }
4582
+ tag(...tags) {
4583
+ return new _modifiers_SchemaTag__rspack_import_9.SchemaTag(tags, this);
4584
+ }
4279
4585
  }
4280
4586
 
4281
4587
 
@@ -4296,6 +4602,7 @@ __webpack_require__.d(__webpack_exports__, {
4296
4602
  /* import */ var _modifiers_SchemaOptional__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaOptional.ts");
4297
4603
  /* import */ var _modifiers_SchemaReadonly__rspack_import_6 = __webpack_require__("./src/schema/property/modifiers/SchemaReadonly.ts");
4298
4604
  /* import */ var _modifiers_SchemaSerialize__rspack_import_8 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
4605
+ /* import */ var _modifiers_SchemaTag__rspack_import_12 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4299
4606
  /* import */ var _SchemaArray__rspack_import_9 = __webpack_require__("./src/schema/property/types/SchemaArray.ts");
4300
4607
 
4301
4608
 
@@ -4309,6 +4616,7 @@ __webpack_require__.d(__webpack_exports__, {
4309
4616
 
4310
4617
 
4311
4618
 
4619
+
4312
4620
  class SchemaBoolean extends _base_SchemaBase__rspack_import_0.SchemaBase {
4313
4621
  instance;
4314
4622
  type = _types__rspack_import_1.SchemaTypes.Boolean;
@@ -4343,6 +4651,9 @@ class SchemaBoolean extends _base_SchemaBase__rspack_import_0.SchemaBase {
4343
4651
  distinct() {
4344
4652
  return new _modifiers_SchemaDistinct__rspack_import_11.SchemaDistinct(this);
4345
4653
  }
4654
+ tag(...tags) {
4655
+ return new _modifiers_SchemaTag__rspack_import_12.SchemaTag(tags, this);
4656
+ }
4346
4657
  }
4347
4658
 
4348
4659
 
@@ -4363,6 +4674,7 @@ __webpack_require__.d(__webpack_exports__, {
4363
4674
  /* import */ var _modifiers_SchemaOptional__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaOptional.ts");
4364
4675
  /* import */ var _modifiers_SchemaReadonly__rspack_import_6 = __webpack_require__("./src/schema/property/modifiers/SchemaReadonly.ts");
4365
4676
  /* import */ var _modifiers_SchemaSerialize__rspack_import_8 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
4677
+ /* import */ var _modifiers_SchemaTag__rspack_import_12 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4366
4678
  /* import */ var _SchemaArray__rspack_import_9 = __webpack_require__("./src/schema/property/types/SchemaArray.ts");
4367
4679
 
4368
4680
 
@@ -4376,6 +4688,7 @@ __webpack_require__.d(__webpack_exports__, {
4376
4688
 
4377
4689
 
4378
4690
 
4691
+
4379
4692
  class SchemaDate extends _base_SchemaBase__rspack_import_0.SchemaBase {
4380
4693
  instance;
4381
4694
  type = _types__rspack_import_1.SchemaTypes.Date;
@@ -4410,6 +4723,9 @@ class SchemaDate extends _base_SchemaBase__rspack_import_0.SchemaBase {
4410
4723
  distinct() {
4411
4724
  return new _modifiers_SchemaDistinct__rspack_import_11.SchemaDistinct(this);
4412
4725
  }
4726
+ tag(...tags) {
4727
+ return new _modifiers_SchemaTag__rspack_import_12.SchemaTag(tags, this);
4728
+ }
4413
4729
  }
4414
4730
 
4415
4731
 
@@ -4421,18 +4737,22 @@ __webpack_require__.d(__webpack_exports__, {
4421
4737
  });
4422
4738
  /* import */ var _types__rspack_import_1 = __webpack_require__("./src/schema/types.ts");
4423
4739
  /* import */ var _base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
4424
- /* import */ var _modifiers_SchemaDefault__rspack_import_6 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
4425
- /* import */ var _modifiers_SchemaDeserialize__rspack_import_8 = __webpack_require__("./src/schema/property/modifiers/SchemaDeserialize.ts");
4426
- /* import */ var _modifiers_SchemaDistinct__rspack_import_13 = __webpack_require__("./src/schema/property/modifiers/SchemaDistinct.ts");
4740
+ /* import */ var _modifiers_SchemaDefault__rspack_import_7 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
4741
+ /* import */ var _modifiers_SchemaDeserialize__rspack_import_9 = __webpack_require__("./src/schema/property/modifiers/SchemaDeserialize.ts");
4742
+ /* import */ var _modifiers_SchemaDistinct__rspack_import_14 = __webpack_require__("./src/schema/property/modifiers/SchemaDistinct.ts");
4743
+ /* import */ var _modifiers_SchemaForeignKey__rspack_import_6 = __webpack_require__("./src/schema/property/modifiers/SchemaForeignKey.ts");
4427
4744
  /* import */ var _modifiers_SchemaFrom__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
4428
- /* import */ var _modifiers_SchemaIdentity__rspack_import_10 = __webpack_require__("./src/schema/property/modifiers/SchemaIdentity.ts");
4429
- /* import */ var _modifiers_SchemaIndex__rspack_import_12 = __webpack_require__("./src/schema/property/modifiers/SchemaIndex.ts");
4745
+ /* import */ var _modifiers_SchemaIdentity__rspack_import_11 = __webpack_require__("./src/schema/property/modifiers/SchemaIdentity.ts");
4746
+ /* import */ var _modifiers_SchemaIndex__rspack_import_13 = __webpack_require__("./src/schema/property/modifiers/SchemaIndex.ts");
4430
4747
  /* import */ var _modifiers_SchemaKey__rspack_import_5 = __webpack_require__("./src/schema/property/modifiers/SchemaKey.ts");
4431
4748
  /* import */ var _modifiers_SchemaNullable__rspack_import_4 = __webpack_require__("./src/schema/property/modifiers/SchemaNullable.ts");
4432
4749
  /* import */ var _modifiers_SchemaOptional__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaOptional.ts");
4433
- /* import */ var _modifiers_SchemaReadonly__rspack_import_7 = __webpack_require__("./src/schema/property/modifiers/SchemaReadonly.ts");
4434
- /* import */ var _modifiers_SchemaSerialize__rspack_import_9 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
4435
- /* import */ var _SchemaArray__rspack_import_11 = __webpack_require__("./src/schema/property/types/SchemaArray.ts");
4750
+ /* import */ var _modifiers_SchemaReadonly__rspack_import_8 = __webpack_require__("./src/schema/property/modifiers/SchemaReadonly.ts");
4751
+ /* import */ var _modifiers_SchemaSerialize__rspack_import_10 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
4752
+ /* import */ var _modifiers_SchemaTag__rspack_import_15 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4753
+ /* import */ var _SchemaArray__rspack_import_12 = __webpack_require__("./src/schema/property/types/SchemaArray.ts");
4754
+
4755
+
4436
4756
 
4437
4757
 
4438
4758
 
@@ -4466,29 +4786,35 @@ class SchemaNumber extends _base_SchemaBase__rspack_import_0.SchemaBase {
4466
4786
  key() {
4467
4787
  return new _modifiers_SchemaKey__rspack_import_5.SchemaKey(this);
4468
4788
  }
4789
+ foreignKey(relatingSchema, property) {
4790
+ return new _modifiers_SchemaForeignKey__rspack_import_6.SchemaForeignKey(this, relatingSchema, property);
4791
+ }
4469
4792
  default(value, injected) {
4470
- return new _modifiers_SchemaDefault__rspack_import_6.SchemaDefault(value, injected, this);
4793
+ return new _modifiers_SchemaDefault__rspack_import_7.SchemaDefault(value, injected, this);
4471
4794
  }
4472
4795
  readonly() {
4473
- return new _modifiers_SchemaReadonly__rspack_import_7.SchemaReadonly(this);
4796
+ return new _modifiers_SchemaReadonly__rspack_import_8.SchemaReadonly(this);
4474
4797
  }
4475
4798
  deserialize(deserializer) {
4476
- return new _modifiers_SchemaDeserialize__rspack_import_8.SchemaDeserialize(deserializer, this);
4799
+ return new _modifiers_SchemaDeserialize__rspack_import_9.SchemaDeserialize(deserializer, this);
4477
4800
  }
4478
4801
  serialize(serializer) {
4479
- return new _modifiers_SchemaSerialize__rspack_import_9.SchemaSerialize(serializer, this);
4802
+ return new _modifiers_SchemaSerialize__rspack_import_10.SchemaSerialize(serializer, this);
4480
4803
  }
4481
4804
  identity() {
4482
- return new _modifiers_SchemaIdentity__rspack_import_10.SchemaIdentity(this);
4805
+ return new _modifiers_SchemaIdentity__rspack_import_11.SchemaIdentity(this);
4483
4806
  }
4484
4807
  array() {
4485
- return new _SchemaArray__rspack_import_11.SchemaArray(this);
4808
+ return new _SchemaArray__rspack_import_12.SchemaArray(this);
4486
4809
  }
4487
4810
  index(...indexes) {
4488
- return new _modifiers_SchemaIndex__rspack_import_12.SchemaIndex(this, ...indexes);
4811
+ return new _modifiers_SchemaIndex__rspack_import_13.SchemaIndex(this, ...indexes);
4489
4812
  }
4490
4813
  distinct() {
4491
- return new _modifiers_SchemaDistinct__rspack_import_13.SchemaDistinct(this);
4814
+ return new _modifiers_SchemaDistinct__rspack_import_14.SchemaDistinct(this);
4815
+ }
4816
+ tag(...tags) {
4817
+ return new _modifiers_SchemaTag__rspack_import_15.SchemaTag(tags, this);
4492
4818
  }
4493
4819
  }
4494
4820
 
@@ -4506,6 +4832,7 @@ __webpack_require__.d(__webpack_exports__, {
4506
4832
  /* import */ var _modifiers_SchemaIdentity__rspack_import_6 = __webpack_require__("./src/schema/property/modifiers/SchemaIdentity.ts");
4507
4833
  /* import */ var _modifiers_SchemaNullable__rspack_import_4 = __webpack_require__("./src/schema/property/modifiers/SchemaNullable.ts");
4508
4834
  /* import */ var _modifiers_SchemaOptional__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaOptional.ts");
4835
+ /* import */ var _modifiers_SchemaTag__rspack_import_8 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4509
4836
  /* import */ var _SchemaArray__rspack_import_7 = __webpack_require__("./src/schema/property/types/SchemaArray.ts");
4510
4837
 
4511
4838
 
@@ -4515,6 +4842,7 @@ __webpack_require__.d(__webpack_exports__, {
4515
4842
 
4516
4843
 
4517
4844
 
4845
+
4518
4846
  class SchemaObject extends _base_SchemaBase__rspack_import_0.SchemaBase {
4519
4847
  instance;
4520
4848
  type = _types__rspack_import_1.SchemaTypes.Object;
@@ -4541,6 +4869,9 @@ class SchemaObject extends _base_SchemaBase__rspack_import_0.SchemaBase {
4541
4869
  array() {
4542
4870
  return new _SchemaArray__rspack_import_7.SchemaArray(this);
4543
4871
  }
4872
+ tag(...tags) {
4873
+ return new _modifiers_SchemaTag__rspack_import_8.SchemaTag(tags, this);
4874
+ }
4544
4875
  }
4545
4876
 
4546
4877
 
@@ -4552,18 +4883,22 @@ __webpack_require__.d(__webpack_exports__, {
4552
4883
  });
4553
4884
  /* import */ var _types__rspack_import_1 = __webpack_require__("./src/schema/types.ts");
4554
4885
  /* import */ var _base_SchemaBase__rspack_import_0 = __webpack_require__("./src/schema/property/base/SchemaBase.ts");
4555
- /* import */ var _modifiers_SchemaDefault__rspack_import_6 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
4556
- /* import */ var _modifiers_SchemaDeserialize__rspack_import_8 = __webpack_require__("./src/schema/property/modifiers/SchemaDeserialize.ts");
4557
- /* import */ var _modifiers_SchemaDistinct__rspack_import_13 = __webpack_require__("./src/schema/property/modifiers/SchemaDistinct.ts");
4886
+ /* import */ var _modifiers_SchemaDefault__rspack_import_7 = __webpack_require__("./src/schema/property/modifiers/SchemaDefault.ts");
4887
+ /* import */ var _modifiers_SchemaDeserialize__rspack_import_9 = __webpack_require__("./src/schema/property/modifiers/SchemaDeserialize.ts");
4888
+ /* import */ var _modifiers_SchemaDistinct__rspack_import_14 = __webpack_require__("./src/schema/property/modifiers/SchemaDistinct.ts");
4889
+ /* import */ var _modifiers_SchemaForeignKey__rspack_import_6 = __webpack_require__("./src/schema/property/modifiers/SchemaForeignKey.ts");
4558
4890
  /* import */ var _modifiers_SchemaFrom__rspack_import_2 = __webpack_require__("./src/schema/property/modifiers/SchemaFrom.ts");
4559
- /* import */ var _modifiers_SchemaIdentity__rspack_import_10 = __webpack_require__("./src/schema/property/modifiers/SchemaIdentity.ts");
4560
- /* import */ var _modifiers_SchemaIndex__rspack_import_12 = __webpack_require__("./src/schema/property/modifiers/SchemaIndex.ts");
4891
+ /* import */ var _modifiers_SchemaIdentity__rspack_import_11 = __webpack_require__("./src/schema/property/modifiers/SchemaIdentity.ts");
4892
+ /* import */ var _modifiers_SchemaIndex__rspack_import_13 = __webpack_require__("./src/schema/property/modifiers/SchemaIndex.ts");
4561
4893
  /* import */ var _modifiers_SchemaKey__rspack_import_5 = __webpack_require__("./src/schema/property/modifiers/SchemaKey.ts");
4562
4894
  /* import */ var _modifiers_SchemaNullable__rspack_import_4 = __webpack_require__("./src/schema/property/modifiers/SchemaNullable.ts");
4563
4895
  /* import */ var _modifiers_SchemaOptional__rspack_import_3 = __webpack_require__("./src/schema/property/modifiers/SchemaOptional.ts");
4564
- /* import */ var _modifiers_SchemaReadonly__rspack_import_7 = __webpack_require__("./src/schema/property/modifiers/SchemaReadonly.ts");
4565
- /* import */ var _modifiers_SchemaSerialize__rspack_import_9 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
4566
- /* import */ var _SchemaArray__rspack_import_11 = __webpack_require__("./src/schema/property/types/SchemaArray.ts");
4896
+ /* import */ var _modifiers_SchemaReadonly__rspack_import_8 = __webpack_require__("./src/schema/property/modifiers/SchemaReadonly.ts");
4897
+ /* import */ var _modifiers_SchemaSerialize__rspack_import_10 = __webpack_require__("./src/schema/property/modifiers/SchemaSerialize.ts");
4898
+ /* import */ var _modifiers_SchemaTag__rspack_import_15 = __webpack_require__("./src/schema/property/modifiers/SchemaTag.ts");
4899
+ /* import */ var _SchemaArray__rspack_import_12 = __webpack_require__("./src/schema/property/types/SchemaArray.ts");
4900
+
4901
+
4567
4902
 
4568
4903
 
4569
4904
 
@@ -4597,29 +4932,35 @@ class SchemaString extends _base_SchemaBase__rspack_import_0.SchemaBase {
4597
4932
  key() {
4598
4933
  return new _modifiers_SchemaKey__rspack_import_5.SchemaKey(this);
4599
4934
  }
4935
+ foreignKey(relatingSchema, property) {
4936
+ return new _modifiers_SchemaForeignKey__rspack_import_6.SchemaForeignKey(this, relatingSchema, property);
4937
+ }
4600
4938
  default(value, injected) {
4601
- return new _modifiers_SchemaDefault__rspack_import_6.SchemaDefault(value, injected, this);
4939
+ return new _modifiers_SchemaDefault__rspack_import_7.SchemaDefault(value, injected, this);
4602
4940
  }
4603
4941
  readonly() {
4604
- return new _modifiers_SchemaReadonly__rspack_import_7.SchemaReadonly(this);
4942
+ return new _modifiers_SchemaReadonly__rspack_import_8.SchemaReadonly(this);
4605
4943
  }
4606
4944
  deserialize(deserializer) {
4607
- return new _modifiers_SchemaDeserialize__rspack_import_8.SchemaDeserialize(deserializer, this);
4945
+ return new _modifiers_SchemaDeserialize__rspack_import_9.SchemaDeserialize(deserializer, this);
4608
4946
  }
4609
4947
  serialize(serializer) {
4610
- return new _modifiers_SchemaSerialize__rspack_import_9.SchemaSerialize(serializer, this);
4948
+ return new _modifiers_SchemaSerialize__rspack_import_10.SchemaSerialize(serializer, this);
4611
4949
  }
4612
4950
  identity() {
4613
- return new _modifiers_SchemaIdentity__rspack_import_10.SchemaIdentity(this);
4951
+ return new _modifiers_SchemaIdentity__rspack_import_11.SchemaIdentity(this);
4614
4952
  }
4615
4953
  array() {
4616
- return new _SchemaArray__rspack_import_11.SchemaArray(this);
4954
+ return new _SchemaArray__rspack_import_12.SchemaArray(this);
4617
4955
  }
4618
4956
  index(...indexes) {
4619
- return new _modifiers_SchemaIndex__rspack_import_12.SchemaIndex(this, ...indexes);
4957
+ return new _modifiers_SchemaIndex__rspack_import_13.SchemaIndex(this, ...indexes);
4620
4958
  }
4621
4959
  distinct() {
4622
- return new _modifiers_SchemaDistinct__rspack_import_13.SchemaDistinct(this);
4960
+ return new _modifiers_SchemaDistinct__rspack_import_14.SchemaDistinct(this);
4961
+ }
4962
+ tag(...tags) {
4963
+ return new _modifiers_SchemaTag__rspack_import_15.SchemaTag(tags, this);
4623
4964
  }
4624
4965
  }
4625
4966
 
@@ -4739,22 +5080,678 @@ var HashType;
4739
5080
  })(HashType || (HashType = {}));
4740
5081
 
4741
5082
 
5083
+ },
5084
+ "./src/schema/utils/standardJsonSchema.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
5085
+ __webpack_require__.r(__webpack_exports__);
5086
+ __webpack_require__.d(__webpack_exports__, {
5087
+ compiledSchemaToJsonSchema: () => (compiledSchemaToJsonSchema),
5088
+ createStandardJsonSchemaProps: () => (createStandardJsonSchemaProps),
5089
+ extractTypeInfo: () => (extractTypeInfo),
5090
+ propertyInfoToJsonSchema: () => (propertyInfoToJsonSchema),
5091
+ rehydrateSchemaFromJsonSchema: () => (rehydrateSchemaFromJsonSchema),
5092
+ rehydrateSchemaFromJsonString: () => (rehydrateSchemaFromJsonString)
5093
+ });
5094
+ /* import */ var _PropertyInfo__rspack_import_1 = __webpack_require__("./src/schema/PropertyInfo.ts");
5095
+ /* import */ var _types__rspack_import_0 = __webpack_require__("./src/schema/types.ts");
5096
+ /* import */ var _property_types_SchemaArray__rspack_import_2 = __webpack_require__("./src/schema/property/types/SchemaArray.ts");
5097
+ /* import */ var _builder__rspack_import_3 = __webpack_require__("./src/schema/builder.ts");
5098
+
5099
+
5100
+
5101
+
5102
+ /**
5103
+ * Converts a primitive property with optional enum/literals
5104
+ */
5105
+ function createPrimitiveConverter(jsonType) {
5106
+ return (property, _context) => {
5107
+ const jsonSchema = { type: jsonType };
5108
+ if (property.literals && property.literals.length > 0) {
5109
+ jsonSchema.enum = property.literals;
5110
+ }
5111
+ return jsonSchema;
5112
+ };
5113
+ }
5114
+ /**
5115
+ * Converts a Date property to JSON Schema
5116
+ */
5117
+ const dateConverter = (_property, _context) => {
5118
+ return {
5119
+ type: 'string',
5120
+ format: 'date-time'
5121
+ };
5122
+ };
5123
+ /**
5124
+ * Converts an Object property to JSON Schema
5125
+ */
5126
+ const objectConverter = (property, context) => {
5127
+ const jsonSchema = { type: 'object' };
5128
+ if (property.children && property.children.length > 0) {
5129
+ const properties = {};
5130
+ const required = [];
5131
+ for (const child of property.children) {
5132
+ // Skip computed and function properties for input schemas
5133
+ // Include them in output schemas as they represent derived values
5134
+ if (!context.useOutputType && (child.type === _types__rspack_import_0.SchemaTypes.Computed || child.type === _types__rspack_import_0.SchemaTypes.Function)) {
5135
+ continue;
5136
+ }
5137
+ const childSchema = context.convertProperty(child);
5138
+ // Skip empty schemas (e.g., computed properties that return empty for input)
5139
+ if (Object.keys(childSchema).length === 0) {
5140
+ continue;
5141
+ }
5142
+ const propertyName = child.from || child.name;
5143
+ properties[propertyName] = childSchema;
5144
+ // Add to required if not optional and not nullable
5145
+ // Computed/function properties are never required in JSON Schema
5146
+ if (!child.isOptional && !child.isNullable &&
5147
+ child.type !== _types__rspack_import_0.SchemaTypes.Computed && child.type !== _types__rspack_import_0.SchemaTypes.Function) {
5148
+ required.push(propertyName);
5149
+ }
5150
+ }
5151
+ if (Object.keys(properties).length > 0) {
5152
+ jsonSchema.properties = properties;
5153
+ }
5154
+ if (required.length > 0) {
5155
+ jsonSchema.required = required;
5156
+ }
5157
+ }
5158
+ else {
5159
+ // Empty object or unknown structure
5160
+ jsonSchema.properties = {};
5161
+ }
5162
+ return jsonSchema;
5163
+ };
5164
+ /**
5165
+ * Converts array inner schema to JSON Schema items
5166
+ * Attempts to fully recurse into object schemas when possible
5167
+ */
5168
+ function convertArrayItems(innerSchema, context) {
5169
+ const innerType = innerSchema.type;
5170
+ switch (innerType) {
5171
+ case _types__rspack_import_0.SchemaTypes.String:
5172
+ return { type: 'string' };
5173
+ case _types__rspack_import_0.SchemaTypes.Number:
5174
+ return { type: 'number' };
5175
+ case _types__rspack_import_0.SchemaTypes.Boolean:
5176
+ return { type: 'boolean' };
5177
+ case _types__rspack_import_0.SchemaTypes.Date:
5178
+ return { type: 'string', format: 'date-time' };
5179
+ case _types__rspack_import_0.SchemaTypes.Object:
5180
+ // Try to extract object structure from innerSchema.instance
5181
+ // For SchemaObject, instance contains the property definitions
5182
+ if (innerSchema.instance && typeof innerSchema.instance === 'object') {
5183
+ const properties = {};
5184
+ const required = [];
5185
+ // Iterate through the instance properties
5186
+ for (const [key, value] of Object.entries(innerSchema.instance)) {
5187
+ if (value && typeof value === 'object' && 'type' in value) {
5188
+ // This is a SchemaBase - try to convert it
5189
+ const schemaBase = value;
5190
+ const tempProperty = new _PropertyInfo__rspack_import_1.PropertyInfo(schemaBase, key);
5191
+ // Skip computed/function for input schemas
5192
+ if (!context.useOutputType &&
5193
+ (tempProperty.type === _types__rspack_import_0.SchemaTypes.Computed || tempProperty.type === _types__rspack_import_0.SchemaTypes.Function)) {
5194
+ continue;
5195
+ }
5196
+ const itemSchema = context.convertProperty(tempProperty);
5197
+ if (Object.keys(itemSchema).length > 0) {
5198
+ properties[key] = itemSchema;
5199
+ if (!tempProperty.isOptional && !tempProperty.isNullable &&
5200
+ tempProperty.type !== _types__rspack_import_0.SchemaTypes.Computed && tempProperty.type !== _types__rspack_import_0.SchemaTypes.Function) {
5201
+ required.push(key);
5202
+ }
5203
+ }
5204
+ }
5205
+ }
5206
+ if (Object.keys(properties).length > 0) {
5207
+ return {
5208
+ type: 'object',
5209
+ properties,
5210
+ ...(required.length > 0 ? { required } : {})
5211
+ };
5212
+ }
5213
+ }
5214
+ // Fallback for unknown object structure
5215
+ return {
5216
+ type: 'object',
5217
+ properties: {},
5218
+ description: 'Array item object schema'
5219
+ };
5220
+ case _types__rspack_import_0.SchemaTypes.Array:
5221
+ // Nested arrays - recursively handle
5222
+ if (innerSchema instanceof _property_types_SchemaArray__rspack_import_2.SchemaArray && innerSchema.innerSchema) {
5223
+ return {
5224
+ type: 'array',
5225
+ items: convertArrayItems(innerSchema.innerSchema, context)
5226
+ };
5227
+ }
5228
+ return {
5229
+ type: 'array',
5230
+ items: { type: 'object' } // Simplified fallback
5231
+ };
5232
+ default:
5233
+ return { type: 'object' };
5234
+ }
5235
+ }
5236
+ /**
5237
+ * Converts an Array property to JSON Schema
5238
+ */
5239
+ const arrayConverter = (property, context) => {
5240
+ const jsonSchema = { type: 'array' };
5241
+ if (property.innerSchema) {
5242
+ jsonSchema.items = convertArrayItems(property.innerSchema, context);
5243
+ }
5244
+ else {
5245
+ jsonSchema.items = { type: 'object' };
5246
+ }
5247
+ return jsonSchema;
5248
+ };
5249
+ /**
5250
+ * Converts computed/function properties to JSON Schema
5251
+ * For input schemas, these return empty (should be skipped)
5252
+ * For output schemas, we include them with a generic object type
5253
+ */
5254
+ const computedConverter = (property, context) => {
5255
+ // For input schemas, computed/function properties are not part of the data shape
5256
+ if (!context.useOutputType) {
5257
+ return {};
5258
+ }
5259
+ // For output schemas, include computed properties
5260
+ // We can't know the exact return type without executing the function,
5261
+ // so we use a generic object type with a note
5262
+ const routierMeta = {
5263
+ isComputed: property.type === _types__rspack_import_0.SchemaTypes.Computed,
5264
+ isFunction: property.type === _types__rspack_import_0.SchemaTypes.Function
5265
+ };
5266
+ // Store function source code for rehydration
5267
+ if (property.functionBody) {
5268
+ try {
5269
+ routierMeta.functionSource = property.functionBody.toString();
5270
+ }
5271
+ catch {
5272
+ // If function can't be serialized, store a placeholder
5273
+ routierMeta.functionSource = null;
5274
+ }
5275
+ }
5276
+ // Store injected value if it's serializable
5277
+ if (property.injected !== null && property.injected !== undefined) {
5278
+ try {
5279
+ // Try to serialize the injected value
5280
+ JSON.stringify(property.injected);
5281
+ routierMeta.injected = property.injected;
5282
+ }
5283
+ catch {
5284
+ // If injected value can't be serialized, store null
5285
+ routierMeta.injected = null;
5286
+ }
5287
+ }
5288
+ else {
5289
+ routierMeta.injected = null;
5290
+ }
5291
+ return {
5292
+ type: 'object',
5293
+ description: property.type === _types__rspack_import_0.SchemaTypes.Computed
5294
+ ? 'Computed property (derived value)'
5295
+ : 'Function property (derived value)',
5296
+ 'x-routier': routierMeta
5297
+ };
5298
+ };
5299
+ /**
5300
+ * Default converter for unknown types
5301
+ */
5302
+ const defaultConverter = () => {
5303
+ return { type: 'object' };
5304
+ };
5305
+ /**
5306
+ * Factory registry mapping SchemaTypes to converters
5307
+ */
5308
+ const converterRegistry = new Map([
5309
+ [_types__rspack_import_0.SchemaTypes.String, createPrimitiveConverter('string')],
5310
+ [_types__rspack_import_0.SchemaTypes.Number, createPrimitiveConverter('number')],
5311
+ [_types__rspack_import_0.SchemaTypes.Boolean, createPrimitiveConverter('boolean')],
5312
+ [_types__rspack_import_0.SchemaTypes.Date, dateConverter],
5313
+ [_types__rspack_import_0.SchemaTypes.Object, objectConverter],
5314
+ [_types__rspack_import_0.SchemaTypes.Array, arrayConverter],
5315
+ [_types__rspack_import_0.SchemaTypes.Computed, computedConverter],
5316
+ [_types__rspack_import_0.SchemaTypes.Function, computedConverter],
5317
+ ]);
5318
+ /**
5319
+ * Applies nullable handling to a JSON Schema based on the target draft version
5320
+ */
5321
+ function applyNullable(jsonSchema, property, target) {
5322
+ if (!property.isNullable) {
5323
+ return;
5324
+ }
5325
+ if (target === 'draft-2020-12') {
5326
+ if (Array.isArray(jsonSchema.type)) {
5327
+ jsonSchema.type.push('null');
5328
+ }
5329
+ else {
5330
+ jsonSchema.type = [jsonSchema.type, 'null'];
5331
+ }
5332
+ }
5333
+ else {
5334
+ jsonSchema.nullable = true;
5335
+ }
5336
+ }
5337
+ /**
5338
+ * Applies Routier-specific metadata to a JSON Schema
5339
+ */
5340
+ function applyRoutierMetadata(jsonSchema, property) {
5341
+ // Don't overwrite existing x-routier metadata (e.g., from computed properties)
5342
+ if (!jsonSchema['x-routier']) {
5343
+ jsonSchema['x-routier'] = {};
5344
+ }
5345
+ const routierMeta = jsonSchema['x-routier'];
5346
+ // Only add metadata if it doesn't already exist (to preserve computed property metadata)
5347
+ if (property.isKey && !routierMeta.isKey) {
5348
+ routierMeta.isKey = true;
5349
+ }
5350
+ if (property.isIdentity && !routierMeta.isIdentity) {
5351
+ routierMeta.isIdentity = true;
5352
+ }
5353
+ if (property.isReadonly && !routierMeta.isReadonly) {
5354
+ routierMeta.isReadonly = true;
5355
+ }
5356
+ if (property.isDistinct && !routierMeta.isDistinct) {
5357
+ routierMeta.isDistinct = true;
5358
+ }
5359
+ if (property.indexes && property.indexes.length > 0 && !routierMeta.indexes) {
5360
+ routierMeta.indexes = property.indexes;
5361
+ }
5362
+ if ((property.valueSerializer || property.valueDeserializer) && !routierMeta.hasCustomSerialization) {
5363
+ routierMeta.hasCustomSerialization = true;
5364
+ }
5365
+ if (property.defaultValue != null && !routierMeta.hasDefault) {
5366
+ routierMeta.hasDefault = true;
5367
+ // Note: We can't serialize function defaults, only note their presence
5368
+ if (typeof property.defaultValue === 'function') {
5369
+ routierMeta.defaultIsFunction = true;
5370
+ }
5371
+ else {
5372
+ // For static defaults, we can include the actual value
5373
+ // Note: This includes falsy values like 0, false, empty string, etc.
5374
+ routierMeta.defaultValue = property.defaultValue;
5375
+ }
5376
+ }
5377
+ // Store the Routier property name in metadata (may differ from JSON Schema key if from() is used)
5378
+ if (!routierMeta.propertyName) {
5379
+ routierMeta.propertyName = property.name;
5380
+ }
5381
+ if (property.from != null && !routierMeta.from) {
5382
+ routierMeta.from = property.from;
5383
+ }
5384
+ }
5385
+ /**
5386
+ * Converts a Routier PropertyInfo to a JSON Schema property definition.
5387
+ */
5388
+ function propertyInfoToJsonSchema(property, target, visited = new Set(), useOutputType = false) {
5389
+ // Create conversion context with recursive converter
5390
+ const context = {
5391
+ target,
5392
+ visited,
5393
+ useOutputType,
5394
+ convertProperty: (prop) => propertyInfoToJsonSchema(prop, target, visited, useOutputType)
5395
+ };
5396
+ // Get converter from factory registry
5397
+ const converter = converterRegistry.get(property.type) ?? defaultConverter;
5398
+ // Convert the property
5399
+ const jsonSchema = converter(property, context);
5400
+ // Apply nullable handling
5401
+ applyNullable(jsonSchema, property, target);
5402
+ // Apply Routier-specific metadata
5403
+ applyRoutierMetadata(jsonSchema, property);
5404
+ return jsonSchema;
5405
+ }
5406
+ /**
5407
+ * Converts a CompiledSchema to a JSON Schema object schema.
5408
+ */
5409
+ function compiledSchemaToJsonSchema(compiledSchema, target, useOutputType = false) {
5410
+ const jsonSchema = {
5411
+ $schema: target === 'draft-2020-12'
5412
+ ? 'https://json-schema.org/draft/2020-12/schema'
5413
+ : target === 'draft-07'
5414
+ ? 'http://json-schema.org/draft-07/schema#'
5415
+ : 'http://json-schema.org/draft-04/schema#',
5416
+ type: 'object',
5417
+ properties: {},
5418
+ required: []
5419
+ };
5420
+ const properties = {};
5421
+ const required = [];
5422
+ // Iterate through all properties
5423
+ for (const property of compiledSchema.properties) {
5424
+ // Skip computed and function properties for input schema
5425
+ // For output schema, we include computed properties
5426
+ if (!useOutputType && (property.type === _types__rspack_import_0.SchemaTypes.Computed || property.type === _types__rspack_import_0.SchemaTypes.Function)) {
5427
+ continue;
5428
+ }
5429
+ // Skip unmapped properties (except computed/function properties in output schema)
5430
+ if (property.isUnmapped && !(useOutputType && (property.type === _types__rspack_import_0.SchemaTypes.Computed || property.type === _types__rspack_import_0.SchemaTypes.Function))) {
5431
+ continue;
5432
+ }
5433
+ const propertySchema = propertyInfoToJsonSchema(property, target, new Set(), useOutputType);
5434
+ // Skip empty schemas (e.g., computed properties that return empty)
5435
+ if (Object.keys(propertySchema).length === 0) {
5436
+ continue;
5437
+ }
5438
+ const propertyName = property.from || property.name;
5439
+ properties[propertyName] = propertySchema;
5440
+ // Add to required if not optional and not nullable
5441
+ if (!property.isOptional && !property.isNullable) {
5442
+ required.push(propertyName);
5443
+ }
5444
+ }
5445
+ jsonSchema.properties = properties;
5446
+ if (required.length > 0) {
5447
+ jsonSchema.required = required;
5448
+ }
5449
+ // Add Routier-specific metadata
5450
+ jsonSchema['x-routier'] = {
5451
+ collectionName: compiledSchema.collectionName,
5452
+ idProperties: compiledSchema.idProperties.map(p => p.name),
5453
+ hasIdentities: compiledSchema.hasIdentities,
5454
+ hasIdentityKeys: compiledSchema.hasIdentityKeys
5455
+ };
5456
+ return jsonSchema;
5457
+ }
5458
+ /**
5459
+ * Creates Standard JSON Schema V1 props for a compiled schema.
5460
+ */
5461
+ function createStandardJsonSchemaProps(compiledSchema) {
5462
+ return {
5463
+ version: 1,
5464
+ vendor: 'routier',
5465
+ types: {
5466
+ input: undefined,
5467
+ output: undefined
5468
+ },
5469
+ jsonSchema: {
5470
+ input: (options) => {
5471
+ return compiledSchemaToJsonSchema(compiledSchema, options.target, false);
5472
+ },
5473
+ output: (options) => {
5474
+ return compiledSchemaToJsonSchema(compiledSchema, options.target, true);
5475
+ }
5476
+ }
5477
+ };
5478
+ }
5479
+ /**
5480
+ * Parses a JSON string containing a JSON Schema and rehydrates it into a Routier SchemaDefinition.
5481
+ * This is a convenience wrapper around `rehydrateSchemaFromJsonSchema` that handles JSON parsing.
5482
+ *
5483
+ * @param jsonString - The JSON string containing the JSON Schema
5484
+ * @param collectionName - The collection name for the schema (if not in x-routier metadata)
5485
+ * @returns A SchemaDefinition that can be compiled
5486
+ * @throws Error if the JSON string is invalid or doesn't contain a valid JSON Schema
5487
+ */
5488
+ function rehydrateSchemaFromJsonString(jsonString, collectionName) {
5489
+ try {
5490
+ const jsonSchema = JSON.parse(jsonString);
5491
+ return rehydrateSchemaFromJsonSchema(jsonSchema, collectionName);
5492
+ }
5493
+ catch (error) {
5494
+ if (error instanceof SyntaxError) {
5495
+ throw new Error(`Invalid JSON string: ${error.message}`);
5496
+ }
5497
+ throw error;
5498
+ }
5499
+ }
5500
+ /**
5501
+ * Rehydrates a JSON Schema back into a Routier SchemaDefinition.
5502
+ * This parses the JSON Schema structure and reconstructs the schema using Routier's builder API.
5503
+ *
5504
+ * @param jsonSchema - The JSON Schema object to rehydrate
5505
+ * @param collectionName - The collection name for the schema (if not in x-routier metadata)
5506
+ * @returns A SchemaDefinition that can be compiled
5507
+ */
5508
+ function rehydrateSchemaFromJsonSchema(jsonSchema, collectionName) {
5509
+ // Extract collection name - provided collectionName takes precedence over metadata
5510
+ const routierMeta = jsonSchema['x-routier'];
5511
+ const finalCollectionName = collectionName || routierMeta?.collectionName || 'unknown';
5512
+ if (!jsonSchema.properties || typeof jsonSchema.properties !== 'object') {
5513
+ throw new Error('JSON Schema must have a properties object');
5514
+ }
5515
+ const properties = jsonSchema.properties;
5516
+ const required = jsonSchema.required || [];
5517
+ const schemaDefinition = {};
5518
+ const computedProperties = [];
5519
+ // Get idProperties from schema-level metadata as fallback
5520
+ const idProperties = routierMeta?.idProperties || [];
5521
+ for (const [propName, propSchema] of Object.entries(properties)) {
5522
+ const prop = propSchema;
5523
+ const isRequired = required.includes(propName);
5524
+ const routierPropMeta = prop['x-routier'];
5525
+ // Use Routier property name from metadata if available, otherwise use JSON Schema property name
5526
+ const routierPropName = routierPropMeta?.propertyName || propName;
5527
+ // Check if this is a computed or function property
5528
+ if (routierPropMeta?.isComputed || routierPropMeta?.isFunction) {
5529
+ computedProperties.push({
5530
+ name: routierPropName,
5531
+ isComputed: routierPropMeta.isComputed === true,
5532
+ functionSource: routierPropMeta.functionSource || null,
5533
+ injected: routierPropMeta.injected !== undefined ? routierPropMeta.injected : null
5534
+ });
5535
+ continue;
5536
+ }
5537
+ // Convert JSON Schema property to Routier schema
5538
+ let schemaBuilder = convertJsonSchemaPropertyToRoutier(prop);
5539
+ // Apply Routier-specific modifiers (using type assertion for method chaining)
5540
+ // Note: Apply key() first as it's required for schema compilation
5541
+ // Check both property-level metadata and schema-level idProperties list
5542
+ const isKey = routierPropMeta?.isKey === true || idProperties.includes(routierPropName);
5543
+ if (isKey && typeof schemaBuilder.key === 'function') {
5544
+ schemaBuilder = schemaBuilder.key();
5545
+ }
5546
+ // Apply from() mapping early, as it's a fundamental property mapping
5547
+ if (routierPropMeta?.from && typeof schemaBuilder.from === 'function') {
5548
+ schemaBuilder = schemaBuilder.from(routierPropMeta.from);
5549
+ }
5550
+ if (routierPropMeta?.isIdentity && typeof schemaBuilder.identity === 'function') {
5551
+ schemaBuilder = schemaBuilder.identity();
5552
+ }
5553
+ if (routierPropMeta?.isReadonly && typeof schemaBuilder.readonly === 'function') {
5554
+ schemaBuilder = schemaBuilder.readonly();
5555
+ }
5556
+ if (routierPropMeta?.isDistinct && typeof schemaBuilder.distinct === 'function') {
5557
+ schemaBuilder = schemaBuilder.distinct();
5558
+ }
5559
+ // Apply optional if property is not required (nullable and optional are independent)
5560
+ if (!isRequired && typeof schemaBuilder.optional === 'function') {
5561
+ schemaBuilder = schemaBuilder.optional();
5562
+ }
5563
+ // Apply nullable if property allows null (nullable and optional are independent)
5564
+ if (prop.nullable === true || (Array.isArray(prop.type) && prop.type.includes('null'))) {
5565
+ if (typeof schemaBuilder.nullable === 'function') {
5566
+ schemaBuilder = schemaBuilder.nullable();
5567
+ }
5568
+ }
5569
+ if (routierPropMeta?.indexes && Array.isArray(routierPropMeta.indexes)) {
5570
+ if (typeof schemaBuilder.index === 'function') {
5571
+ schemaBuilder = schemaBuilder.index(...routierPropMeta.indexes);
5572
+ }
5573
+ }
5574
+ // Apply default value if present (only static defaults, not function defaults)
5575
+ // hasDefault=true and defaultIsFunction=false means we have a static default value stored
5576
+ if (routierPropMeta?.hasDefault && !routierPropMeta.defaultIsFunction && routierPropMeta.hasOwnProperty('defaultValue')) {
5577
+ if (typeof schemaBuilder.default === 'function') {
5578
+ schemaBuilder = schemaBuilder.default(routierPropMeta.defaultValue);
5579
+ }
5580
+ }
5581
+ schemaDefinition[routierPropName] = schemaBuilder;
5582
+ }
5583
+ // Build base schema
5584
+ let schema = _builder__rspack_import_3.s.define(finalCollectionName, schemaDefinition);
5585
+ // Add computed properties via modify()
5586
+ if (computedProperties.length > 0) {
5587
+ schema = schema.modify(x => {
5588
+ const computedDefs = {};
5589
+ for (const computedProp of computedProperties) {
5590
+ if (computedProp.functionSource) {
5591
+ // Recreate the function from source code
5592
+ // The function signature is: (entity, collectionName, injected) => result
5593
+ // We use new Function() to create the function, but wrap it so toString() returns the arrow function
5594
+ let recreatedFn;
5595
+ try {
5596
+ const functionSource = computedProp.functionSource;
5597
+ // Parse the arrow function to extract parameters and body
5598
+ const arrowMatch = functionSource.match(/^\(([^)]*)\)\s*=>\s*(.+)$/s);
5599
+ if (!arrowMatch) {
5600
+ throw new Error('Function source is not an arrow function');
5601
+ }
5602
+ // Parse parameters
5603
+ const paramsStr = arrowMatch[1].trim();
5604
+ const params = paramsStr ? paramsStr.split(',').map(p => p.trim()).filter(p => p) : [];
5605
+ const body = arrowMatch[2].trim();
5606
+ // Create function body - if it's a block (starts with {), use as-is, otherwise wrap in return
5607
+ const functionBody = body.startsWith('{')
5608
+ ? body.slice(1, -1) // Remove outer braces
5609
+ : `return ${body}`;
5610
+ // Create the function using new Function()
5611
+ // If no parameters, call with just the body; otherwise spread the params
5612
+ const fn = params.length > 0
5613
+ ? new Function(...params, functionBody)
5614
+ : new Function(functionBody);
5615
+ // Wrap it so toString() returns the original arrow function string
5616
+ // This is needed because the schema system validates that functions are arrow functions
5617
+ recreatedFn = Object.assign(fn, {
5618
+ toString: () => functionSource
5619
+ });
5620
+ }
5621
+ catch (e) {
5622
+ // If we can't recreate the function, create a placeholder arrow function that throws
5623
+ recreatedFn = () => {
5624
+ throw new Error(`Cannot recreate computed property ${computedProp.name}: ${e instanceof Error ? e.message : 'unknown error'}`);
5625
+ };
5626
+ // Ensure toString returns an arrow function for validation
5627
+ Object.assign(recreatedFn, {
5628
+ toString: () => `() => { throw new Error("Cannot recreate computed property ${computedProp.name}"); }`
5629
+ });
5630
+ }
5631
+ // Add computed property with optional injected value
5632
+ if (computedProp.isComputed) {
5633
+ computedDefs[computedProp.name] = x.computed(recreatedFn, computedProp.injected);
5634
+ }
5635
+ else {
5636
+ computedDefs[computedProp.name] = x.function(recreatedFn, computedProp.injected);
5637
+ }
5638
+ }
5639
+ else {
5640
+ // No function source available - create a placeholder
5641
+ computedDefs[computedProp.name] = computedProp.isComputed
5642
+ ? x.computed(() => {
5643
+ throw new Error(`Computed property ${computedProp.name} could not be rehydrated: function source not available`);
5644
+ })
5645
+ : x.function(() => {
5646
+ throw new Error(`Function property ${computedProp.name} could not be rehydrated: function source not available`);
5647
+ });
5648
+ }
5649
+ }
5650
+ return computedDefs;
5651
+ });
5652
+ }
5653
+ return schema;
5654
+ }
5655
+ /**
5656
+ * Converts a JSON Schema property definition to a Routier schema builder.
5657
+ */
5658
+ function convertJsonSchemaPropertyToRoutier(prop) {
5659
+ const type = Array.isArray(prop.type)
5660
+ ? prop.type.find(t => t !== 'null') || prop.type[0]
5661
+ : prop.type;
5662
+ // Check for date type - dates are serialized as string with format 'date-time'
5663
+ if (type === 'string' && prop.format === 'date-time') {
5664
+ return _builder__rspack_import_3.s.date();
5665
+ }
5666
+ switch (type) {
5667
+ case 'string':
5668
+ if (prop.enum && Array.isArray(prop.enum)) {
5669
+ return _builder__rspack_import_3.s.string(...prop.enum);
5670
+ }
5671
+ return _builder__rspack_import_3.s.string();
5672
+ case 'number':
5673
+ case 'integer':
5674
+ if (prop.enum && Array.isArray(prop.enum)) {
5675
+ return _builder__rspack_import_3.s.number(...prop.enum);
5676
+ }
5677
+ return _builder__rspack_import_3.s.number();
5678
+ case 'boolean':
5679
+ return _builder__rspack_import_3.s.boolean();
5680
+ case 'object':
5681
+ // Recurse into object properties
5682
+ if (prop.properties && typeof prop.properties === 'object') {
5683
+ const objectProps = prop.properties;
5684
+ const objectSchema = {};
5685
+ for (const [key, value] of Object.entries(objectProps)) {
5686
+ objectSchema[key] = convertJsonSchemaPropertyToRoutier(value);
5687
+ }
5688
+ return _builder__rspack_import_3.s.object(objectSchema);
5689
+ }
5690
+ return _builder__rspack_import_3.s.object({});
5691
+ case 'array':
5692
+ // Handle array items
5693
+ if (prop.items && typeof prop.items === 'object') {
5694
+ const itemsSchema = convertJsonSchemaPropertyToRoutier(prop.items);
5695
+ return _builder__rspack_import_3.s.array(itemsSchema);
5696
+ }
5697
+ return _builder__rspack_import_3.s.array(_builder__rspack_import_3.s.object({}));
5698
+ default:
5699
+ // Fallback to object for unknown types
5700
+ return _builder__rspack_import_3.s.object({});
5701
+ }
5702
+ }
5703
+ /**
5704
+ * Attempts to extract type information from a compiled schema for better type inference.
5705
+ *
5706
+ * Note: TypeScript types are compile-time only, so we can't extract actual type information at runtime.
5707
+ * The Standard JSON Schema spec allows libraries to advertise their inferred types via the `types` property,
5708
+ * but this requires compile-time type information that isn't available at runtime.
5709
+ *
5710
+ * For proper type inference, consumers should use TypeScript's type system:
5711
+ * ```typescript
5712
+ * const schema = s.define("users", { ... }).compile();
5713
+ * type User = InferType<typeof schema>;
5714
+ * type CreateUser = InferCreateType<typeof schema>;
5715
+ * ```
5716
+ *
5717
+ * @param compiledSchema - The compiled schema to extract type info from
5718
+ * @returns A description of the type names (for documentation purposes only)
5719
+ */
5720
+ function extractTypeInfo(compiledSchema) {
5721
+ return {
5722
+ inputType: `InferCreateType<${compiledSchema.collectionName}>`,
5723
+ outputType: `InferType<${compiledSchema.collectionName}>`
5724
+ };
5725
+ }
5726
+
5727
+
4742
5728
  },
4743
5729
  "./src/utilities/logger.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4744
5730
  __webpack_require__.r(__webpack_exports__);
4745
5731
  __webpack_require__.d(__webpack_exports__, {
4746
5732
  logger: () => (logger)
4747
5733
  });
4748
- const isDevelopment = () => {
4749
- if (typeof process === 'undefined' || process.env == null) {
4750
- return false;
4751
- }
4752
- const env = "development"?.toLowerCase();
4753
- return env === 'dev' || env === 'development' || env === 'test';
5734
+ /**
5735
+ * Enable logging by setting `globalThis.__ROUTIER_DEBUG__ = true` before any routier code runs.
5736
+ */
5737
+ const shouldLog = () => {
5738
+ if (typeof globalThis !== 'undefined') {
5739
+ const g = globalThis;
5740
+ if (g.__ROUTIER_DEBUG__ === true)
5741
+ return true;
5742
+ }
5743
+ if (typeof process !== 'undefined' && process.env != null) {
5744
+ const debug = process.env.DEBUG;
5745
+ if (debug === 'routier' || debug === '*')
5746
+ return true;
5747
+ const env = "development"?.toLowerCase();
5748
+ if (env === 'dev' || env === 'development' || env === 'test')
5749
+ return true;
5750
+ }
5751
+ return false;
4754
5752
  };
4755
- const shouldLog = isDevelopment();
4756
5753
  const tryLog = (type, ...args) => {
4757
- if (shouldLog) {
5754
+ if (shouldLog()) {
4758
5755
  console[type](...args);
4759
5756
  }
4760
5757
  };
@@ -5063,8 +6060,10 @@ __webpack_require__.d(__webpack_exports__, {
5063
6060
  SchemaComputed: () => (/* reexport safe */ _table__rspack_import_1.SchemaComputed),
5064
6061
  SchemaDate: () => (/* reexport safe */ _property_types__rspack_import_4.SchemaDate),
5065
6062
  SchemaDefault: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaDefault),
6063
+ SchemaDefinition: () => (/* reexport safe */ _SchemaDefinition__rspack_import_8.SchemaDefinition),
5066
6064
  SchemaDeserialize: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaDeserialize),
5067
6065
  SchemaDistinct: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaDistinct),
6066
+ SchemaForeignKey: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaForeignKey),
5068
6067
  SchemaFrom: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaFrom),
5069
6068
  SchemaFunction: () => (/* reexport safe */ _table__rspack_import_1.SchemaFunction),
5070
6069
  SchemaIdentity: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaIdentity),
@@ -5077,8 +6076,15 @@ __webpack_require__.d(__webpack_exports__, {
5077
6076
  SchemaReadonly: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaReadonly),
5078
6077
  SchemaSerialize: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaSerialize),
5079
6078
  SchemaString: () => (/* reexport safe */ _property_types__rspack_import_4.SchemaString),
6079
+ SchemaTag: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaTag),
5080
6080
  SchemaTracked: () => (/* reexport safe */ _property_modifiers__rspack_import_3.SchemaTracked),
5081
6081
  SchemaTypes: () => (/* reexport safe */ _types__rspack_import_6.SchemaTypes),
6082
+ compiledSchemaToJsonSchema: () => (/* reexport safe */ _utils_standardJsonSchema__rspack_import_7.compiledSchemaToJsonSchema),
6083
+ createStandardJsonSchemaProps: () => (/* reexport safe */ _utils_standardJsonSchema__rspack_import_7.createStandardJsonSchemaProps),
6084
+ extractTypeInfo: () => (/* reexport safe */ _utils_standardJsonSchema__rspack_import_7.extractTypeInfo),
6085
+ propertyInfoToJsonSchema: () => (/* reexport safe */ _utils_standardJsonSchema__rspack_import_7.propertyInfoToJsonSchema),
6086
+ rehydrateSchemaFromJsonSchema: () => (/* reexport safe */ _utils_standardJsonSchema__rspack_import_7.rehydrateSchemaFromJsonSchema),
6087
+ rehydrateSchemaFromJsonString: () => (/* reexport safe */ _utils_standardJsonSchema__rspack_import_7.rehydrateSchemaFromJsonString),
5082
6088
  s: () => (/* reexport safe */ _builder__rspack_import_0.s)
5083
6089
  });
5084
6090
  /* import */ var _builder__rspack_import_0 = __webpack_require__("./src/schema/builder.ts");
@@ -5088,6 +6094,10 @@ __webpack_require__.d(__webpack_exports__, {
5088
6094
  /* import */ var _property_types__rspack_import_4 = __webpack_require__("./src/schema/property/types/index.ts");
5089
6095
  /* import */ var _PropertyInfo__rspack_import_5 = __webpack_require__("./src/schema/PropertyInfo.ts");
5090
6096
  /* import */ var _types__rspack_import_6 = __webpack_require__("./src/schema/types.ts");
6097
+ /* import */ var _utils_standardJsonSchema__rspack_import_7 = __webpack_require__("./src/schema/utils/standardJsonSchema.ts");
6098
+ /* import */ var _SchemaDefinition__rspack_import_8 = __webpack_require__("./src/schema/SchemaDefinition.ts");
6099
+
6100
+
5091
6101
 
5092
6102
 
5093
6103
 
@@ -5106,8 +6116,10 @@ var __webpack_exports__SchemaBoolean = __webpack_exports__.SchemaBoolean;
5106
6116
  var __webpack_exports__SchemaComputed = __webpack_exports__.SchemaComputed;
5107
6117
  var __webpack_exports__SchemaDate = __webpack_exports__.SchemaDate;
5108
6118
  var __webpack_exports__SchemaDefault = __webpack_exports__.SchemaDefault;
6119
+ var __webpack_exports__SchemaDefinition = __webpack_exports__.SchemaDefinition;
5109
6120
  var __webpack_exports__SchemaDeserialize = __webpack_exports__.SchemaDeserialize;
5110
6121
  var __webpack_exports__SchemaDistinct = __webpack_exports__.SchemaDistinct;
6122
+ var __webpack_exports__SchemaForeignKey = __webpack_exports__.SchemaForeignKey;
5111
6123
  var __webpack_exports__SchemaFrom = __webpack_exports__.SchemaFrom;
5112
6124
  var __webpack_exports__SchemaFunction = __webpack_exports__.SchemaFunction;
5113
6125
  var __webpack_exports__SchemaIdentity = __webpack_exports__.SchemaIdentity;
@@ -5120,9 +6132,16 @@ var __webpack_exports__SchemaOptional = __webpack_exports__.SchemaOptional;
5120
6132
  var __webpack_exports__SchemaReadonly = __webpack_exports__.SchemaReadonly;
5121
6133
  var __webpack_exports__SchemaSerialize = __webpack_exports__.SchemaSerialize;
5122
6134
  var __webpack_exports__SchemaString = __webpack_exports__.SchemaString;
6135
+ var __webpack_exports__SchemaTag = __webpack_exports__.SchemaTag;
5123
6136
  var __webpack_exports__SchemaTracked = __webpack_exports__.SchemaTracked;
5124
6137
  var __webpack_exports__SchemaTypes = __webpack_exports__.SchemaTypes;
6138
+ var __webpack_exports__compiledSchemaToJsonSchema = __webpack_exports__.compiledSchemaToJsonSchema;
6139
+ var __webpack_exports__createStandardJsonSchemaProps = __webpack_exports__.createStandardJsonSchemaProps;
6140
+ var __webpack_exports__extractTypeInfo = __webpack_exports__.extractTypeInfo;
6141
+ var __webpack_exports__propertyInfoToJsonSchema = __webpack_exports__.propertyInfoToJsonSchema;
6142
+ var __webpack_exports__rehydrateSchemaFromJsonSchema = __webpack_exports__.rehydrateSchemaFromJsonSchema;
6143
+ var __webpack_exports__rehydrateSchemaFromJsonString = __webpack_exports__.rehydrateSchemaFromJsonString;
5125
6144
  var __webpack_exports__s = __webpack_exports__.s;
5126
- export { __webpack_exports__HashType as HashType, __webpack_exports__PropertyInfo as PropertyInfo, __webpack_exports__SchemaArray as SchemaArray, __webpack_exports__SchemaBase as SchemaBase, __webpack_exports__SchemaBoolean as SchemaBoolean, __webpack_exports__SchemaComputed as SchemaComputed, __webpack_exports__SchemaDate as SchemaDate, __webpack_exports__SchemaDefault as SchemaDefault, __webpack_exports__SchemaDeserialize as SchemaDeserialize, __webpack_exports__SchemaDistinct as SchemaDistinct, __webpack_exports__SchemaFrom as SchemaFrom, __webpack_exports__SchemaFunction as SchemaFunction, __webpack_exports__SchemaIdentity as SchemaIdentity, __webpack_exports__SchemaIndex as SchemaIndex, __webpack_exports__SchemaKey as SchemaKey, __webpack_exports__SchemaNullable as SchemaNullable, __webpack_exports__SchemaNumber as SchemaNumber, __webpack_exports__SchemaObject as SchemaObject, __webpack_exports__SchemaOptional as SchemaOptional, __webpack_exports__SchemaReadonly as SchemaReadonly, __webpack_exports__SchemaSerialize as SchemaSerialize, __webpack_exports__SchemaString as SchemaString, __webpack_exports__SchemaTracked as SchemaTracked, __webpack_exports__SchemaTypes as SchemaTypes, __webpack_exports__s as s };
6145
+ export { __webpack_exports__HashType as HashType, __webpack_exports__PropertyInfo as PropertyInfo, __webpack_exports__SchemaArray as SchemaArray, __webpack_exports__SchemaBase as SchemaBase, __webpack_exports__SchemaBoolean as SchemaBoolean, __webpack_exports__SchemaComputed as SchemaComputed, __webpack_exports__SchemaDate as SchemaDate, __webpack_exports__SchemaDefault as SchemaDefault, __webpack_exports__SchemaDefinition as SchemaDefinition, __webpack_exports__SchemaDeserialize as SchemaDeserialize, __webpack_exports__SchemaDistinct as SchemaDistinct, __webpack_exports__SchemaForeignKey as SchemaForeignKey, __webpack_exports__SchemaFrom as SchemaFrom, __webpack_exports__SchemaFunction as SchemaFunction, __webpack_exports__SchemaIdentity as SchemaIdentity, __webpack_exports__SchemaIndex as SchemaIndex, __webpack_exports__SchemaKey as SchemaKey, __webpack_exports__SchemaNullable as SchemaNullable, __webpack_exports__SchemaNumber as SchemaNumber, __webpack_exports__SchemaObject as SchemaObject, __webpack_exports__SchemaOptional as SchemaOptional, __webpack_exports__SchemaReadonly as SchemaReadonly, __webpack_exports__SchemaSerialize as SchemaSerialize, __webpack_exports__SchemaString as SchemaString, __webpack_exports__SchemaTag as SchemaTag, __webpack_exports__SchemaTracked as SchemaTracked, __webpack_exports__SchemaTypes as SchemaTypes, __webpack_exports__compiledSchemaToJsonSchema as compiledSchemaToJsonSchema, __webpack_exports__createStandardJsonSchemaProps as createStandardJsonSchemaProps, __webpack_exports__extractTypeInfo as extractTypeInfo, __webpack_exports__propertyInfoToJsonSchema as propertyInfoToJsonSchema, __webpack_exports__rehydrateSchemaFromJsonSchema as rehydrateSchemaFromJsonSchema, __webpack_exports__rehydrateSchemaFromJsonString as rehydrateSchemaFromJsonString, __webpack_exports__s as s };
5127
6146
 
5128
6147
  //# sourceMappingURL=index.js.map