@routier/core 0.0.1-alpha.1 → 0.0.1-alpha.2
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/dist/assertions/index.d.ts +5 -0
- package/dist/assertions/index.js +131 -0
- package/dist/assertions/index.js.map +1 -0
- package/dist/codegen/SlotPath.d.ts +7 -0
- package/dist/codegen/blocks.d.ts +130 -0
- package/dist/codegen/handlers/CloneHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/CompareHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/DeserializeHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/EnableChangeTrackingHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/EnrichmentHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/FreezeHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/HashHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/HashTypeHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/IdSelectorHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/MergeHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/PrepareHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/SerializeHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/StripHandlerBuilder.d.ts +4 -0
- package/dist/codegen/handlers/clone/CloneObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/clone/CloneValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/compare/CompareObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/compare/CompareValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/deserialize/DeserializeComputedValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/deserialize/DeserializeDateHandler.d.ts +9 -0
- package/dist/codegen/handlers/deserialize/DeserializeFunctionHandler.d.ts +6 -0
- package/dist/codegen/handlers/deserialize/DeserializeObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/deserialize/DeserializeValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/enableChangeTracking/EnableChangeTrackingPrimitiveValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/enrichment/EnrichmentComputedValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/enrichment/EnrichmentDefaultFunctionHandler.d.ts +6 -0
- package/dist/codegen/handlers/enrichment/EnrichmentDefaultValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/enrichment/EnrichmentFunctionHandler.d.ts +6 -0
- package/dist/codegen/handlers/enrichment/EnrichmentNullableObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/enrichment/EnrichmentObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/enrichment/EnrichmentObjectIdentityHandler.d.ts +6 -0
- package/dist/codegen/handlers/enrichment/EnrichmentPrimitiveHandler.d.ts +6 -0
- package/dist/codegen/handlers/enrichment/EnrichmentPrimitiveIdentityHandler.d.ts +6 -0
- package/dist/codegen/handlers/freeze/FreezeObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/freeze/FreezePrimitiveValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashComputedValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashDateHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashFunctionHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashIdentityHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashKeyHandler.d.ts +6 -0
- package/dist/codegen/handlers/hash/HashValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/hashType/HashTypeValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/idSelector/IdSelectorValueHandler.d.ts +6 -0
- package/{src/codegen/handlers/index.ts → dist/codegen/handlers/index.d.ts} +1 -1
- package/dist/codegen/handlers/merge/MergeComputedValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/merge/MergeDefaultFunctionHandler.d.ts +6 -0
- package/dist/codegen/handlers/merge/MergeDefaultValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/merge/MergeFunctionHandler.d.ts +6 -0
- package/dist/codegen/handlers/merge/MergePrimitiveHandler.d.ts +6 -0
- package/dist/codegen/handlers/prepare/PrepareComputedValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/prepare/PrepareFunctionHandler.d.ts +6 -0
- package/dist/codegen/handlers/prepare/PrepareIdentityHandler.d.ts +6 -0
- package/dist/codegen/handlers/prepare/PrepareKeyHandler.d.ts +6 -0
- package/dist/codegen/handlers/prepare/PrepareObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/prepare/PrepareValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/serialize/SerializeDateHandler.d.ts +9 -0
- package/dist/codegen/handlers/serialize/SerializeObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/serialize/SerializeValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/strip/StripIdentityHandler.d.ts +6 -0
- package/dist/codegen/handlers/strip/StripKeyHandler.d.ts +6 -0
- package/dist/codegen/handlers/strip/StripObjectHandler.d.ts +6 -0
- package/dist/codegen/handlers/strip/StripValueHandler.d.ts +6 -0
- package/dist/codegen/handlers/types.d.ts +18 -0
- package/{src/codegen/index.ts → dist/codegen/index.d.ts} +1 -1
- package/dist/codegen/types.d.ts +9 -0
- package/dist/codegen/utils.d.ts +22 -0
- package/dist/collections/Changes.d.ts +51 -0
- package/dist/collections/Changes.test.d.ts +1 -0
- package/dist/collections/IdSet.d.ts +7 -0
- package/dist/collections/MemoryDataCollection.d.ts +22 -0
- package/dist/collections/MemoryDataCollection.test.d.ts +1 -0
- package/dist/collections/SchemaCollection.d.ts +8 -0
- package/dist/collections/TagCollection.d.ts +15 -0
- package/dist/collections/TagCollection.test.d.ts +1 -0
- package/{src/collections/index.ts → dist/collections/index.d.ts} +1 -1
- package/dist/collections/index.js +659 -0
- package/dist/collections/index.js.map +1 -0
- package/dist/errors/SchemaError.d.ts +3 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.js +90 -0
- package/dist/errors/index.js.map +1 -0
- package/{src/expressions/index.ts → dist/expressions/index.d.ts} +1 -1
- package/{src/expressions/parser.ts → dist/expressions/index.js} +387 -205
- package/dist/expressions/index.js.map +1 -0
- package/dist/expressions/parser.d.ts +4 -0
- package/dist/expressions/parser.test.d.ts +1 -0
- package/{src/expressions/types.ts → dist/expressions/types.d.ts} +42 -99
- package/dist/expressions/utils.d.ts +10 -0
- package/dist/expressions/utils.test.d.ts +1 -0
- package/{src/index.ts → dist/index.d.ts} +1 -1
- package/dist/index.js +8434 -0
- package/dist/index.js.map +1 -0
- package/dist/performance/index.d.ts +5 -0
- package/dist/performance/index.js +65 -0
- package/dist/performance/index.js.map +1 -0
- package/dist/pipeline/SyncronousQueue.d.ts +7 -0
- package/dist/pipeline/SyncronousQueue.test.d.ts +1 -0
- package/dist/pipeline/TrampolinePipeline.d.ts +36 -0
- package/dist/pipeline/TrampolinePipeline.test.d.ts +1 -0
- package/dist/pipeline/index.d.ts +2 -0
- package/{src/pipeline/TrampolinePipeline.ts → dist/pipeline/index.js} +297 -140
- package/dist/pipeline/index.js.map +1 -0
- package/dist/plugins/EphemeralDataPlugin.d.ts +13 -0
- package/dist/plugins/capabilities/DbPluginCapability.d.ts +23 -0
- package/{src/plugins/capabilities/index.ts → dist/plugins/capabilities/index.d.ts} +1 -1
- package/dist/plugins/capabilities/logging/DbPluginLoggingCapability.d.ts +28 -0
- package/dist/plugins/capabilities/logging/index.d.ts +1 -0
- package/{src/plugins/index.ts → dist/plugins/index.d.ts} +1 -1
- package/dist/plugins/index.js +2328 -0
- package/dist/plugins/index.js.map +1 -0
- package/dist/plugins/query/Query.d.ts +13 -0
- package/dist/plugins/query/QueryOptionsCollection.d.ts +27 -0
- package/dist/plugins/query/QueryOptionsCollection.test.d.ts +1 -0
- package/{src/plugins/query/index.ts → dist/plugins/query/index.d.ts} +1 -1
- package/{src/plugins/query/types.ts → dist/plugins/query/types.d.ts} +29 -20
- package/dist/plugins/replication/OptimisticReplicationDbPlugin.d.ts +21 -0
- package/dist/plugins/replication/ReplicationDbPlugin.d.ts +21 -0
- package/{src/plugins/replication/index.ts → dist/plugins/replication/index.d.ts} +1 -1
- package/{src/plugins/replication/types.ts → dist/plugins/replication/types.d.ts} +1 -2
- package/dist/plugins/translators/DataTranslator.d.ts +18 -0
- package/dist/plugins/translators/JsonTranslator.d.ts +17 -0
- package/dist/plugins/translators/JsonTranslator.test.d.ts +1 -0
- package/dist/plugins/translators/SqlTranslator.d.ts +14 -0
- package/{src/plugins/translators/index.ts → dist/plugins/translators/index.d.ts} +1 -1
- package/{src/plugins/types.ts → dist/plugins/types.d.ts} +11 -26
- package/dist/results/Result.d.ts +29 -0
- package/{src/results/index.ts → dist/results/index.d.ts} +1 -1
- package/dist/results/index.js +192 -0
- package/dist/results/index.js.map +1 -0
- package/{src/results/types.ts → dist/results/types.d.ts} +18 -7
- package/dist/results/utils.d.ts +2 -0
- package/dist/schema/PropertyInfo.d.ts +132 -0
- package/dist/schema/PropertyInfo.test.d.ts +1 -0
- package/dist/schema/SchemaDefinition.d.ts +17 -0
- package/dist/schema/builder.d.ts +17 -0
- package/{src/schema/index.ts → dist/schema/index.d.ts} +1 -1
- package/dist/schema/index.js +4822 -0
- package/dist/schema/index.js.map +1 -0
- package/dist/schema/property/base/SchemaBase.d.ts +23 -0
- package/dist/schema/property/base/index.d.ts +1 -0
- package/dist/schema/property/modifiers/SchemaDefault.d.ts +13 -0
- package/dist/schema/property/modifiers/SchemaDeserialize.d.ts +11 -0
- package/dist/schema/property/modifiers/SchemaDistinct.d.ts +7 -0
- package/dist/schema/property/modifiers/SchemaFrom.d.ts +23 -0
- package/dist/schema/property/modifiers/SchemaIdentity.d.ts +7 -0
- package/dist/schema/property/modifiers/SchemaIndex.d.ts +23 -0
- package/dist/schema/property/modifiers/SchemaKey.d.ts +13 -0
- package/dist/schema/property/modifiers/SchemaNullable.d.ts +9 -0
- package/dist/schema/property/modifiers/SchemaOptional.d.ts +9 -0
- package/dist/schema/property/modifiers/SchemaReadonly.d.ts +15 -0
- package/dist/schema/property/modifiers/SchemaSerialize.d.ts +9 -0
- package/dist/schema/property/modifiers/SchemaTracked.d.ts +7 -0
- package/{src/schema/property/modifiers/index.ts → dist/schema/property/modifiers/index.d.ts} +1 -1
- package/dist/schema/property/types/SchemaArray.d.ts +23 -0
- package/dist/schema/property/types/SchemaBoolean.d.ts +27 -0
- package/dist/schema/property/types/SchemaDate.d.ts +27 -0
- package/dist/schema/property/types/SchemaNumber.d.ts +31 -0
- package/dist/schema/property/types/SchemaObject.d.ts +20 -0
- package/dist/schema/property/types/SchemaString.d.ts +31 -0
- package/{src/schema/property/types/index.ts → dist/schema/property/types/index.d.ts} +1 -1
- package/dist/schema/table/SchemaComputed.d.ts +10 -0
- package/dist/schema/table/SchemaFunction.d.ts +8 -0
- package/{src/schema/table/index.ts → dist/schema/table/index.d.ts} +1 -1
- package/{src/schema/types.ts → dist/schema/types.d.ts} +59 -99
- package/{src/types/index.ts → dist/types/index.d.ts} +1 -2
- package/dist/types/index.js +25 -0
- package/dist/types/index.js.map +1 -0
- package/dist/utilities/arrays.d.ts +1 -0
- package/dist/utilities/arrays.test.d.ts +1 -0
- package/dist/utilities/dates.d.ts +1 -0
- package/dist/utilities/dates.test.d.ts +1 -0
- package/dist/utilities/dbPluginEventUtils.d.ts +14 -0
- package/{src/utilities/index.ts → dist/utilities/index.d.ts} +1 -1
- package/dist/utilities/index.js +554 -0
- package/dist/utilities/index.js.map +1 -0
- package/dist/utilities/objects.d.ts +2 -0
- package/dist/utilities/queryOptionsCollection.d.ts +2 -0
- package/dist/utilities/replication.d.ts +3 -0
- package/dist/utilities/runtime.d.ts +1 -0
- package/dist/utilities/strings.d.ts +1 -0
- package/dist/utilities/types.d.ts +1 -0
- package/dist/utilities/uuid.d.ts +2 -0
- package/package.json +6 -1
- package/readme.md +95 -0
- package/CHANGELOG.md +0 -8
- package/rspack.config.mjs +0 -65
- package/src/assertions/index.ts +0 -37
- package/src/codegen/SlotPath.ts +0 -20
- package/src/codegen/blocks.ts +0 -578
- package/src/codegen/handlers/CloneHandlerBuilder.ts +0 -13
- package/src/codegen/handlers/CompareHandlerBuilder.ts +0 -13
- package/src/codegen/handlers/DeserializeHandlerBuilder.ts +0 -20
- package/src/codegen/handlers/EnableChangeTrackingHandlerBuilder.ts +0 -13
- package/src/codegen/handlers/EnrichmentHandlerBuilder.ts +0 -28
- package/src/codegen/handlers/FreezeHandlerBuilder.ts +0 -13
- package/src/codegen/handlers/HashHandlerBuilder.ts +0 -25
- package/src/codegen/handlers/HashTypeHandlerBuilder.ts +0 -11
- package/src/codegen/handlers/IdSelectorHandlerBuilder.ts +0 -10
- package/src/codegen/handlers/MergeHandlerBuilder.ts +0 -19
- package/src/codegen/handlers/PrepareHandlerBuilder.ts +0 -23
- package/src/codegen/handlers/SerializeHandlerBuilder.ts +0 -15
- package/src/codegen/handlers/StripHandlerBuilder.ts +0 -18
- package/src/codegen/handlers/clone/CloneObjectHandler.ts +0 -29
- package/src/codegen/handlers/clone/CloneValueHandler.ts +0 -33
- package/src/codegen/handlers/compare/CompareObjectHandler.ts +0 -15
- package/src/codegen/handlers/compare/CompareValueHandler.ts +0 -27
- package/src/codegen/handlers/deserialize/DeserializeComputedValueHandler.ts +0 -16
- package/src/codegen/handlers/deserialize/DeserializeDateHandler.ts +0 -45
- package/src/codegen/handlers/deserialize/DeserializeFunctionHandler.ts +0 -16
- package/src/codegen/handlers/deserialize/DeserializeObjectHandler.ts +0 -29
- package/src/codegen/handlers/deserialize/DeserializeValueHandler.ts +0 -33
- package/src/codegen/handlers/enableChangeTracking/EnableChangeTrackingObjectHandler.ts +0 -20
- package/src/codegen/handlers/enableChangeTracking/EnableChangeTrackingPrimitiveValueHandler.ts +0 -15
- package/src/codegen/handlers/enrichment/EnrichmentComputedValueHandler.ts +0 -37
- package/src/codegen/handlers/enrichment/EnrichmentDefaultFunctionHandler.ts +0 -50
- package/src/codegen/handlers/enrichment/EnrichmentDefaultValueHandler.ts +0 -18
- package/src/codegen/handlers/enrichment/EnrichmentFunctionHandler.ts +0 -38
- package/src/codegen/handlers/enrichment/EnrichmentNullableObjectHandler.ts +0 -44
- package/src/codegen/handlers/enrichment/EnrichmentObjectHandler.ts +0 -29
- package/src/codegen/handlers/enrichment/EnrichmentObjectIdentityHandler.ts +0 -16
- package/src/codegen/handlers/enrichment/EnrichmentPrimitiveHandler.ts +0 -13
- package/src/codegen/handlers/enrichment/EnrichmentPrimitiveIdentityHandler.ts +0 -21
- package/src/codegen/handlers/freeze/FreezeObjectHandler.ts +0 -20
- package/src/codegen/handlers/freeze/FreezePrimitiveValueHandler.ts +0 -15
- package/src/codegen/handlers/hash/HashComputedValueHandler.ts +0 -15
- package/src/codegen/handlers/hash/HashDateHandler.ts +0 -26
- package/src/codegen/handlers/hash/HashFunctionHandler.ts +0 -16
- package/src/codegen/handlers/hash/HashIdentityHandler.ts +0 -15
- package/src/codegen/handlers/hash/HashKeyHandler.ts +0 -26
- package/src/codegen/handlers/hash/HashValueHandler.ts +0 -26
- package/src/codegen/handlers/hashType/HashTypeValueHandler.ts +0 -20
- package/src/codegen/handlers/idSelector/IdSelectorValueHandler.ts +0 -28
- package/src/codegen/handlers/merge/MergeComputedValueHandler.ts +0 -37
- package/src/codegen/handlers/merge/MergeDefaultFunctionHandler.ts +0 -40
- package/src/codegen/handlers/merge/MergeDefaultValueHandler.ts +0 -32
- package/src/codegen/handlers/merge/MergeFunctionHandler.ts +0 -16
- package/src/codegen/handlers/merge/MergePrimitiveHandler.ts +0 -21
- package/src/codegen/handlers/prepare/PrepareComputedValueHandler.ts +0 -16
- package/src/codegen/handlers/prepare/PrepareFunctionHandler.ts +0 -16
- package/src/codegen/handlers/prepare/PrepareIdentityHandler.ts +0 -21
- package/src/codegen/handlers/prepare/PrepareKeyHandler.ts +0 -21
- package/src/codegen/handlers/prepare/PrepareObjectHandler.ts +0 -38
- package/src/codegen/handlers/prepare/PrepareValueHandler.ts +0 -36
- package/src/codegen/handlers/serialize/SerializeDateHandler.ts +0 -45
- package/src/codegen/handlers/serialize/SerializeObjectHandler.ts +0 -28
- package/src/codegen/handlers/serialize/SerializeValueHandler.ts +0 -33
- package/src/codegen/handlers/strip/StripIdentityHandler.ts +0 -15
- package/src/codegen/handlers/strip/StripKeyHandler.ts +0 -15
- package/src/codegen/handlers/strip/StripObjectHandler.ts +0 -35
- package/src/codegen/handlers/strip/StripValueHandler.ts +0 -36
- package/src/codegen/handlers/types.ts +0 -119
- package/src/codegen/types.ts +0 -2
- package/src/codegen/utils.ts +0 -74
- package/src/collections/Changes.test.ts +0 -337
- package/src/collections/Changes.ts +0 -177
- package/src/collections/IdSet.ts +0 -28
- package/src/collections/MemoryDataCollection.test.ts +0 -424
- package/src/collections/MemoryDataCollection.ts +0 -134
- package/src/collections/SchemaCollection.ts +0 -22
- package/src/collections/TagCollection.test.ts +0 -443
- package/src/collections/TagCollection.ts +0 -62
- package/src/errors/SchemaError.ts +0 -6
- package/src/errors/index.ts +0 -1
- package/src/expressions/parser.test.ts +0 -913
- package/src/expressions/utils.test.ts +0 -346
- package/src/expressions/utils.ts +0 -59
- package/src/performance/index.ts +0 -26
- package/src/pipeline/SyncronousQueue.test.ts +0 -269
- package/src/pipeline/SyncronousQueue.ts +0 -30
- package/src/pipeline/TrampolinePipeline.test.ts +0 -374
- package/src/pipeline/index.ts +0 -2
- package/src/plugins/EphemeralDataPlugin.ts +0 -132
- package/src/plugins/capabilities/DbPluginCapability.ts +0 -111
- package/src/plugins/capabilities/logging/DbPluginLoggingCapability.ts +0 -261
- package/src/plugins/capabilities/logging/index.ts +0 -1
- package/src/plugins/query/Query.ts +0 -67
- package/src/plugins/query/QueryOptionsCollection.test.ts +0 -86
- package/src/plugins/query/QueryOptionsCollection.ts +0 -154
- package/src/plugins/replication/OptimisticReplicationDbPlugin.ts +0 -202
- package/src/plugins/replication/ReplicationDbPlugin.ts +0 -137
- package/src/plugins/translators/DataTranslator.ts +0 -46
- package/src/plugins/translators/JsonTranslator.test.ts +0 -618
- package/src/plugins/translators/JsonTranslator.ts +0 -211
- package/src/plugins/translators/SqlTranslator.ts +0 -45
- package/src/results/Result.ts +0 -91
- package/src/results/utils.ts +0 -15
- package/src/schema/PropertyInfo.test.ts +0 -479
- package/src/schema/PropertyInfo.ts +0 -374
- package/src/schema/SchemaDefinition.ts +0 -626
- package/src/schema/builder.ts +0 -18
- package/src/schema/property/base/SchemaBase.ts +0 -49
- package/src/schema/property/base/index.ts +0 -1
- package/src/schema/property/modifiers/SchemaDefault.ts +0 -29
- package/src/schema/property/modifiers/SchemaDeserialize.ts +0 -23
- package/src/schema/property/modifiers/SchemaDistinct.ts +0 -14
- package/src/schema/property/modifiers/SchemaFrom.ts +0 -54
- package/src/schema/property/modifiers/SchemaIdentity.ts +0 -13
- package/src/schema/property/modifiers/SchemaIndex.ts +0 -60
- package/src/schema/property/modifiers/SchemaKey.ts +0 -28
- package/src/schema/property/modifiers/SchemaNullable.ts +0 -18
- package/src/schema/property/modifiers/SchemaOptional.ts +0 -19
- package/src/schema/property/modifiers/SchemaReadonly.ts +0 -34
- package/src/schema/property/modifiers/SchemaSerialize.ts +0 -18
- package/src/schema/property/modifiers/SchemaTracked.ts +0 -14
- package/src/schema/property/types/SchemaArray.ts +0 -50
- package/src/schema/property/types/SchemaBoolean.ts +0 -59
- package/src/schema/property/types/SchemaDate.ts +0 -58
- package/src/schema/property/types/SchemaNumber.ts +0 -69
- package/src/schema/property/types/SchemaObject.ts +0 -44
- package/src/schema/property/types/SchemaString.ts +0 -69
- package/src/schema/table/SchemaComputed.ts +0 -20
- package/src/schema/table/SchemaFunction.ts +0 -15
- package/src/utilities/arrays.test.ts +0 -312
- package/src/utilities/arrays.ts +0 -12
- package/src/utilities/dates.test.ts +0 -388
- package/src/utilities/dates.ts +0 -11
- package/src/utilities/dbPluginEventUtils.ts +0 -44
- package/src/utilities/objects.ts +0 -7
- package/src/utilities/queryOptionsCollection.ts +0 -16
- package/src/utilities/replication.ts +0 -23
- package/src/utilities/runtime.ts +0 -3
- package/src/utilities/strings.ts +0 -18
- package/src/utilities/types.ts +0 -1
- package/src/utilities/uuid.ts +0 -56
- package/tsconfig.json +0 -28
- package/vitest.config.ts +0 -11
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
export type SyncronousUnitOfWork = (done: () => void) => void
|
|
2
|
-
|
|
3
|
-
export class SyncronousQueue {
|
|
4
|
-
|
|
5
|
-
private readonly _queue: SyncronousUnitOfWork[] = [];
|
|
6
|
-
private _current: SyncronousUnitOfWork | null = null;
|
|
7
|
-
|
|
8
|
-
enqueue(unitOfWork: SyncronousUnitOfWork) {
|
|
9
|
-
this._queue.push(unitOfWork);
|
|
10
|
-
this._next();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
private _next() {
|
|
14
|
-
if (this._current != null || this._queue.length === 0) {
|
|
15
|
-
return;
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Take first item
|
|
19
|
-
this._current = this._queue.shift() ?? null;
|
|
20
|
-
|
|
21
|
-
if (this._current == null) {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
this._current(() => {
|
|
26
|
-
this._current = null;
|
|
27
|
-
this._next();
|
|
28
|
-
})
|
|
29
|
-
}
|
|
30
|
-
}
|
|
@@ -1,374 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { TrampolinePipeline, AsyncPipeline, Processor, AsyncUnitOfWork } from './TrampolinePipeline';
|
|
3
|
-
import { Result } from '../results';
|
|
4
|
-
|
|
5
|
-
describe('TrampolinePipeline', () => {
|
|
6
|
-
describe('filter', () => {
|
|
7
|
-
it('should call done immediately when no processors are added', async () => {
|
|
8
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
9
|
-
const initialData = 'test data';
|
|
10
|
-
|
|
11
|
-
return new Promise<void>((resolve) => {
|
|
12
|
-
pipeline.filter(initialData, (result, error) => {
|
|
13
|
-
expect(error).toBeUndefined();
|
|
14
|
-
expect(result).toBe(initialData);
|
|
15
|
-
resolve();
|
|
16
|
-
});
|
|
17
|
-
});
|
|
18
|
-
});
|
|
19
|
-
|
|
20
|
-
it('should process single processor synchronously', async () => {
|
|
21
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
22
|
-
const processor: Processor<string, string> = vi.fn((data, callback) => {
|
|
23
|
-
expect(data).toBe('test');
|
|
24
|
-
callback('result');
|
|
25
|
-
});
|
|
26
|
-
|
|
27
|
-
pipeline.pipe(processor);
|
|
28
|
-
|
|
29
|
-
return new Promise<void>((resolve) => {
|
|
30
|
-
pipeline.filter('test', (result, error) => {
|
|
31
|
-
expect(error).toBeUndefined();
|
|
32
|
-
expect(result).toBe('result');
|
|
33
|
-
expect(processor).toHaveBeenCalledTimes(1);
|
|
34
|
-
resolve();
|
|
35
|
-
});
|
|
36
|
-
});
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should process multiple processors in order', async () => {
|
|
40
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
41
|
-
const executionOrder: number[] = [];
|
|
42
|
-
|
|
43
|
-
const processor1: Processor<string, number> = vi.fn((data, callback) => {
|
|
44
|
-
executionOrder.push(1);
|
|
45
|
-
expect(data).toBe('test');
|
|
46
|
-
callback(42);
|
|
47
|
-
});
|
|
48
|
-
|
|
49
|
-
const processor2: Processor<number, string> = vi.fn((data, callback) => {
|
|
50
|
-
executionOrder.push(2);
|
|
51
|
-
expect(data).toBe(42);
|
|
52
|
-
callback('result');
|
|
53
|
-
});
|
|
54
|
-
|
|
55
|
-
pipeline.pipe(processor1).pipe(processor2);
|
|
56
|
-
|
|
57
|
-
return new Promise<void>((resolve) => {
|
|
58
|
-
pipeline.filter('test', (result, error) => {
|
|
59
|
-
expect(error).toBeUndefined();
|
|
60
|
-
expect(result).toBe('result');
|
|
61
|
-
expect(executionOrder).toEqual([1, 2]);
|
|
62
|
-
expect(processor1).toHaveBeenCalledTimes(1);
|
|
63
|
-
expect(processor2).toHaveBeenCalledTimes(1);
|
|
64
|
-
resolve();
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
});
|
|
68
|
-
|
|
69
|
-
it('should handle asynchronous processors', async () => {
|
|
70
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
71
|
-
const processor: Processor<string, string> = vi.fn((data, callback) => {
|
|
72
|
-
setTimeout(() => {
|
|
73
|
-
callback(data.toUpperCase());
|
|
74
|
-
}, 10);
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
pipeline.pipe(processor);
|
|
78
|
-
|
|
79
|
-
return new Promise<void>((resolve) => {
|
|
80
|
-
pipeline.filter('test', (result, error) => {
|
|
81
|
-
expect(error).toBeUndefined();
|
|
82
|
-
expect(result).toBe('TEST');
|
|
83
|
-
expect(processor).toHaveBeenCalledTimes(1);
|
|
84
|
-
resolve();
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
it('should handle mixed sync and async processors', async () => {
|
|
90
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
91
|
-
const executionOrder: number[] = [];
|
|
92
|
-
|
|
93
|
-
const syncProcessor: Processor<string, number> = vi.fn((data, callback) => {
|
|
94
|
-
executionOrder.push(1);
|
|
95
|
-
callback(data.length);
|
|
96
|
-
});
|
|
97
|
-
|
|
98
|
-
const asyncProcessor: Processor<number, string> = vi.fn((data, callback) => {
|
|
99
|
-
executionOrder.push(2);
|
|
100
|
-
setTimeout(() => {
|
|
101
|
-
callback(`Length: ${data}`);
|
|
102
|
-
}, 10);
|
|
103
|
-
});
|
|
104
|
-
|
|
105
|
-
pipeline.pipe(syncProcessor).pipe(asyncProcessor);
|
|
106
|
-
|
|
107
|
-
return new Promise<void>((resolve) => {
|
|
108
|
-
pipeline.filter('test', (result, error) => {
|
|
109
|
-
expect(error).toBeUndefined();
|
|
110
|
-
expect(result).toBe('Length: 4');
|
|
111
|
-
expect(executionOrder).toEqual([1, 2]);
|
|
112
|
-
expect(syncProcessor).toHaveBeenCalledTimes(1);
|
|
113
|
-
expect(asyncProcessor).toHaveBeenCalledTimes(1);
|
|
114
|
-
resolve();
|
|
115
|
-
});
|
|
116
|
-
});
|
|
117
|
-
});
|
|
118
|
-
|
|
119
|
-
it('should handle overlapping filter calls', async () => {
|
|
120
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
121
|
-
const processor: Processor<string, string> = vi.fn((data, callback) => {
|
|
122
|
-
setTimeout(() => {
|
|
123
|
-
callback(data.toUpperCase());
|
|
124
|
-
}, 10);
|
|
125
|
-
});
|
|
126
|
-
|
|
127
|
-
pipeline.pipe(processor);
|
|
128
|
-
|
|
129
|
-
return new Promise<void>((resolve) => {
|
|
130
|
-
let completedCount = 0;
|
|
131
|
-
const checkDone = () => {
|
|
132
|
-
completedCount++;
|
|
133
|
-
if (completedCount === 2) {
|
|
134
|
-
resolve();
|
|
135
|
-
}
|
|
136
|
-
};
|
|
137
|
-
|
|
138
|
-
// Start two filter operations simultaneously
|
|
139
|
-
pipeline.filter('test1', (result, error) => {
|
|
140
|
-
expect(error).toBeUndefined();
|
|
141
|
-
expect(result).toBe('TEST1');
|
|
142
|
-
checkDone();
|
|
143
|
-
});
|
|
144
|
-
|
|
145
|
-
pipeline.filter('test2', (result, error) => {
|
|
146
|
-
expect(error).toBeUndefined();
|
|
147
|
-
expect(result).toBe('TEST2');
|
|
148
|
-
checkDone();
|
|
149
|
-
});
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
});
|
|
153
|
-
|
|
154
|
-
describe('pipe', () => {
|
|
155
|
-
it('should return pipeline instance for chaining', () => {
|
|
156
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
157
|
-
const processor: Processor<string, string> = vi.fn((data, callback) => {
|
|
158
|
-
callback(data);
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const result = pipeline.pipe(processor);
|
|
162
|
-
|
|
163
|
-
expect(result).toBe(pipeline);
|
|
164
|
-
});
|
|
165
|
-
|
|
166
|
-
it('should add processor to the list', async () => {
|
|
167
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
168
|
-
const processor: Processor<string, string> = vi.fn((data, callback) => {
|
|
169
|
-
callback(data);
|
|
170
|
-
});
|
|
171
|
-
|
|
172
|
-
pipeline.pipe(processor);
|
|
173
|
-
|
|
174
|
-
return new Promise<void>((resolve) => {
|
|
175
|
-
pipeline.filter('test', (result, error) => {
|
|
176
|
-
expect(processor).toHaveBeenCalledTimes(1);
|
|
177
|
-
resolve();
|
|
178
|
-
});
|
|
179
|
-
});
|
|
180
|
-
});
|
|
181
|
-
});
|
|
182
|
-
|
|
183
|
-
describe('pipeEach', () => {
|
|
184
|
-
it('should process each item in array', async () => {
|
|
185
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
186
|
-
const items = ['a', 'b', 'c'];
|
|
187
|
-
const processedItems: string[] = [];
|
|
188
|
-
|
|
189
|
-
pipeline.pipeEach(
|
|
190
|
-
items,
|
|
191
|
-
(payload, done) => {
|
|
192
|
-
if (payload.ok === Result.SUCCESS) {
|
|
193
|
-
processedItems.push(payload.data);
|
|
194
|
-
done(Result.success(payload.data.toUpperCase()));
|
|
195
|
-
}
|
|
196
|
-
},
|
|
197
|
-
(previous, current) => current
|
|
198
|
-
);
|
|
199
|
-
|
|
200
|
-
return new Promise<void>((resolve) => {
|
|
201
|
-
pipeline.filter('initial', (result, error) => {
|
|
202
|
-
expect(error).toBeUndefined();
|
|
203
|
-
// The result should be a Result object with the last processed item
|
|
204
|
-
expect(result).toEqual({ ok: 'success', data: 'C' });
|
|
205
|
-
expect(processedItems).toEqual(['a', 'b', 'c']);
|
|
206
|
-
resolve();
|
|
207
|
-
});
|
|
208
|
-
});
|
|
209
|
-
});
|
|
210
|
-
|
|
211
|
-
it('should handle empty array in pipeEach', async () => {
|
|
212
|
-
const pipeline = new TrampolinePipeline<string, string>();
|
|
213
|
-
|
|
214
|
-
pipeline.pipeEach(
|
|
215
|
-
[],
|
|
216
|
-
(payload, done) => {
|
|
217
|
-
if (payload.ok === Result.SUCCESS) {
|
|
218
|
-
done(Result.success(payload.data));
|
|
219
|
-
}
|
|
220
|
-
},
|
|
221
|
-
(previous, current) => current
|
|
222
|
-
);
|
|
223
|
-
|
|
224
|
-
return new Promise<void>((resolve) => {
|
|
225
|
-
pipeline.filter('initial', (result, error) => {
|
|
226
|
-
expect(error).toBeUndefined();
|
|
227
|
-
expect(result).toBe('initial');
|
|
228
|
-
resolve();
|
|
229
|
-
});
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
});
|
|
233
|
-
});
|
|
234
|
-
|
|
235
|
-
describe('AsyncPipeline', () => {
|
|
236
|
-
describe('filter', () => {
|
|
237
|
-
it('should call done with empty array when no processors are added', async () => {
|
|
238
|
-
const pipeline = new AsyncPipeline<string, string>();
|
|
239
|
-
|
|
240
|
-
return new Promise<void>((resolve) => {
|
|
241
|
-
pipeline.filter((result) => {
|
|
242
|
-
expect(result.ok).toBe(Result.SUCCESS);
|
|
243
|
-
if (result.ok === Result.SUCCESS) {
|
|
244
|
-
// When no processors are added, data should be undefined, not empty array
|
|
245
|
-
expect(result.data).toBeUndefined();
|
|
246
|
-
}
|
|
247
|
-
resolve();
|
|
248
|
-
});
|
|
249
|
-
});
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('should process single unit of work', async () => {
|
|
253
|
-
const pipeline = new AsyncPipeline<string, string>();
|
|
254
|
-
const unitOfWork: AsyncUnitOfWork<string, string> = vi.fn((payload, done) => {
|
|
255
|
-
expect(payload).toBe('test');
|
|
256
|
-
done(Result.success('result'));
|
|
257
|
-
});
|
|
258
|
-
|
|
259
|
-
pipeline.pipe('test', unitOfWork);
|
|
260
|
-
|
|
261
|
-
return new Promise<void>((resolve) => {
|
|
262
|
-
pipeline.filter((result) => {
|
|
263
|
-
expect(result.ok).toBe(Result.SUCCESS);
|
|
264
|
-
if (result.ok === Result.SUCCESS) {
|
|
265
|
-
expect(result.data).toEqual(['result']);
|
|
266
|
-
}
|
|
267
|
-
expect(unitOfWork).toHaveBeenCalledTimes(1);
|
|
268
|
-
resolve();
|
|
269
|
-
});
|
|
270
|
-
});
|
|
271
|
-
});
|
|
272
|
-
|
|
273
|
-
it('should process multiple units of work', async () => {
|
|
274
|
-
const pipeline = new AsyncPipeline<string, string>();
|
|
275
|
-
const executionOrder: number[] = [];
|
|
276
|
-
|
|
277
|
-
const unitOfWork1: AsyncUnitOfWork<string, string> = vi.fn((payload, done) => {
|
|
278
|
-
executionOrder.push(1);
|
|
279
|
-
done(Result.success(`result1-${payload}`));
|
|
280
|
-
});
|
|
281
|
-
|
|
282
|
-
const unitOfWork2: AsyncUnitOfWork<string, string> = vi.fn((payload, done) => {
|
|
283
|
-
executionOrder.push(2);
|
|
284
|
-
done(Result.success(`result2-${payload}`));
|
|
285
|
-
});
|
|
286
|
-
|
|
287
|
-
pipeline.pipe('test1', unitOfWork1);
|
|
288
|
-
pipeline.pipe('test2', unitOfWork2);
|
|
289
|
-
|
|
290
|
-
return new Promise<void>((resolve) => {
|
|
291
|
-
pipeline.filter((result) => {
|
|
292
|
-
expect(result.ok).toBe(Result.SUCCESS);
|
|
293
|
-
if (result.ok === Result.SUCCESS) {
|
|
294
|
-
expect(result.data).toEqual(['result1-test1', 'result2-test2']);
|
|
295
|
-
}
|
|
296
|
-
expect(executionOrder).toEqual([1, 2]);
|
|
297
|
-
expect(unitOfWork1).toHaveBeenCalledTimes(1);
|
|
298
|
-
expect(unitOfWork2).toHaveBeenCalledTimes(1);
|
|
299
|
-
resolve();
|
|
300
|
-
});
|
|
301
|
-
});
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
describe('pipe', () => {
|
|
306
|
-
it('should add unit of work to the list', async () => {
|
|
307
|
-
const pipeline = new AsyncPipeline<string, string>();
|
|
308
|
-
const unitOfWork: AsyncUnitOfWork<string, string> = vi.fn((payload, done) => {
|
|
309
|
-
done(Result.success(payload));
|
|
310
|
-
});
|
|
311
|
-
|
|
312
|
-
pipeline.pipe('test', unitOfWork);
|
|
313
|
-
|
|
314
|
-
return new Promise<void>((resolve) => {
|
|
315
|
-
pipeline.filter((result) => {
|
|
316
|
-
expect(result.ok).toBe(Result.SUCCESS);
|
|
317
|
-
if (result.ok === Result.SUCCESS) {
|
|
318
|
-
expect(result.data).toEqual(['test']);
|
|
319
|
-
}
|
|
320
|
-
expect(unitOfWork).toHaveBeenCalledTimes(1);
|
|
321
|
-
resolve();
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
describe('pipeEach', () => {
|
|
328
|
-
it('should process each item in array', async () => {
|
|
329
|
-
const pipeline = new AsyncPipeline<string, string>();
|
|
330
|
-
const items = ['a', 'b', 'c'];
|
|
331
|
-
const processedItems: string[] = [];
|
|
332
|
-
|
|
333
|
-
const unitOfWork: AsyncUnitOfWork<string, string> = vi.fn((payload, done) => {
|
|
334
|
-
processedItems.push(payload);
|
|
335
|
-
done(Result.success(payload.toUpperCase()));
|
|
336
|
-
});
|
|
337
|
-
|
|
338
|
-
pipeline.pipeEach(items, unitOfWork);
|
|
339
|
-
|
|
340
|
-
return new Promise<void>((resolve) => {
|
|
341
|
-
pipeline.filter((result) => {
|
|
342
|
-
expect(result.ok).toBe(Result.SUCCESS);
|
|
343
|
-
if (result.ok === Result.SUCCESS) {
|
|
344
|
-
expect(result.data).toEqual(['A', 'B', 'C']);
|
|
345
|
-
}
|
|
346
|
-
expect(processedItems).toEqual(['a', 'b', 'c']);
|
|
347
|
-
expect(unitOfWork).toHaveBeenCalledTimes(3);
|
|
348
|
-
resolve();
|
|
349
|
-
});
|
|
350
|
-
});
|
|
351
|
-
});
|
|
352
|
-
|
|
353
|
-
it('should handle empty array in pipeEach', async () => {
|
|
354
|
-
const pipeline = new AsyncPipeline<string, string>();
|
|
355
|
-
const unitOfWork: AsyncUnitOfWork<string, string> = vi.fn((payload, done) => {
|
|
356
|
-
done(Result.success(payload));
|
|
357
|
-
});
|
|
358
|
-
|
|
359
|
-
pipeline.pipeEach([], unitOfWork);
|
|
360
|
-
|
|
361
|
-
return new Promise<void>((resolve) => {
|
|
362
|
-
pipeline.filter((result) => {
|
|
363
|
-
expect(result.ok).toBe(Result.SUCCESS);
|
|
364
|
-
if (result.ok === Result.SUCCESS) {
|
|
365
|
-
// When pipeEach is called with empty array, data should be undefined, not empty array
|
|
366
|
-
expect(result.data).toBeUndefined();
|
|
367
|
-
}
|
|
368
|
-
expect(unitOfWork).toHaveBeenCalledTimes(0);
|
|
369
|
-
resolve();
|
|
370
|
-
});
|
|
371
|
-
});
|
|
372
|
-
});
|
|
373
|
-
});
|
|
374
|
-
});
|
package/src/pipeline/index.ts
DELETED
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
import { assertIsNotNull } from '../assertions';
|
|
2
|
-
import { BulkPersistResult } from '../collections';
|
|
3
|
-
import { WorkPipeline } from '../pipeline';
|
|
4
|
-
import { DbPluginBulkPersistEvent, DbPluginEvent, DbPluginQueryEvent, IDbPlugin, JsonTranslator } from '.';
|
|
5
|
-
import { PluginEventCallbackPartialResult, PluginEventCallbackResult, PluginEventResult, Result } from '../results';
|
|
6
|
-
import { CompiledSchema, InferCreateType } from '../schema';
|
|
7
|
-
import { DeepPartial } from '../types';
|
|
8
|
-
import { MemoryDataCollection } from '../collections/MemoryDataCollection';
|
|
9
|
-
import { UnknownRecord } from '../utilities';
|
|
10
|
-
|
|
11
|
-
export abstract class EphemeralDataPlugin implements IDbPlugin {
|
|
12
|
-
|
|
13
|
-
protected databaseName: string;
|
|
14
|
-
|
|
15
|
-
constructor(databaseName: string) {
|
|
16
|
-
this.databaseName = databaseName;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
protected abstract resolveCollection<TEntity extends {}>(schema: CompiledSchema<TEntity>): MemoryDataCollection;
|
|
20
|
-
|
|
21
|
-
bulkPersist(event: DbPluginBulkPersistEvent, done: PluginEventCallbackPartialResult<BulkPersistResult>) {
|
|
22
|
-
try {
|
|
23
|
-
const pipeline = new WorkPipeline();
|
|
24
|
-
const bulkPersistResult = event.operation.toResult();
|
|
25
|
-
|
|
26
|
-
for (const [schemaId, changes] of event.operation) {
|
|
27
|
-
|
|
28
|
-
pipeline.pipe((d) => {
|
|
29
|
-
try {
|
|
30
|
-
|
|
31
|
-
const { adds, hasItems, removes, updates } = changes;
|
|
32
|
-
|
|
33
|
-
if (hasItems === false) {
|
|
34
|
-
d(Result.success());
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
const result = bulkPersistResult.get(schemaId);
|
|
39
|
-
const schema = event.schemas.get(schemaId);
|
|
40
|
-
|
|
41
|
-
assertIsNotNull(schema);
|
|
42
|
-
|
|
43
|
-
const collection = this.resolveCollection(schema);
|
|
44
|
-
collection.load(readResult => {
|
|
45
|
-
|
|
46
|
-
if (readResult.ok === Result.ERROR) {
|
|
47
|
-
d(readResult);
|
|
48
|
-
return;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
for (let i = 0, length = adds.length; i < length; i++) {
|
|
52
|
-
collection.add(adds[i]);
|
|
53
|
-
result.adds.push(adds[i] as DeepPartial<InferCreateType<UnknownRecord>>);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
for (let i = 0, length = updates.length; i < length; i++) {
|
|
57
|
-
collection.update(updates[i].entity);
|
|
58
|
-
result.updates.push(updates[i].entity);
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
for (let i = 0, length = removes.length; i < length; i++) {
|
|
62
|
-
collection.remove(removes[i]);
|
|
63
|
-
result.removes.push(removes[i]);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
collection.save(saveResult => {
|
|
67
|
-
|
|
68
|
-
if (saveResult.ok === Result.ERROR) {
|
|
69
|
-
d(saveResult);
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
d(Result.success());
|
|
74
|
-
});
|
|
75
|
-
})
|
|
76
|
-
|
|
77
|
-
} catch (e) {
|
|
78
|
-
d(Result.error(e));
|
|
79
|
-
}
|
|
80
|
-
});
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
let successCount = 0;
|
|
84
|
-
|
|
85
|
-
pipeline.filter((asyncResult) => {
|
|
86
|
-
|
|
87
|
-
if (asyncResult.ok !== PluginEventResult.SUCCESS) {
|
|
88
|
-
|
|
89
|
-
if (successCount === 0) {
|
|
90
|
-
done(PluginEventResult.error(event.id, asyncResult.error))
|
|
91
|
-
return;
|
|
92
|
-
}
|
|
93
|
-
|
|
94
|
-
done(PluginEventResult.partial(event.id, bulkPersistResult, asyncResult.error))
|
|
95
|
-
return;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
successCount++;
|
|
99
|
-
|
|
100
|
-
done(PluginEventResult.success(event.id, bulkPersistResult));
|
|
101
|
-
});
|
|
102
|
-
} catch (e: any) {
|
|
103
|
-
done(PluginEventResult.error(event.id, e))
|
|
104
|
-
}
|
|
105
|
-
}
|
|
106
|
-
|
|
107
|
-
query<TEntity extends {}, TShape extends any = TEntity>(event: DbPluginQueryEvent<TEntity, TShape>, done: PluginEventCallbackResult<TShape>): void {
|
|
108
|
-
|
|
109
|
-
try {
|
|
110
|
-
const { operation } = event;
|
|
111
|
-
const translator = new JsonTranslator<TEntity, TShape>(operation);
|
|
112
|
-
const collection = this.resolveCollection(operation.schema);
|
|
113
|
-
|
|
114
|
-
// translate if we are doing any operations like count/sum/min/max/skip/take
|
|
115
|
-
collection.load(r => {
|
|
116
|
-
|
|
117
|
-
if (r.ok === Result.ERROR) {
|
|
118
|
-
done(PluginEventResult.error(event.id, r.error));
|
|
119
|
-
return;
|
|
120
|
-
}
|
|
121
|
-
|
|
122
|
-
const translated = translator.translate(collection.records);
|
|
123
|
-
|
|
124
|
-
done(PluginEventResult.success(event.id, translated));
|
|
125
|
-
})
|
|
126
|
-
} catch (e) {
|
|
127
|
-
done(PluginEventResult.error(event.id, e));
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
abstract destroy(event: DbPluginEvent, done: PluginEventCallbackResult<never>): void;
|
|
132
|
-
}
|
|
@@ -1,111 +0,0 @@
|
|
|
1
|
-
import { BulkPersistResult } from "../../collections";
|
|
2
|
-
import { PluginEventPartialResultType, PluginEventResultType } from "../../results";
|
|
3
|
-
import { DbPluginBulkPersistEvent, DbPluginEvent, DbPluginQueryEvent, IDbPlugin } from "../types";
|
|
4
|
-
|
|
5
|
-
export type DbPluginCapabilityEvent = "queryStart" | "queryComplete" | "destroyStart" | "destroyComplete" | "bulkPersistStart" | "bulkPersistComplete";
|
|
6
|
-
|
|
7
|
-
export interface IDbPluginCapability {
|
|
8
|
-
apply<T extends IDbPlugin>(plugin: T): void;
|
|
9
|
-
}
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Extends plugin functionality through hooks and event handlers without
|
|
13
|
-
* changing the plugin's type (mixin). Essential for maintaining type safety
|
|
14
|
-
* in routier's core systems.
|
|
15
|
-
*/
|
|
16
|
-
export class DbPluginCapability {
|
|
17
|
-
|
|
18
|
-
private events: Record<string, { before?: Function, after?: Function }> = {};
|
|
19
|
-
|
|
20
|
-
add<TRoot extends {}, TShape extends any = TRoot>(name: "queryStart", callback: (event: DbPluginQueryEvent<TRoot, TShape>) => void): DbPluginCapability;
|
|
21
|
-
add<TRoot extends {}, TShape extends any = TRoot>(name: "queryComplete", callback: (event: PluginEventResultType<TShape>) => void): DbPluginCapability;
|
|
22
|
-
add<TRoot extends {}, TShape extends any = TRoot>(name: "destroyStart", callback: (event: DbPluginEvent) => void): DbPluginCapability;
|
|
23
|
-
add<TRoot extends {}, TShape extends any = TRoot>(name: "destroyComplete", callback: (event: PluginEventResultType<never>) => void): DbPluginCapability;
|
|
24
|
-
add<TRoot extends {}, TShape extends any = TRoot>(name: "bulkPersistStart", callback: (event: DbPluginBulkPersistEvent) => void): DbPluginCapability;
|
|
25
|
-
add<TRoot extends {}, TShape extends any = TRoot>(name: "bulkPersistComplete", callback: (event: PluginEventPartialResultType<BulkPersistResult>) => void): DbPluginCapability;
|
|
26
|
-
add<TRoot extends {}, TShape extends any = TRoot>(name: DbPluginCapabilityEvent, callback: Function): DbPluginCapability {
|
|
27
|
-
|
|
28
|
-
this.resolve(name);
|
|
29
|
-
|
|
30
|
-
switch (name) {
|
|
31
|
-
case "queryStart":
|
|
32
|
-
this.events["query"].before = callback;
|
|
33
|
-
break;
|
|
34
|
-
case "queryComplete":
|
|
35
|
-
this.events["query"].after = callback;
|
|
36
|
-
break;
|
|
37
|
-
case "destroyStart":
|
|
38
|
-
this.events["destroy"].before = callback;
|
|
39
|
-
break;
|
|
40
|
-
case "destroyComplete":
|
|
41
|
-
this.events["destroy"].after = callback;
|
|
42
|
-
break;
|
|
43
|
-
case "bulkPersistStart":
|
|
44
|
-
this.events["bulkPersist"].before = callback;
|
|
45
|
-
break;
|
|
46
|
-
case "bulkPersistComplete":
|
|
47
|
-
this.events["bulkPersist"].after = callback;
|
|
48
|
-
break;
|
|
49
|
-
}
|
|
50
|
-
|
|
51
|
-
return this;
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
private resolve(name: DbPluginCapabilityEvent) {
|
|
55
|
-
|
|
56
|
-
switch (name) {
|
|
57
|
-
case "queryStart":
|
|
58
|
-
case "queryComplete":
|
|
59
|
-
if (!this.events["query"]) {
|
|
60
|
-
this.events["query"] = {};
|
|
61
|
-
}
|
|
62
|
-
return;
|
|
63
|
-
case "destroyStart":
|
|
64
|
-
case "destroyComplete":
|
|
65
|
-
if (!this.events["destroy"]) {
|
|
66
|
-
this.events["destroy"] = {};
|
|
67
|
-
}
|
|
68
|
-
return;
|
|
69
|
-
case "bulkPersistStart":
|
|
70
|
-
case "bulkPersistComplete":
|
|
71
|
-
if (!this.events["bulkPersist"]) {
|
|
72
|
-
this.events["bulkPersist"] = {};
|
|
73
|
-
}
|
|
74
|
-
return;
|
|
75
|
-
|
|
76
|
-
default:
|
|
77
|
-
throw new Error("Exhaustive check")
|
|
78
|
-
}
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
apply<T extends IDbPlugin>(plugin: T) {
|
|
82
|
-
|
|
83
|
-
const methodWrappers: { method: keyof IDbPlugin, events: { before?: Function, after?: Function } }[] = [
|
|
84
|
-
{ method: 'query', events: this.events.query },
|
|
85
|
-
{ method: 'destroy', events: this.events.destroy },
|
|
86
|
-
{ method: 'bulkPersist', events: this.events.bulkPersist }
|
|
87
|
-
];
|
|
88
|
-
|
|
89
|
-
// apply the mixins
|
|
90
|
-
for (let i = 0, length = methodWrappers.length; i < length; i++) {
|
|
91
|
-
|
|
92
|
-
const { events, method } = methodWrappers[i];
|
|
93
|
-
|
|
94
|
-
if (events?.before || events?.after) {
|
|
95
|
-
const original = plugin[method].bind(plugin);
|
|
96
|
-
plugin[method] = ((event: unknown, done: Function) => {
|
|
97
|
-
events.before?.(event, done);
|
|
98
|
-
|
|
99
|
-
if (events.after) {
|
|
100
|
-
return original(event, (result: unknown) => {
|
|
101
|
-
events.after(result);
|
|
102
|
-
done(result);
|
|
103
|
-
});
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
return original(event, done);
|
|
107
|
-
});
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
}
|
|
111
|
-
}
|