@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.
- package/LICENSE +21 -0
- package/{readme.md → README.md} +2 -2
- package/dist/assertions/index.cjs +191 -0
- package/dist/assertions/index.cjs.map +1 -0
- package/dist/assertions/index.d.ts +30 -0
- package/dist/assertions/index.js +94 -30
- 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 +580 -545
- package/dist/capabilities/index.js.map +1 -1
- package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +10 -1
- package/dist/codegen/handlers/SetHandlerBuilder.d.ts +4 -0
- 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/index.d.ts +1 -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/serialize/SerializeComputedHandler.d.ts +6 -0
- package/dist/codegen/handlers/set/SetComplexHandler.d.ts +6 -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 +100 -127
- package/dist/codegen/index.js.map +1 -1
- package/dist/collections/Changes.d.ts +2 -2
- package/dist/collections/MemoryDataCollection.d.ts +15 -1
- package/dist/collections/TagCollection.d.ts +7 -8
- 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/constants.d.ts +2 -0
- 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 +2 -0
- package/dist/expressions/index.js +1784 -772
- 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/expressions/utils.d.ts +1 -2
- package/dist/index.cjs +13925 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.js +12094 -7049
- 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 +126 -50
- 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 +229 -156
- 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 +6104 -0
- package/dist/plugins/index.cjs.map +1 -0
- package/dist/plugins/index.d.ts +5 -1
- package/dist/plugins/index.js +5572 -1491
- package/dist/plugins/index.js.map +1 -1
- package/dist/plugins/query/QueryOptionsCollection.d.ts +22 -0
- package/dist/plugins/query/index.d.ts +2 -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 +64 -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/TranslatedArrayValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedGroupValue.d.ts +3 -1
- package/dist/plugins/translators/TranslatedSingleValue.d.ts +3 -1
- package/dist/plugins/translators/TupleTranslator.d.ts +45 -0
- package/dist/plugins/translators/index.d.ts +1 -0
- package/dist/plugins/translators/types.d.ts +8 -1
- package/dist/plugins/types.d.ts +87 -11
- 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 +123 -0
- package/dist/results/Result.d.ts +2 -2
- 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 +35 -2
- package/dist/schema/SchemaDefinition.d.ts +51 -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 +4 -0
- package/dist/schema/index.js +5781 -3973
- package/dist/schema/index.js.map +1 -1
- package/dist/schema/property/base/SchemaBase.d.ts +50 -2
- package/dist/schema/property/modifiers/SchemaDeserialize.d.ts +5 -1
- package/dist/schema/property/modifiers/SchemaForeignKey.d.ts +15 -0
- package/dist/schema/property/modifiers/SchemaKey.d.ts +2 -0
- package/dist/schema/property/modifiers/SchemaNullable.d.ts +15 -1
- package/dist/schema/property/modifiers/SchemaOptional.d.ts +22 -1
- package/dist/schema/property/modifiers/SchemaSearchable.d.ts +34 -0
- package/dist/schema/property/modifiers/SchemaTag.d.ts +27 -0
- package/dist/schema/property/modifiers/SchemaTracked.d.ts +5 -1
- package/dist/schema/property/modifiers/index.d.ts +3 -0
- package/dist/schema/property/types/SchemaArray.d.ts +2 -0
- package/dist/schema/property/types/SchemaBoolean.d.ts +2 -0
- package/dist/schema/property/types/SchemaDate.d.ts +2 -0
- package/dist/schema/property/types/SchemaFile.d.ts +60 -0
- package/dist/schema/property/types/SchemaNumber.d.ts +5 -1
- package/dist/schema/property/types/SchemaObject.d.ts +2 -0
- package/dist/schema/property/types/SchemaString.d.ts +25 -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 +200 -32
- package/dist/schema/utils/propertyKind.d.ts +4 -0
- package/dist/schema/utils/standardJsonSchema.d.ts +90 -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/functions.d.ts +1 -1
- package/dist/utilities/index.cjs +982 -0
- package/dist/utilities/index.cjs.map +1 -0
- package/dist/utilities/index.js +590 -321
- package/dist/utilities/index.js.map +1 -1
- package/dist/utilities/logger.d.ts +48 -0
- package/package.json +152 -98
- package/dist/collections/Changes.test.d.ts +0 -1
- package/dist/collections/MemoryDataCollection.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/utils.test.d.ts +0 -1
- package/dist/pipeline/SyncronousQueue.test.d.ts +0 -1
- package/dist/pipeline/WorkPipeline.test.d.ts +0 -1
- package/dist/plugins/EphemeralDataPlugin.test.d.ts +0 -1
- package/dist/plugins/query/QueryOptionsCollection.test.d.ts +0 -1
- package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +0 -23
- package/dist/plugins/replication/ReplicationDbPlugin.d.ts +0 -22
- package/dist/plugins/replication/index.d.ts +0 -3
- package/dist/plugins/replication/types.d.ts +0 -5
- package/dist/plugins/translators/JsonTranslator.test.d.ts +0 -1
- package/dist/schema/PropertyInfo.test.d.ts +0 -1
- package/dist/schema/schemaGeneration.test.d.ts +0 -1
- package/dist/schema/testSchemas.test.d.ts +0 -314
- package/dist/utilities/arrays.test.d.ts +0 -1
- package/dist/utilities/dates.test.d.ts +0 -1
- package/dist/utilities/strings.test.d.ts +0 -1
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 James DeMeuse
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/{readme.md → README.md}
RENAMED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<img src="docs/assets/routier.svg" alt="Routier" width="140" height="140" />
|
|
5
5
|
</p>
|
|
6
6
|
|
|
7
|
-
> **⚠️
|
|
7
|
+
> **⚠️ Release Candidate** - This project is currently a release candidate. APIs may change between versions. Use with caution in production.
|
|
8
8
|
|
|
9
9
|
A reactive data toolkit for building fast, local-first apps. Define schemas, create collections, use live queries, and make optimistic mutations with a plugin model for any storage.
|
|
10
10
|
|
|
@@ -44,7 +44,7 @@ class AppContext extends DataStore {
|
|
|
44
44
|
constructor() {
|
|
45
45
|
super(new MemoryPlugin("routier-app"));
|
|
46
46
|
}
|
|
47
|
-
users = this.collection(userSchema).create();
|
|
47
|
+
users = this.collection(userSchema).proxy().create();
|
|
48
48
|
}
|
|
49
49
|
|
|
50
50
|
const ctx = new AppContext();
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
(() => {
|
|
2
|
+
"use strict";
|
|
3
|
+
var __webpack_modules__ = ({
|
|
4
|
+
835(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
5
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
6
|
+
t: () => (EXPRESSION_TYPES)
|
|
7
|
+
});
|
|
8
|
+
const EXPRESSION_TYPES = [
|
|
9
|
+
"operator",
|
|
10
|
+
"comparator",
|
|
11
|
+
"property",
|
|
12
|
+
"value",
|
|
13
|
+
"empty",
|
|
14
|
+
"not-parsable"
|
|
15
|
+
];
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
},
|
|
19
|
+
76(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
20
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
21
|
+
$: () => (isDate)
|
|
22
|
+
});
|
|
23
|
+
const isDate = (data)=>{
|
|
24
|
+
if (data == null) {
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
if (typeof data !== "object") {
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
return data instanceof Date;
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
});
|
|
37
|
+
// The module cache
|
|
38
|
+
var __webpack_module_cache__ = {};
|
|
39
|
+
|
|
40
|
+
// The require function
|
|
41
|
+
function __webpack_require__(moduleId) {
|
|
42
|
+
|
|
43
|
+
// Check if module is in cache
|
|
44
|
+
var cachedModule = __webpack_module_cache__[moduleId];
|
|
45
|
+
if (cachedModule !== undefined) {
|
|
46
|
+
return cachedModule.exports;
|
|
47
|
+
}
|
|
48
|
+
// Create a new module (and put it into the cache)
|
|
49
|
+
var module = (__webpack_module_cache__[moduleId] = {
|
|
50
|
+
exports: {}
|
|
51
|
+
});
|
|
52
|
+
// Execute the module function
|
|
53
|
+
__webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
54
|
+
|
|
55
|
+
// Return the exports of the module
|
|
56
|
+
return module.exports;
|
|
57
|
+
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
// webpack/runtime/define_property_getters
|
|
61
|
+
(() => {
|
|
62
|
+
__webpack_require__.d = (exports, definition) => {
|
|
63
|
+
for(var key in definition) {
|
|
64
|
+
if(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {
|
|
65
|
+
Object.defineProperty(exports, key, { enumerable: true, get: definition[key] });
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
})();
|
|
70
|
+
// webpack/runtime/has_own_property
|
|
71
|
+
(() => {
|
|
72
|
+
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
73
|
+
})();
|
|
74
|
+
// webpack/runtime/make_namespace_object
|
|
75
|
+
(() => {
|
|
76
|
+
// define __esModule on exports
|
|
77
|
+
__webpack_require__.r = (exports) => {
|
|
78
|
+
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
79
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
80
|
+
}
|
|
81
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
82
|
+
};
|
|
83
|
+
})();
|
|
84
|
+
var __webpack_exports__ = {};
|
|
85
|
+
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
86
|
+
(() => {
|
|
87
|
+
__webpack_require__.r(__webpack_exports__);
|
|
88
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
89
|
+
assertDate: () => (assertDate),
|
|
90
|
+
assertInstanceOf: () => (assertInstanceOf),
|
|
91
|
+
assertIsArray: () => (assertIsArray),
|
|
92
|
+
assertIsNotNull: () => (assertIsNotNull),
|
|
93
|
+
assertIsNumber: () => (assertIsNumber),
|
|
94
|
+
assertString: () => (assertString),
|
|
95
|
+
isComparatorExpression: () => (isComparatorExpression),
|
|
96
|
+
isEmptyExpression: () => (isEmptyExpression),
|
|
97
|
+
isExpression: () => (isExpression),
|
|
98
|
+
isNotParsableExpression: () => (isNotParsableExpression),
|
|
99
|
+
isOperatorExpression: () => (isOperatorExpression),
|
|
100
|
+
isPropertyExpression: () => (isPropertyExpression),
|
|
101
|
+
isValueExpression: () => (isValueExpression)
|
|
102
|
+
});
|
|
103
|
+
/* import */ var _expressions_constants__rspack_import_1 = __webpack_require__(835);
|
|
104
|
+
/* import */ var _utilities__rspack_import_0 = __webpack_require__(76);
|
|
105
|
+
|
|
106
|
+
|
|
107
|
+
function assertDate(data) {
|
|
108
|
+
if ((0,_utilities__rspack_import_0/* .isDate */.$)(data) === false) {
|
|
109
|
+
throw new TypeError('Value is not a Date');
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function assertIsNotNull(data, message) {
|
|
113
|
+
if (data == null) {
|
|
114
|
+
if (message == null) {
|
|
115
|
+
throw new TypeError('Assertion failed, data is null');
|
|
116
|
+
}
|
|
117
|
+
if (typeof message === "string") {
|
|
118
|
+
throw new TypeError(message);
|
|
119
|
+
}
|
|
120
|
+
throw new TypeError(message());
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
function assertIsArray(data, message) {
|
|
124
|
+
if (!Array.isArray(data)) {
|
|
125
|
+
throw new TypeError(message ?? 'Assertion failed, data is not of type Array');
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function assertString(data, message) {
|
|
129
|
+
if (typeof data !== "string") {
|
|
130
|
+
throw new TypeError(message ?? 'Assertion failed, data is not of type String');
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
function assertInstanceOf(value, Instance) {
|
|
134
|
+
if (value instanceof Instance) {
|
|
135
|
+
return;
|
|
136
|
+
}
|
|
137
|
+
if (value != null && typeof value === "object" && "constructor" in value) {
|
|
138
|
+
throw new TypeError(`value is not instance of type. Type: ${value.constructor.name}`);
|
|
139
|
+
}
|
|
140
|
+
throw new TypeError(`value is not instance of type`);
|
|
141
|
+
}
|
|
142
|
+
function assertIsNumber(value) {
|
|
143
|
+
if (typeof value !== "number") {
|
|
144
|
+
throw new TypeError("value is not of type `number`");
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function isObjectWithType(value) {
|
|
148
|
+
return typeof value === "object" && value !== null && "type" in value;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.
|
|
152
|
+
*/ function isExpression(value) {
|
|
153
|
+
return isObjectWithType(value) && _expressions_constants__rspack_import_1/* .EXPRESSION_TYPES.includes */.t.includes(value.type);
|
|
154
|
+
}
|
|
155
|
+
/**
|
|
156
|
+
* Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === "operator"`.
|
|
157
|
+
*/ function isOperatorExpression(value) {
|
|
158
|
+
return isObjectWithType(value) && value.type === "operator";
|
|
159
|
+
}
|
|
160
|
+
/**
|
|
161
|
+
* Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === "comparator"`.
|
|
162
|
+
*/ function isComparatorExpression(value) {
|
|
163
|
+
return isObjectWithType(value) && value.type === "comparator";
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === "property"`.
|
|
167
|
+
*/ function isPropertyExpression(value) {
|
|
168
|
+
return isObjectWithType(value) && value.type === "property";
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Type guard: narrows `value` to `ValueExpression` when it is an object with `type === "value"`.
|
|
172
|
+
*/ function isValueExpression(value) {
|
|
173
|
+
return isObjectWithType(value) && value.type === "value";
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === "empty"`.
|
|
177
|
+
*/ function isEmptyExpression(value) {
|
|
178
|
+
return isObjectWithType(value) && value.type === "empty";
|
|
179
|
+
}
|
|
180
|
+
/**
|
|
181
|
+
* Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === "not-parsable"`.
|
|
182
|
+
*/ function isNotParsableExpression(value) {
|
|
183
|
+
return isObjectWithType(value) && value.type === "not-parsable";
|
|
184
|
+
}
|
|
185
|
+
|
|
186
|
+
})();
|
|
187
|
+
|
|
188
|
+
module.exports = __webpack_exports__;
|
|
189
|
+
})()
|
|
190
|
+
;
|
|
191
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"assertions/index.cjs","sources":["webpack://@routier/core/./src/expressions/constants.ts","webpack://@routier/core/./src/utilities/dates.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/assertions/index.ts"],"sourcesContent":["import { ExpressionType } from \"./types\";\n\nexport const EXPRESSION_TYPES: ExpressionType[] = [\n \"operator\",\n \"comparator\",\n \"property\",\n \"value\",\n \"empty\",\n \"not-parsable\",\n];\n","export const isDate = (data: unknown): data is Date => {\n if (data == null) {\n return false;\n }\n\n if (typeof data !== \"object\") {\n return false;\n }\n\n return data instanceof Date;\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 { EXPRESSION_TYPES } from \"../expressions/constants\";\nimport { ComparatorExpression, EmptyExpression, Expression, ExpressionType, NotParsableExpression, OperatorExpression, PropertyExpression, ValueExpression } from \"../expressions/types\";\nimport { isDate } from \"../utilities\";\n\nexport function assertDate(data: unknown): asserts data is Date {\n if (isDate(data) === false) {\n throw new TypeError('Value is not a Date');\n }\n}\n\nexport function assertIsNotNull<T>(data: T | null | undefined, message?: string | (() => string)): asserts data is NonNullable<T> {\n if (data == null) {\n if (message == null) {\n throw new TypeError('Assertion failed, data is null');\n }\n\n if (typeof message === \"string\") {\n throw new TypeError(message);\n }\n\n throw new TypeError(message());\n }\n}\n\nexport function assertIsArray<T>(data: unknown, message?: string): asserts data is T[] {\n if (!Array.isArray(data)) {\n throw new TypeError(message ?? 'Assertion failed, data is not of type Array');\n }\n}\n\nexport function assertString(data: unknown, message?: string): asserts data is string {\n if (typeof data !== \"string\") {\n throw new TypeError(message ?? 'Assertion failed, data is not of type String');\n }\n}\n\nexport function assertInstanceOf<T extends new (...args: any[]) => any>(value: unknown, Instance: T): asserts value is T {\n if (value instanceof Instance) {\n return;\n }\n\n if (value != null && typeof value === \"object\" && \"constructor\" in value) {\n throw new TypeError(`value is not instance of type. Type: ${value.constructor.name}`);\n }\n\n throw new TypeError(`value is not instance of type`);\n}\n\nexport function assertIsNumber(value: unknown): asserts value is number {\n if (typeof value !== \"number\") {\n throw new TypeError(\"value is not of type `number`\");\n }\n}\n\n\nfunction isObjectWithType(value: unknown): value is Record<\"type\", unknown> {\n return typeof value === \"object\" && value !== null && \"type\" in value;\n}\n\n/**\n * Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.\n */\nexport function isExpression(value: unknown): value is Expression {\n return isObjectWithType(value) && EXPRESSION_TYPES.includes(value.type as ExpressionType);\n}\n\n/**\n * Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === \"operator\"`.\n */\nexport function isOperatorExpression(value: unknown): value is OperatorExpression {\n return isObjectWithType(value) && value.type === \"operator\";\n}\n\n/**\n * Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === \"comparator\"`.\n */\nexport function isComparatorExpression(value: unknown): value is ComparatorExpression {\n return isObjectWithType(value) && value.type === \"comparator\";\n}\n\n/**\n * Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === \"property\"`.\n */\nexport function isPropertyExpression(value: unknown): value is PropertyExpression {\n return isObjectWithType(value) && value.type === \"property\";\n}\n\n/**\n * Type guard: narrows `value` to `ValueExpression` when it is an object with `type === \"value\"`.\n */\nexport function isValueExpression(value: unknown): value is ValueExpression {\n return isObjectWithType(value) && value.type === \"value\";\n}\n\n/**\n * Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === \"empty\"`.\n */\nexport function isEmptyExpression(value: unknown): value is EmptyExpression {\n return isObjectWithType(value) && value.type === \"empty\";\n}\n\n/**\n * Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === \"not-parsable\"`.\n */\nexport function isNotParsableExpression(value: unknown): value is NotParsableExpression {\n return isObjectWithType(value) && value.type === \"not-parsable\";\n}"],"names":["EXPRESSION_TYPES","isDate","data","Date","assertDate","TypeError","assertIsNotNull","message","assertIsArray","Array","assertString","assertInstanceOf","value","Instance","assertIsNumber","isObjectWithType","isExpression","isOperatorExpression","isComparatorExpression","isPropertyExpression","isValueExpression","isEmptyExpression","isNotParsableExpression"],"mappings":";;;;;;;AAEO,MAAMA,mBAAqC;IAC9C;IACA;IACA;IACA;IACA;IACA;CACH,CAAC;;;;;;;;ACTK,MAAMC,SAAS,CAACC;IACnB,IAAIA,QAAQ,MAAM;QACd,OAAO;IACX;IAEA,IAAI,OAAOA,SAAS,UAAU;QAC1B,OAAO;IACX;IAEA,OAAOA,gBAAgBC;AAC3B,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVD;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;ACAA;AACA;AACA;AACA,uDAAuD,iBAAiB;AACxE;AACA,gDAAgD,aAAa;AAC7D,E;;;;;;;;;;;;;;;;;;;;;;;ACN4D;AAEtB;AAE/B,SAASC,WAAWF,IAAa;IACpC,IAAID,8CAAMA,CAACC,UAAU,OAAO;QACxB,MAAM,IAAIG,UAAU;IACxB;AACJ;AAEO,SAASC,gBAAmBJ,IAA0B,EAAEK,OAAiC;IAC5F,IAAIL,QAAQ,MAAM;QACd,IAAIK,WAAW,MAAM;YACjB,MAAM,IAAIF,UAAU;QACxB;QAEA,IAAI,OAAOE,YAAY,UAAU;YAC7B,MAAM,IAAIF,UAAUE;QACxB;QAEA,MAAM,IAAIF,UAAUE;IACxB;AACJ;AAEO,SAASC,cAAiBN,IAAa,EAAEK,OAAgB;IAC5D,IAAI,CAACE,MAAM,OAAO,CAACP,OAAO;QACtB,MAAM,IAAIG,UAAUE,WAAW;IACnC;AACJ;AAEO,SAASG,aAAaR,IAAa,EAAEK,OAAgB;IACxD,IAAI,OAAOL,SAAS,UAAU;QAC1B,MAAM,IAAIG,UAAUE,WAAW;IACnC;AACJ;AAEO,SAASI,iBAAwDC,KAAc,EAAEC,QAAW;IAC/F,IAAID,iBAAiBC,UAAU;QAC3B;IACJ;IAEA,IAAID,SAAS,QAAQ,OAAOA,UAAU,YAAY,iBAAiBA,OAAO;QACtE,MAAM,IAAIP,UAAU,CAAC,sCAAsC,EAAEO,MAAM,WAAW,CAAC,IAAI,EAAE;IACzF;IAEA,MAAM,IAAIP,UAAU,CAAC,6BAA6B,CAAC;AACvD;AAEO,SAASS,eAAeF,KAAc;IACzC,IAAI,OAAOA,UAAU,UAAU;QAC3B,MAAM,IAAIP,UAAU;IACxB;AACJ;AAGA,SAASU,iBAAiBH,KAAc;IACpC,OAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,UAAUA;AACpE;AAEA;;CAEC,GACM,SAASI,aAAaJ,KAAc;IACvC,OAAOG,iBAAiBH,UAAUZ,kFAAyB,CAACY,MAAM,IAAI;AAC1E;AAEA;;CAEC,GACM,SAASK,qBAAqBL,KAAc;IAC/C,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASM,uBAAuBN,KAAc;IACjD,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASO,qBAAqBP,KAAc;IAC/C,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASQ,kBAAkBR,KAAc;IAC5C,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASS,kBAAkBT,KAAc;IAC5C,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASU,wBAAwBV,KAAc;IAClD,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD"}
|
|
@@ -1,5 +1,35 @@
|
|
|
1
|
+
import { ComparatorExpression, EmptyExpression, Expression, NotParsableExpression, OperatorExpression, PropertyExpression, ValueExpression } from "../expressions/types";
|
|
1
2
|
export declare function assertDate(data: unknown): asserts data is Date;
|
|
2
3
|
export declare function assertIsNotNull<T>(data: T | null | undefined, message?: string | (() => string)): asserts data is NonNullable<T>;
|
|
3
4
|
export declare function assertIsArray<T>(data: unknown, message?: string): asserts data is T[];
|
|
4
5
|
export declare function assertString(data: unknown, message?: string): asserts data is string;
|
|
5
6
|
export declare function assertInstanceOf<T extends new (...args: any[]) => any>(value: unknown, Instance: T): asserts value is T;
|
|
7
|
+
export declare function assertIsNumber(value: unknown): asserts value is number;
|
|
8
|
+
/**
|
|
9
|
+
* Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.
|
|
10
|
+
*/
|
|
11
|
+
export declare function isExpression(value: unknown): value is Expression;
|
|
12
|
+
/**
|
|
13
|
+
* Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === "operator"`.
|
|
14
|
+
*/
|
|
15
|
+
export declare function isOperatorExpression(value: unknown): value is OperatorExpression;
|
|
16
|
+
/**
|
|
17
|
+
* Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === "comparator"`.
|
|
18
|
+
*/
|
|
19
|
+
export declare function isComparatorExpression(value: unknown): value is ComparatorExpression;
|
|
20
|
+
/**
|
|
21
|
+
* Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === "property"`.
|
|
22
|
+
*/
|
|
23
|
+
export declare function isPropertyExpression(value: unknown): value is PropertyExpression;
|
|
24
|
+
/**
|
|
25
|
+
* Type guard: narrows `value` to `ValueExpression` when it is an object with `type === "value"`.
|
|
26
|
+
*/
|
|
27
|
+
export declare function isValueExpression(value: unknown): value is ValueExpression;
|
|
28
|
+
/**
|
|
29
|
+
* Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === "empty"`.
|
|
30
|
+
*/
|
|
31
|
+
export declare function isEmptyExpression(value: unknown): value is EmptyExpression;
|
|
32
|
+
/**
|
|
33
|
+
* Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === "not-parsable"`.
|
|
34
|
+
*/
|
|
35
|
+
export declare function isNotParsableExpression(value: unknown): value is NotParsableExpression;
|
package/dist/assertions/index.js
CHANGED
|
@@ -1,10 +1,24 @@
|
|
|
1
1
|
var __webpack_modules__ = ({
|
|
2
|
-
|
|
3
|
-
__webpack_require__.r(__webpack_exports__);
|
|
2
|
+
835(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
4
3
|
__webpack_require__.d(__webpack_exports__, {
|
|
5
|
-
|
|
4
|
+
t: () => (EXPRESSION_TYPES)
|
|
6
5
|
});
|
|
7
|
-
const
|
|
6
|
+
const EXPRESSION_TYPES = [
|
|
7
|
+
"operator",
|
|
8
|
+
"comparator",
|
|
9
|
+
"property",
|
|
10
|
+
"value",
|
|
11
|
+
"empty",
|
|
12
|
+
"not-parsable"
|
|
13
|
+
];
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
},
|
|
17
|
+
76(__unused_rspack_module, __webpack_exports__, __webpack_require__) {
|
|
18
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
19
|
+
$: () => (isDate)
|
|
20
|
+
});
|
|
21
|
+
const isDate = (data)=>{
|
|
8
22
|
if (data == null) {
|
|
9
23
|
return false;
|
|
10
24
|
}
|
|
@@ -55,31 +69,30 @@ __webpack_require__.d = (exports, definition) => {
|
|
|
55
69
|
(() => {
|
|
56
70
|
__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))
|
|
57
71
|
})();
|
|
58
|
-
// webpack/runtime/make_namespace_object
|
|
59
|
-
(() => {
|
|
60
|
-
// define __esModule on exports
|
|
61
|
-
__webpack_require__.r = (exports) => {
|
|
62
|
-
if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
|
|
63
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
64
|
-
}
|
|
65
|
-
Object.defineProperty(exports, '__esModule', { value: true });
|
|
66
|
-
};
|
|
67
|
-
})();
|
|
68
72
|
var __webpack_exports__ = {};
|
|
69
73
|
// This entry needs to be wrapped in an IIFE because it needs to be isolated against other modules in the chunk.
|
|
70
74
|
(() => {
|
|
71
|
-
__webpack_require__.r(__webpack_exports__);
|
|
72
75
|
__webpack_require__.d(__webpack_exports__, {
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
76
|
+
AF: () => (isNotParsableExpression),
|
|
77
|
+
BH: () => (isExpression),
|
|
78
|
+
Cv: () => (assertString),
|
|
79
|
+
S6: () => (isValueExpression),
|
|
80
|
+
Ye: () => (assertIsNumber),
|
|
81
|
+
dp: () => (assertDate),
|
|
82
|
+
e3: () => (isPropertyExpression),
|
|
83
|
+
jf: () => (assertIsNotNull),
|
|
84
|
+
nn: () => (assertInstanceOf),
|
|
85
|
+
vg: () => (isOperatorExpression),
|
|
86
|
+
wL: () => (isEmptyExpression),
|
|
87
|
+
xH: () => (isComparatorExpression),
|
|
88
|
+
ys: () => (assertIsArray)
|
|
78
89
|
});
|
|
79
|
-
/* import */ var
|
|
90
|
+
/* import */ var _expressions_constants__rspack_import_1 = __webpack_require__(835);
|
|
91
|
+
/* import */ var _utilities__rspack_import_0 = __webpack_require__(76);
|
|
92
|
+
|
|
80
93
|
|
|
81
94
|
function assertDate(data) {
|
|
82
|
-
if ((0,_utilities__rspack_import_0.isDate)(data) === false) {
|
|
95
|
+
if ((0,_utilities__rspack_import_0/* .isDate */.$)(data) === false) {
|
|
83
96
|
throw new TypeError('Value is not a Date');
|
|
84
97
|
}
|
|
85
98
|
}
|
|
@@ -109,18 +122,69 @@ function assertInstanceOf(value, Instance) {
|
|
|
109
122
|
return;
|
|
110
123
|
}
|
|
111
124
|
if (value != null && typeof value === "object" && "constructor" in value) {
|
|
112
|
-
throw new TypeError(`
|
|
125
|
+
throw new TypeError(`value is not instance of type. Type: ${value.constructor.name}`);
|
|
113
126
|
}
|
|
114
|
-
throw new TypeError(`
|
|
127
|
+
throw new TypeError(`value is not instance of type`);
|
|
128
|
+
}
|
|
129
|
+
function assertIsNumber(value) {
|
|
130
|
+
if (typeof value !== "number") {
|
|
131
|
+
throw new TypeError("value is not of type `number`");
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
function isObjectWithType(value) {
|
|
135
|
+
return typeof value === "object" && value !== null && "type" in value;
|
|
136
|
+
}
|
|
137
|
+
/**
|
|
138
|
+
* Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.
|
|
139
|
+
*/ function isExpression(value) {
|
|
140
|
+
return isObjectWithType(value) && _expressions_constants__rspack_import_1/* .EXPRESSION_TYPES.includes */.t.includes(value.type);
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === "operator"`.
|
|
144
|
+
*/ function isOperatorExpression(value) {
|
|
145
|
+
return isObjectWithType(value) && value.type === "operator";
|
|
146
|
+
}
|
|
147
|
+
/**
|
|
148
|
+
* Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === "comparator"`.
|
|
149
|
+
*/ function isComparatorExpression(value) {
|
|
150
|
+
return isObjectWithType(value) && value.type === "comparator";
|
|
151
|
+
}
|
|
152
|
+
/**
|
|
153
|
+
* Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === "property"`.
|
|
154
|
+
*/ function isPropertyExpression(value) {
|
|
155
|
+
return isObjectWithType(value) && value.type === "property";
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Type guard: narrows `value` to `ValueExpression` when it is an object with `type === "value"`.
|
|
159
|
+
*/ function isValueExpression(value) {
|
|
160
|
+
return isObjectWithType(value) && value.type === "value";
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === "empty"`.
|
|
164
|
+
*/ function isEmptyExpression(value) {
|
|
165
|
+
return isObjectWithType(value) && value.type === "empty";
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === "not-parsable"`.
|
|
169
|
+
*/ function isNotParsableExpression(value) {
|
|
170
|
+
return isObjectWithType(value) && value.type === "not-parsable";
|
|
115
171
|
}
|
|
116
172
|
|
|
117
173
|
})();
|
|
118
174
|
|
|
119
|
-
var __webpack_exports__assertDate = __webpack_exports__.
|
|
120
|
-
var __webpack_exports__assertInstanceOf = __webpack_exports__.
|
|
121
|
-
var __webpack_exports__assertIsArray = __webpack_exports__.
|
|
122
|
-
var __webpack_exports__assertIsNotNull = __webpack_exports__.
|
|
123
|
-
var
|
|
124
|
-
|
|
175
|
+
var __webpack_exports__assertDate = __webpack_exports__.dp;
|
|
176
|
+
var __webpack_exports__assertInstanceOf = __webpack_exports__.nn;
|
|
177
|
+
var __webpack_exports__assertIsArray = __webpack_exports__.ys;
|
|
178
|
+
var __webpack_exports__assertIsNotNull = __webpack_exports__.jf;
|
|
179
|
+
var __webpack_exports__assertIsNumber = __webpack_exports__.Ye;
|
|
180
|
+
var __webpack_exports__assertString = __webpack_exports__.Cv;
|
|
181
|
+
var __webpack_exports__isComparatorExpression = __webpack_exports__.xH;
|
|
182
|
+
var __webpack_exports__isEmptyExpression = __webpack_exports__.wL;
|
|
183
|
+
var __webpack_exports__isExpression = __webpack_exports__.BH;
|
|
184
|
+
var __webpack_exports__isNotParsableExpression = __webpack_exports__.AF;
|
|
185
|
+
var __webpack_exports__isOperatorExpression = __webpack_exports__.vg;
|
|
186
|
+
var __webpack_exports__isPropertyExpression = __webpack_exports__.e3;
|
|
187
|
+
var __webpack_exports__isValueExpression = __webpack_exports__.S6;
|
|
188
|
+
export { __webpack_exports__assertDate as assertDate, __webpack_exports__assertInstanceOf as assertInstanceOf, __webpack_exports__assertIsArray as assertIsArray, __webpack_exports__assertIsNotNull as assertIsNotNull, __webpack_exports__assertIsNumber as assertIsNumber, __webpack_exports__assertString as assertString, __webpack_exports__isComparatorExpression as isComparatorExpression, __webpack_exports__isEmptyExpression as isEmptyExpression, __webpack_exports__isExpression as isExpression, __webpack_exports__isNotParsableExpression as isNotParsableExpression, __webpack_exports__isOperatorExpression as isOperatorExpression, __webpack_exports__isPropertyExpression as isPropertyExpression, __webpack_exports__isValueExpression as isValueExpression };
|
|
125
189
|
|
|
126
190
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assertions/index.js","sources":["webpack://@routier/core/./src/
|
|
1
|
+
{"version":3,"file":"assertions/index.js","sources":["webpack://@routier/core/./src/expressions/constants.ts","webpack://@routier/core/./src/utilities/dates.ts","webpack://@routier/core/webpack/runtime/define_property_getters","webpack://@routier/core/webpack/runtime/has_own_property","webpack://@routier/core/./src/assertions/index.ts"],"sourcesContent":["import { ExpressionType } from \"./types\";\n\nexport const EXPRESSION_TYPES: ExpressionType[] = [\n \"operator\",\n \"comparator\",\n \"property\",\n \"value\",\n \"empty\",\n \"not-parsable\",\n];\n","export const isDate = (data: unknown): data is Date => {\n if (data == null) {\n return false;\n }\n\n if (typeof data !== \"object\") {\n return false;\n }\n\n return data instanceof Date;\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 { EXPRESSION_TYPES } from \"../expressions/constants\";\nimport { ComparatorExpression, EmptyExpression, Expression, ExpressionType, NotParsableExpression, OperatorExpression, PropertyExpression, ValueExpression } from \"../expressions/types\";\nimport { isDate } from \"../utilities\";\n\nexport function assertDate(data: unknown): asserts data is Date {\n if (isDate(data) === false) {\n throw new TypeError('Value is not a Date');\n }\n}\n\nexport function assertIsNotNull<T>(data: T | null | undefined, message?: string | (() => string)): asserts data is NonNullable<T> {\n if (data == null) {\n if (message == null) {\n throw new TypeError('Assertion failed, data is null');\n }\n\n if (typeof message === \"string\") {\n throw new TypeError(message);\n }\n\n throw new TypeError(message());\n }\n}\n\nexport function assertIsArray<T>(data: unknown, message?: string): asserts data is T[] {\n if (!Array.isArray(data)) {\n throw new TypeError(message ?? 'Assertion failed, data is not of type Array');\n }\n}\n\nexport function assertString(data: unknown, message?: string): asserts data is string {\n if (typeof data !== \"string\") {\n throw new TypeError(message ?? 'Assertion failed, data is not of type String');\n }\n}\n\nexport function assertInstanceOf<T extends new (...args: any[]) => any>(value: unknown, Instance: T): asserts value is T {\n if (value instanceof Instance) {\n return;\n }\n\n if (value != null && typeof value === \"object\" && \"constructor\" in value) {\n throw new TypeError(`value is not instance of type. Type: ${value.constructor.name}`);\n }\n\n throw new TypeError(`value is not instance of type`);\n}\n\nexport function assertIsNumber(value: unknown): asserts value is number {\n if (typeof value !== \"number\") {\n throw new TypeError(\"value is not of type `number`\");\n }\n}\n\n\nfunction isObjectWithType(value: unknown): value is Record<\"type\", unknown> {\n return typeof value === \"object\" && value !== null && \"type\" in value;\n}\n\n/**\n * Type guard: narrows `value` to `Expression` when it is an object with a valid `type` property.\n */\nexport function isExpression(value: unknown): value is Expression {\n return isObjectWithType(value) && EXPRESSION_TYPES.includes(value.type as ExpressionType);\n}\n\n/**\n * Type guard: narrows `value` to `OperatorExpression` when it is an object with `type === \"operator\"`.\n */\nexport function isOperatorExpression(value: unknown): value is OperatorExpression {\n return isObjectWithType(value) && value.type === \"operator\";\n}\n\n/**\n * Type guard: narrows `value` to `ComparatorExpression` when it is an object with `type === \"comparator\"`.\n */\nexport function isComparatorExpression(value: unknown): value is ComparatorExpression {\n return isObjectWithType(value) && value.type === \"comparator\";\n}\n\n/**\n * Type guard: narrows `value` to `PropertyExpression` when it is an object with `type === \"property\"`.\n */\nexport function isPropertyExpression(value: unknown): value is PropertyExpression {\n return isObjectWithType(value) && value.type === \"property\";\n}\n\n/**\n * Type guard: narrows `value` to `ValueExpression` when it is an object with `type === \"value\"`.\n */\nexport function isValueExpression(value: unknown): value is ValueExpression {\n return isObjectWithType(value) && value.type === \"value\";\n}\n\n/**\n * Type guard: narrows `value` to `EmptyExpression` when it is an object with `type === \"empty\"`.\n */\nexport function isEmptyExpression(value: unknown): value is EmptyExpression {\n return isObjectWithType(value) && value.type === \"empty\";\n}\n\n/**\n * Type guard: narrows `value` to `NotParsableExpression` when it is an object with `type === \"not-parsable\"`.\n */\nexport function isNotParsableExpression(value: unknown): value is NotParsableExpression {\n return isObjectWithType(value) && value.type === \"not-parsable\";\n}"],"names":["EXPRESSION_TYPES","isDate","data","Date","assertDate","TypeError","assertIsNotNull","message","assertIsArray","Array","assertString","assertInstanceOf","value","Instance","assertIsNumber","isObjectWithType","isExpression","isOperatorExpression","isComparatorExpression","isPropertyExpression","isValueExpression","isEmptyExpression","isNotParsableExpression"],"mappings":";;;;;AAEO,MAAMA,mBAAqC;IAC9C;IACA;IACA;IACA;IACA;IACA;CACH,CAAC;;;;;;;;ACTK,MAAMC,SAAS,CAACC;IACnB,IAAIA,QAAQ,MAAM;QACd,OAAO;IACX;IAEA,IAAI,OAAOA,SAAS,UAAU;QAC1B,OAAO;IACX;IAEA,OAAOA,gBAAgBC;AAC3B,EAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;ACVD;AACA;AACA;AACA,kDAAkD,wCAAwC;AAC1F;AACA;AACA,E;;;;ACNA,wF;;;;;;;;;;;;;;;;;;;;;;ACA4D;AAEtB;AAE/B,SAASC,WAAWF,IAAa;IACpC,IAAID,8CAAMA,CAACC,UAAU,OAAO;QACxB,MAAM,IAAIG,UAAU;IACxB;AACJ;AAEO,SAASC,gBAAmBJ,IAA0B,EAAEK,OAAiC;IAC5F,IAAIL,QAAQ,MAAM;QACd,IAAIK,WAAW,MAAM;YACjB,MAAM,IAAIF,UAAU;QACxB;QAEA,IAAI,OAAOE,YAAY,UAAU;YAC7B,MAAM,IAAIF,UAAUE;QACxB;QAEA,MAAM,IAAIF,UAAUE;IACxB;AACJ;AAEO,SAASC,cAAiBN,IAAa,EAAEK,OAAgB;IAC5D,IAAI,CAACE,MAAM,OAAO,CAACP,OAAO;QACtB,MAAM,IAAIG,UAAUE,WAAW;IACnC;AACJ;AAEO,SAASG,aAAaR,IAAa,EAAEK,OAAgB;IACxD,IAAI,OAAOL,SAAS,UAAU;QAC1B,MAAM,IAAIG,UAAUE,WAAW;IACnC;AACJ;AAEO,SAASI,iBAAwDC,KAAc,EAAEC,QAAW;IAC/F,IAAID,iBAAiBC,UAAU;QAC3B;IACJ;IAEA,IAAID,SAAS,QAAQ,OAAOA,UAAU,YAAY,iBAAiBA,OAAO;QACtE,MAAM,IAAIP,UAAU,CAAC,sCAAsC,EAAEO,MAAM,WAAW,CAAC,IAAI,EAAE;IACzF;IAEA,MAAM,IAAIP,UAAU,CAAC,6BAA6B,CAAC;AACvD;AAEO,SAASS,eAAeF,KAAc;IACzC,IAAI,OAAOA,UAAU,UAAU;QAC3B,MAAM,IAAIP,UAAU;IACxB;AACJ;AAGA,SAASU,iBAAiBH,KAAc;IACpC,OAAO,OAAOA,UAAU,YAAYA,UAAU,QAAQ,UAAUA;AACpE;AAEA;;CAEC,GACM,SAASI,aAAaJ,KAAc;IACvC,OAAOG,iBAAiBH,UAAUZ,kFAAyB,CAACY,MAAM,IAAI;AAC1E;AAEA;;CAEC,GACM,SAASK,qBAAqBL,KAAc;IAC/C,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASM,uBAAuBN,KAAc;IACjD,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASO,qBAAqBP,KAAc;IAC/C,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASQ,kBAAkBR,KAAc;IAC5C,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASS,kBAAkBT,KAAc;IAC5C,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD;AAEA;;CAEC,GACM,SAASU,wBAAwBV,KAAc;IAClD,OAAOG,iBAAiBH,UAAUA,MAAM,IAAI,KAAK;AACrD"}
|