@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,346 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { getProperties } from './utils';
|
|
3
|
-
import { PropertyExpression, ComparatorExpression, OperatorExpression, ValueExpression, EmptyExpression } from './types';
|
|
4
|
-
import { PropertyInfo } from '../schema/PropertyInfo';
|
|
5
|
-
|
|
6
|
-
const createMockProperty = (name: string): PropertyInfo<any> => ({
|
|
7
|
-
name,
|
|
8
|
-
type: 'string',
|
|
9
|
-
isNullable: false,
|
|
10
|
-
isOptional: false,
|
|
11
|
-
isKey: false,
|
|
12
|
-
isIdentity: false,
|
|
13
|
-
isReadonly: false,
|
|
14
|
-
isUnmapped: false,
|
|
15
|
-
isDistinct: false,
|
|
16
|
-
indexes: [],
|
|
17
|
-
injected: null,
|
|
18
|
-
defaultValue: null,
|
|
19
|
-
valueSerializer: null,
|
|
20
|
-
valueDeserializer: null,
|
|
21
|
-
functionBody: null,
|
|
22
|
-
children: [],
|
|
23
|
-
schema: {} as any,
|
|
24
|
-
literals: [],
|
|
25
|
-
getPathArray: () => [name],
|
|
26
|
-
getParentPathArray: () => [] as any[],
|
|
27
|
-
getValue: () => undefined as any,
|
|
28
|
-
setValue: () => { },
|
|
29
|
-
getSelectrorPath: () => name,
|
|
30
|
-
getAssignmentPath: () => name,
|
|
31
|
-
get level() { return 0; },
|
|
32
|
-
get hasNullableParents() { return false; },
|
|
33
|
-
get hasIdentityChildren() { return false; },
|
|
34
|
-
get id() { return name; },
|
|
35
|
-
_getPropertyChain: () => [] as any[],
|
|
36
|
-
_needsOptionalChaining: () => false,
|
|
37
|
-
_resolvePathArray: () => [name]
|
|
38
|
-
} as unknown as PropertyInfo<any>);
|
|
39
|
-
|
|
40
|
-
describe('getProperties', () => {
|
|
41
|
-
it('should extract properties from a simple property expression', () => {
|
|
42
|
-
const property = createMockProperty('name');
|
|
43
|
-
const expression = new PropertyExpression({ property });
|
|
44
|
-
|
|
45
|
-
const result = getProperties(expression);
|
|
46
|
-
|
|
47
|
-
expect(result).toHaveLength(1);
|
|
48
|
-
expect(result[0]).toBe(property);
|
|
49
|
-
});
|
|
50
|
-
|
|
51
|
-
it('should extract properties from a comparator expression with property on left', () => {
|
|
52
|
-
const property = createMockProperty('age');
|
|
53
|
-
const expression = new ComparatorExpression({
|
|
54
|
-
comparator: 'equals',
|
|
55
|
-
negated: false,
|
|
56
|
-
strict: false,
|
|
57
|
-
left: new PropertyExpression({ property }),
|
|
58
|
-
right: new ValueExpression({ value: 25 })
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
const result = getProperties(expression);
|
|
62
|
-
|
|
63
|
-
expect(result).toHaveLength(1);
|
|
64
|
-
expect(result[0]).toBe(property);
|
|
65
|
-
});
|
|
66
|
-
|
|
67
|
-
it('should extract properties from a comparator expression with property on right', () => {
|
|
68
|
-
const property = createMockProperty('score');
|
|
69
|
-
const expression = new ComparatorExpression({
|
|
70
|
-
comparator: 'greater-than',
|
|
71
|
-
negated: false,
|
|
72
|
-
strict: false,
|
|
73
|
-
left: new ValueExpression({ value: 100 }),
|
|
74
|
-
right: new PropertyExpression({ property })
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
const result = getProperties(expression);
|
|
78
|
-
|
|
79
|
-
expect(result).toHaveLength(1);
|
|
80
|
-
expect(result[0]).toBe(property);
|
|
81
|
-
});
|
|
82
|
-
|
|
83
|
-
it('should extract properties from a comparator expression with properties on both sides', () => {
|
|
84
|
-
const leftProperty = createMockProperty('x');
|
|
85
|
-
const rightProperty = createMockProperty('y');
|
|
86
|
-
const expression = new ComparatorExpression({
|
|
87
|
-
comparator: 'equals',
|
|
88
|
-
negated: false,
|
|
89
|
-
strict: false,
|
|
90
|
-
left: new PropertyExpression({ property: leftProperty }),
|
|
91
|
-
right: new PropertyExpression({ property: rightProperty })
|
|
92
|
-
});
|
|
93
|
-
|
|
94
|
-
const result = getProperties(expression);
|
|
95
|
-
|
|
96
|
-
expect(result).toHaveLength(2);
|
|
97
|
-
expect(result).toContain(leftProperty);
|
|
98
|
-
expect(result).toContain(rightProperty);
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
it('should extract properties from an operator expression with two properties', () => {
|
|
102
|
-
const leftProperty = createMockProperty('isActive');
|
|
103
|
-
const rightProperty = createMockProperty('isVerified');
|
|
104
|
-
const expression = new OperatorExpression({
|
|
105
|
-
operator: '&&',
|
|
106
|
-
left: new PropertyExpression({ property: leftProperty }),
|
|
107
|
-
right: new PropertyExpression({ property: rightProperty })
|
|
108
|
-
});
|
|
109
|
-
|
|
110
|
-
const result = getProperties(expression);
|
|
111
|
-
|
|
112
|
-
expect(result).toHaveLength(2);
|
|
113
|
-
expect(result).toContain(leftProperty);
|
|
114
|
-
expect(result).toContain(rightProperty);
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
it('should extract properties from a complex nested expression', () => {
|
|
118
|
-
const prop1 = createMockProperty('name');
|
|
119
|
-
const prop2 = createMockProperty('age');
|
|
120
|
-
const prop3 = createMockProperty('email');
|
|
121
|
-
|
|
122
|
-
const innerExpression = new OperatorExpression({
|
|
123
|
-
operator: '||',
|
|
124
|
-
left: new PropertyExpression({ property: prop2 }),
|
|
125
|
-
right: new PropertyExpression({ property: prop3 })
|
|
126
|
-
});
|
|
127
|
-
|
|
128
|
-
const expression = new OperatorExpression({
|
|
129
|
-
operator: '&&',
|
|
130
|
-
left: new PropertyExpression({ property: prop1 }),
|
|
131
|
-
right: innerExpression
|
|
132
|
-
});
|
|
133
|
-
|
|
134
|
-
const result = getProperties(expression);
|
|
135
|
-
|
|
136
|
-
expect(result).toHaveLength(3);
|
|
137
|
-
expect(result).toContain(prop1);
|
|
138
|
-
expect(result).toContain(prop2);
|
|
139
|
-
expect(result).toContain(prop3);
|
|
140
|
-
});
|
|
141
|
-
|
|
142
|
-
it('should extract properties from a deeply nested expression', () => {
|
|
143
|
-
const prop1 = createMockProperty('level1');
|
|
144
|
-
const prop2 = createMockProperty('level2');
|
|
145
|
-
const prop3 = createMockProperty('level3');
|
|
146
|
-
|
|
147
|
-
const level3Expression = new PropertyExpression({ property: prop3 });
|
|
148
|
-
|
|
149
|
-
const level2Expression = new OperatorExpression({
|
|
150
|
-
operator: '&&',
|
|
151
|
-
left: new PropertyExpression({ property: prop2 }),
|
|
152
|
-
right: level3Expression
|
|
153
|
-
});
|
|
154
|
-
|
|
155
|
-
const level1Expression = new OperatorExpression({
|
|
156
|
-
operator: '||',
|
|
157
|
-
left: new PropertyExpression({ property: prop1 }),
|
|
158
|
-
right: level2Expression
|
|
159
|
-
});
|
|
160
|
-
|
|
161
|
-
const result = getProperties(level1Expression);
|
|
162
|
-
|
|
163
|
-
expect(result).toHaveLength(3);
|
|
164
|
-
expect(result).toContain(prop1);
|
|
165
|
-
expect(result).toContain(prop2);
|
|
166
|
-
expect(result).toContain(prop3);
|
|
167
|
-
});
|
|
168
|
-
|
|
169
|
-
it('should handle expressions with duplicate properties', () => {
|
|
170
|
-
const property = createMockProperty('status');
|
|
171
|
-
const expression = new OperatorExpression({
|
|
172
|
-
operator: '&&',
|
|
173
|
-
left: new PropertyExpression({ property }),
|
|
174
|
-
right: new PropertyExpression({ property })
|
|
175
|
-
});
|
|
176
|
-
|
|
177
|
-
const result = getProperties(expression);
|
|
178
|
-
|
|
179
|
-
expect(result).toHaveLength(2);
|
|
180
|
-
expect(result[0]).toBe(property);
|
|
181
|
-
expect(result[1]).toBe(property);
|
|
182
|
-
});
|
|
183
|
-
|
|
184
|
-
it('should handle expressions with only value expressions', () => {
|
|
185
|
-
const expression = new ValueExpression({ value: 'test' });
|
|
186
|
-
|
|
187
|
-
const result = getProperties(expression);
|
|
188
|
-
|
|
189
|
-
expect(result).toHaveLength(0);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('should handle expressions with mixed property and value expressions', () => {
|
|
193
|
-
const property = createMockProperty('category');
|
|
194
|
-
const expression = new OperatorExpression({
|
|
195
|
-
operator: '&&',
|
|
196
|
-
left: new PropertyExpression({ property }),
|
|
197
|
-
right: new ValueExpression({ value: 'electronics' })
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
const result = getProperties(expression);
|
|
201
|
-
|
|
202
|
-
expect(result).toHaveLength(1);
|
|
203
|
-
expect(result[0]).toBe(property);
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
it('should handle expressions with null or undefined children', () => {
|
|
207
|
-
const property = createMockProperty('title');
|
|
208
|
-
const expression = new ComparatorExpression({
|
|
209
|
-
comparator: 'equals',
|
|
210
|
-
negated: false,
|
|
211
|
-
strict: false,
|
|
212
|
-
left: new PropertyExpression({ property }),
|
|
213
|
-
right: null as any
|
|
214
|
-
});
|
|
215
|
-
|
|
216
|
-
const result = getProperties(expression);
|
|
217
|
-
|
|
218
|
-
expect(result).toHaveLength(1);
|
|
219
|
-
expect(result[0]).toBe(property);
|
|
220
|
-
});
|
|
221
|
-
|
|
222
|
-
it('should handle empty expression', () => {
|
|
223
|
-
const expression = new EmptyExpression();
|
|
224
|
-
|
|
225
|
-
const result = getProperties(expression);
|
|
226
|
-
|
|
227
|
-
expect(result).toHaveLength(0);
|
|
228
|
-
});
|
|
229
|
-
|
|
230
|
-
it('should handle complex expression with multiple operators and properties', () => {
|
|
231
|
-
const prop1 = createMockProperty('firstName');
|
|
232
|
-
const prop2 = createMockProperty('lastName');
|
|
233
|
-
const prop3 = createMockProperty('email');
|
|
234
|
-
const prop4 = createMockProperty('phone');
|
|
235
|
-
|
|
236
|
-
const leftBranch = new OperatorExpression({
|
|
237
|
-
operator: '&&',
|
|
238
|
-
left: new PropertyExpression({ property: prop1 }),
|
|
239
|
-
right: new PropertyExpression({ property: prop2 })
|
|
240
|
-
});
|
|
241
|
-
|
|
242
|
-
const rightBranch = new OperatorExpression({
|
|
243
|
-
operator: '||',
|
|
244
|
-
left: new PropertyExpression({ property: prop3 }),
|
|
245
|
-
right: new PropertyExpression({ property: prop4 })
|
|
246
|
-
});
|
|
247
|
-
|
|
248
|
-
const rootExpression = new OperatorExpression({
|
|
249
|
-
operator: '&&',
|
|
250
|
-
left: leftBranch,
|
|
251
|
-
right: rightBranch
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
const result = getProperties(rootExpression);
|
|
255
|
-
|
|
256
|
-
expect(result).toHaveLength(4);
|
|
257
|
-
expect(result).toContain(prop1);
|
|
258
|
-
expect(result).toContain(prop2);
|
|
259
|
-
expect(result).toContain(prop3);
|
|
260
|
-
expect(result).toContain(prop4);
|
|
261
|
-
});
|
|
262
|
-
|
|
263
|
-
it('should handle a large expression tree with many properties', () => {
|
|
264
|
-
const properties = [
|
|
265
|
-
createMockProperty('prop1'),
|
|
266
|
-
createMockProperty('prop2'),
|
|
267
|
-
createMockProperty('prop3'),
|
|
268
|
-
createMockProperty('prop4'),
|
|
269
|
-
createMockProperty('prop5')
|
|
270
|
-
];
|
|
271
|
-
|
|
272
|
-
const expression = new OperatorExpression({
|
|
273
|
-
operator: '&&',
|
|
274
|
-
left: new OperatorExpression({
|
|
275
|
-
operator: '||',
|
|
276
|
-
left: new PropertyExpression({ property: properties[0] }),
|
|
277
|
-
right: new PropertyExpression({ property: properties[1] })
|
|
278
|
-
}),
|
|
279
|
-
right: new OperatorExpression({
|
|
280
|
-
operator: '&&',
|
|
281
|
-
left: new PropertyExpression({ property: properties[2] }),
|
|
282
|
-
right: new OperatorExpression({
|
|
283
|
-
operator: '||',
|
|
284
|
-
left: new PropertyExpression({ property: properties[3] }),
|
|
285
|
-
right: new PropertyExpression({ property: properties[4] })
|
|
286
|
-
})
|
|
287
|
-
})
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
const result = getProperties(expression);
|
|
291
|
-
|
|
292
|
-
expect(result).toHaveLength(5);
|
|
293
|
-
properties.forEach(prop => {
|
|
294
|
-
expect(result).toContain(prop);
|
|
295
|
-
});
|
|
296
|
-
});
|
|
297
|
-
|
|
298
|
-
it('should handle expressions with only non-property expressions', () => {
|
|
299
|
-
const expression = new OperatorExpression({
|
|
300
|
-
operator: '&&',
|
|
301
|
-
left: new ValueExpression({ value: true }),
|
|
302
|
-
right: new ValueExpression({ value: false })
|
|
303
|
-
});
|
|
304
|
-
|
|
305
|
-
const result = getProperties(expression);
|
|
306
|
-
|
|
307
|
-
expect(result).toHaveLength(0);
|
|
308
|
-
});
|
|
309
|
-
|
|
310
|
-
it('should handle expressions with one property and one non-property', () => {
|
|
311
|
-
const property = createMockProperty('enabled');
|
|
312
|
-
const expression = new OperatorExpression({
|
|
313
|
-
operator: '&&',
|
|
314
|
-
left: new PropertyExpression({ property }),
|
|
315
|
-
right: new ValueExpression({ value: true })
|
|
316
|
-
});
|
|
317
|
-
|
|
318
|
-
const result = getProperties(expression);
|
|
319
|
-
|
|
320
|
-
expect(result).toHaveLength(1);
|
|
321
|
-
expect(result[0]).toBe(property);
|
|
322
|
-
});
|
|
323
|
-
|
|
324
|
-
it('should preserve order of properties as they appear in traversal', () => {
|
|
325
|
-
const prop1 = createMockProperty('a');
|
|
326
|
-
const prop2 = createMockProperty('b');
|
|
327
|
-
const prop3 = createMockProperty('c');
|
|
328
|
-
|
|
329
|
-
const expression = new OperatorExpression({
|
|
330
|
-
operator: '&&',
|
|
331
|
-
left: new PropertyExpression({ property: prop1 }),
|
|
332
|
-
right: new OperatorExpression({
|
|
333
|
-
operator: '||',
|
|
334
|
-
left: new PropertyExpression({ property: prop2 }),
|
|
335
|
-
right: new PropertyExpression({ property: prop3 })
|
|
336
|
-
})
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
const result = getProperties(expression);
|
|
340
|
-
|
|
341
|
-
expect(result).toHaveLength(3);
|
|
342
|
-
expect(result[0]).toBe(prop1);
|
|
343
|
-
expect(result[1]).toBe(prop2);
|
|
344
|
-
expect(result[2]).toBe(prop3);
|
|
345
|
-
});
|
|
346
|
-
});
|
package/src/expressions/utils.ts
DELETED
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
import { PropertyInfo } from "../schema";
|
|
2
|
-
import { Expression, PropertyExpression } from "./types";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Extracts all properties referenced in an expression
|
|
6
|
-
* @param expression The expression to analyze
|
|
7
|
-
* @returns Array of PropertyInfo objects referenced in the expression
|
|
8
|
-
*/
|
|
9
|
-
export function getProperties(expression: Expression): PropertyInfo<any>[] {
|
|
10
|
-
const properties: PropertyInfo<any>[] = [];
|
|
11
|
-
|
|
12
|
-
function traverse(expr: Expression) {
|
|
13
|
-
// If this is a property expression, add it to our collection
|
|
14
|
-
if (expr.type === "property") {
|
|
15
|
-
properties.push((expr as PropertyExpression).property);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
// Traverse left and right expressions if they exist
|
|
19
|
-
if (expr.left) {
|
|
20
|
-
traverse(expr.left);
|
|
21
|
-
}
|
|
22
|
-
if (expr.right) {
|
|
23
|
-
traverse(expr.right);
|
|
24
|
-
}
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
traverse(expression);
|
|
28
|
-
return properties;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
export function isPropertyExpression(expression: Expression): expression is PropertyExpression {
|
|
32
|
-
return expression.type === "property";
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export function forEach(expression: Expression, callback: (expression: Expression) => boolean) {
|
|
36
|
-
function traverse(expr: Expression): boolean {
|
|
37
|
-
// Call the callback for this expression
|
|
38
|
-
// If callback returns false, stop traversing
|
|
39
|
-
if (!callback(expr)) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
// Traverse left and right expressions if they exist
|
|
44
|
-
if (expr.left) {
|
|
45
|
-
if (!traverse(expr.left)) {
|
|
46
|
-
return false;
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
if (expr.right) {
|
|
50
|
-
if (!traverse(expr.right)) {
|
|
51
|
-
return false;
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return true;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
traverse(expression);
|
|
59
|
-
}
|
package/src/performance/index.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
const measurements: Record<string, number> = {}
|
|
2
|
-
|
|
3
|
-
export const now = (): number => {
|
|
4
|
-
if (typeof performance !== 'undefined' && performance.now) {
|
|
5
|
-
// Browser or modern Node.js
|
|
6
|
-
return performance.now();
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
// Fallback for older environments
|
|
10
|
-
return Date.now();
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
export const measure = {
|
|
14
|
-
start: (name: string): void => {
|
|
15
|
-
measurements[name] = now();
|
|
16
|
-
},
|
|
17
|
-
end: (name: string): void => {
|
|
18
|
-
const start = measurements[name];
|
|
19
|
-
|
|
20
|
-
delete measurements[name];
|
|
21
|
-
|
|
22
|
-
const delta = now() - start;
|
|
23
|
-
|
|
24
|
-
console.log(`[ROUTIER] - Performance: ${name} took ${delta}`);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
@@ -1,269 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, vi } from 'vitest';
|
|
2
|
-
import { SyncronousQueue, SyncronousUnitOfWork } from './SyncronousQueue';
|
|
3
|
-
|
|
4
|
-
describe('SyncronousQueue', () => {
|
|
5
|
-
describe('enqueue', () => {
|
|
6
|
-
it('should add unit of work to queue and start processing', () => {
|
|
7
|
-
const queue = new SyncronousQueue();
|
|
8
|
-
const mockUnitOfWork = vi.fn((done: () => void) => {
|
|
9
|
-
done();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
queue.enqueue(mockUnitOfWork);
|
|
13
|
-
|
|
14
|
-
expect(mockUnitOfWork).toHaveBeenCalledTimes(1);
|
|
15
|
-
});
|
|
16
|
-
|
|
17
|
-
it('should process multiple units of work in order', () => {
|
|
18
|
-
const queue = new SyncronousQueue();
|
|
19
|
-
const executionOrder: number[] = [];
|
|
20
|
-
|
|
21
|
-
const unitOfWork1 = vi.fn((done: () => void) => {
|
|
22
|
-
executionOrder.push(1);
|
|
23
|
-
done();
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
const unitOfWork2 = vi.fn((done: () => void) => {
|
|
27
|
-
executionOrder.push(2);
|
|
28
|
-
done();
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
queue.enqueue(unitOfWork1);
|
|
32
|
-
queue.enqueue(unitOfWork2);
|
|
33
|
-
|
|
34
|
-
expect(executionOrder).toEqual([1, 2]);
|
|
35
|
-
expect(unitOfWork1).toHaveBeenCalledTimes(1);
|
|
36
|
-
expect(unitOfWork2).toHaveBeenCalledTimes(1);
|
|
37
|
-
});
|
|
38
|
-
|
|
39
|
-
it('should not start processing if already processing', () => {
|
|
40
|
-
const queue = new SyncronousQueue();
|
|
41
|
-
let doneCalled = false;
|
|
42
|
-
|
|
43
|
-
const slowUnitOfWork = vi.fn((done: () => void) => {
|
|
44
|
-
setTimeout(() => {
|
|
45
|
-
doneCalled = true;
|
|
46
|
-
done();
|
|
47
|
-
}, 10);
|
|
48
|
-
});
|
|
49
|
-
|
|
50
|
-
const fastUnitOfWork = vi.fn((done: () => void) => {
|
|
51
|
-
done();
|
|
52
|
-
});
|
|
53
|
-
|
|
54
|
-
queue.enqueue(slowUnitOfWork);
|
|
55
|
-
queue.enqueue(fastUnitOfWork);
|
|
56
|
-
|
|
57
|
-
expect(slowUnitOfWork).toHaveBeenCalledTimes(1);
|
|
58
|
-
expect(fastUnitOfWork).toHaveBeenCalledTimes(0);
|
|
59
|
-
});
|
|
60
|
-
|
|
61
|
-
it('should process next unit of work after current one completes', async () => {
|
|
62
|
-
const queue = new SyncronousQueue();
|
|
63
|
-
const executionOrder: number[] = [];
|
|
64
|
-
|
|
65
|
-
const slowUnitOfWork = vi.fn((done: () => void) => {
|
|
66
|
-
executionOrder.push(1);
|
|
67
|
-
setTimeout(() => {
|
|
68
|
-
done();
|
|
69
|
-
}, 10);
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
const fastUnitOfWork = vi.fn((done: () => void) => {
|
|
73
|
-
executionOrder.push(2);
|
|
74
|
-
done();
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
queue.enqueue(slowUnitOfWork);
|
|
78
|
-
queue.enqueue(fastUnitOfWork);
|
|
79
|
-
|
|
80
|
-
await new Promise(resolve => setTimeout(resolve, 20));
|
|
81
|
-
|
|
82
|
-
expect(executionOrder).toEqual([1, 2]);
|
|
83
|
-
expect(slowUnitOfWork).toHaveBeenCalledTimes(1);
|
|
84
|
-
expect(fastUnitOfWork).toHaveBeenCalledTimes(1);
|
|
85
|
-
});
|
|
86
|
-
});
|
|
87
|
-
|
|
88
|
-
describe('queue behavior', () => {
|
|
89
|
-
it('should handle empty queue', () => {
|
|
90
|
-
const queue = new SyncronousQueue();
|
|
91
|
-
|
|
92
|
-
expect(() => {
|
|
93
|
-
queue.enqueue(vi.fn((done: () => void) => done()));
|
|
94
|
-
}).not.toThrow();
|
|
95
|
-
});
|
|
96
|
-
|
|
97
|
-
it('should handle unit of work that never calls done', () => {
|
|
98
|
-
const queue = new SyncronousQueue();
|
|
99
|
-
const stuckUnitOfWork = vi.fn((done: () => void) => {
|
|
100
|
-
// Never calls done
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
const secondUnitOfWork = vi.fn((done: () => void) => {
|
|
104
|
-
done();
|
|
105
|
-
});
|
|
106
|
-
|
|
107
|
-
queue.enqueue(stuckUnitOfWork);
|
|
108
|
-
queue.enqueue(secondUnitOfWork);
|
|
109
|
-
|
|
110
|
-
expect(stuckUnitOfWork).toHaveBeenCalledTimes(1);
|
|
111
|
-
expect(secondUnitOfWork).toHaveBeenCalledTimes(0);
|
|
112
|
-
});
|
|
113
|
-
|
|
114
|
-
it('should handle unit of work that calls done multiple times', () => {
|
|
115
|
-
const queue = new SyncronousQueue();
|
|
116
|
-
const executionOrder: number[] = [];
|
|
117
|
-
|
|
118
|
-
const multiDoneUnitOfWork = vi.fn((done: () => void) => {
|
|
119
|
-
executionOrder.push(1);
|
|
120
|
-
done();
|
|
121
|
-
done(); // Call done multiple times
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
const secondUnitOfWork = vi.fn((done: () => void) => {
|
|
125
|
-
executionOrder.push(2);
|
|
126
|
-
done();
|
|
127
|
-
});
|
|
128
|
-
|
|
129
|
-
queue.enqueue(multiDoneUnitOfWork);
|
|
130
|
-
queue.enqueue(secondUnitOfWork);
|
|
131
|
-
|
|
132
|
-
expect(executionOrder).toEqual([1, 2]);
|
|
133
|
-
expect(multiDoneUnitOfWork).toHaveBeenCalledTimes(1);
|
|
134
|
-
expect(secondUnitOfWork).toHaveBeenCalledTimes(1);
|
|
135
|
-
});
|
|
136
|
-
|
|
137
|
-
it('should handle rapid enqueueing of multiple units', () => {
|
|
138
|
-
const queue = new SyncronousQueue();
|
|
139
|
-
const executionOrder: number[] = [];
|
|
140
|
-
|
|
141
|
-
const createUnitOfWork = (id: number) => vi.fn((done: () => void) => {
|
|
142
|
-
executionOrder.push(id);
|
|
143
|
-
done();
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
for (let i = 1; i <= 5; i++) {
|
|
147
|
-
queue.enqueue(createUnitOfWork(i));
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
expect(executionOrder).toEqual([1, 2, 3, 4, 5]);
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
it('should handle unit of work that throws error', () => {
|
|
154
|
-
const queue = new SyncronousQueue();
|
|
155
|
-
const errorUnitOfWork = vi.fn((done: () => void) => {
|
|
156
|
-
throw new Error('Test error');
|
|
157
|
-
});
|
|
158
|
-
|
|
159
|
-
const secondUnitOfWork = vi.fn((done: () => void) => {
|
|
160
|
-
done();
|
|
161
|
-
});
|
|
162
|
-
|
|
163
|
-
expect(() => {
|
|
164
|
-
queue.enqueue(errorUnitOfWork);
|
|
165
|
-
}).toThrow('Test error');
|
|
166
|
-
|
|
167
|
-
expect(errorUnitOfWork).toHaveBeenCalledTimes(1);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('should not process next unit after error', () => {
|
|
171
|
-
const queue = new SyncronousQueue();
|
|
172
|
-
const errorUnitOfWork = vi.fn((done: () => void) => {
|
|
173
|
-
throw new Error('Test error');
|
|
174
|
-
});
|
|
175
|
-
|
|
176
|
-
const secondUnitOfWork = vi.fn((done: () => void) => {
|
|
177
|
-
done();
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
try {
|
|
181
|
-
queue.enqueue(errorUnitOfWork);
|
|
182
|
-
} catch (error) {
|
|
183
|
-
// Error is thrown, queue stops processing
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
queue.enqueue(secondUnitOfWork);
|
|
187
|
-
|
|
188
|
-
expect(errorUnitOfWork).toHaveBeenCalledTimes(1);
|
|
189
|
-
expect(secondUnitOfWork).toHaveBeenCalledTimes(0);
|
|
190
|
-
});
|
|
191
|
-
|
|
192
|
-
it('should handle unit of work that calls done asynchronously', async () => {
|
|
193
|
-
const queue = new SyncronousQueue();
|
|
194
|
-
const executionOrder: number[] = [];
|
|
195
|
-
|
|
196
|
-
const asyncUnitOfWork = vi.fn((done: () => void) => {
|
|
197
|
-
executionOrder.push(1);
|
|
198
|
-
Promise.resolve().then(() => {
|
|
199
|
-
done();
|
|
200
|
-
});
|
|
201
|
-
});
|
|
202
|
-
|
|
203
|
-
const syncUnitOfWork = vi.fn((done: () => void) => {
|
|
204
|
-
executionOrder.push(2);
|
|
205
|
-
done();
|
|
206
|
-
});
|
|
207
|
-
|
|
208
|
-
queue.enqueue(asyncUnitOfWork);
|
|
209
|
-
queue.enqueue(syncUnitOfWork);
|
|
210
|
-
|
|
211
|
-
await new Promise(resolve => setTimeout(resolve, 10));
|
|
212
|
-
|
|
213
|
-
expect(executionOrder).toEqual([1, 2]);
|
|
214
|
-
expect(asyncUnitOfWork).toHaveBeenCalledTimes(1);
|
|
215
|
-
expect(syncUnitOfWork).toHaveBeenCalledTimes(1);
|
|
216
|
-
});
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
describe('edge cases', () => {
|
|
220
|
-
it('should handle null done callback', () => {
|
|
221
|
-
const queue = new SyncronousQueue();
|
|
222
|
-
const unitOfWork = vi.fn((done: () => void) => {
|
|
223
|
-
done();
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
expect(() => {
|
|
227
|
-
queue.enqueue(unitOfWork);
|
|
228
|
-
}).not.toThrow();
|
|
229
|
-
|
|
230
|
-
expect(unitOfWork).toHaveBeenCalledTimes(1);
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
it('should handle unit of work that enqueues another unit of work', () => {
|
|
234
|
-
const queue = new SyncronousQueue();
|
|
235
|
-
const executionOrder: number[] = [];
|
|
236
|
-
|
|
237
|
-
const recursiveUnitOfWork = vi.fn((done: () => void) => {
|
|
238
|
-
executionOrder.push(1);
|
|
239
|
-
queue.enqueue(vi.fn((innerDone: () => void) => {
|
|
240
|
-
executionOrder.push(2);
|
|
241
|
-
innerDone();
|
|
242
|
-
}));
|
|
243
|
-
done();
|
|
244
|
-
});
|
|
245
|
-
|
|
246
|
-
queue.enqueue(recursiveUnitOfWork);
|
|
247
|
-
|
|
248
|
-
expect(executionOrder).toEqual([1, 2]);
|
|
249
|
-
expect(recursiveUnitOfWork).toHaveBeenCalledTimes(1);
|
|
250
|
-
});
|
|
251
|
-
|
|
252
|
-
it('should handle multiple rapid enqueue operations', () => {
|
|
253
|
-
const queue = new SyncronousQueue();
|
|
254
|
-
const executionCount = { count: 0 };
|
|
255
|
-
|
|
256
|
-
const unitOfWork = vi.fn((done: () => void) => {
|
|
257
|
-
executionCount.count++;
|
|
258
|
-
done();
|
|
259
|
-
});
|
|
260
|
-
|
|
261
|
-
for (let i = 0; i < 100; i++) {
|
|
262
|
-
queue.enqueue(unitOfWork);
|
|
263
|
-
}
|
|
264
|
-
|
|
265
|
-
expect(executionCount.count).toBe(100);
|
|
266
|
-
expect(unitOfWork).toHaveBeenCalledTimes(100);
|
|
267
|
-
});
|
|
268
|
-
});
|
|
269
|
-
});
|