@routier/core 0.2.0 → 0.3.0

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 (174) hide show
  1. package/LICENSE +21 -0
  2. package/{readme.md → README.md} +2 -2
  3. package/dist/assertions/index.cjs +191 -0
  4. package/dist/assertions/index.cjs.map +1 -0
  5. package/dist/assertions/index.d.ts +30 -0
  6. package/dist/assertions/index.js +94 -30
  7. package/dist/assertions/index.js.map +1 -1
  8. package/dist/capabilities/index.cjs +820 -0
  9. package/dist/capabilities/index.cjs.map +1 -0
  10. package/dist/capabilities/index.js +580 -545
  11. package/dist/capabilities/index.js.map +1 -1
  12. package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
  13. package/dist/codegen/handlers/SetHandlerBuilder.d.ts +4 -0
  14. package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +3 -0
  15. package/dist/codegen/handlers/clone/CloneDateHandler.d.ts +13 -0
  16. package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +16 -0
  17. package/dist/codegen/handlers/compare/CompareComputedHandler.d.ts +10 -0
  18. package/dist/codegen/handlers/compare/CompareFunctionHandler.d.ts +10 -0
  19. package/dist/codegen/handlers/deserialize/DeserializeArrayHandler.d.ts +14 -0
  20. package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.d.ts +11 -0
  21. package/dist/codegen/handlers/enrichment/EnrichmentArrayHandler.d.ts +11 -0
  22. package/dist/codegen/handlers/freeze/FreezeArrayHandler.d.ts +6 -0
  23. package/dist/codegen/handlers/hash/HashArrayHandler.d.ts +10 -0
  24. package/dist/codegen/handlers/hash/HashFileHandler.d.ts +24 -0
  25. package/dist/codegen/handlers/hash/HashObjectHandler.d.ts +10 -0
  26. package/dist/codegen/handlers/hash/HashTransformHandler.d.ts +23 -0
  27. package/dist/codegen/handlers/index.d.ts +1 -0
  28. package/dist/codegen/handlers/merge/MergeArrayHandler.d.ts +20 -0
  29. package/dist/codegen/handlers/merge/MergeObjectHandler.d.ts +10 -0
  30. package/dist/codegen/handlers/serialize/SerializeArrayHandler.d.ts +19 -0
  31. package/dist/codegen/handlers/serialize/SerializeComputedHandler.d.ts +6 -0
  32. package/dist/codegen/handlers/set/SetComplexHandler.d.ts +6 -0
  33. package/dist/codegen/handlers/strip/StripComputedHandler.d.ts +10 -0
  34. package/dist/codegen/handlers/strip/StripFunctionHandler.d.ts +9 -0
  35. package/dist/codegen/handlers/types.d.ts +55 -1
  36. package/dist/codegen/index.cjs +618 -0
  37. package/dist/codegen/index.cjs.map +1 -0
  38. package/dist/codegen/index.js +100 -127
  39. package/dist/codegen/index.js.map +1 -1
  40. package/dist/collections/Changes.d.ts +2 -2
  41. package/dist/collections/MemoryDataCollection.d.ts +15 -1
  42. package/dist/collections/TagCollection.d.ts +7 -8
  43. package/dist/collections/index.cjs +702 -0
  44. package/dist/collections/index.cjs.map +1 -0
  45. package/dist/collections/index.js +282 -276
  46. package/dist/collections/index.js.map +1 -1
  47. package/dist/errors/OptimisticConcurrencyError.d.ts +18 -0
  48. package/dist/errors/PluginDestroyedError.d.ts +10 -0
  49. package/dist/errors/index.cjs +132 -0
  50. package/dist/errors/index.cjs.map +1 -0
  51. package/dist/errors/index.d.ts +2 -0
  52. package/dist/errors/index.js +61 -19
  53. package/dist/errors/index.js.map +1 -1
  54. package/dist/expressions/constants.d.ts +2 -0
  55. package/dist/expressions/evaluate.d.ts +53 -0
  56. package/dist/expressions/index.cjs +2087 -0
  57. package/dist/expressions/index.cjs.map +1 -0
  58. package/dist/expressions/index.d.ts +2 -0
  59. package/dist/expressions/index.js +1784 -772
  60. package/dist/expressions/index.js.map +1 -1
  61. package/dist/expressions/parser.d.ts +19 -0
  62. package/dist/expressions/types.d.ts +87 -2
  63. package/dist/expressions/utils.d.ts +1 -2
  64. package/dist/index.cjs +13925 -0
  65. package/dist/index.cjs.map +1 -0
  66. package/dist/index.js +12094 -7049
  67. package/dist/index.js.map +1 -1
  68. package/dist/performance/index.cjs +217 -0
  69. package/dist/performance/index.cjs.map +1 -0
  70. package/dist/performance/index.js +126 -50
  71. package/dist/performance/index.js.map +1 -1
  72. package/dist/pipeline/index.cjs +576 -0
  73. package/dist/pipeline/index.cjs.map +1 -0
  74. package/dist/pipeline/index.js +229 -156
  75. package/dist/pipeline/index.js.map +1 -1
  76. package/dist/plugins/BatchingDbPlugin.d.ts +139 -0
  77. package/dist/plugins/CacheDbPlugin.d.ts +70 -0
  78. package/dist/plugins/ConcurrencyDbPlugin.d.ts +78 -0
  79. package/dist/plugins/EphemeralDataPlugin.d.ts +57 -1
  80. package/dist/plugins/RetryDbPlugin.d.ts +77 -0
  81. package/dist/plugins/index.cjs +6104 -0
  82. package/dist/plugins/index.cjs.map +1 -0
  83. package/dist/plugins/index.d.ts +5 -1
  84. package/dist/plugins/index.js +5572 -1491
  85. package/dist/plugins/index.js.map +1 -1
  86. package/dist/plugins/query/QueryOptionsCollection.d.ts +22 -0
  87. package/dist/plugins/query/index.d.ts +2 -0
  88. package/dist/plugins/query/join.d.ts +210 -0
  89. package/dist/plugins/query/similarity.d.ts +38 -0
  90. package/dist/plugins/query/types.d.ts +64 -1
  91. package/dist/plugins/translators/DataTranslator.d.ts +28 -0
  92. package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
  93. package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
  94. package/dist/plugins/translators/TranslatedArrayValue.d.ts +3 -1
  95. package/dist/plugins/translators/TranslatedGroupValue.d.ts +3 -1
  96. package/dist/plugins/translators/TranslatedSingleValue.d.ts +3 -1
  97. package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
  98. package/dist/plugins/translators/index.d.ts +1 -0
  99. package/dist/plugins/translators/types.d.ts +8 -1
  100. package/dist/plugins/types.d.ts +87 -11
  101. package/dist/plugins/wire/handler.d.ts +122 -0
  102. package/dist/plugins/wire/index.d.ts +4 -0
  103. package/dist/plugins/wire/persist.d.ts +43 -0
  104. package/dist/plugins/wire/query.d.ts +49 -0
  105. package/dist/plugins/wire/types.d.ts +123 -0
  106. package/dist/results/Result.d.ts +2 -2
  107. package/dist/results/index.cjs +174 -0
  108. package/dist/results/index.cjs.map +1 -0
  109. package/dist/results/index.js +29 -44
  110. package/dist/results/index.js.map +1 -1
  111. package/dist/schema/PropertyInfo.d.ts +35 -2
  112. package/dist/schema/SchemaDefinition.d.ts +51 -1
  113. package/dist/schema/builder.d.ts +35 -1
  114. package/dist/schema/communication/broadcast.d.ts +17 -1
  115. package/dist/schema/index.cjs +6911 -0
  116. package/dist/schema/index.cjs.map +1 -0
  117. package/dist/schema/index.d.ts +4 -0
  118. package/dist/schema/index.js +5781 -3973
  119. package/dist/schema/index.js.map +1 -1
  120. package/dist/schema/property/base/SchemaBase.d.ts +50 -2
  121. package/dist/schema/property/modifiers/SchemaDeserialize.d.ts +5 -1
  122. package/dist/schema/property/modifiers/SchemaForeignKey.d.ts +15 -0
  123. package/dist/schema/property/modifiers/SchemaKey.d.ts +2 -0
  124. package/dist/schema/property/modifiers/SchemaNullable.d.ts +15 -1
  125. package/dist/schema/property/modifiers/SchemaOptional.d.ts +22 -1
  126. package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
  127. package/dist/schema/property/modifiers/SchemaTag.d.ts +27 -0
  128. package/dist/schema/property/modifiers/SchemaTracked.d.ts +5 -1
  129. package/dist/schema/property/modifiers/index.d.ts +3 -0
  130. package/dist/schema/property/types/SchemaArray.d.ts +2 -0
  131. package/dist/schema/property/types/SchemaBoolean.d.ts +2 -0
  132. package/dist/schema/property/types/SchemaDate.d.ts +2 -0
  133. package/dist/schema/property/types/SchemaFile.d.ts +60 -0
  134. package/dist/schema/property/types/SchemaNumber.d.ts +5 -1
  135. package/dist/schema/property/types/SchemaObject.d.ts +2 -0
  136. package/dist/schema/property/types/SchemaString.d.ts +25 -1
  137. package/dist/schema/property/types/SchemaVector.d.ts +61 -0
  138. package/dist/schema/property/types/index.d.ts +2 -0
  139. package/dist/schema/table/SchemaTransform.d.ts +40 -0
  140. package/dist/schema/table/index.d.ts +1 -0
  141. package/dist/schema/types.d.ts +200 -32
  142. package/dist/schema/utils/propertyKind.d.ts +4 -0
  143. package/dist/schema/utils/standardJsonSchema.d.ts +90 -0
  144. package/dist/types/index.cjs +23 -0
  145. package/dist/types/index.cjs.map +1 -0
  146. package/dist/types/index.js +0 -14
  147. package/dist/types/index.js.map +1 -1
  148. package/dist/utilities/functions.d.ts +1 -1
  149. package/dist/utilities/index.cjs +982 -0
  150. package/dist/utilities/index.cjs.map +1 -0
  151. package/dist/utilities/index.js +590 -321
  152. package/dist/utilities/index.js.map +1 -1
  153. package/dist/utilities/logger.d.ts +48 -0
  154. package/package.json +152 -98
  155. package/dist/collections/Changes.test.d.ts +0 -1
  156. package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
  157. package/dist/collections/TagCollection.test.d.ts +0 -1
  158. package/dist/expressions/parser.test.d.ts +0 -1
  159. package/dist/expressions/utils.test.d.ts +0 -1
  160. package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
  161. package/dist/pipeline/WorkPipeline.test.d.ts +0 -1
  162. package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
  163. package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
  164. package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +0 -23
  165. package/dist/plugins/replication/ReplicationDbPlugin.d.ts +0 -22
  166. package/dist/plugins/replication/index.d.ts +0 -3
  167. package/dist/plugins/replication/types.d.ts +0 -5
  168. package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
  169. package/dist/schema/PropertyInfo.test.d.ts +0 -1
  170. package/dist/schema/schemaGeneration.test.d.ts +0 -1
  171. package/dist/schema/testSchemas.test.d.ts +0 -314
  172. package/dist/utilities/arrays.test.d.ts +0 -1
  173. package/dist/utilities/dates.test.d.ts +0 -1
  174. package/dist/utilities/strings.test.d.ts +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"results/index.cjs","sources":["webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/results/utils.ts","webpack://@routier/core/./src/results/index.ts"],"sourcesContent":["import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","import { Result } from \"./Result\";\nimport { CallbackResult } from \"./types\";\n\nexport function toPromise<T>(fn: (callback: CallbackResult<T>) => void) {\n return new Promise<T>((resolve, reject) => {\n fn((r) => {\n if (r.ok === Result.ERROR) {\n reject(r.error);\n return;\n }\n\n resolve(r.data);\n });\n });\n}\n","export * from './Result';\nexport * from './types';\nexport * from './utils';"],"names":["BaseResult","result","resolve","reject","Error","Result","data","error","PluginEventResult","id","toPromise","fn","Promise","r"],"mappings":";;;;;;;;AAEA,MAAeA;IACX,OAAO,QAAQ,QAAiB;IAChC,OAAO,UAAU,UAAmB;IACpC,OAAO,UAAU,UAAmB;IAEpC,OAAO,QAAWC,MAA4C,EAAEC,OAA0B,EAAEC,MAA6B,EAAE;QACvH,IAAIF,OAAO,EAAE,KAAKD,WAAW,OAAO,EAAE;YAClCE,QAAQD,OAAO,IAAI;YACnB;QACJ;QAEA,IAAIA,OAAO,EAAE,KAAKD,WAAW,OAAO,EAAE;YAClCG,OAAO;gBACH,SAASF,OAAO,IAAI;gBACpB,OAAOA,OAAO,KAAK;YACvB;YACA;QACJ;QAEAE,OAAOF,OAAO,KAAK;IACvB;IAEA,OAAO,cAAiBA,MAAW,EAAgD;QAC/E,IAAIA,OAAO,EAAE,KAAKD,WAAW,OAAO,EAAE;YAClC,MAAM,IAAII,MAAM,CAAC,iCAAiC,EAAEH,OAAO,EAAE,CAAC,EAAE,EAAEA,OAAO,KAAK,EAAE;QACpF;IACJ;AACJ;AAEO,MAAMI,eAAeL;IAGxB,OAAO,QAAWM,IAAQ,EAAiB;QACvC,OAAO;YACH,IAAID,OAAO,OAAO;YAClBC;QACJ;IACJ;IAEA,OAAO,MAASC,KAAU,EAAiB;QACvC,OAAO;YACH,IAAIF,OAAO,KAAK;YAChBE;QACJ;IACJ;IAEA,OAAO,QAAWD,IAAO,EAAEC,KAAU,EAAwB;QACzD,OAAO;YACH,IAAIF,OAAO,OAAO;YAClBC;YACAC;QACJ;IACJ;AACJ;AAEO,MAAMC,0BAA0BR;IAGnC,OAAO,QAAWS,EAAU,EAAEH,IAAQ,EAA4B;QAC9D,OAAO;YACHG;YACA,IAAIJ,OAAO,OAAO;YAClBC;QACJ;IACJ;IAEA,OAAO,MAASG,EAAU,EAAEF,KAAU,EAA4B;QAC9D,OAAO;YACHE;YACA,IAAIJ,OAAO,KAAK;YAChBE;QACJ;IACJ;IAEA,OAAO,QAAWE,EAAU,EAAEH,IAAO,EAAEC,KAAU,EAAmC;QAChF,OAAO;YACHE;YACA,IAAIJ,OAAO,OAAO;YAClBC;YACAC;QACJ;IACJ;IAEA,OAAO,cAAiBN,MAAgC,EAA4D;QAChH,IAAIA,OAAO,EAAE,KAAKI,OAAO,OAAO,EAAE;YAC9B,MAAM,IAAID,MAAM,CAAC,iCAAiC,EAAEH,OAAO,EAAE,CAAC,EAAE,EAAEA,OAAO,KAAK,EAAE;QACpF;IACJ;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1FA;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;;;;;;;;ACNkC;AAG3B,SAASS,UAAaC,EAAyC;IAClE,OAAO,IAAIC,QAAW,CAACV,SAASC;QAC5BQ,GAAG,CAACE;YACA,IAAIA,EAAE,EAAE,KAAKR,iCAAY,EAAE;gBACvBF,OAAOU,EAAE,KAAK;gBACd;YACJ;YAEAX,QAAQW,EAAE,IAAI;QAClB;IACJ;AACJ;;;ACdyB;AACD;AACA"}
@@ -1,9 +1,8 @@
1
1
  var __webpack_modules__ = ({
2
- "./src/results/Result.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
3
- __webpack_require__.r(__webpack_exports__);
2
+ 718(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
4
3
  __webpack_require__.d(__webpack_exports__, {
5
- PluginEventResult: () => (PluginEventResult),
6
- Result: () => (Result)
4
+ D: () => (PluginEventResult),
5
+ Q: () => (Result)
7
6
  });
8
7
  class BaseResult {
9
8
  static ERROR = "error";
@@ -81,27 +80,6 @@ class PluginEventResult extends BaseResult {
81
80
  }
82
81
 
83
82
 
84
- },
85
- "./src/results/utils.ts"(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
86
- __webpack_require__.r(__webpack_exports__);
87
- __webpack_require__.d(__webpack_exports__, {
88
- toPromise: () => (toPromise)
89
- });
90
- /* import */ var _Result__rspack_import_0 = __webpack_require__("./src/results/Result.ts");
91
-
92
- function toPromise(fn) {
93
- return new Promise((resolve, reject) => {
94
- fn((r) => {
95
- if (r.ok === _Result__rspack_import_0.Result.ERROR) {
96
- reject(r.error);
97
- return;
98
- }
99
- resolve(r.data);
100
- });
101
- });
102
- }
103
-
104
-
105
83
  },
106
84
 
107
85
  });
@@ -142,36 +120,43 @@ __webpack_require__.d = (exports, definition) => {
142
120
  (() => {
143
121
  __webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
144
122
  })();
145
- // webpack/runtime/make_namespace_object
146
- (() => {
147
- // define __esModule on exports
148
- __webpack_require__.r = (exports) => {
149
- if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
150
- Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
151
- }
152
- Object.defineProperty(exports, '__esModule', { value: true });
153
- };
154
- })();
155
123
  var __webpack_exports__ = {};
156
124
  // This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
157
125
  (() => {
158
- __webpack_require__.r(__webpack_exports__);
126
+
127
+ // EXPORTS
159
128
  __webpack_require__.d(__webpack_exports__, {
160
- PluginEventResult: () => (/* reexport safe */ _Result__rspack_import_0.PluginEventResult),
161
- Result: () => (/* reexport safe */ _Result__rspack_import_0.Result),
162
- toPromise: () => (/* reexport safe */ _utils__rspack_import_1.toPromise)
129
+ Dq: () => (/* reexport */ Result/* .PluginEventResult */.D),
130
+ Q7: () => (/* reexport */ Result/* .Result */.Q),
131
+ hq: () => (/* reexport */ toPromise)
163
132
  });
164
- /* import */ var _Result__rspack_import_0 = __webpack_require__("./src/results/Result.ts");
165
- /* import */ var _utils__rspack_import_1 = __webpack_require__("./src/results/utils.ts");
133
+
134
+ // EXTERNAL MODULE: ./src/results/Result.ts
135
+ var Result = __webpack_require__(718);
136
+ ;// CONCATENATED MODULE: ./src/results/utils.ts
137
+
138
+ function toPromise(fn) {
139
+ return new Promise((resolve, reject)=>{
140
+ fn((r)=>{
141
+ if (r.ok === Result/* .Result.ERROR */.Q.ERROR) {
142
+ reject(r.error);
143
+ return;
144
+ }
145
+ resolve(r.data);
146
+ });
147
+ });
148
+ }
149
+
150
+ ;// CONCATENATED MODULE: ./src/results/index.ts
166
151
 
167
152
 
168
153
 
169
154
 
170
155
  })();
171
156
 
172
- var __webpack_exports__PluginEventResult = __webpack_exports__.PluginEventResult;
173
- var __webpack_exports__Result = __webpack_exports__.Result;
174
- var __webpack_exports__toPromise = __webpack_exports__.toPromise;
157
+ var __webpack_exports__PluginEventResult = __webpack_exports__.Dq;
158
+ var __webpack_exports__Result = __webpack_exports__.Q7;
159
+ var __webpack_exports__toPromise = __webpack_exports__.hq;
175
160
  export { __webpack_exports__PluginEventResult as PluginEventResult, __webpack_exports__Result as Result, __webpack_exports__toPromise as toPromise };
176
161
 
177
162
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"results/index.js","sources":["webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/./src/results/utils.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/webpack/runtime/make_namespace_object","webpack://@routier/core/./src/results/index.ts"],"sourcesContent":["import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success<T>(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success<T>(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","import { Result } from \"./Result\";\nimport { CallbackResult } from \"./types\";\n\nexport function toPromise<T>(fn: (callback: CallbackResult<T>) => void) {\n return new Promise<T>((resolve, reject) => {\n fn((r) => {\n if (r.ok === Result.ERROR) {\n reject(r.error);\n return;\n }\n\n resolve(r.data);\n });\n });\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","export * from './Result';\nexport * from './types';\nexport * from './utils';"],"names":[],"mappings":"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"}
1
+ {"version":3,"file":"results/index.js","sources":["webpack://@routier/core/./src/results/Result.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/./src/results/utils.ts","webpack://@routier/core/./src/results/index.ts"],"sourcesContent":["import { PartialResultType, PluginEventPartialResultType, PluginEventResultType, ResultType } from \"./types\";\n\nabstract class BaseResult {\n static ERROR = \"error\" as const;\n static SUCCESS = \"success\" as const;\n static PARTIAL = \"partial\" as const;\n\n static resolve<T>(result: ResultType<T> | PartialResultType<T>, resolve: (data: T) => void, reject: (error?: any) => void) {\n if (result.ok === BaseResult.SUCCESS) {\n resolve(result.data);\n return;\n }\n\n if (result.ok === BaseResult.PARTIAL) {\n reject({\n partial: result.data,\n error: result.error\n });\n return;\n }\n\n reject(result.error);\n }\n\n static assertSuccess<T>(result: any): asserts result is { ok: \"success\"; data: T } {\n if (result.ok !== BaseResult.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n\nexport class Result extends BaseResult {\n static success<T>(data: T): ResultType<T>;\n static success(): ResultType<never>;\n static success<T>(data?: T): ResultType<T> {\n return {\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(error: any): ResultType<T> {\n return {\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(data: T, error: any): PartialResultType<T> {\n return {\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n}\n\nexport class PluginEventResult extends BaseResult {\n static success<T>(id: string, data: T): PluginEventResultType<T>;\n static success(id: string): PluginEventResultType<never>;\n static success<T>(id: string, data?: T): PluginEventResultType<T> {\n return {\n id,\n ok: Result.SUCCESS,\n data\n }\n }\n\n static error<T>(id: string, error: any): PluginEventResultType<T> {\n return {\n id,\n ok: Result.ERROR,\n error\n }\n }\n\n static partial<T>(id: string, data: T, error: any): PluginEventPartialResultType<T> {\n return {\n id,\n ok: Result.PARTIAL,\n data,\n error\n }\n }\n\n static assertSuccess<T>(result: PluginEventResultType<T>): asserts result is { ok: \"success\"; data: T; id: string } {\n if (result.ok !== Result.SUCCESS) {\n throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);\n }\n }\n}\n","__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n }\n }\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","import { Result } from \"./Result\";\nimport { CallbackResult } from \"./types\";\n\nexport function toPromise<T>(fn: (callback: CallbackResult<T>) => void) {\n return new Promise<T>((resolve, reject) => {\n fn((r) => {\n if (r.ok === Result.ERROR) {\n reject(r.error);\n return;\n }\n\n resolve(r.data);\n });\n });\n}\n","export * from './Result';\nexport * from './types';\nexport * from './utils';"],"names":["BaseResult","result","resolve","reject","Error","Result","data","error","PluginEventResult","id","toPromise","fn","Promise","r"],"mappings":";;;;;;AAEA,MAAeA;IACX,OAAO,QAAQ,QAAiB;IAChC,OAAO,UAAU,UAAmB;IACpC,OAAO,UAAU,UAAmB;IAEpC,OAAO,QAAWC,MAA4C,EAAEC,OAA0B,EAAEC,MAA6B,EAAE;QACvH,IAAIF,OAAO,EAAE,KAAKD,WAAW,OAAO,EAAE;YAClCE,QAAQD,OAAO,IAAI;YACnB;QACJ;QAEA,IAAIA,OAAO,EAAE,KAAKD,WAAW,OAAO,EAAE;YAClCG,OAAO;gBACH,SAASF,OAAO,IAAI;gBACpB,OAAOA,OAAO,KAAK;YACvB;YACA;QACJ;QAEAE,OAAOF,OAAO,KAAK;IACvB;IAEA,OAAO,cAAiBA,MAAW,EAAgD;QAC/E,IAAIA,OAAO,EAAE,KAAKD,WAAW,OAAO,EAAE;YAClC,MAAM,IAAII,MAAM,CAAC,iCAAiC,EAAEH,OAAO,EAAE,CAAC,EAAE,EAAEA,OAAO,KAAK,EAAE;QACpF;IACJ;AACJ;AAEO,MAAMI,eAAeL;IAGxB,OAAO,QAAWM,IAAQ,EAAiB;QACvC,OAAO;YACH,IAAID,OAAO,OAAO;YAClBC;QACJ;IACJ;IAEA,OAAO,MAASC,KAAU,EAAiB;QACvC,OAAO;YACH,IAAIF,OAAO,KAAK;YAChBE;QACJ;IACJ;IAEA,OAAO,QAAWD,IAAO,EAAEC,KAAU,EAAwB;QACzD,OAAO;YACH,IAAIF,OAAO,OAAO;YAClBC;YACAC;QACJ;IACJ;AACJ;AAEO,MAAMC,0BAA0BR;IAGnC,OAAO,QAAWS,EAAU,EAAEH,IAAQ,EAA4B;QAC9D,OAAO;YACHG;YACA,IAAIJ,OAAO,OAAO;YAClBC;QACJ;IACJ;IAEA,OAAO,MAASG,EAAU,EAAEF,KAAU,EAA4B;QAC9D,OAAO;YACHE;YACA,IAAIJ,OAAO,KAAK;YAChBE;QACJ;IACJ;IAEA,OAAO,QAAWE,EAAU,EAAEH,IAAO,EAAEC,KAAU,EAAmC;QAChF,OAAO;YACHE;YACA,IAAIJ,OAAO,OAAO;YAClBC;YACAC;QACJ;IACJ;IAEA,OAAO,cAAiBN,MAAgC,EAA4D;QAChH,IAAIA,OAAO,EAAE,KAAKI,OAAO,OAAO,EAAE;YAC9B,MAAM,IAAID,MAAM,CAAC,iCAAiC,EAAEH,OAAO,EAAE,CAAC,EAAE,EAAEA,OAAO,KAAK,EAAE;QACpF;IACJ;AACJ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AC1FA;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;;;;;;;;;;;;;ACAkC;AAG3B,SAASS,UAAaC,EAAyC;IAClE,OAAO,IAAIC,QAAW,CAACV,SAASC;QAC5BQ,GAAG,CAACE;YACA,IAAIA,EAAE,EAAE,KAAKR,iCAAY,EAAE;gBACvBF,OAAOU,EAAE,KAAK;gBACd;YACJ;YAEAX,QAAQW,EAAE,IAAI;QAClB;IACJ;AACJ;;;ACdyB;AACD;AACA"}
@@ -1,6 +1,6 @@
1
1
  import { UnknownRecord } from '../utilities';
2
2
  import { SchemaBase } from './property/base/SchemaBase';
3
- import { DefaultValue, FunctionBody, PropertyDeserializer, PropertySerializer, SchemaTypes } from './types';
3
+ import { DefaultValue, ForeignKey, FunctionBody, PropertyDeserializer, PropertySerializer, SchemaTypes, PropertyTransform } from './types';
4
4
  /**
5
5
  * Represents metadata and utilities for a property in a schema, including its type, name, parent, children, and serialization details.
6
6
  */
@@ -18,6 +18,8 @@ export declare class PropertyInfo<T extends {}> {
18
18
  readonly isOptional: boolean;
19
19
  /** Whether the property is a key. */
20
20
  readonly isKey: boolean;
21
+ /** Foreign key schema and property */
22
+ readonly foreignKeyDefinition: ForeignKey<unknown> | null;
21
23
  /** Whether the property is an identity property. */
22
24
  readonly isIdentity: boolean;
23
25
  /** Whether the property is readonly. */
@@ -26,6 +28,14 @@ export declare class PropertyInfo<T extends {}> {
26
28
  readonly isUnmapped: boolean;
27
29
  /** Whether the property is distinct. */
28
30
  readonly isDistinct: boolean;
31
+ /**
32
+ * A two-way transform between the application value and the stored value, or `null`.
33
+ *
34
+ * A LIVE reference. Unlike `computed`, which is stringified into generated code, this is
35
+ * held as-is so it can close over a key, a client, or anything else a caller needs — and
36
+ * so it can be async, which generated code cannot be.
37
+ */
38
+ readonly transform: PropertyTransform<unknown> | null;
29
39
  /** Indexes associated with the property. */
30
40
  readonly indexes: string[];
31
41
  /** Any injected value for the property. */
@@ -44,8 +54,21 @@ export declare class PropertyInfo<T extends {}> {
44
54
  readonly schema: SchemaBase<T, any>;
45
55
  /** The inner schema if this property is an array. */
46
56
  readonly innerSchema?: SchemaBase<unknown, any>;
57
+ /** How many numbers this property holds if it is a vector, `null` otherwise. */
58
+ readonly dimensions: number | null;
59
+ /** The longest value this property is declared to hold, `null` if it declares none. */
60
+ readonly maxLength: number | null;
61
+ /**
62
+ * Whether this property may be tokenised into a full-text search index.
63
+ *
64
+ * True only for a string. See the constructor — this is derived from the declaration and
65
+ * the type together, not copied.
66
+ */
67
+ readonly isSearchable: boolean;
47
68
  /** Literal values allowed for this property. */
48
69
  readonly literals: T[];
70
+ /** Tags passed from the schema */
71
+ readonly tags: string[];
49
72
  /** The parent property, if any. */
50
73
  readonly parent?: PropertyInfo<T>;
51
74
  private _propertyChainCache?;
@@ -54,6 +77,7 @@ export declare class PropertyInfo<T extends {}> {
54
77
  private _idCache?;
55
78
  private _levelCache?;
56
79
  private _hasNullableParentsCache?;
80
+ private _hasRenamedSegmentsCache?;
57
81
  constructor(schema: SchemaBase<T, any>, name: string, parent?: PropertyInfo<T> | null);
58
82
  /**
59
83
  * Returns the depth (level) of this property in the property tree.
@@ -81,13 +105,22 @@ export declare class PropertyInfo<T extends {}> {
81
105
  *
82
106
  * @returns {string[]} The property path as an array of names, excluding this property.
83
107
  */
84
- getParentPathArray(): string[];
108
+ getParentPathArray(options?: {
109
+ useFromPropertyName?: boolean;
110
+ }): string[];
85
111
  /**
86
112
  * Returns true if any parent property is nullable or optional.
87
113
  *
88
114
  * @returns {boolean} True if any parent is nullable or optional, false otherwise.
89
115
  */
90
116
  get hasNullableParents(): boolean;
117
+ /**
118
+ * Returns true if this property or any parent is renamed with from().
119
+ * Storage paths for such properties differ from their in-memory paths.
120
+ *
121
+ * @returns {boolean} True if any segment of the path is renamed, false otherwise.
122
+ */
123
+ get hasRenamedSegments(): boolean;
91
124
  /**
92
125
  * Returns true if any child property (recursively) is an identity property.
93
126
  *
@@ -1,18 +1,68 @@
1
1
  import { SchemaFunction } from './table/SchemaFunction';
2
+ import { SchemaTransform } from './table/SchemaTransform';
2
3
  import { SchemaComputed } from './table/SchemaComputed';
3
4
  import { SchemaBase } from "./property/base/SchemaBase";
4
- import { CollectionName, CompiledSchema, InferType, SchemaTypes } from './types';
5
+ import { CollectionName, CompiledSchema, CompiledSchemaWithMetadata, InferCreateType, InferType, SchemaTypes, PropertyTransform } from './types';
6
+ import { StandardJSONSchemaV1 } from './utils/standardJsonSchema';
5
7
  export declare class SchemaDefinition<T extends {}> extends SchemaBase<T, any> {
6
8
  instance: T;
7
9
  type: SchemaTypes;
8
10
  collectionName: CollectionName;
9
11
  constructor(collectionName: CollectionName, schema: T);
12
+ /**
13
+ * Creates a SchemaDefinition from a JSON string containing a JSON Schema.
14
+ * Parses the JSON string, rehydrates the schema structure, and compiles it.
15
+ *
16
+ * @param jsonString - The JSON string containing the JSON Schema (typically from `schema['~standard'].jsonSchema.input()` or `output()`)
17
+ * @param collectionName - Optional collection name override (if not present in JSON Schema metadata)
18
+ * @returns A compiled schema ready to use
19
+ * @throws Error if the JSON string is invalid or doesn't contain a valid JSON Schema
20
+ *
21
+ * @example
22
+ * ```typescript
23
+ * // Serialize a schema to JSON
24
+ * const jsonSchema = mySchema['~standard'].jsonSchema.input({ target: 'draft-2020-12' });
25
+ * const jsonString = JSON.stringify(jsonSchema);
26
+ *
27
+ * // Rehydrate from JSON string
28
+ * const rehydratedSchema = SchemaDefinition.fromJson(jsonString);
29
+ * // Schema is already compiled and ready to use
30
+ * ```
31
+ */
32
+ static fromJson(jsonString: string, collectionName?: string): CompiledSchema<any>;
33
+ /**
34
+ * Standard JSON Schema V1 implementation.
35
+ * Provides JSON Schema conversion for Routier schemas.
36
+ */
37
+ get '~standard'(): StandardJSONSchemaV1.Props<InferCreateType<T>, InferType<T>>;
10
38
  private createReturnFunction;
11
39
  private createFunction;
12
40
  modify<R>(builder: (d: {
13
41
  function: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaFunction<UU, I, "unmapped">;
14
42
  computed: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaComputed<UU, I, "computed" | "unmapped">;
43
+ /**
44
+ * Replaces a property with a transformed version of itself.
45
+ *
46
+ * `computed` derives a value one way and cannot come back. A transform declares both
47
+ * directions, so the property keeps its type and only its STORED form changes.
48
+ *
49
+ * ```ts
50
+ * .modify(x => ({
51
+ * ssn: x.transform(s.string(), {
52
+ * to: (value, keys) => myEncrypt(value, keys),
53
+ * from: (text, keys) => myDecrypt(text, keys),
54
+ * stores: SchemaTypes.String,
55
+ * }, myKeys),
56
+ * }))
57
+ * ```
58
+ *
59
+ * `to` and `from` may be async and are held as live references, so they can close
60
+ * over whatever they need. `injected` is there for when passing it explicitly reads
61
+ * better than capturing it.
62
+ */
63
+ transform: <UU>(transform: PropertyTransform<UU>) => SchemaTransform<UU>;
15
64
  }) => R): SchemaDefinition<R & T>;
16
65
  private _iterate;
66
+ compile<TMetadata>(metadata: TMetadata): CompiledSchemaWithMetadata<T, TMetadata>;
17
67
  compile(): CompiledSchema<T>;
18
68
  }
@@ -5,13 +5,47 @@ import { SchemaDate } from "./property/types/SchemaDate";
5
5
  import { SchemaDefinition } from "./SchemaDefinition";
6
6
  import { SchemaNumber } from "./property/types/SchemaNumber";
7
7
  import { SchemaObject } from "./property/types/SchemaObject";
8
+ import { SchemaFile } from "./property/types/SchemaFile";
8
9
  import { SchemaString } from "./property/types/SchemaString";
10
+ import { SchemaVector } from "./property/types/SchemaVector";
11
+ import { FileReferenceValue, StringOptions, VectorValue } from "./types";
12
+ /**
13
+ * A string, optionally declaring how long it can be and which values it may take.
14
+ *
15
+ * ```ts
16
+ * s.string() // any string
17
+ * s.string("draft", "published") // a literal union
18
+ * s.string({ maxLength: 4000 }) // any string, declared long
19
+ * s.string({ maxLength: 8 }, "a", "b") // both
20
+ * ```
21
+ *
22
+ * The options object is a leading parameter rather than a `.maxLength()` modifier so the
23
+ * declaration stays on the factory, next to the literals. A modifier would also have to survive
24
+ * being wrapped by another modifier, which is the trap `SchemaBase.maxLength` documents.
25
+ */
26
+ declare function string<T extends string[] = string[]>(...literals: T): SchemaString<T[number] extends never ? string : T[number], never>;
27
+ declare function string<T extends string[] = string[]>(options: StringOptions, ...literals: T): SchemaString<T[number] extends never ? string : T[number], never>;
9
28
  export declare const s: {
10
29
  number: <T extends number[] = number[]>(...literals: T) => SchemaNumber<T[number] extends never ? number : T[number], never>;
11
- string: <T extends string[] = string[]>(...literals: T) => SchemaString<T[number] extends never ? string : T[number], never>;
30
+ string: typeof string;
12
31
  boolean: <T extends boolean = boolean>() => SchemaBoolean<T, never>;
13
32
  date: <T extends Date = Date>() => SchemaDate<T, never>;
14
33
  array: <T extends unknown>(schema: SchemaBase<T, never>) => SchemaArray<SchemaBase<T, never>, never>;
15
34
  object: <T extends {} = {}>(schema: T) => SchemaObject<T, never>;
35
+ /**
36
+ * A file. Assign content, read back a reference.
37
+ *
38
+ * Needs `@routier/blob-plugin` wrapping your plugin to turn the one into the other; core
39
+ * only carries the value through untouched.
40
+ */
41
+ file: () => SchemaFile<FileReferenceValue, never>;
42
+ /**
43
+ * An embedding of `dimensions` numbers, searchable with `.nearest()`.
44
+ *
45
+ * Every backend supports it. One with a native vector column uses it; the rest store the
46
+ * numbers as JSON and score the search in memory, which returns the same rows.
47
+ */
48
+ vector: (dimensions: number) => SchemaVector<VectorValue, never>;
16
49
  define: <T extends {}>(collectionName: string, schema: T) => SchemaDefinition<T>;
17
50
  };
51
+ export {};
@@ -1,9 +1,25 @@
1
1
  import { CompiledSchemaCore, ISchemaSubscription, SubscriptionChanges } from "../types";
2
+ export type SchemaSubscriptionOptions = {
3
+ /**
4
+ * Whether changes must reach listeners OUTSIDE this process — another browser tab, or
5
+ * another worker thread in Node. Default `true`, which is the historical behaviour.
6
+ *
7
+ * It cannot be inferred. A BroadcastChannel gives a sender no way to ask who is on the
8
+ * other end, so `send` can only count the listeners registered in THIS process. When
9
+ * this is `true`, `send` must assume a listener it cannot see and always publish. When
10
+ * a caller sets it to `false`, it promises there is no such listener, and `send` skips
11
+ * the whole preprocess-and-post step whenever nobody local is listening.
12
+ */
13
+ crossTabSync?: boolean;
14
+ };
2
15
  export declare class SchemaSubscription<T extends {}> implements ISchemaSubscription<T> {
3
16
  private readonly id;
4
17
  private readonly schema;
18
+ private readonly scope?;
5
19
  private readonly createdAt;
6
- constructor(schema: CompiledSchemaCore<T>, signal?: AbortSignal);
20
+ private readonly crossTabSync;
21
+ private isDisposed;
22
+ constructor(schema: CompiledSchemaCore<T>, signal?: AbortSignal, scope?: string, options?: SchemaSubscriptionOptions);
7
23
  send(changes: SubscriptionChanges<T>): void;
8
24
  onMessage(callback: (changes: SubscriptionChanges<T>) => void): void;
9
25
  dispose(): void;