@routier/core 0.2.1 → 0.4.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.
- package/LICENSE +21 -0
- package/{readme.md → README.md} +3 -3
- package/dist/assertions/index.cjs +191 -0
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.js +43 -63
- package/dist/assertions/index.js.map +1 -1
- package/dist/capabilities/index.cjs +820 -0
- package/dist/capabilities/index.cjs.map +1 -0
- package/dist/capabilities/index.js +584 -558
- package/dist/capabilities/index.js.map +1 -1
- package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
- package/dist/codegen/handlers/clone/CloneArrayHandler.d.ts +3 -0
- package/dist/codegen/handlers/clone/CloneDateHandler.d.ts +13 -0
- package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +16 -0
- package/dist/codegen/handlers/compare/CompareComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/compare/CompareFunctionHandler.d.ts +10 -0
- package/dist/codegen/handlers/deserialize/DeserializeArrayHandler.d.ts +14 -0
- package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/enrichment/EnrichmentArrayHandler.d.ts +11 -0
- package/dist/codegen/handlers/freeze/FreezeArrayHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashArrayHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashFileHandler.d.ts +24 -0
- package/dist/codegen/handlers/hash/HashObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/hash/HashTransformHandler.d.ts +23 -0
- package/dist/codegen/handlers/merge/MergeArrayHandler.d.ts +20 -0
- package/dist/codegen/handlers/merge/MergeObjectHandler.d.ts +10 -0
- package/dist/codegen/handlers/serialize/SerializeArrayHandler.d.ts +19 -0
- package/dist/codegen/handlers/strip/StripComputedHandler.d.ts +10 -0
- package/dist/codegen/handlers/strip/StripFunctionHandler.d.ts +9 -0
- package/dist/codegen/handlers/types.d.ts +55 -1
- package/dist/codegen/index.cjs +618 -0
- package/dist/codegen/index.cjs.map +1 -0
- package/dist/codegen/index.js +99 -127
- package/dist/codegen/index.js.map +1 -1
- package/dist/collections/MemoryDataCollection.d.ts +15 -1
- package/dist/collections/TagCollection.d.ts +0 -1
- package/dist/collections/index.cjs +702 -0
- package/dist/collections/index.cjs.map +1 -0
- package/dist/collections/index.js +282 -276
- package/dist/collections/index.js.map +1 -1
- package/dist/errors/OptimisticConcurrencyError.d.ts +18 -0
- package/dist/errors/PluginDestroyedError.d.ts +10 -0
- package/dist/errors/index.cjs +132 -0
- package/dist/errors/index.cjs.map +1 -0
- package/dist/errors/index.d.ts +2 -0
- package/dist/errors/index.js +61 -19
- package/dist/errors/index.js.map +1 -1
- package/dist/expressions/evaluate.d.ts +53 -0
- package/dist/expressions/index.cjs +2087 -0
- package/dist/expressions/index.cjs.map +1 -0
- package/dist/expressions/index.d.ts +1 -1
- package/dist/expressions/index.js +1727 -1082
- package/dist/expressions/index.js.map +1 -1
- package/dist/expressions/parser.d.ts +19 -0
- package/dist/expressions/types.d.ts +87 -2
- package/dist/index.cjs +14377 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +12374 -7931
- package/dist/index.js.map +1 -1
- package/dist/performance/index.cjs +217 -0
- package/dist/performance/index.cjs.map +1 -0
- package/dist/performance/index.js +120 -55
- package/dist/performance/index.js.map +1 -1
- package/dist/pipeline/index.cjs +576 -0
- package/dist/pipeline/index.cjs.map +1 -0
- package/dist/pipeline/index.js +223 -161
- package/dist/pipeline/index.js.map +1 -1
- package/dist/plugins/BatchingDbPlugin.d.ts +139 -0
- package/dist/plugins/CacheDbPlugin.d.ts +70 -0
- package/dist/plugins/ConcurrencyDbPlugin.d.ts +78 -0
- package/dist/plugins/EphemeralDataPlugin.d.ts +57 -1
- package/dist/plugins/RetryDbPlugin.d.ts +77 -0
- package/dist/plugins/index.cjs +6551 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.ts +5 -0
- package/dist/plugins/index.js +6271 -1170
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/QueryOptionsCollection.d.ts +34 -0
- package/dist/plugins/query/explain.d.ts +82 -0
- package/dist/plugins/query/formatExplanation.d.ts +9 -0
- package/dist/plugins/query/index.d.ts +4 -0
- package/dist/plugins/query/join.d.ts +210 -0
- package/dist/plugins/query/similarity.d.ts +38 -0
- package/dist/plugins/query/types.d.ts +75 -1
- package/dist/plugins/translators/DataTranslator.d.ts +28 -0
- package/dist/plugins/translators/JsonTranslator.d.ts +27 -0
- package/dist/plugins/translators/SqlTranslator.d.ts +45 -0
- package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
- package/dist/plugins/translators/index.d.ts +1 -0
- package/dist/plugins/types.d.ts +125 -3
- package/dist/plugins/wire/handler.d.ts +122 -0
- package/dist/plugins/wire/index.d.ts +4 -0
- package/dist/plugins/wire/persist.d.ts +43 -0
- package/dist/plugins/wire/query.d.ts +49 -0
- package/dist/plugins/wire/types.d.ts +139 -0
- package/dist/results/index.cjs +174 -0
- package/dist/results/index.cjs.map +1 -0
- package/dist/results/index.js +29 -44
- package/dist/results/index.js.map +1 -1
- package/dist/schema/PropertyInfo.d.ts +31 -2
- package/dist/schema/SchemaDefinition.d.ts +23 -1
- package/dist/schema/builder.d.ts +35 -1
- package/dist/schema/communication/broadcast.d.ts +17 -1
- package/dist/schema/index.cjs +6911 -0
- package/dist/schema/index.cjs.map +1 -0
- package/dist/schema/index.d.ts +2 -0
- package/dist/schema/index.js +5330 -4541
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/base/SchemaBase.d.ts +48 -2
- package/dist/schema/property/modifiers/SchemaNullable.d.ts +10 -0
- package/dist/schema/property/modifiers/SchemaOptional.d.ts +19 -0
- package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
- package/dist/schema/property/modifiers/index.d.ts +1 -0
- package/dist/schema/property/types/SchemaFile.d.ts +60 -0
- package/dist/schema/property/types/SchemaString.d.ts +21 -1
- package/dist/schema/property/types/SchemaVector.d.ts +61 -0
- package/dist/schema/property/types/index.d.ts +2 -0
- package/dist/schema/table/SchemaTransform.d.ts +40 -0
- package/dist/schema/table/index.d.ts +1 -0
- package/dist/schema/types.d.ts +166 -8
- package/dist/schema/utils/propertyKind.d.ts +4 -0
- package/dist/types/index.cjs +23 -0
- package/dist/types/index.cjs.map +1 -0
- package/dist/types/index.js +0 -14
- package/dist/types/index.js.map +1 -1
- package/dist/utilities/index.cjs +1013 -0
- package/dist/utilities/index.cjs.map +1 -0
- package/dist/utilities/index.js +541 -379
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/logger.d.ts +48 -0
- package/package.json +156 -98
- package/dist/codegen/SlotPath.test.d.ts +0 -1
- package/dist/codegen/blocks.test.d.ts +0 -1
- package/dist/codegen/utils.test.d.ts +0 -1
- package/dist/collections/Changes.test.d.ts +0 -1
- package/dist/collections/IdSet.test.d.ts +0 -1
- package/dist/collections/MemoryDataCollection.test.d.ts +0 -1
- package/dist/collections/TagCollection.contract.test.d.ts +0 -1
- package/dist/collections/TagCollection.test.d.ts +0 -1
- package/dist/expressions/parser.test.d.ts +0 -1
- package/dist/expressions/sql.d.ts +0 -28
- package/dist/expressions/sql.test.d.ts +0 -1
- package/dist/expressions/utils.test.d.ts +0 -1
- package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
- package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
- package/dist/plugins/query/Query.test.d.ts +0 -1
- package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
- package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
- package/dist/plugins/translators/SqlTranslator.test.d.ts +0 -1
- package/dist/plugins/translators/TranslatedValues.test.d.ts +0 -1
- package/dist/results/Result.test.d.ts +0 -1
- package/dist/results/utils.test.d.ts +0 -1
- package/dist/schema/PropertyInfo.test.d.ts +0 -1
- package/dist/schema/communication/broadcast.test.d.ts +0 -1
- package/dist/schema/schemaGeneration.test.d.ts +0 -1
- package/dist/schema/utils/standardJsonSchema.test.d.ts +0 -1
- package/dist/utilities/arrays.test.d.ts +0 -1
- package/dist/utilities/dates.test.d.ts +0 -1
- package/dist/utilities/runtime.test.d.ts +0 -1
- package/dist/utilities/strings.test.d.ts +0 -1
- package/dist/utilities/uuid.test.d.ts +0 -1
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_modules__ = ({
|
|
4
|
+
718(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
6
|
+
D: () => (PluginEventResult),
|
|
7
|
+
Q: () => (Result)
|
|
8
|
+
});
|
|
9
|
+
class BaseResult {
|
|
10
|
+
static ERROR = "error";
|
|
11
|
+
static SUCCESS = "success";
|
|
12
|
+
static PARTIAL = "partial";
|
|
13
|
+
static resolve(result, resolve, reject) {
|
|
14
|
+
if (result.ok === BaseResult.SUCCESS) {
|
|
15
|
+
resolve(result.data);
|
|
16
|
+
return;
|
|
17
|
+
}
|
|
18
|
+
if (result.ok === BaseResult.PARTIAL) {
|
|
19
|
+
reject({
|
|
20
|
+
partial: result.data,
|
|
21
|
+
error: result.error
|
|
22
|
+
});
|
|
23
|
+
return;
|
|
24
|
+
}
|
|
25
|
+
reject(result.error);
|
|
26
|
+
}
|
|
27
|
+
static assertSuccess(result) {
|
|
28
|
+
if (result.ok !== BaseResult.SUCCESS) {
|
|
29
|
+
throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
class Result extends BaseResult {
|
|
34
|
+
static success(data) {
|
|
35
|
+
return {
|
|
36
|
+
ok: Result.SUCCESS,
|
|
37
|
+
data
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
static error(error) {
|
|
41
|
+
return {
|
|
42
|
+
ok: Result.ERROR,
|
|
43
|
+
error
|
|
44
|
+
};
|
|
45
|
+
}
|
|
46
|
+
static partial(data, error) {
|
|
47
|
+
return {
|
|
48
|
+
ok: Result.PARTIAL,
|
|
49
|
+
data,
|
|
50
|
+
error
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
class PluginEventResult extends BaseResult {
|
|
55
|
+
static success(id, data) {
|
|
56
|
+
return {
|
|
57
|
+
id,
|
|
58
|
+
ok: Result.SUCCESS,
|
|
59
|
+
data
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
static error(id, error) {
|
|
63
|
+
return {
|
|
64
|
+
id,
|
|
65
|
+
ok: Result.ERROR,
|
|
66
|
+
error
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
static partial(id, data, error) {
|
|
70
|
+
return {
|
|
71
|
+
id,
|
|
72
|
+
ok: Result.PARTIAL,
|
|
73
|
+
data,
|
|
74
|
+
error
|
|
75
|
+
};
|
|
76
|
+
}
|
|
77
|
+
static assertSuccess(result) {
|
|
78
|
+
if (result.ok !== Result.SUCCESS) {
|
|
79
|
+
throw new Error(`Expected success result, but got ${result.ok}: ${result.error}`);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
},
|
|
86
|
+
|
|
87
|
+
});
|
|
88
|
+
// The module cache
|
|
89
|
+
var __webpack_module_cache__ = {};
|
|
90
|
+
|
|
91
|
+
// The require function
|
|
92
|
+
function __webpack_require__(moduleId) {
|
|
93
|
+
|
|
94
|
+
// Check if module is in cache
|
|
95
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
96
|
+
if (cachedModule !== undefined) {
|
|
97
|
+
return cachedModule.exports;
|
|
98
|
+
}
|
|
99
|
+
// Create a new module (and put it into the cache)
|
|
100
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
101
|
+
exports: {}
|
|
102
|
+
});
|
|
103
|
+
// Execute the module function
|
|
104
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
105
|
+
|
|
106
|
+
// Return the exports of the module
|
|
107
|
+
return module.exports;
|
|
108
|
+
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
// webpack/runtime/define_property_getters
|
|
112
|
+
(() => {
|
|
113
|
+
__webpack_require__.d = (exports, definition) => {
|
|
114
|
+
for(var key in definition) {
|
|
115
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
116
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
})();
|
|
121
|
+
// webpack/runtime/has_own_property
|
|
122
|
+
(() => {
|
|
123
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
124
|
+
})();
|
|
125
|
+
// webpack/runtime/make_namespace_object
|
|
126
|
+
(() => {
|
|
127
|
+
// define __esModule on exports
|
|
128
|
+
__webpack_require__.r = (exports) => {
|
|
129
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
130
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
131
|
+
}
|
|
132
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
133
|
+
};
|
|
134
|
+
})();
|
|
135
|
+
var __webpack_exports__ = {};
|
|
136
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
137
|
+
(() => {
|
|
138
|
+
// ESM COMPAT FLAG
|
|
139
|
+
__webpack_require__.r(__webpack_exports__);
|
|
140
|
+
|
|
141
|
+
// EXPORTS
|
|
142
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
143
|
+
PluginEventResult: () => (/* reexport */ Result/* .PluginEventResult */.D),
|
|
144
|
+
toPromise: () => (/* reexport */ toPromise),
|
|
145
|
+
Result: () => (/* reexport */ Result/* .Result */.Q)
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// EXTERNAL MODULE: ./src/results/Result.ts
|
|
149
|
+
var Result = __webpack_require__(718);
|
|
150
|
+
;// CONCATENATED MODULE: ./src/results/utils.ts
|
|
151
|
+
|
|
152
|
+
function toPromise(fn) {
|
|
153
|
+
return new Promise((resolve, reject)=>{
|
|
154
|
+
fn((r)=>{
|
|
155
|
+
if (r.ok === Result/* .Result.ERROR */.Q.ERROR) {
|
|
156
|
+
reject(r.error);
|
|
157
|
+
return;
|
|
158
|
+
}
|
|
159
|
+
resolve(r.data);
|
|
160
|
+
});
|
|
161
|
+
});
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
;// CONCATENATED MODULE: ./src/results/index.ts
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
|
|
169
|
+
})();
|
|
170
|
+
|
|
171
|
+
module.exports = __webpack_exports__;
|
|
172
|
+
})()
|
|
173
|
+
;
|
|
174
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -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"}
|
package/dist/results/index.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
var __webpack_modules__ = ({
|
|
2
|
-
|
|
3
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2
|
+
718(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
4
3
|
__webpack_require__.d(__webpack_exports__, {
|
|
5
|
-
|
|
6
|
-
|
|
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
|
-
|
|
126
|
+
|
|
127
|
+
// EXPORTS
|
|
159
128
|
__webpack_require__.d(__webpack_exports__, {
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
129
|
+
Dq: () => (/* reexport */ Result/* .PluginEventResult */.D),
|
|
130
|
+
Q7: () => (/* reexport */ Result/* .Result */.Q),
|
|
131
|
+
hq: () => (/* reexport */ toPromise)
|
|
163
132
|
});
|
|
164
|
-
|
|
165
|
-
|
|
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__.
|
|
173
|
-
var __webpack_exports__Result = __webpack_exports__.
|
|
174
|
-
var __webpack_exports__toPromise = __webpack_exports__.
|
|
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
|
|
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, ForeignKey, 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
|
*/
|
|
@@ -28,6 +28,14 @@ export declare class PropertyInfo<T extends {}> {
|
|
|
28
28
|
readonly isUnmapped: boolean;
|
|
29
29
|
/** Whether the property is distinct. */
|
|
30
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;
|
|
31
39
|
/** Indexes associated with the property. */
|
|
32
40
|
readonly indexes: string[];
|
|
33
41
|
/** Any injected value for the property. */
|
|
@@ -46,6 +54,17 @@ export declare class PropertyInfo<T extends {}> {
|
|
|
46
54
|
readonly schema: SchemaBase<T, any>;
|
|
47
55
|
/** The inner schema if this property is an array. */
|
|
48
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;
|
|
49
68
|
/** Literal values allowed for this property. */
|
|
50
69
|
readonly literals: T[];
|
|
51
70
|
/** Tags passed from the schema */
|
|
@@ -58,6 +77,7 @@ export declare class PropertyInfo<T extends {}> {
|
|
|
58
77
|
private _idCache?;
|
|
59
78
|
private _levelCache?;
|
|
60
79
|
private _hasNullableParentsCache?;
|
|
80
|
+
private _hasRenamedSegmentsCache?;
|
|
61
81
|
constructor(schema: SchemaBase<T, any>, name: string, parent?: PropertyInfo<T> | null);
|
|
62
82
|
/**
|
|
63
83
|
* Returns the depth (level) of this property in the property tree.
|
|
@@ -85,13 +105,22 @@ export declare class PropertyInfo<T extends {}> {
|
|
|
85
105
|
*
|
|
86
106
|
* @returns {string[]} The property path as an array of names, excluding this property.
|
|
87
107
|
*/
|
|
88
|
-
getParentPathArray(
|
|
108
|
+
getParentPathArray(options?: {
|
|
109
|
+
useFromPropertyName?: boolean;
|
|
110
|
+
}): string[];
|
|
89
111
|
/**
|
|
90
112
|
* Returns true if any parent property is nullable or optional.
|
|
91
113
|
*
|
|
92
114
|
* @returns {boolean} True if any parent is nullable or optional, false otherwise.
|
|
93
115
|
*/
|
|
94
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;
|
|
95
124
|
/**
|
|
96
125
|
* Returns true if any child property (recursively) is an identity property.
|
|
97
126
|
*
|
|
@@ -1,7 +1,8 @@
|
|
|
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, CompiledSchemaWithMetadata, InferCreateType, InferType, SchemaTypes } from './types';
|
|
5
|
+
import { CollectionName, CompiledSchema, CompiledSchemaWithMetadata, InferCreateType, InferType, SchemaTypes, PropertyTransform } from './types';
|
|
5
6
|
import { StandardJSONSchemaV1 } from './utils/standardJsonSchema';
|
|
6
7
|
export declare class SchemaDefinition<T extends {}> extends SchemaBase<T, any> {
|
|
7
8
|
instance: T;
|
|
@@ -39,6 +40,27 @@ export declare class SchemaDefinition<T extends {}> extends SchemaBase<T, any> {
|
|
|
39
40
|
modify<R>(builder: (d: {
|
|
40
41
|
function: <UU, I = never>(fn: (entity: InferType<CompiledSchema<T>>, collectionName: CollectionName, injected: I) => UU, injected?: I) => SchemaFunction<UU, I, "unmapped">;
|
|
41
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>;
|
|
42
64
|
}) => R): SchemaDefinition<R & T>;
|
|
43
65
|
private _iterate;
|
|
44
66
|
compile<TMetadata>(metadata: TMetadata): CompiledSchemaWithMetadata<T, TMetadata>;
|
package/dist/schema/builder.d.ts
CHANGED
|
@@ -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:
|
|
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
|
-
|
|
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;
|