@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,33 +0,0 @@
|
|
|
1
|
-
import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';
|
|
2
|
-
import { SlotPath } from '../../SlotPath';
|
|
3
|
-
import { PropertyInfoHandler } from "../types";
|
|
4
|
-
import { PropertyInfo, SchemaTypes } from "../../../schema";
|
|
5
|
-
|
|
6
|
-
export class SerializeValueHandler extends PropertyInfoHandler {
|
|
7
|
-
|
|
8
|
-
override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {
|
|
9
|
-
|
|
10
|
-
if (property.type != SchemaTypes.Object && property.type != SchemaTypes.Date) {
|
|
11
|
-
let objectBuilder = builder.getOrDefault<ObjectBuilder>("result.variable.object");
|
|
12
|
-
const entitySelectorPath = property.getAssignmentPath({ parent: "entity" });
|
|
13
|
-
|
|
14
|
-
if (objectBuilder == null) {
|
|
15
|
-
objectBuilder = builder.get<SlotBlock>("result")
|
|
16
|
-
.assign("const result", { name: "variable" })
|
|
17
|
-
.object({ name: "object" });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (property.parent == null) {
|
|
21
|
-
objectBuilder.property(`${property.name}: ${entitySelectorPath}`);
|
|
22
|
-
return builder;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
const slotPath = new SlotPath(...property.getParentPathArray());
|
|
26
|
-
objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());
|
|
27
|
-
objectBuilder.property(`${property.name}: ${entitySelectorPath}`);
|
|
28
|
-
return builder;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
return super.handle(property, builder);
|
|
32
|
-
}
|
|
33
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { CodeBuilder } from '../../blocks';
|
|
2
|
-
import { PropertyInfoHandler } from "../types";
|
|
3
|
-
import { PropertyInfo } from "../../../schema";
|
|
4
|
-
|
|
5
|
-
export class StripIdentityHandler extends PropertyInfoHandler {
|
|
6
|
-
|
|
7
|
-
override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {
|
|
8
|
-
|
|
9
|
-
if (property.isIdentity === true) {
|
|
10
|
-
return builder;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return super.handle(property, builder);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { CodeBuilder } from '../../blocks';
|
|
2
|
-
import { PropertyInfoHandler } from "../types";
|
|
3
|
-
import { PropertyInfo } from "../../../schema";
|
|
4
|
-
|
|
5
|
-
export class StripKeyHandler extends PropertyInfoHandler {
|
|
6
|
-
|
|
7
|
-
override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {
|
|
8
|
-
|
|
9
|
-
if (property.isKey === true) {
|
|
10
|
-
return builder;
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
return super.handle(property, builder);
|
|
14
|
-
}
|
|
15
|
-
}
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';
|
|
2
|
-
import { SlotPath } from '../../SlotPath';
|
|
3
|
-
import { PropertyInfoHandler } from "../types";
|
|
4
|
-
import { PropertyInfo, SchemaTypes } from "../../../schema";
|
|
5
|
-
|
|
6
|
-
export class StripObjectHandler extends PropertyInfoHandler {
|
|
7
|
-
|
|
8
|
-
override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {
|
|
9
|
-
|
|
10
|
-
if (property.type === SchemaTypes.Object) {
|
|
11
|
-
const slotPath = new SlotPath("result.variable.object");
|
|
12
|
-
let objectBuilder = builder.getOrDefault<ObjectBuilder>(slotPath.get());
|
|
13
|
-
|
|
14
|
-
if (objectBuilder == null) {
|
|
15
|
-
objectBuilder = builder.get<SlotBlock>("result")
|
|
16
|
-
.assign("const result", { name: "variable" })
|
|
17
|
-
.object({ name: "object" });
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
if (property.parent == null) {
|
|
21
|
-
objectBuilder.nested(property.name, property.name)
|
|
22
|
-
|
|
23
|
-
return builder;
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
slotPath.push(...property.getParentPathArray());
|
|
27
|
-
const nestedObjectBuilder = builder.get<ObjectBuilder>(slotPath.get());
|
|
28
|
-
nestedObjectBuilder.nested(property.name, property.name)
|
|
29
|
-
|
|
30
|
-
return builder;
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
return super.handle(property, builder);
|
|
34
|
-
}
|
|
35
|
-
}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { PropertyInfo, SchemaTypes } from "../../../schema";
|
|
2
|
-
import { PropertyInfoHandler } from "../types";
|
|
3
|
-
import { CodeBuilder, ObjectBuilder, SlotBlock } from '../../blocks';
|
|
4
|
-
import { SlotPath } from '../../SlotPath';
|
|
5
|
-
|
|
6
|
-
export class StripValueHandler extends PropertyInfoHandler {
|
|
7
|
-
|
|
8
|
-
override handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {
|
|
9
|
-
|
|
10
|
-
if (property.type != SchemaTypes.Object) {
|
|
11
|
-
let objectBuilder = builder.getOrDefault<ObjectBuilder>("result.variable.object");
|
|
12
|
-
const entitySelectorPath = property.getAssignmentPath({ parent: "entity" });
|
|
13
|
-
|
|
14
|
-
// There is a chance this is the first property we handle,
|
|
15
|
-
// if that is the case, the main result variable will not be
|
|
16
|
-
// constructed yet
|
|
17
|
-
if (objectBuilder == null) {
|
|
18
|
-
objectBuilder = builder.get<SlotBlock>("result")
|
|
19
|
-
.assign("const result", { name: "variable" })
|
|
20
|
-
.object({ name: "object" });
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
if (property.parent == null) {
|
|
24
|
-
objectBuilder.property(`${property.name}: ${entitySelectorPath}`);
|
|
25
|
-
return builder;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const slotPath = new SlotPath(...property.getParentPathArray());
|
|
29
|
-
objectBuilder = objectBuilder.get<ObjectBuilder>(slotPath.get());
|
|
30
|
-
objectBuilder.property(`${property.name}: ${entitySelectorPath}`);
|
|
31
|
-
return builder;
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
return super.handle(property, builder);
|
|
35
|
-
}
|
|
36
|
-
}
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
import { AssignmentBuilder, CodeBuilder, ContainerBlock, ObjectBuilder, SlotBlock } from '..';
|
|
2
|
-
import { PropertyInfo } from '../../schema/PropertyInfo';
|
|
3
|
-
import { SlotPath } from '../SlotPath';
|
|
4
|
-
import { SchemaError } from '../../errors/SchemaError';
|
|
5
|
-
import { uuid } from '../../utilities/uuid';
|
|
6
|
-
import { countWordOccurance } from '../utils';
|
|
7
|
-
|
|
8
|
-
export interface IHandler {
|
|
9
|
-
setNext(handler: IHandler): IHandler;
|
|
10
|
-
|
|
11
|
-
handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null;
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
export abstract class PropertyInfoHandler implements IHandler {
|
|
15
|
-
|
|
16
|
-
private _next: IHandler | null;
|
|
17
|
-
|
|
18
|
-
setNext(handler: IHandler): IHandler {
|
|
19
|
-
this._next = handler;
|
|
20
|
-
|
|
21
|
-
return handler;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
handle(property: PropertyInfo<any>, builder: CodeBuilder): CodeBuilder | null {
|
|
25
|
-
try {
|
|
26
|
-
if (this._next) {
|
|
27
|
-
return this._next.handle(property, builder);
|
|
28
|
-
}
|
|
29
|
-
|
|
30
|
-
return null;
|
|
31
|
-
} catch (e: any) {
|
|
32
|
-
throw new SchemaError(e, `Error handling property: ${property.name}`);
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
protected buildSlotPath(property: PropertyInfo<any>, path: SlotPath) {
|
|
37
|
-
|
|
38
|
-
const result = new SlotPath(...path.path);
|
|
39
|
-
const items: string[] = []
|
|
40
|
-
let p = property;
|
|
41
|
-
|
|
42
|
-
while (p.parent != null) {
|
|
43
|
-
items.unshift(p.name);
|
|
44
|
-
p = p.parent;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
items.unshift(p.name);
|
|
48
|
-
|
|
49
|
-
result.push(...items);
|
|
50
|
-
|
|
51
|
-
return result
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
protected setEnrichedProperty(property: PropertyInfo<any>, root: CodeBuilder) {
|
|
55
|
-
const useFromPropertyName = property.from != null;
|
|
56
|
-
const entitySelectorPath = property.getAssignmentPath({ parent: "entity", useFromPropertyName });
|
|
57
|
-
|
|
58
|
-
if (property.parent != null) {
|
|
59
|
-
const slotPath = new SlotPath("factory", "function", "assignment");
|
|
60
|
-
const path = property.parent.getAssignmentPath({ parent: "enriched" });
|
|
61
|
-
slotPath.push(`[${path}]`)
|
|
62
|
-
const builder = root.get<AssignmentBuilder>(slotPath.get());
|
|
63
|
-
const objectBuilder = builder.getValue as ObjectBuilder;
|
|
64
|
-
|
|
65
|
-
const childEntityPathSelector = property.getSelectrorPath({ parent: "entity", useFromPropertyName });
|
|
66
|
-
objectBuilder.property(`${property.name}: ${childEntityPathSelector}`);
|
|
67
|
-
return;
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
const slotPath = new SlotPath("factory", "function", "enriched", "object", "enriched");
|
|
71
|
-
let enriched = root.getOrDefault<ObjectBuilder>(slotPath.get());
|
|
72
|
-
|
|
73
|
-
if (enriched == null) {
|
|
74
|
-
const enrichedSlot = root.get<SlotBlock>("factory.function.enriched");
|
|
75
|
-
enriched = enrichedSlot.variable("enriched", { name: "object" }).object({ name: "enriched" });
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
enriched.property(`${property.name}: ${entitySelectorPath}`);
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
protected toNamedFunction(stringifiedFunction: string, parent: ContainerBlock) {
|
|
82
|
-
const name = `_${uuid()}`;
|
|
83
|
-
|
|
84
|
-
const builder = parent.function(name);
|
|
85
|
-
const occurences = countWordOccurance(stringifiedFunction, "=>")
|
|
86
|
-
|
|
87
|
-
if (occurences > 0) {
|
|
88
|
-
|
|
89
|
-
const split = stringifiedFunction.split("=>").map(w => w.trim());
|
|
90
|
-
const parameters = split[0].replace(/\(|\)/g, "").split(",");
|
|
91
|
-
let body = split[1];
|
|
92
|
-
|
|
93
|
-
if (occurences > 1) {
|
|
94
|
-
// we have a function that returns a function
|
|
95
|
-
const index = stringifiedFunction.indexOf("=>");
|
|
96
|
-
body = stringifiedFunction.slice(index + 2, stringifiedFunction.length)
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
if (body.startsWith("{") === true && body.endsWith("}")) {
|
|
100
|
-
|
|
101
|
-
// Remove brackets, wrapping function will have them
|
|
102
|
-
builder.appendBody(body.slice(1, body.length - 1));
|
|
103
|
-
|
|
104
|
-
return {
|
|
105
|
-
builder,
|
|
106
|
-
parameters
|
|
107
|
-
};
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
builder.appendBody(`return ${body};`);
|
|
111
|
-
return {
|
|
112
|
-
builder,
|
|
113
|
-
parameters
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
throw new Error("Only arrow functions are allowed in the schema definition: function () {} ---> () => {}");
|
|
118
|
-
}
|
|
119
|
-
}
|
package/src/codegen/types.ts
DELETED
package/src/codegen/utils.ts
DELETED
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Counts non-overlapping occurrences of a term in text.
|
|
3
|
-
*
|
|
4
|
-
* Behavior:
|
|
5
|
-
* - Case-sensitive matching
|
|
6
|
-
* - If the search term is composed entirely of word characters (A–Z, a–z, 0–9, _),
|
|
7
|
-
* enforce whole-word boundaries so "red" does not match inside "redder".
|
|
8
|
-
* - If the search term contains any non-word character (e.g. "=>", "()", "::"),
|
|
9
|
-
* match anywhere without boundary checks (useful for symbols).
|
|
10
|
-
* - Non-overlapping matches (after a hit, advances by term length)
|
|
11
|
-
* - Optimized single-character fast path; otherwise uses indexOf loop
|
|
12
|
-
*
|
|
13
|
-
* Examples:
|
|
14
|
-
* - countWordOccurance("red redder red", "red") => 2
|
|
15
|
-
* - countWordOccurance("()=>{}", "=>") => 1
|
|
16
|
-
* - countWordOccurance("aaaa", "aa") => 2 (non-overlapping)
|
|
17
|
-
*
|
|
18
|
-
* @param text The source text to scan
|
|
19
|
-
* @param word The term to match (must be non-empty)
|
|
20
|
-
* @returns The number of occurrences found
|
|
21
|
-
*/
|
|
22
|
-
export const countWordOccurance = (text: string, word: string) => {
|
|
23
|
-
const wl = word.length;
|
|
24
|
-
const tl = text.length;
|
|
25
|
-
|
|
26
|
-
if (wl === 0 || wl > tl) return 0;
|
|
27
|
-
|
|
28
|
-
// Fast path for single-character words
|
|
29
|
-
if (wl === 1) {
|
|
30
|
-
let c = 0;
|
|
31
|
-
const code = word.charCodeAt(0);
|
|
32
|
-
for (let i = 0; i < tl; i++) if (text.charCodeAt(i) === code) c++;
|
|
33
|
-
return c;
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
let count = 0;
|
|
37
|
-
let i = 0;
|
|
38
|
-
|
|
39
|
-
function isWordCharCode(c: number): boolean {
|
|
40
|
-
return (c >= 48 && c <= 57) // 0-9
|
|
41
|
-
|| (c >= 65 && c <= 90) // A-Z
|
|
42
|
-
|| (c >= 97 && c <= 122) // a-z
|
|
43
|
-
|| c === 95; // _
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
// Decide whether to enforce word boundaries based on the search term
|
|
47
|
-
let enforceWordBoundaries = true;
|
|
48
|
-
for (let k = 0; k < wl; k++) {
|
|
49
|
-
const cc = word.charCodeAt(k);
|
|
50
|
-
if (!isWordCharCode(cc)) {
|
|
51
|
-
enforceWordBoundaries = false;
|
|
52
|
-
break;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
while (true) {
|
|
57
|
-
i = text.indexOf(word, i);
|
|
58
|
-
if (i === -1) break;
|
|
59
|
-
|
|
60
|
-
if (enforceWordBoundaries) {
|
|
61
|
-
const left = i - 1;
|
|
62
|
-
const right = i + wl;
|
|
63
|
-
const leftOk = left < 0 || !isWordCharCode(text.charCodeAt(left));
|
|
64
|
-
const rightOk = right >= tl || !isWordCharCode(text.charCodeAt(right));
|
|
65
|
-
if (leftOk && rightOk) count++;
|
|
66
|
-
} else {
|
|
67
|
-
// No boundary enforcement for symbol-containing terms
|
|
68
|
-
count++;
|
|
69
|
-
}
|
|
70
|
-
i += wl; // non-overlapping word matches
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
return count;
|
|
74
|
-
}
|
|
@@ -1,337 +0,0 @@
|
|
|
1
|
-
import { describe, it, expect, beforeEach } from 'vitest';
|
|
2
|
-
import { BulkPersistResult, BulkPersistChanges, SchemaPersistChanges, SchemaPersistResult } from './Changes';
|
|
3
|
-
import { TagCollection } from './TagCollection';
|
|
4
|
-
|
|
5
|
-
describe('SchemaPersistChanges', () => {
|
|
6
|
-
let changes: SchemaPersistChanges;
|
|
7
|
-
|
|
8
|
-
beforeEach(() => {
|
|
9
|
-
changes = new SchemaPersistChanges();
|
|
10
|
-
});
|
|
11
|
-
|
|
12
|
-
describe('initialization', () => {
|
|
13
|
-
it('should initialize with empty arrays and new TagCollection', () => {
|
|
14
|
-
expect(changes.adds).toEqual([]);
|
|
15
|
-
expect(changes.updates).toEqual([]);
|
|
16
|
-
expect(changes.removes).toEqual([]);
|
|
17
|
-
expect(changes.tags).toBeInstanceOf(TagCollection);
|
|
18
|
-
});
|
|
19
|
-
});
|
|
20
|
-
|
|
21
|
-
describe('hasItems', () => {
|
|
22
|
-
it('should return false when all arrays are empty', () => {
|
|
23
|
-
expect(changes.hasItems).toBe(false);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
it('should return true when adds has items', () => {
|
|
27
|
-
changes.adds.push({ id: '1', name: 'Test' } as any);
|
|
28
|
-
expect(changes.hasItems).toBe(true);
|
|
29
|
-
});
|
|
30
|
-
|
|
31
|
-
it('should return true when updates has items', () => {
|
|
32
|
-
changes.updates.push({ entity: { id: '1' }, changeType: 'propertiesChanged', delta: {} } as any);
|
|
33
|
-
expect(changes.hasItems).toBe(true);
|
|
34
|
-
});
|
|
35
|
-
|
|
36
|
-
it('should return true when removes has items', () => {
|
|
37
|
-
changes.removes.push({ id: '1', name: 'Test' } as any);
|
|
38
|
-
expect(changes.hasItems).toBe(true);
|
|
39
|
-
});
|
|
40
|
-
});
|
|
41
|
-
|
|
42
|
-
describe('total', () => {
|
|
43
|
-
it('should return 0 for empty changes', () => {
|
|
44
|
-
expect(changes.total).toBe(0);
|
|
45
|
-
});
|
|
46
|
-
|
|
47
|
-
it('should return correct total with mixed items', () => {
|
|
48
|
-
changes.adds.push({ id: '1' } as any);
|
|
49
|
-
changes.adds.push({ id: '2' } as any);
|
|
50
|
-
changes.updates.push({ entity: { id: '3' }, changeType: 'propertiesChanged', delta: {} } as any);
|
|
51
|
-
changes.removes.push({ id: '4' } as any);
|
|
52
|
-
|
|
53
|
-
expect(changes.total).toBe(4);
|
|
54
|
-
});
|
|
55
|
-
|
|
56
|
-
it('should handle large numbers correctly', () => {
|
|
57
|
-
for (let i = 0; i < 1000; i++) {
|
|
58
|
-
changes.adds.push({ id: i.toString() } as any);
|
|
59
|
-
}
|
|
60
|
-
expect(changes.total).toBe(1000);
|
|
61
|
-
});
|
|
62
|
-
});
|
|
63
|
-
});
|
|
64
|
-
|
|
65
|
-
describe('SchemaPersistResult', () => {
|
|
66
|
-
let result: SchemaPersistResult;
|
|
67
|
-
|
|
68
|
-
beforeEach(() => {
|
|
69
|
-
result = new SchemaPersistResult();
|
|
70
|
-
});
|
|
71
|
-
|
|
72
|
-
describe('initialization', () => {
|
|
73
|
-
it('should initialize with empty arrays', () => {
|
|
74
|
-
expect(result.adds).toEqual([]);
|
|
75
|
-
expect(result.updates).toEqual([]);
|
|
76
|
-
expect(result.removes).toEqual([]);
|
|
77
|
-
});
|
|
78
|
-
});
|
|
79
|
-
|
|
80
|
-
describe('hasItems', () => {
|
|
81
|
-
it('should return false when all arrays are empty', () => {
|
|
82
|
-
expect(result.hasItems).toBe(false);
|
|
83
|
-
});
|
|
84
|
-
|
|
85
|
-
it('should return true when adds has items', () => {
|
|
86
|
-
result.adds.push({ id: '1', name: 'Test' } as any);
|
|
87
|
-
expect(result.hasItems).toBe(true);
|
|
88
|
-
});
|
|
89
|
-
|
|
90
|
-
it('should return true when updates has items', () => {
|
|
91
|
-
result.updates.push({ id: '1', name: 'Test' } as any);
|
|
92
|
-
expect(result.hasItems).toBe(true);
|
|
93
|
-
});
|
|
94
|
-
|
|
95
|
-
it('should return true when removes has items', () => {
|
|
96
|
-
result.removes.push({ id: '1', name: 'Test' } as any);
|
|
97
|
-
expect(result.hasItems).toBe(true);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
100
|
-
|
|
101
|
-
describe('total', () => {
|
|
102
|
-
it('should return 0 for empty result', () => {
|
|
103
|
-
expect(result.total).toBe(0);
|
|
104
|
-
});
|
|
105
|
-
|
|
106
|
-
it('should return correct total with mixed items', () => {
|
|
107
|
-
result.adds.push({ id: '1' } as any);
|
|
108
|
-
result.adds.push({ id: '2' } as any);
|
|
109
|
-
result.updates.push({ id: '3' } as any);
|
|
110
|
-
result.removes.push({ id: '4' } as any);
|
|
111
|
-
|
|
112
|
-
expect(result.total).toBe(4);
|
|
113
|
-
});
|
|
114
|
-
});
|
|
115
|
-
});
|
|
116
|
-
|
|
117
|
-
describe('BulkPersistResult', () => {
|
|
118
|
-
let result: BulkPersistResult;
|
|
119
|
-
|
|
120
|
-
beforeEach(() => {
|
|
121
|
-
result = new BulkPersistResult();
|
|
122
|
-
});
|
|
123
|
-
|
|
124
|
-
describe('resolve', () => {
|
|
125
|
-
it('should return existing result if schemaId exists', () => {
|
|
126
|
-
const existingResult = new SchemaPersistResult();
|
|
127
|
-
result.set(1, existingResult);
|
|
128
|
-
|
|
129
|
-
const resolved = result.resolve(1);
|
|
130
|
-
expect(resolved).toBe(existingResult);
|
|
131
|
-
});
|
|
132
|
-
|
|
133
|
-
it('should create and return new result if schemaId does not exist', () => {
|
|
134
|
-
const resolved = result.resolve(1);
|
|
135
|
-
expect(resolved).toBeInstanceOf(SchemaPersistResult);
|
|
136
|
-
expect(result.has(1)).toBe(true);
|
|
137
|
-
});
|
|
138
|
-
|
|
139
|
-
it('should return the same instance when called multiple times', () => {
|
|
140
|
-
const first = result.resolve(1);
|
|
141
|
-
const second = result.resolve(1);
|
|
142
|
-
expect(first).toBe(second);
|
|
143
|
-
});
|
|
144
|
-
});
|
|
145
|
-
|
|
146
|
-
describe('get with generic type', () => {
|
|
147
|
-
it('should return typed result', () => {
|
|
148
|
-
const typedResult = result.get<{ id: string; name: string }>(1);
|
|
149
|
-
expect(typedResult).toBeInstanceOf(SchemaPersistResult);
|
|
150
|
-
});
|
|
151
|
-
});
|
|
152
|
-
|
|
153
|
-
describe('aggregate properties', () => {
|
|
154
|
-
beforeEach(() => {
|
|
155
|
-
// Setup test data
|
|
156
|
-
const result1 = new SchemaPersistResult();
|
|
157
|
-
result1.adds.push({ id: '1' } as any);
|
|
158
|
-
result1.adds.push({ id: '2' } as any);
|
|
159
|
-
result1.updates.push({ id: '3' } as any);
|
|
160
|
-
result1.removes.push({ id: '4' } as any);
|
|
161
|
-
|
|
162
|
-
const result2 = new SchemaPersistResult();
|
|
163
|
-
result2.adds.push({ id: '5' } as any);
|
|
164
|
-
result2.updates.push({ id: '6' } as any);
|
|
165
|
-
|
|
166
|
-
result.set(1, result1);
|
|
167
|
-
result.set(2, result2);
|
|
168
|
-
});
|
|
169
|
-
|
|
170
|
-
it('should calculate aggregate size correctly', () => {
|
|
171
|
-
expect(result.aggregate.size).toBe(6); // 2+1+1+1+0+1
|
|
172
|
-
});
|
|
173
|
-
|
|
174
|
-
it('should calculate aggregate adds correctly', () => {
|
|
175
|
-
expect(result.aggregate.adds).toBe(3); // 2+1
|
|
176
|
-
});
|
|
177
|
-
|
|
178
|
-
it('should calculate aggregate updates correctly', () => {
|
|
179
|
-
expect(result.aggregate.updates).toBe(2); // 1+1
|
|
180
|
-
});
|
|
181
|
-
|
|
182
|
-
it('should calculate aggregate removes correctly', () => {
|
|
183
|
-
expect(result.aggregate.removes).toBe(1); // 1+0
|
|
184
|
-
});
|
|
185
|
-
});
|
|
186
|
-
|
|
187
|
-
describe('aggregate with empty results', () => {
|
|
188
|
-
it('should return 0 for all aggregates when empty', () => {
|
|
189
|
-
expect(result.aggregate.size).toBe(0);
|
|
190
|
-
expect(result.aggregate.adds).toBe(0);
|
|
191
|
-
expect(result.aggregate.updates).toBe(0);
|
|
192
|
-
expect(result.aggregate.removes).toBe(0);
|
|
193
|
-
});
|
|
194
|
-
});
|
|
195
|
-
});
|
|
196
|
-
|
|
197
|
-
describe('BulkPersistChanges', () => {
|
|
198
|
-
let changes: BulkPersistChanges;
|
|
199
|
-
|
|
200
|
-
beforeEach(() => {
|
|
201
|
-
changes = new BulkPersistChanges();
|
|
202
|
-
});
|
|
203
|
-
|
|
204
|
-
describe('resolve', () => {
|
|
205
|
-
it('should return existing changes if schemaId exists', () => {
|
|
206
|
-
const existingChanges = new SchemaPersistChanges();
|
|
207
|
-
changes.set(1, existingChanges);
|
|
208
|
-
|
|
209
|
-
const resolved = changes.resolve(1);
|
|
210
|
-
expect(resolved).toBe(existingChanges);
|
|
211
|
-
});
|
|
212
|
-
|
|
213
|
-
it('should create and return new changes if schemaId does not exist', () => {
|
|
214
|
-
const resolved = changes.resolve(1);
|
|
215
|
-
expect(resolved).toBeInstanceOf(SchemaPersistChanges);
|
|
216
|
-
expect(changes.has(1)).toBe(true);
|
|
217
|
-
});
|
|
218
|
-
|
|
219
|
-
it('should return the same instance when called multiple times', () => {
|
|
220
|
-
const first = changes.resolve(1);
|
|
221
|
-
const second = changes.resolve(1);
|
|
222
|
-
expect(first).toBe(second);
|
|
223
|
-
});
|
|
224
|
-
});
|
|
225
|
-
|
|
226
|
-
describe('get with generic type', () => {
|
|
227
|
-
it('should return typed changes', () => {
|
|
228
|
-
const typedChanges = changes.get<{ id: string; name: string }>(1);
|
|
229
|
-
expect(typedChanges).toBeInstanceOf(SchemaPersistChanges);
|
|
230
|
-
});
|
|
231
|
-
});
|
|
232
|
-
|
|
233
|
-
describe('aggregate properties', () => {
|
|
234
|
-
beforeEach(() => {
|
|
235
|
-
// Setup test data
|
|
236
|
-
const changes1 = new SchemaPersistChanges();
|
|
237
|
-
changes1.adds.push({ id: '1' } as any);
|
|
238
|
-
changes1.adds.push({ id: '2' } as any);
|
|
239
|
-
changes1.updates.push({ entity: { id: '3' }, changeType: 'propertiesChanged', delta: {} } as any);
|
|
240
|
-
changes1.removes.push({ id: '4' } as any);
|
|
241
|
-
|
|
242
|
-
const changes2 = new SchemaPersistChanges();
|
|
243
|
-
changes2.adds.push({ id: '5' } as any);
|
|
244
|
-
changes2.updates.push({ entity: { id: '6' }, changeType: 'propertiesChanged', delta: {} } as any);
|
|
245
|
-
|
|
246
|
-
changes.set(1, changes1);
|
|
247
|
-
changes.set(2, changes2);
|
|
248
|
-
});
|
|
249
|
-
|
|
250
|
-
it('should calculate aggregate size correctly', () => {
|
|
251
|
-
expect(changes.aggregate.size).toBe(6); // 2+1+1+1+0+1
|
|
252
|
-
});
|
|
253
|
-
|
|
254
|
-
it('should calculate aggregate adds correctly', () => {
|
|
255
|
-
expect(changes.aggregate.adds).toBe(3); // 2+1
|
|
256
|
-
});
|
|
257
|
-
|
|
258
|
-
it('should calculate aggregate updates correctly', () => {
|
|
259
|
-
expect(changes.aggregate.updates).toBe(2); // 1+1
|
|
260
|
-
});
|
|
261
|
-
|
|
262
|
-
it('should calculate aggregate removes correctly', () => {
|
|
263
|
-
expect(changes.aggregate.removes).toBe(1); // 1+0
|
|
264
|
-
});
|
|
265
|
-
});
|
|
266
|
-
|
|
267
|
-
describe('toResult', () => {
|
|
268
|
-
it('should create result with same schema IDs', () => {
|
|
269
|
-
changes.set(1, new SchemaPersistChanges());
|
|
270
|
-
changes.set(2, new SchemaPersistChanges());
|
|
271
|
-
|
|
272
|
-
const result = changes.toResult();
|
|
273
|
-
|
|
274
|
-
expect(result.has(1)).toBe(true);
|
|
275
|
-
expect(result.has(2)).toBe(true);
|
|
276
|
-
expect(result.size).toBe(2);
|
|
277
|
-
});
|
|
278
|
-
|
|
279
|
-
it('should create empty SchemaPersistResult instances', () => {
|
|
280
|
-
changes.set(1, new SchemaPersistChanges());
|
|
281
|
-
const result = changes.toResult();
|
|
282
|
-
|
|
283
|
-
const schemaResult = result.get(1);
|
|
284
|
-
expect(schemaResult).toBeInstanceOf(SchemaPersistResult);
|
|
285
|
-
expect(schemaResult.adds).toEqual([]);
|
|
286
|
-
expect(schemaResult.updates).toEqual([]);
|
|
287
|
-
expect(schemaResult.removes).toEqual([]);
|
|
288
|
-
});
|
|
289
|
-
|
|
290
|
-
it('should handle empty changes map', () => {
|
|
291
|
-
const result = changes.toResult();
|
|
292
|
-
expect(result.size).toBe(0);
|
|
293
|
-
});
|
|
294
|
-
});
|
|
295
|
-
|
|
296
|
-
describe('aggregate with empty changes', () => {
|
|
297
|
-
it('should return 0 for all aggregates when empty', () => {
|
|
298
|
-
expect(changes.aggregate.size).toBe(0);
|
|
299
|
-
expect(changes.aggregate.adds).toBe(0);
|
|
300
|
-
expect(changes.aggregate.updates).toBe(0);
|
|
301
|
-
expect(changes.aggregate.removes).toBe(0);
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
});
|
|
305
|
-
|
|
306
|
-
describe('Edge cases and error scenarios', () => {
|
|
307
|
-
it('should handle very large numbers correctly', () => {
|
|
308
|
-
const changes = new SchemaPersistChanges();
|
|
309
|
-
for (let i = 0; i < 10000; i++) {
|
|
310
|
-
changes.adds.push({ id: i.toString() } as any);
|
|
311
|
-
}
|
|
312
|
-
expect(changes.total).toBe(10000);
|
|
313
|
-
expect(changes.hasItems).toBe(true);
|
|
314
|
-
});
|
|
315
|
-
|
|
316
|
-
it('should handle mixed data types in arrays', () => {
|
|
317
|
-
const changes = new SchemaPersistChanges();
|
|
318
|
-
changes.adds.push({ id: '1', name: 'Test' } as any);
|
|
319
|
-
changes.adds.push({ id: 2, count: 42 } as any);
|
|
320
|
-
changes.adds.push({ id: '3', active: true } as any);
|
|
321
|
-
|
|
322
|
-
expect(changes.total).toBe(3);
|
|
323
|
-
expect(changes.hasItems).toBe(true);
|
|
324
|
-
});
|
|
325
|
-
|
|
326
|
-
it('should handle concurrent modifications', () => {
|
|
327
|
-
const bulkChanges = new BulkPersistChanges();
|
|
328
|
-
const changes1 = bulkChanges.resolve(1);
|
|
329
|
-
const changes2 = bulkChanges.resolve(2);
|
|
330
|
-
|
|
331
|
-
changes1.adds.push({ id: '1' } as any);
|
|
332
|
-
changes2.adds.push({ id: '2' } as any);
|
|
333
|
-
|
|
334
|
-
expect(bulkChanges.aggregate.adds).toBe(2);
|
|
335
|
-
expect(bulkChanges.aggregate.size).toBe(2);
|
|
336
|
-
});
|
|
337
|
-
});
|