@cratis/chronicle 6.62.0 → 6.64.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ChronicleClient.ts +86 -3
- package/artifacts/DefaultClientArtifactsProvider.ts +5 -0
- package/artifacts/IClientArtifactsProvider.ts +3 -0
- package/connection/ConnectionLifecycle.ts +42 -1
- package/dist/ChronicleClient.d.ts +28 -1
- package/dist/ChronicleClient.d.ts.map +1 -1
- package/dist/ChronicleClient.js +71 -3
- package/dist/ChronicleClient.js.map +1 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts +2 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts.map +1 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.js +4 -0
- package/dist/artifacts/DefaultClientArtifactsProvider.js.map +1 -1
- package/dist/artifacts/IClientArtifactsProvider.d.ts +2 -0
- package/dist/artifacts/IClientArtifactsProvider.d.ts.map +1 -1
- package/dist/connection/ConnectionLifecycle.d.ts +24 -0
- package/dist/connection/ConnectionLifecycle.d.ts.map +1 -1
- package/dist/connection/ConnectionLifecycle.js +40 -1
- package/dist/connection/ConnectionLifecycle.js.map +1 -1
- package/dist/observation/ObservationReconnectBackoff.d.ts +64 -0
- package/dist/observation/ObservationReconnectBackoff.d.ts.map +1 -0
- package/dist/observation/ObservationReconnectBackoff.js +75 -0
- package/dist/observation/ObservationReconnectBackoff.js.map +1 -0
- package/dist/observation/ObservationStreamOutcome.d.ts +10 -0
- package/dist/observation/ObservationStreamOutcome.d.ts.map +1 -0
- package/dist/observation/ObservationStreamOutcome.js +4 -0
- package/dist/observation/ObservationStreamOutcome.js.map +1 -0
- package/dist/observation/classifyStreamError.d.ts +25 -0
- package/dist/observation/classifyStreamError.d.ts.map +1 -0
- package/dist/observation/classifyStreamError.js +55 -0
- package/dist/observation/classifyStreamError.js.map +1 -0
- package/dist/observation/for_ObservationReconnectBackoff/given/a_backoff.d.ts +13 -0
- package/dist/observation/for_ObservationReconnectBackoff/given/a_backoff.d.ts.map +1 -0
- package/dist/observation/for_ObservationReconnectBackoff/given/a_backoff.js +25 -0
- package/dist/observation/for_ObservationReconnectBackoff/given/a_backoff.js.map +1 -0
- package/dist/observation/for_ObservationReconnectBackoff/given/a_scripted_stream.d.ts +27 -0
- package/dist/observation/for_ObservationReconnectBackoff/given/a_scripted_stream.d.ts.map +1 -0
- package/dist/observation/for_ObservationReconnectBackoff/given/a_scripted_stream.js +36 -0
- package/dist/observation/for_ObservationReconnectBackoff/given/a_scripted_stream.js.map +1 -0
- package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts +2 -1
- package/dist/projections/for_Graphs/given/a_discovered_graph.d.ts.map +1 -1
- package/dist/projections/for_Graphs/given/a_discovered_graph.js +3 -2
- package/dist/projections/for_Graphs/given/a_discovered_graph.js.map +1 -1
- package/dist/projections/for_Graphs/given/a_graph_with_views.d.ts +40 -0
- package/dist/projections/for_Graphs/given/a_graph_with_views.d.ts.map +1 -0
- package/dist/projections/for_Graphs/given/a_graph_with_views.js +80 -0
- package/dist/projections/for_Graphs/given/a_graph_with_views.js.map +1 -0
- package/dist/projections/for_Graphs/given/organization.d.ts +2 -1
- package/dist/projections/for_Graphs/given/organization.d.ts.map +1 -1
- package/dist/projections/for_Graphs/given/organization.js +3 -2
- package/dist/projections/for_Graphs/given/organization.js.map +1 -1
- package/dist/projections/graphs/Graphs.d.ts +5 -0
- package/dist/projections/graphs/Graphs.d.ts.map +1 -1
- package/dist/projections/graphs/Graphs.js +43 -0
- package/dist/projections/graphs/Graphs.js.map +1 -1
- package/dist/projections/graphs/IGraphs.d.ts +9 -2
- package/dist/projections/graphs/IGraphs.d.ts.map +1 -1
- package/dist/projections/graphs/index.d.ts +1 -0
- package/dist/projections/graphs/index.d.ts.map +1 -1
- package/dist/projections/graphs/index.js +1 -0
- package/dist/projections/graphs/index.js.map +1 -1
- package/dist/projections/graphs/views/AmbiguousDirection.d.ts +16 -0
- package/dist/projections/graphs/views/AmbiguousDirection.d.ts.map +1 -0
- package/dist/projections/graphs/views/AmbiguousDirection.js +21 -0
- package/dist/projections/graphs/views/AmbiguousDirection.js.map +1 -0
- package/dist/projections/graphs/views/DuplicateViewName.d.ts +16 -0
- package/dist/projections/graphs/views/DuplicateViewName.d.ts.map +1 -0
- package/dist/projections/graphs/views/DuplicateViewName.js +21 -0
- package/dist/projections/graphs/views/DuplicateViewName.js.map +1 -0
- package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.d.ts +17 -0
- package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.d.ts.map +1 -0
- package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.js +22 -0
- package/dist/projections/graphs/views/EdgeNotIncidentOnRoot.js.map +1 -0
- package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.d.ts +14 -0
- package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.d.ts.map +1 -0
- package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.js +19 -0
- package/dist/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.js.map +1 -0
- package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.d.ts +15 -0
- package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.d.ts.map +1 -0
- package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.js +20 -0
- package/dist/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.js.map +1 -0
- package/dist/projections/graphs/views/FollowsOptions.d.ts +16 -0
- package/dist/projections/graphs/views/FollowsOptions.d.ts.map +1 -0
- package/dist/projections/graphs/views/FollowsOptions.js +4 -0
- package/dist/projections/graphs/views/FollowsOptions.js.map +1 -0
- package/dist/projections/graphs/views/GraphEdgeDirection.d.ts +10 -0
- package/dist/projections/graphs/views/GraphEdgeDirection.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphEdgeDirection.js +13 -0
- package/dist/projections/graphs/views/GraphEdgeDirection.js.map +1 -0
- package/dist/projections/graphs/views/GraphView.d.ts +13 -0
- package/dist/projections/graphs/views/GraphView.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphView.js +4 -0
- package/dist/projections/graphs/views/GraphView.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewBuildResult.d.ts +15 -0
- package/dist/projections/graphs/views/GraphViewBuildResult.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewBuildResult.js +4 -0
- package/dist/projections/graphs/views/GraphViewBuildResult.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewCardinality.d.ts +10 -0
- package/dist/projections/graphs/views/GraphViewCardinality.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewCardinality.js +13 -0
- package/dist/projections/graphs/views/GraphViewCardinality.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinition.d.ts +15 -0
- package/dist/projections/graphs/views/GraphViewDefinition.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinition.js +4 -0
- package/dist/projections/graphs/views/GraphViewDefinition.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinitionBuilder.d.ts +30 -0
- package/dist/projections/graphs/views/GraphViewDefinitionBuilder.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinitionBuilder.js +259 -0
- package/dist/projections/graphs/views/GraphViewDefinitionBuilder.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinitionSerializer.d.ts +21 -0
- package/dist/projections/graphs/views/GraphViewDefinitionSerializer.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewDefinitionSerializer.js +77 -0
- package/dist/projections/graphs/views/GraphViewDefinitionSerializer.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewEdgeReference.d.ts +6 -0
- package/dist/projections/graphs/views/GraphViewEdgeReference.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewEdgeReference.js +4 -0
- package/dist/projections/graphs/views/GraphViewEdgeReference.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewMember.d.ts +8 -0
- package/dist/projections/graphs/views/GraphViewMember.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewMember.js +4 -0
- package/dist/projections/graphs/views/GraphViewMember.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewMemberKind.d.ts +12 -0
- package/dist/projections/graphs/views/GraphViewMemberKind.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewMemberKind.js +15 -0
- package/dist/projections/graphs/views/GraphViewMemberKind.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewMemberMetadata.d.ts +22 -0
- package/dist/projections/graphs/views/GraphViewMemberMetadata.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewMemberMetadata.js +4 -0
- package/dist/projections/graphs/views/GraphViewMemberMetadata.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewPropertyMember.d.ts +13 -0
- package/dist/projections/graphs/views/GraphViewPropertyMember.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewPropertyMember.js +4 -0
- package/dist/projections/graphs/views/GraphViewPropertyMember.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewReason.d.ts +33 -0
- package/dist/projections/graphs/views/GraphViewReason.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewReason.js +36 -0
- package/dist/projections/graphs/views/GraphViewReason.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewRelationMember.d.ts +21 -0
- package/dist/projections/graphs/views/GraphViewRelationMember.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewRelationMember.js +4 -0
- package/dist/projections/graphs/views/GraphViewRelationMember.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchema.d.ts +10 -0
- package/dist/projections/graphs/views/GraphViewSchema.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchema.js +4 -0
- package/dist/projections/graphs/views/GraphViewSchema.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchemaEdge.d.ts +14 -0
- package/dist/projections/graphs/views/GraphViewSchemaEdge.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchemaEdge.js +4 -0
- package/dist/projections/graphs/views/GraphViewSchemaEdge.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchemaNode.d.ts +10 -0
- package/dist/projections/graphs/views/GraphViewSchemaNode.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewSchemaNode.js +4 -0
- package/dist/projections/graphs/views/GraphViewSchemaNode.js.map +1 -0
- package/dist/projections/graphs/views/GraphViewSerializerOptions.d.ts +9 -0
- package/dist/projections/graphs/views/GraphViewSerializerOptions.d.ts.map +1 -0
- package/dist/projections/graphs/views/GraphViewSerializerOptions.js +4 -0
- package/dist/projections/graphs/views/GraphViewSerializerOptions.js.map +1 -0
- package/dist/projections/graphs/views/RecursiveView.d.ts +15 -0
- package/dist/projections/graphs/views/RecursiveView.d.ts.map +1 -0
- package/dist/projections/graphs/views/RecursiveView.js +20 -0
- package/dist/projections/graphs/views/RecursiveView.js.map +1 -0
- package/dist/projections/graphs/views/RelationTargetNotAView.d.ts +16 -0
- package/dist/projections/graphs/views/RelationTargetNotAView.d.ts.map +1 -0
- package/dist/projections/graphs/views/RelationTargetNotAView.js +21 -0
- package/dist/projections/graphs/views/RelationTargetNotAView.js.map +1 -0
- package/dist/projections/graphs/views/TargetLabelMismatch.d.ts +18 -0
- package/dist/projections/graphs/views/TargetLabelMismatch.d.ts.map +1 -0
- package/dist/projections/graphs/views/TargetLabelMismatch.js +23 -0
- package/dist/projections/graphs/views/TargetLabelMismatch.js.map +1 -0
- package/dist/projections/graphs/views/UnknownEdge.d.ts +16 -0
- package/dist/projections/graphs/views/UnknownEdge.d.ts.map +1 -0
- package/dist/projections/graphs/views/UnknownEdge.js +21 -0
- package/dist/projections/graphs/views/UnknownEdge.js.map +1 -0
- package/dist/projections/graphs/views/UnknownEdgeProperty.d.ts +17 -0
- package/dist/projections/graphs/views/UnknownEdgeProperty.d.ts.map +1 -0
- package/dist/projections/graphs/views/UnknownEdgeProperty.js +22 -0
- package/dist/projections/graphs/views/UnknownEdgeProperty.js.map +1 -0
- package/dist/projections/graphs/views/UnknownNodeProperty.d.ts +17 -0
- package/dist/projections/graphs/views/UnknownNodeProperty.d.ts.map +1 -0
- package/dist/projections/graphs/views/UnknownNodeProperty.js +22 -0
- package/dist/projections/graphs/views/UnknownNodeProperty.js.map +1 -0
- package/dist/projections/graphs/views/ViewIsAlsoSchema.d.ts +14 -0
- package/dist/projections/graphs/views/ViewIsAlsoSchema.d.ts.map +1 -0
- package/dist/projections/graphs/views/ViewIsAlsoSchema.js +19 -0
- package/dist/projections/graphs/views/ViewIsAlsoSchema.js.map +1 -0
- package/dist/projections/graphs/views/ViewOfMetadata.d.ts +8 -0
- package/dist/projections/graphs/views/ViewOfMetadata.d.ts.map +1 -0
- package/dist/projections/graphs/views/ViewOfMetadata.js +4 -0
- package/dist/projections/graphs/views/ViewOfMetadata.js.map +1 -0
- package/dist/projections/graphs/views/ViewOfOptions.d.ts +6 -0
- package/dist/projections/graphs/views/ViewOfOptions.d.ts.map +1 -0
- package/dist/projections/graphs/views/ViewOfOptions.js +4 -0
- package/dist/projections/graphs/views/ViewOfOptions.js.map +1 -0
- package/dist/projections/graphs/views/ViewRootNotANode.d.ts +16 -0
- package/dist/projections/graphs/views/ViewRootNotANode.d.ts.map +1 -0
- package/dist/projections/graphs/views/ViewRootNotANode.js +21 -0
- package/dist/projections/graphs/views/ViewRootNotANode.js.map +1 -0
- package/dist/projections/graphs/views/declareGraphViewMember.d.ts +17 -0
- package/dist/projections/graphs/views/declareGraphViewMember.d.ts.map +1 -0
- package/dist/projections/graphs/views/declareGraphViewMember.js +31 -0
- package/dist/projections/graphs/views/declareGraphViewMember.js.map +1 -0
- package/dist/projections/graphs/views/follows.d.ts +13 -0
- package/dist/projections/graphs/views/follows.d.ts.map +1 -0
- package/dist/projections/graphs/views/follows.js +24 -0
- package/dist/projections/graphs/views/follows.js.map +1 -0
- package/dist/projections/graphs/views/fromEdge.d.ts +10 -0
- package/dist/projections/graphs/views/fromEdge.d.ts.map +1 -0
- package/dist/projections/graphs/views/fromEdge.js +15 -0
- package/dist/projections/graphs/views/fromEdge.js.map +1 -0
- package/dist/projections/graphs/views/index.d.ts +41 -0
- package/dist/projections/graphs/views/index.d.ts.map +1 -0
- package/dist/projections/graphs/views/index.js +28 -0
- package/dist/projections/graphs/views/index.js.map +1 -0
- package/dist/projections/graphs/views/viewKey.d.ts +8 -0
- package/dist/projections/graphs/views/viewKey.d.ts.map +1 -0
- package/dist/projections/graphs/views/viewKey.js +13 -0
- package/dist/projections/graphs/views/viewKey.js.map +1 -0
- package/dist/projections/graphs/views/viewOf.d.ts +22 -0
- package/dist/projections/graphs/views/viewOf.d.ts.map +1 -0
- package/dist/projections/graphs/views/viewOf.js +41 -0
- package/dist/projections/graphs/views/viewOf.js.map +1 -0
- package/dist/projections/graphs/views/viewProperty.d.ts +9 -0
- package/dist/projections/graphs/views/viewProperty.d.ts.map +1 -0
- package/dist/projections/graphs/views/viewProperty.js +14 -0
- package/dist/projections/graphs/views/viewProperty.js.map +1 -0
- package/dist/reactors/Reactors.d.ts +15 -5
- package/dist/reactors/Reactors.d.ts.map +1 -1
- package/dist/reactors/Reactors.js +95 -18
- package/dist/reactors/Reactors.js.map +1 -1
- package/dist/reactors/for_Reactors/when_reconnecting_the_observation_stream/given/a_reactor_whose_stream_ends.d.ts +26 -0
- package/dist/reactors/for_Reactors/when_reconnecting_the_observation_stream/given/a_reactor_whose_stream_ends.d.ts.map +1 -0
- package/dist/reactors/for_Reactors/when_reconnecting_the_observation_stream/given/a_reactor_whose_stream_ends.js +64 -0
- package/dist/reactors/for_Reactors/when_reconnecting_the_observation_stream/given/a_reactor_whose_stream_ends.js.map +1 -0
- package/dist/reducers/Reducers.d.ts +11 -5
- package/dist/reducers/Reducers.d.ts.map +1 -1
- package/dist/reducers/Reducers.js +93 -19
- package/dist/reducers/Reducers.js.map +1 -1
- package/dist/reducers/for_Reducers/when_reconnecting_the_observation_stream/given/a_reducer_whose_stream_ends.d.ts +25 -0
- package/dist/reducers/for_Reducers/when_reconnecting_the_observation_stream/given/a_reducer_whose_stream_ends.d.ts.map +1 -0
- package/dist/reducers/for_Reducers/when_reconnecting_the_observation_stream/given/a_reducer_whose_stream_ends.js +70 -0
- package/dist/reducers/for_Reducers/when_reconnecting_the_observation_stream/given/a_reducer_whose_stream_ends.js.map +1 -0
- package/dist/testing/InProcessAppendMetadata.d.ts +30 -0
- package/dist/testing/InProcessAppendMetadata.d.ts.map +1 -0
- package/dist/testing/InProcessAppendMetadata.js +107 -0
- package/dist/testing/InProcessAppendMetadata.js.map +1 -0
- package/dist/testing/InProcessBatchAppend.d.ts +62 -0
- package/dist/testing/InProcessBatchAppend.d.ts.map +1 -0
- package/dist/testing/InProcessBatchAppend.js +131 -0
- package/dist/testing/InProcessBatchAppend.js.map +1 -0
- package/dist/testing/InProcessEventPayload.d.ts +23 -0
- package/dist/testing/InProcessEventPayload.d.ts.map +1 -0
- package/dist/testing/InProcessEventPayload.js +94 -0
- package/dist/testing/InProcessEventPayload.js.map +1 -0
- package/dist/testing/InProcessEventReadCriteria.d.ts +9 -0
- package/dist/testing/InProcessEventReadCriteria.d.ts.map +1 -0
- package/dist/testing/InProcessEventReadCriteria.js +4 -0
- package/dist/testing/InProcessEventReadCriteria.js.map +1 -0
- package/dist/testing/InProcessEventReadFilter.d.ts +14 -0
- package/dist/testing/InProcessEventReadFilter.d.ts.map +1 -0
- package/dist/testing/InProcessEventReadFilter.js +31 -0
- package/dist/testing/InProcessEventReadFilter.js.map +1 -0
- package/dist/testing/InProcessEventSequence.d.ts +8 -5
- package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
- package/dist/testing/InProcessEventSequence.js +59 -275
- package/dist/testing/InProcessEventSequence.js.map +1 -1
- package/dist/testing/InProcessEventSequenceEnvironment.d.ts +13 -0
- package/dist/testing/InProcessEventSequenceEnvironment.d.ts.map +1 -0
- package/dist/testing/InProcessEventSequenceEnvironment.js +4 -0
- package/dist/testing/InProcessEventSequenceEnvironment.js.map +1 -0
- package/dist/testing/InProcessSingleAppend.d.ts +34 -0
- package/dist/testing/InProcessSingleAppend.d.ts.map +1 -0
- package/dist/testing/InProcessSingleAppend.js +95 -0
- package/dist/testing/InProcessSingleAppend.js.map +1 -0
- package/dist/testing/projections/ProjectionCapabilities.d.ts +0 -8
- package/dist/testing/projections/ProjectionCapabilities.d.ts.map +1 -1
- package/dist/testing/projections/ProjectionCapabilities.js +21 -312
- package/dist/testing/projections/ProjectionCapabilities.js.map +1 -1
- package/dist/testing/projections/ProjectionCapabilityReject.d.ts +3 -0
- package/dist/testing/projections/ProjectionCapabilityReject.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionCapabilityReject.js +4 -0
- package/dist/testing/projections/ProjectionCapabilityReject.js.map +1 -0
- package/dist/testing/projections/ProjectionCapabilityReporter.d.ts +12 -0
- package/dist/testing/projections/ProjectionCapabilityReporter.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionCapabilityReporter.js +33 -0
- package/dist/testing/projections/ProjectionCapabilityReporter.js.map +1 -0
- package/dist/testing/projections/ProjectionDefinitionCapabilities.d.ts +11 -0
- package/dist/testing/projections/ProjectionDefinitionCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionDefinitionCapabilities.js +45 -0
- package/dist/testing/projections/ProjectionDefinitionCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionEventSchemaResolver.d.ts +13 -0
- package/dist/testing/projections/ProjectionEventSchemaResolver.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionEventSchemaResolver.js +22 -0
- package/dist/testing/projections/ProjectionEventSchemaResolver.js.map +1 -0
- package/dist/testing/projections/ProjectionExpressionCapabilities.d.ts +19 -0
- package/dist/testing/projections/ProjectionExpressionCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionExpressionCapabilities.js +103 -0
- package/dist/testing/projections/ProjectionExpressionCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionInitialValueCapabilities.d.ts +16 -0
- package/dist/testing/projections/ProjectionInitialValueCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionInitialValueCapabilities.js +72 -0
- package/dist/testing/projections/ProjectionInitialValueCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionMappingCapabilities.d.ts +21 -0
- package/dist/testing/projections/ProjectionMappingCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionMappingCapabilities.js +86 -0
- package/dist/testing/projections/ProjectionMappingCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionMappingValidation.d.ts +9 -0
- package/dist/testing/projections/ProjectionMappingValidation.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionMappingValidation.js +4 -0
- package/dist/testing/projections/ProjectionMappingValidation.js.map +1 -0
- package/dist/testing/projections/ProjectionReadModelCapabilities.d.ts +11 -0
- package/dist/testing/projections/ProjectionReadModelCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionReadModelCapabilities.js +40 -0
- package/dist/testing/projections/ProjectionReadModelCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionRootCapabilities.d.ts +20 -0
- package/dist/testing/projections/ProjectionRootCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionRootCapabilities.js +73 -0
- package/dist/testing/projections/ProjectionRootCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionScalarConverter.d.ts +21 -0
- package/dist/testing/projections/ProjectionScalarConverter.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionScalarConverter.js +105 -0
- package/dist/testing/projections/ProjectionScalarConverter.js.map +1 -0
- package/dist/testing/projections/ProjectionSchemaCapabilities.d.ts +26 -0
- package/dist/testing/projections/ProjectionSchemaCapabilities.d.ts.map +1 -0
- package/dist/testing/projections/ProjectionSchemaCapabilities.js +109 -0
- package/dist/testing/projections/ProjectionSchemaCapabilities.js.map +1 -0
- package/dist/testing/projections/ProjectionValueConverter.d.ts +5 -0
- package/dist/testing/projections/ProjectionValueConverter.d.ts.map +1 -1
- package/dist/testing/projections/ProjectionValueConverter.js +36 -84
- package/dist/testing/projections/ProjectionValueConverter.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/DecoratorType.d.ts +3 -1
- package/dist/types/DecoratorType.d.ts.map +1 -1
- package/dist/types/DecoratorType.js +2 -0
- package/dist/types/DecoratorType.js.map +1 -1
- package/for_ChronicleClient/when_reconnecting/and_an_observation_stream_lost_its_session.spec.ts +212 -0
- package/observation/ObservationReconnectBackoff.ts +109 -0
- package/observation/ObservationStreamOutcome.ts +12 -0
- package/observation/classifyStreamError.ts +67 -0
- package/observation/for_ObservationReconnectBackoff/given/a_backoff.ts +29 -0
- package/observation/for_ObservationReconnectBackoff/given/a_scripted_stream.ts +52 -0
- package/observation/for_ObservationReconnectBackoff/when_a_stream_delivered_before_it_ended.spec.ts +23 -0
- package/observation/for_ObservationReconnectBackoff/when_a_stream_stayed_open_before_it_ended.spec.ts +25 -0
- package/observation/for_ObservationReconnectBackoff/when_jittering_the_delay.spec.ts +24 -0
- package/observation/for_ObservationReconnectBackoff/when_streams_keep_ending_without_working.spec.ts +24 -0
- package/observation/for_ObservationReconnectBackoff/when_the_base_delay_is_not_positive.spec.ts +18 -0
- package/observation/for_ObservationReconnectBackoff/when_the_settings_are_not_finite.spec.ts +32 -0
- package/observation/for_ObservationReconnectBackoff/when_using_the_defaults.spec.ts +29 -0
- package/observation/for_classifyStreamError/when_classifying_a_stream_error.spec.ts +36 -0
- package/package.json +2 -2
- package/projections/for_Graphs/given/a_discovered_graph.ts +3 -2
- package/projections/for_Graphs/given/a_graph_with_views.ts +91 -0
- package/projections/for_Graphs/given/organization.ts +3 -2
- package/projections/for_Graphs/given/organization_with_views.fixture.ts +129 -0
- package/projections/for_Graphs/when_building_graph_views.spec.ts +218 -0
- package/projections/for_Graphs/when_declaring_an_invalid_graph_view.spec.ts +229 -0
- package/projections/for_Graphs/when_declaring_graph_views.standard.spec.ts +49 -0
- package/projections/for_Graphs/when_discovering_graph_views.spec.ts +58 -0
- package/projections/graphs/Graphs.ts +44 -0
- package/projections/graphs/IGraphs.ts +10 -2
- package/projections/graphs/index.ts +1 -0
- package/projections/graphs/views/AmbiguousDirection.ts +23 -0
- package/projections/graphs/views/DuplicateViewName.ts +23 -0
- package/projections/graphs/views/EdgeNotIncidentOnRoot.ts +24 -0
- package/projections/graphs/views/EdgePropertyViewNotUsedAsTarget.ts +21 -0
- package/projections/graphs/views/EdgePropertyViewSharedAcrossEdges.ts +22 -0
- package/projections/graphs/views/FollowsOptions.ts +20 -0
- package/projections/graphs/views/GraphEdgeDirection.ts +13 -0
- package/projections/graphs/views/GraphView.ts +18 -0
- package/projections/graphs/views/GraphViewBuildResult.ts +19 -0
- package/projections/graphs/views/GraphViewCardinality.ts +13 -0
- package/projections/graphs/views/GraphViewDefinition.ts +20 -0
- package/projections/graphs/views/GraphViewDefinitionBuilder.ts +322 -0
- package/projections/graphs/views/GraphViewDefinitionSerializer.ts +90 -0
- package/projections/graphs/views/GraphViewEdgeReference.ts +8 -0
- package/projections/graphs/views/GraphViewMember.ts +11 -0
- package/projections/graphs/views/GraphViewMemberKind.ts +16 -0
- package/projections/graphs/views/GraphViewMemberMetadata.ts +31 -0
- package/projections/graphs/views/GraphViewPropertyMember.ts +18 -0
- package/projections/graphs/views/GraphViewReason.ts +47 -0
- package/projections/graphs/views/GraphViewRelationMember.ts +29 -0
- package/projections/graphs/views/GraphViewSchema.ts +14 -0
- package/projections/graphs/views/GraphViewSchemaEdge.ts +20 -0
- package/projections/graphs/views/GraphViewSchemaNode.ts +14 -0
- package/projections/graphs/views/GraphViewSerializerOptions.ts +11 -0
- package/projections/graphs/views/RecursiveView.ts +22 -0
- package/projections/graphs/views/RelationTargetNotAView.ts +23 -0
- package/projections/graphs/views/TargetLabelMismatch.ts +25 -0
- package/projections/graphs/views/UnknownEdge.ts +23 -0
- package/projections/graphs/views/UnknownEdgeProperty.ts +24 -0
- package/projections/graphs/views/UnknownNodeProperty.ts +24 -0
- package/projections/graphs/views/ViewIsAlsoSchema.ts +21 -0
- package/projections/graphs/views/ViewOfMetadata.ts +11 -0
- package/projections/graphs/views/ViewOfOptions.ts +8 -0
- package/projections/graphs/views/ViewRootNotANode.ts +23 -0
- package/projections/graphs/views/declareGraphViewMember.ts +36 -0
- package/projections/graphs/views/follows.ts +28 -0
- package/projections/graphs/views/fromEdge.ts +17 -0
- package/projections/graphs/views/index.ts +43 -0
- package/projections/graphs/views/viewKey.ts +15 -0
- package/projections/graphs/views/viewOf.ts +50 -0
- package/projections/graphs/views/viewProperty.ts +16 -0
- package/reactors/Reactors.ts +101 -18
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/and_a_handler_failed_with_a_lost_session.spec.ts +32 -0
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/and_a_replaced_stream_fails_late.spec.ts +28 -0
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/and_a_stream_delivered_before_it_ended.spec.ts +24 -0
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/and_a_stream_stayed_open_before_it_ended.spec.ts +23 -0
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/and_it_is_disposed_while_waiting_to_reopen.spec.ts +27 -0
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/and_streams_keep_ending_without_working.spec.ts +24 -0
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/and_the_client_reconnected_after_streams_kept_ending.spec.ts +24 -0
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/and_the_client_reconnected_while_waiting_to_reopen.spec.ts +25 -0
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/and_the_kernel_lost_the_session.spec.ts +24 -0
- package/reactors/for_Reactors/when_reconnecting_the_observation_stream/given/a_reactor_whose_stream_ends.ts +69 -0
- package/reducers/Reducers.ts +99 -19
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/and_a_reducer_failed_with_a_lost_session.spec.ts +33 -0
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/and_a_replaced_stream_fails_late.spec.ts +28 -0
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/and_a_stream_delivered_before_it_ended.spec.ts +24 -0
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/and_a_stream_stayed_open_before_it_ended.spec.ts +23 -0
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/and_it_is_disposed_while_waiting_to_reopen.spec.ts +27 -0
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/and_streams_keep_ending_without_working.spec.ts +24 -0
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/and_the_client_reconnected_after_streams_kept_ending.spec.ts +24 -0
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/and_the_client_reconnected_while_waiting_to_reopen.spec.ts +25 -0
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/and_the_kernel_lost_the_session.spec.ts +24 -0
- package/reducers/for_Reducers/when_reconnecting_the_observation_stream/given/a_reducer_whose_stream_ends.ts +69 -0
- package/testing/InProcessAppendMetadata.ts +119 -0
- package/testing/InProcessBatchAppend.ts +142 -0
- package/testing/InProcessEventPayload.ts +100 -0
- package/testing/InProcessEventReadCriteria.ts +11 -0
- package/testing/InProcessEventReadFilter.ts +37 -0
- package/testing/InProcessEventSequence.ts +63 -257
- package/testing/InProcessEventSequenceEnvironment.ts +16 -0
- package/testing/InProcessSingleAppend.ts +99 -0
- package/testing/for_InProcessEventSequence/when_preserving_validation_and_commit_order.spec.ts +95 -0
- package/testing/projections/ProjectionCapabilities.ts +23 -279
- package/testing/projections/ProjectionCapabilityReject.ts +5 -0
- package/testing/projections/ProjectionCapabilityReporter.ts +31 -0
- package/testing/projections/ProjectionDefinitionCapabilities.ts +45 -0
- package/testing/projections/ProjectionEventSchemaResolver.ts +23 -0
- package/testing/projections/ProjectionExpressionCapabilities.ts +101 -0
- package/testing/projections/ProjectionInitialValueCapabilities.ts +73 -0
- package/testing/projections/ProjectionMappingCapabilities.ts +85 -0
- package/testing/projections/ProjectionMappingValidation.ts +12 -0
- package/testing/projections/ProjectionReadModelCapabilities.ts +42 -0
- package/testing/projections/ProjectionRootCapabilities.ts +75 -0
- package/testing/projections/ProjectionScalarConverter.ts +106 -0
- package/testing/projections/ProjectionSchemaCapabilities.ts +112 -0
- package/testing/projections/ProjectionValueConverter.ts +37 -76
- package/testing/projections/for_ProjectionCapabilities/when_reporting_the_first_unsupported_operation.spec.ts +74 -0
- package/testing/projections/for_ProjectionValueConverter/when_converting_structured_and_scalar_values.spec.ts +64 -0
- package/types/DecoratorType.ts +4 -1
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
import { AutoMap } from '@cratis/chronicle.contracts';
|
|
4
|
+
import { eventContractPath } from '../../projections/eventContractPath.js';
|
|
5
|
+
import { ProjectionArithmetic } from './ProjectionArithmetic.js';
|
|
6
|
+
import { ProjectionMappingCapabilities } from './ProjectionMappingCapabilities.js';
|
|
7
|
+
/** Validates root subscriptions and accumulator interactions before child traversal. */
|
|
8
|
+
export class ProjectionRootCapabilities {
|
|
9
|
+
schema;
|
|
10
|
+
wire;
|
|
11
|
+
reject;
|
|
12
|
+
from;
|
|
13
|
+
removedWith;
|
|
14
|
+
constructor(schema, wire, reject) {
|
|
15
|
+
this.schema = schema;
|
|
16
|
+
this.wire = wire;
|
|
17
|
+
this.reject = reject;
|
|
18
|
+
this.from = wire.From ?? [];
|
|
19
|
+
this.removedWith = wire.RemovedWith ?? [];
|
|
20
|
+
}
|
|
21
|
+
validate(resolver) {
|
|
22
|
+
this.checkOverlaps();
|
|
23
|
+
const accumulators = new Set(this.from.flatMap(entry => Object.entries(entry.Value.Properties ?? {})
|
|
24
|
+
.filter(([, expression]) => ProjectionArithmetic.isArithmetic(expression)).map(([property]) => property)));
|
|
25
|
+
this.checkAccumulatorChildren(accumulators);
|
|
26
|
+
for (const entry of this.from)
|
|
27
|
+
this.checkClearedAccumulators(entry, accumulators);
|
|
28
|
+
const mappings = new ProjectionMappingCapabilities(this.schema, this.reject, accumulators);
|
|
29
|
+
for (const entry of [...this.from, ...this.removedWith])
|
|
30
|
+
this.subscription(entry, resolver, mappings);
|
|
31
|
+
}
|
|
32
|
+
checkOverlaps() {
|
|
33
|
+
for (const entry of this.from) {
|
|
34
|
+
if (this.removedWith.some(removal => removal.Key.Id === entry.Key.Id)) {
|
|
35
|
+
this.reject(eventContractPath('From', entry.Key), 'events subscribed through both From and RemovedWith require a kernel-backed test (ChronicleKernelScenario / live kernel)');
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
checkAccumulatorChildren(accumulators) {
|
|
40
|
+
if (accumulators.size && Object.keys(this.wire.Children ?? {}).length) {
|
|
41
|
+
this.reject('Children', 'root arithmetic combined with children requires a kernel-backed test');
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
checkClearedAccumulators(entry, accumulators) {
|
|
45
|
+
for (const [property, expression] of Object.entries(entry.Value.Properties ?? {})) {
|
|
46
|
+
if (expression === '$null' && accumulators.has(property)) {
|
|
47
|
+
this.reject(`${eventContractPath('From', entry.Key)}.Properties.${property}`, 'clearing an arithmetic accumulator requires a kernel-backed test; the kernel rejects arithmetic on a present null');
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
subscription(entry, resolver, mappings) {
|
|
52
|
+
const section = this.from.includes(entry) ? 'From' : 'RemovedWith';
|
|
53
|
+
const path = eventContractPath(section, entry.Key);
|
|
54
|
+
const eventSchema = resolver.require(entry.Key, path);
|
|
55
|
+
if (entry.Value.Key !== '$eventSourceId')
|
|
56
|
+
this.reject(`${path}.Key`, 'only $eventSourceId keys are supported');
|
|
57
|
+
if (entry.Value.ParentKey)
|
|
58
|
+
this.reject(`${path}.ParentKey`, 'parent keys require a kernel-backed test');
|
|
59
|
+
if (section === 'RemovedWith')
|
|
60
|
+
return;
|
|
61
|
+
this.properties(entry, eventSchema, path, mappings);
|
|
62
|
+
}
|
|
63
|
+
properties(entry, eventSchema, path, mappings) {
|
|
64
|
+
const properties = entry.Value.Properties ?? {};
|
|
65
|
+
for (const [property, expression] of Object.entries(properties)) {
|
|
66
|
+
mappings.check({ eventSchema, destination: property, expression, path: `${path}.Properties.${property}` });
|
|
67
|
+
}
|
|
68
|
+
if (this.wire.AutoMap !== AutoMap.Disabled && !ProjectionArithmetic.suppressesAutoMap(properties)) {
|
|
69
|
+
mappings.autoMap(eventSchema, properties, this.wire.NoAutoMapProperties ?? [], path);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=ProjectionRootCapabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionRootCapabilities.js","sourceRoot":"","sources":["../../../testing/projections/ProjectionRootCapabilities.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,EAAE,OAAO,EAAE,MAAM,6BAA6B,CAAC;AAEtD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAE3E,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAGjE,OAAO,EAAE,6BAA6B,EAAE,MAAM,oCAAoC,CAAC;AAEnF,wFAAwF;AACxF,MAAM,OAAO,0BAA0B;IAIN,MAAM;IAA+B,IAAI;IAA4C,MAAM;IAH/G,IAAI,CAAe;IACnB,WAAW,CAAsB;IAE1C,YAA6B,MAAkB,EAAmB,IAA6B,EAAmB,MAAkC;sBAAvH,MAAM;oBAA+B,IAAI;sBAA4C,MAAM;QACpH,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,IAAoB,IAAI,EAAE,CAAC;QAC5C,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC,WAAkC,IAAI,EAAE,CAAC;IACrE,CAAC;IAED,QAAQ,CAAC,QAAuC;QAC5C,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,MAAM,Y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AA0C,CAAC,CAAC;QACxG,IAAI,OAAO,KAAK,aAAa;YAAE,OAAO;QACtC,IAAI,CAAC,UAAU,CAAC,KAAmB,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,CAAC,CAAC;IACtE,CAAC;IAEO,UAAU,CAAC,KAAiB,EAAE,WAAuB,EAAE,IAAY,EAAE,QAAuC;QAChH,MAAM,UAAU,GAAG,KAAK,CAAC,KAAK,CAAC,UAAU,IAAI,EAAE,CAAC;QAChD,KAAK,MAAM,CAAC,QAAQ,EAAE,UAAU,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,EAAE,CAAC;YAC9D,QAAQ,CAAC,KAAK,CAAC,EAAE,WAAW,EAAE,WAAW,EAAE,QAAQ,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,IAAI,eAAe,QAAQ,EAAE,EAAE,CAAC,CAAC;QAC/G,CAAC;QACD,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,KAAK,OAAO,CAAC,QAAQ,IAAI,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,UAAU,CAAC,EAAE,CAAC;YAChG,QAAQ,CAAC,OAAO,CAAC,WAAW,EAAE,UAAU,EAAE,IAAI,CAAC,IAAI,CAAC,mBAA+B,IAAI,EAAE,EAAE,IAAI,CAAC,CAAC;QACrG,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { JsonSchema } from '../../schemas/JsonSchema.js';
|
|
2
|
+
/** Scalar conversions shared by schema-bound input and expression evaluation. */
|
|
3
|
+
export declare class ProjectionScalarConverter {
|
|
4
|
+
static convert(value: unknown, schema: JsonSchema, eventContent: boolean): unknown;
|
|
5
|
+
static checkNumber(number: number, schema: JsonSchema): void;
|
|
6
|
+
private static invalidInteger;
|
|
7
|
+
private static outsideBounds;
|
|
8
|
+
private static boolean;
|
|
9
|
+
private static booleanText;
|
|
10
|
+
private static number;
|
|
11
|
+
private static numericText;
|
|
12
|
+
private static dateTime;
|
|
13
|
+
private static utcDateTime;
|
|
14
|
+
private static utcDateTimeText;
|
|
15
|
+
private static stringSchema;
|
|
16
|
+
private static schemaString;
|
|
17
|
+
private static checkEventString;
|
|
18
|
+
private static string;
|
|
19
|
+
private static guid;
|
|
20
|
+
}
|
|
21
|
+
//# sourceMappingURL=ProjectionScalarConverter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionScalarConverter.d.ts","sourceRoot":"","sources":["../../../testing/projections/ProjectionScalarConverter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAE9D,iFAAiF;AACjF,qBAAa,yBAAyB;IAClC,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,EAAE,OAAO,GAAG,OAAO,CAKjF;IAED,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAI3D;IAED,OAAO,CAAC,MAAM,CAAC,cAAc;IAQ7B,OAAO,CAAC,MAAM,CAAC,aAAa;IAI5B,OAAO,CAAC,MAAM,CAAC,OAAO;IAMtB,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B,OAAO,CAAC,MAAM,CAAC,MAAM;IAYrB,OAAO,CAAC,MAAM,CAAC,WAAW;IAK1B,OAAO,CAAC,MAAM,CAAC,QAAQ;IAQvB,OAAO,CAAC,MAAM,CAAC,WAAW;IAO1B,OAAO,CAAC,MAAM,CAAC,eAAe;IAI9B,OAAO,CAAC,MAAM,CAAC,YAAY;IAI3B,OAAO,CAAC,MAAM,CAAC,YAAY;IAK3B,OAAO,CAAC,MAAM,CAAC,gBAAgB;IAM/B,OAAO,CAAC,MAAM,CAAC,MAAM;IAMrB,OAAO,CAAC,MAAM,CAAC,IAAI;CAMtB"}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** Scalar conversions shared by schema-bound input and expression evaluation. */
|
|
4
|
+
export class ProjectionScalarConverter {
|
|
5
|
+
static convert(value, schema, eventContent) {
|
|
6
|
+
if (schema.type === 'boolean')
|
|
7
|
+
return this.boolean(value, eventContent);
|
|
8
|
+
if (schema.type === 'number' || schema.type === 'integer')
|
|
9
|
+
return this.number(value, schema, eventContent);
|
|
10
|
+
if (schema.format === 'date-time')
|
|
11
|
+
return this.dateTime(value);
|
|
12
|
+
return this.schemaString(value, schema, eventContent);
|
|
13
|
+
}
|
|
14
|
+
static checkNumber(number, schema) {
|
|
15
|
+
if (!Number.isFinite(number) || this.invalidInteger(number, schema)) {
|
|
16
|
+
throw new RangeError(`Projection numeric value '${number}' is outside the supported ${schema.type}/${schema.format ?? 'double'} range.`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
static invalidInteger(number, schema) {
|
|
20
|
+
if (schema.type !== 'integer')
|
|
21
|
+
return false;
|
|
22
|
+
if (!Number.isSafeInteger(number))
|
|
23
|
+
return true;
|
|
24
|
+
if (schema.format === 'int32')
|
|
25
|
+
return this.outsideBounds(number, [-2147483648, 2147483647]);
|
|
26
|
+
if (schema.format === 'uint32')
|
|
27
|
+
return this.outsideBounds(number, [0, 4294967295]);
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
static outsideBounds(number, [minimum, maximum]) {
|
|
31
|
+
return number < minimum || number > maximum;
|
|
32
|
+
}
|
|
33
|
+
static boolean(value, eventContent) {
|
|
34
|
+
if (typeof value === 'boolean')
|
|
35
|
+
return value;
|
|
36
|
+
if (!eventContent && this.booleanText(value))
|
|
37
|
+
return value.toLowerCase() === 'true';
|
|
38
|
+
throw new RangeError(`Projection boolean value '${String(value)}' requires a kernel-backed test (ChronicleKernelScenario / live kernel).`);
|
|
39
|
+
}
|
|
40
|
+
static booleanText(value) {
|
|
41
|
+
return typeof value === 'string' && /^(true|false)$/i.test(value);
|
|
42
|
+
}
|
|
43
|
+
static number(value, schema, eventContent) {
|
|
44
|
+
if (eventContent && typeof value !== 'number') {
|
|
45
|
+
throw new RangeError(`Projection event numeric value '${String(value)}' must be a JSON number.`);
|
|
46
|
+
}
|
|
47
|
+
if (typeof value !== 'number' && !this.numericText(value, schema)) {
|
|
48
|
+
throw new RangeError(`Projection numeric value '${String(value)}' is not supported by ${schema.type}/${schema.format ?? 'double'}.`);
|
|
49
|
+
}
|
|
50
|
+
const number = typeof value === 'number' ? value : Number(value);
|
|
51
|
+
this.checkNumber(number, schema);
|
|
52
|
+
return number;
|
|
53
|
+
}
|
|
54
|
+
static numericText(value, schema) {
|
|
55
|
+
if (typeof value !== 'string')
|
|
56
|
+
return false;
|
|
57
|
+
return schema.type === 'integer' ? /^[+-]?\d+$/.test(value) : /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(value);
|
|
58
|
+
}
|
|
59
|
+
static dateTime(value) {
|
|
60
|
+
if (value === '0001-01-01T00:00:00')
|
|
61
|
+
return value; // Kernel default for a missing DateTime member.
|
|
62
|
+
if (!this.utcDateTime(value)) {
|
|
63
|
+
throw new RangeError(`Projection date-time value '${String(value)}' is outside the supported DateTime range or UTC ISO format.`);
|
|
64
|
+
}
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
static utcDateTime(value) {
|
|
68
|
+
// Date.parse accepts years beyond DateTime.MaxValue and normalizes invalid calendar dates.
|
|
69
|
+
if (!this.utcDateTimeText(value))
|
|
70
|
+
return false;
|
|
71
|
+
if (+value.slice(0, 4) < 1 || !Number.isFinite(Date.parse(value)))
|
|
72
|
+
return false;
|
|
73
|
+
return new Date(value).toISOString().slice(0, 19) === value.slice(0, 19);
|
|
74
|
+
}
|
|
75
|
+
static utcDateTimeText(value) {
|
|
76
|
+
return typeof value === 'string' && /^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/.test(value);
|
|
77
|
+
}
|
|
78
|
+
static stringSchema(schema) {
|
|
79
|
+
return schema.type === 'string' || (Array.isArray(schema.type) && schema.type[0] === 'string');
|
|
80
|
+
}
|
|
81
|
+
static schemaString(value, schema, eventContent) {
|
|
82
|
+
if (eventContent && this.stringSchema(schema))
|
|
83
|
+
this.checkEventString(value);
|
|
84
|
+
return this.string(value, schema);
|
|
85
|
+
}
|
|
86
|
+
static checkEventString(value) {
|
|
87
|
+
if (typeof value !== 'string') {
|
|
88
|
+
throw new RangeError(`Projection event string value '${String(value)}' must be a JSON string.`);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
static string(value, schema) {
|
|
92
|
+
if (schema.format === 'guid' && typeof value === 'string')
|
|
93
|
+
return this.guid(value);
|
|
94
|
+
if (schema.type === 'string' && typeof value !== 'string')
|
|
95
|
+
return String(value);
|
|
96
|
+
return value;
|
|
97
|
+
}
|
|
98
|
+
static guid(value) {
|
|
99
|
+
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)) {
|
|
100
|
+
throw new RangeError(`Projection GUID value '${value}' requires a kernel-backed test (ChronicleKernelScenario / live kernel).`);
|
|
101
|
+
}
|
|
102
|
+
return value.toLowerCase();
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
//# sourceMappingURL=ProjectionScalarConverter.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionScalarConverter.js","sourceRoot":"","sources":["../../../testing/projections/ProjectionScalarConverter.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAIrG,iFAAiF;AACjF,MAAM,OAAO,yBAAyB;IAClC,MAAM,CAAC,OAAO,CAAC,KAAc,EAAE,MAAkB,EAAE,YAAqB;QACpE,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,YA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EAAE,CAAC;IAC/B,CAAC;CACJ"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import type { JsonSchema } from '../../schemas/JsonSchema.js';
|
|
2
|
+
import type { ProjectionCapabilityReject } from './ProjectionCapabilityReject.js';
|
|
3
|
+
/** Schema boundaries shared by root, join, and child mappings. */
|
|
4
|
+
export declare class ProjectionSchemaCapabilities {
|
|
5
|
+
static numeric(schema: JsonSchema): boolean;
|
|
6
|
+
static compatible(source: JsonSchema, target: JsonSchema): boolean;
|
|
7
|
+
static check(schema: JsonSchema, path: string, reject: ProjectionCapabilityReject): void;
|
|
8
|
+
static checkProtection(schema: JsonSchema, path: string, reject: ProjectionCapabilityReject): void;
|
|
9
|
+
static outsideIntegerRange(value: number, schema: JsonSchema): boolean;
|
|
10
|
+
private static doubleFormat;
|
|
11
|
+
private static integer;
|
|
12
|
+
private static sameSchema;
|
|
13
|
+
private static scalar;
|
|
14
|
+
private static nullableString;
|
|
15
|
+
private static checkIntegerWidth;
|
|
16
|
+
private static checkItems;
|
|
17
|
+
private static plainString;
|
|
18
|
+
private static textTarget;
|
|
19
|
+
private static integerToNumber;
|
|
20
|
+
private static supportedType;
|
|
21
|
+
private static supportedFormat;
|
|
22
|
+
private static checkProtected;
|
|
23
|
+
private static checkProperties;
|
|
24
|
+
private static checkAdditionalProtection;
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=ProjectionSchemaCapabilities.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionSchemaCapabilities.d.ts","sourceRoot":"","sources":["../../../testing/projections/ProjectionSchemaCapabilities.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,iCAAiC,CAAC;AAElF,kEAAkE;AAClE,qBAAa,4BAA4B;IACrC,MAAM,CAAC,OAAO,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAG1C;IAED,MAAM,CAAC,UAAU,CAAC,MAAM,EAAE,UAAU,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAKjE;IAED,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,0BAA0B,GAAG,IAAI,CAQvF;IAED,MAAM,CAAC,eAAe,CAAC,MAAM,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,0BAA0B,GAAG,IAAI,CAKjG;IAED,MAAM,CAAC,mBAAmB,CAAC,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,OAAO,CAKrE;IAED,OAAO,CAAC,MAAM,CAAC,YAAY;IAI3B,OAAO,CAAC,MAAM,CAAC,OAAO;IAItB,OAAO,CAAC,MAAM,CAAC,UAAU;IAIzB,OAAO,CAAC,MAAM,CAAC,MAAM;IAIrB,OAAO,CAAC,MAAM,CAAC,cAAc;IAI7B,OAAO,CAAC,MAAM,CAAC,iBAAiB;IAIhC,OAAO,CAAC,MAAM,CAAC,UAAU;IAIzB,OAAO,CAAC,MAAM,CAAC,WAAW;IAI1B,OAAO,CAAC,MAAM,CAAC,UAAU;IAKzB,OAAO,CAAC,MAAM,CAAC,eAAe;IAK9B,OAAO,CAAC,MAAM,CAAC,aAAa;IAM5B,OAAO,CAAC,MAAM,CAAC,eAAe;IAM9B,OAAO,CAAC,MAAM,CAAC,cAAc;IAI7B,OAAO,CAAC,MAAM,CAAC,eAAe;IAI9B,OAAO,CAAC,MAAM,CAAC,yBAAyB;CAK3C"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
// Copyright (c) Cratis. All rights reserved.
|
|
2
|
+
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
/** Schema boundaries shared by root, join, and child mappings. */
|
|
4
|
+
export class ProjectionSchemaCapabilities {
|
|
5
|
+
static numeric(schema) {
|
|
6
|
+
if (schema.type === 'number')
|
|
7
|
+
return this.doubleFormat(schema);
|
|
8
|
+
return this.integer(schema);
|
|
9
|
+
}
|
|
10
|
+
static compatible(source, target) {
|
|
11
|
+
if (this.sameSchema(source, target))
|
|
12
|
+
return this.scalar(source);
|
|
13
|
+
if (this.plainString(source))
|
|
14
|
+
return this.textTarget(target);
|
|
15
|
+
if (source.type === 'string' && source.format === 'guid')
|
|
16
|
+
return this.plainString(target);
|
|
17
|
+
return this.integerToNumber(source, target);
|
|
18
|
+
}
|
|
19
|
+
static check(schema, path, reject) {
|
|
20
|
+
this.checkProtected(schema, path, reject);
|
|
21
|
+
if (!this.supportedType(schema.type) || !this.supportedFormat(schema)) {
|
|
22
|
+
reject(path, `schema type/format '${schema.type ?? 'unknown'}${schema.format ? `/${schema.format}` : ''}' requires a kernel-backed test`);
|
|
23
|
+
}
|
|
24
|
+
this.checkIntegerWidth(schema, path, reject);
|
|
25
|
+
this.checkItems(schema, path, reject);
|
|
26
|
+
if (schema.type === 'object')
|
|
27
|
+
this.checkProperties(schema, path, reject);
|
|
28
|
+
}
|
|
29
|
+
static checkProtection(schema, path, reject) {
|
|
30
|
+
this.checkProtected(schema, path, reject);
|
|
31
|
+
for (const [name, property] of Object.entries(schema.properties ?? {}))
|
|
32
|
+
this.checkProtection(property, `${path}.${name}`, reject);
|
|
33
|
+
if (schema.items)
|
|
34
|
+
this.checkProtection(schema.items, `${path}.items`, reject);
|
|
35
|
+
this.checkAdditionalProtection(schema, path, reject);
|
|
36
|
+
}
|
|
37
|
+
static outsideIntegerRange(value, schema) {
|
|
38
|
+
if (!Number.isSafeInteger(value))
|
|
39
|
+
return true;
|
|
40
|
+
if (schema.format === 'int32')
|
|
41
|
+
return value < -2147483648 || value > 2147483647;
|
|
42
|
+
if (schema.format === 'uint32')
|
|
43
|
+
return value < 0 || value > 4294967295;
|
|
44
|
+
return false;
|
|
45
|
+
}
|
|
46
|
+
static doubleFormat(schema) {
|
|
47
|
+
return !schema.format || schema.format === 'double';
|
|
48
|
+
}
|
|
49
|
+
static integer(schema) {
|
|
50
|
+
return schema.type === 'integer' && ['int32', 'uint32'].includes(schema.format ?? '');
|
|
51
|
+
}
|
|
52
|
+
static sameSchema(source, target) {
|
|
53
|
+
return JSON.stringify(source.type) === JSON.stringify(target.type) && source.format === target.format;
|
|
54
|
+
}
|
|
55
|
+
static scalar(schema) {
|
|
56
|
+
return schema.type !== 'object' && schema.type !== 'array';
|
|
57
|
+
}
|
|
58
|
+
static nullableString(type) {
|
|
59
|
+
return Array.isArray(type) && type[0] === 'string' && type[1] === 'null';
|
|
60
|
+
}
|
|
61
|
+
static checkIntegerWidth(schema, path, reject) {
|
|
62
|
+
if (schema.type === 'integer' && !this.numeric(schema))
|
|
63
|
+
reject(path, 'integer width requires a kernel-backed test');
|
|
64
|
+
}
|
|
65
|
+
static checkItems(schema, path, reject) {
|
|
66
|
+
if (schema.type === 'array' && schema.items)
|
|
67
|
+
this.check(schema.items, path, reject);
|
|
68
|
+
}
|
|
69
|
+
static plainString(schema) {
|
|
70
|
+
return schema.type === 'string' && !schema.format;
|
|
71
|
+
}
|
|
72
|
+
static textTarget(target) {
|
|
73
|
+
if (this.nullableString(target.type))
|
|
74
|
+
return true;
|
|
75
|
+
return this.numeric(target);
|
|
76
|
+
}
|
|
77
|
+
static integerToNumber(source, target) {
|
|
78
|
+
if (!this.integer(source))
|
|
79
|
+
return false;
|
|
80
|
+
return target.type === 'number' && this.numeric(target);
|
|
81
|
+
}
|
|
82
|
+
static supportedType(type) {
|
|
83
|
+
if (!type || type === 'null')
|
|
84
|
+
return false;
|
|
85
|
+
if (!Array.isArray(type))
|
|
86
|
+
return true;
|
|
87
|
+
return type.length === 2 && this.nullableString(type);
|
|
88
|
+
}
|
|
89
|
+
static supportedFormat(schema) {
|
|
90
|
+
if (!schema.format)
|
|
91
|
+
return true;
|
|
92
|
+
const types = { guid: 'string', 'date-time': 'string', double: 'number', int32: 'integer', uint32: 'integer' };
|
|
93
|
+
return Object.hasOwn(types, schema.format) && schema.type === types[schema.format];
|
|
94
|
+
}
|
|
95
|
+
static checkProtected(schema, path, reject) {
|
|
96
|
+
if (schema.compliance?.length || schema.security?.length)
|
|
97
|
+
reject(path, 'protected fields require a kernel-backed test');
|
|
98
|
+
}
|
|
99
|
+
static checkProperties(schema, path, reject) {
|
|
100
|
+
for (const property of Object.values(schema.properties ?? {}))
|
|
101
|
+
this.check(property, path, reject);
|
|
102
|
+
}
|
|
103
|
+
static checkAdditionalProtection(schema, path, reject) {
|
|
104
|
+
if (schema.additionalProperties && typeof schema.additionalProperties === 'object') {
|
|
105
|
+
this.checkProtection(schema.additionalProperties, `${path}.additionalProperties`, reject);
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
//# sourceMappingURL=ProjectionSchemaCapabilities.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProjectionSchemaCapabilities.js","sourceRoot":"","sources":["../../../testing/projections/ProjectionSchemaCapabilities.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAKrG,kEAAkE;AAClE,MAAM,OAAO,4BAA4B;IACrC,MAAM,CAAC,OAAO,CAAC,MAAkB;QAC7B,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ;YAAE,OAAO,IAAI,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC;IAChC,CAAC;IAED,MAAM,CAAC,UAAU,CAAC,MAAkB,EAAE,MAAkB;QACpD,IAAI,IAAI,CAAC,UAAU,CAAC,MAAM,EAAE,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QAChE,IAAI,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC;QAC7D,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,C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;QACzG,IAAI,MAAM,CAAC,oBAAoB,IAAI,OAAO,MAAM,CAAC,oBAAoB,KAAK,QAAQ,EAAE,CAAC;YACjF,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,oBAAoB,EAAE,GAAG,IAAI,uBAAuB,EAAE,MAAM,CAAC,CAAC;QAC9F,CAAC;IACL,CAAC;CACJ"}
|
|
@@ -9,5 +9,10 @@ export declare class ProjectionValueConverter {
|
|
|
9
9
|
static eventContent(content: unknown, schema: JsonSchema): Record<string, unknown>;
|
|
10
10
|
static convert(value: unknown, schema: JsonSchema, eventContent?: boolean, expression?: boolean): unknown;
|
|
11
11
|
static checkNumber(number: number, schema: JsonSchema): void;
|
|
12
|
+
private static isObject;
|
|
13
|
+
private static isConcept;
|
|
14
|
+
private static object;
|
|
15
|
+
private static array;
|
|
16
|
+
private static properties;
|
|
12
17
|
}
|
|
13
18
|
//# sourceMappingURL=ProjectionValueConverter.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectionValueConverter.d.ts","sourceRoot":"","sources":["../../../testing/projections/ProjectionValueConverter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;
|
|
1
|
+
{"version":3,"file":"ProjectionValueConverter.d.ts","sourceRoot":"","sources":["../../../testing/projections/ProjectionValueConverter.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,6BAA6B,CAAC;AAG9D,uGAAuG;AACvG,qBAAa,wBAAwB;IACjC,8FAA8F;IAC9F,MAAM,CAAC,YAAY,CAAC,MAAM,EAAE,UAAU,GAAG,OAAO,CAO/C;IAED,kGAAkG;IAClG,OAAO,CAAC,MAAM,CAAC,SAAS;IAKxB,uFAAuF;IACvF,MAAM,CAAC,YAAY,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAGjF;IAED,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,UAAU,EAAE,YAAY,UAAQ,EAAE,UAAU,UAAO,GAAG,OAAO,CASnG;IAED,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,UAAU,GAAG,IAAI,CAE3D;IAED,OAAO,CAAC,MAAM,CAAC,QAAQ;IAIvB,OAAO,CAAC,MAAM,CAAC,SAAS;IAKxB,OAAO,CAAC,MAAM,CAAC,MAAM;IAKrB,OAAO,CAAC,MAAM,CAAC,KAAK;IAIpB,OAAO,CAAC,MAAM,CAAC,UAAU;CAU5B"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Copyright (c) Cratis. All rights reserved.
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
|
+
import { ProjectionScalarConverter } from './ProjectionScalarConverter.js';
|
|
3
4
|
/** Converts values only in the numeric and scalar schema subset admitted by ProjectionCapabilities. */
|
|
4
5
|
export class ProjectionValueConverter {
|
|
5
6
|
/** Kernel JsonSchemaExtensions.GetDefaultValue: only nullable schemas have a null default. */
|
|
@@ -23,100 +24,51 @@ export class ProjectionValueConverter {
|
|
|
23
24
|
}
|
|
24
25
|
/** The kernel deserializes event JSON against its registered schema before mapping. */
|
|
25
26
|
static eventContent(content, schema) {
|
|
26
|
-
const serialized = content
|
|
27
|
-
|
|
28
|
-
const result = Object.create(null);
|
|
29
|
-
for (const [name, property] of Object.entries(schema.properties ?? {})) {
|
|
30
|
-
const source = this.sourceKey(serialized, name);
|
|
31
|
-
const value = source === undefined ? null : serialized[source];
|
|
32
|
-
if (value !== null && value !== undefined)
|
|
33
|
-
result[name] = this.convert(value, property, true, false);
|
|
34
|
-
else {
|
|
35
|
-
const fallback = this.defaultValue(property);
|
|
36
|
-
if (fallback !== null && fallback !== undefined)
|
|
37
|
-
result[name] = fallback;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
return result;
|
|
27
|
+
const serialized = this.isObject(content) ? content : {};
|
|
28
|
+
return this.properties(serialized, schema, true);
|
|
41
29
|
}
|
|
42
30
|
static convert(value, schema, eventContent = false, expression = true) {
|
|
43
31
|
if (value == null)
|
|
44
32
|
return null;
|
|
45
33
|
// Concept conversion belongs to expression evaluation, never schema-bound input deserialization.
|
|
46
|
-
if (expression &&
|
|
47
|
-
typeof value === 'object' && !Array.isArray(value) && Object.keys(value).length === 1 && 'value' in value) {
|
|
34
|
+
if (expression && this.isConcept(value, schema)) {
|
|
48
35
|
return this.convert(value.value, schema, eventContent, expression);
|
|
49
36
|
}
|
|
50
|
-
if (schema.type === 'object' &&
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
for (const [name, property] of Object.entries(schema.properties)) {
|
|
56
|
-
const source = this.sourceKey(input, name);
|
|
57
|
-
if (source !== undefined && input[source] != null)
|
|
58
|
-
result[name] = this.convert(input[source], property, eventContent, false);
|
|
59
|
-
else {
|
|
60
|
-
const fallback = this.defaultValue(property);
|
|
61
|
-
if (fallback !== null && fallback !== undefined)
|
|
62
|
-
result[name] = fallback;
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
return result;
|
|
66
|
-
}
|
|
67
|
-
if (schema.type === 'array' && Array.isArray(value)) {
|
|
68
|
-
return value.map(item => schema.items ? this.convert(item, schema.items, eventContent, false) : structuredClone(item));
|
|
69
|
-
}
|
|
70
|
-
if (schema.type === 'boolean') {
|
|
71
|
-
if (typeof value === 'boolean')
|
|
72
|
-
return value;
|
|
73
|
-
if (!eventContent && typeof value === 'string' && /^(true|false)$/i.test(value))
|
|
74
|
-
return value.toLowerCase() === 'true';
|
|
75
|
-
throw new RangeError(`Projection boolean value '${String(value)}' requires a kernel-backed test (ChronicleKernelScenario / live kernel).`);
|
|
76
|
-
}
|
|
77
|
-
if (schema.type === 'number' || schema.type === 'integer') {
|
|
78
|
-
if (eventContent && typeof value !== 'number') {
|
|
79
|
-
throw new RangeError(`Projection event numeric value '${String(value)}' must be a JSON number.`);
|
|
80
|
-
}
|
|
81
|
-
if (typeof value !== 'number' && (typeof value !== 'string' ||
|
|
82
|
-
!(schema.type === 'integer' ? /^[+-]?\d+$/.test(value) : /^[+-]?(?:\d+(?:\.\d+)?|\.\d+)$/.test(value)))) {
|
|
83
|
-
throw new RangeError(`Projection numeric value '${String(value)}' is not supported by ${schema.type}/${schema.format ?? 'double'}.`);
|
|
84
|
-
}
|
|
85
|
-
const number = typeof value === 'number' ? value : Number(value);
|
|
86
|
-
this.checkNumber(number, schema);
|
|
87
|
-
return number;
|
|
88
|
-
}
|
|
89
|
-
if (schema.format === 'date-time') {
|
|
90
|
-
if (value === '0001-01-01T00:00:00')
|
|
91
|
-
return value; // Kernel default for a missing DateTime member.
|
|
92
|
-
// Bound the accepted subset to UTC ISO text with a four-digit year. Date.parse accepts
|
|
93
|
-
// years beyond DateTime.MaxValue, and silently normalizes some invalid calendar dates.
|
|
94
|
-
if (typeof value !== 'string' || !/^\d{4}-\d{2}-\d{2}T\d{2}:\d{2}:\d{2}(?:\.\d{3})?Z$/.test(value) ||
|
|
95
|
-
+value.slice(0, 4) < 1 || !Number.isFinite(Date.parse(value)) ||
|
|
96
|
-
new Date(value).toISOString().slice(0, 19) !== value.slice(0, 19)) {
|
|
97
|
-
throw new RangeError(`Projection date-time value '${String(value)}' is outside the supported DateTime range or UTC ISO format.`);
|
|
98
|
-
}
|
|
99
|
-
return value;
|
|
100
|
-
}
|
|
101
|
-
if (eventContent && (schema.type === 'string' || (Array.isArray(schema.type) && schema.type[0] === 'string')) && typeof value !== 'string') {
|
|
102
|
-
throw new RangeError(`Projection event string value '${String(value)}' must be a JSON string.`);
|
|
103
|
-
}
|
|
104
|
-
if (schema.format === 'guid' && typeof value === 'string') {
|
|
105
|
-
if (!/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i.test(value)) {
|
|
106
|
-
throw new RangeError(`Projection GUID value '${value}' requires a kernel-backed test (ChronicleKernelScenario / live kernel).`);
|
|
107
|
-
}
|
|
108
|
-
return value.toLowerCase();
|
|
109
|
-
}
|
|
110
|
-
if (schema.type === 'string' && typeof value !== 'string')
|
|
111
|
-
return String(value);
|
|
112
|
-
return value;
|
|
37
|
+
if (schema.type === 'object' && this.isObject(value))
|
|
38
|
+
return this.object(value, schema, eventContent);
|
|
39
|
+
if (schema.type === 'array' && Array.isArray(value))
|
|
40
|
+
return this.array(value, schema, eventContent);
|
|
41
|
+
return ProjectionScalarConverter.convert(value, schema, eventContent);
|
|
113
42
|
}
|
|
114
43
|
static checkNumber(number, schema) {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
44
|
+
ProjectionScalarConverter.checkNumber(number, schema);
|
|
45
|
+
}
|
|
46
|
+
static isObject(value) {
|
|
47
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
48
|
+
}
|
|
49
|
+
static isConcept(value, schema) {
|
|
50
|
+
if (schema.type === 'object' || schema.type === 'array')
|
|
51
|
+
return false;
|
|
52
|
+
return this.isObject(value) && Object.keys(value).length === 1 && 'value' in value;
|
|
53
|
+
}
|
|
54
|
+
static object(input, schema, eventContent) {
|
|
55
|
+
if (schema.additionalProperties || !schema.properties)
|
|
56
|
+
return structuredClone(input);
|
|
57
|
+
return this.properties(input, schema, eventContent);
|
|
58
|
+
}
|
|
59
|
+
static array(input, schema, eventContent) {
|
|
60
|
+
return input.map(item => schema.items ? this.convert(item, schema.items, eventContent, false) : structuredClone(item));
|
|
61
|
+
}
|
|
62
|
+
static properties(input, schema, eventContent) {
|
|
63
|
+
const result = Object.create(null);
|
|
64
|
+
for (const [name, property] of Object.entries(schema.properties ?? {})) {
|
|
65
|
+
const source = this.sourceKey(input, name);
|
|
66
|
+
const value = source === undefined ? null : input[source];
|
|
67
|
+
const converted = value == null ? this.defaultValue(property) : this.convert(value, property, eventContent, false);
|
|
68
|
+
if (converted != null)
|
|
69
|
+
result[name] = converted;
|
|
119
70
|
}
|
|
71
|
+
return result;
|
|
120
72
|
}
|
|
121
73
|
}
|
|
122
74
|
//# sourceMappingURL=ProjectionValueConverter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProjectionValueConverter.js","sourceRoot":"","sources":["../../../testing/projections/ProjectionValueConverter.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;
|
|
1
|
+
{"version":3,"file":"ProjectionValueConverter.js","sourceRoot":"","sources":["../../../testing/projections/ProjectionValueConverter.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAGrG,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAE3E,uGAAuG;AACvG,MAAM,OAAO,wBAAwB;IACjC,8FAA8F;IAC9F,MAAM,CAAC,YAAY,CAAC,MAAkB;QAClC,IAAI,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,MAAM,CAAC;YAAE,OAAO,IAAI,CAAC;QAC5E,IAAI,MAAM,CAAC,MAAM,KAAK,MAAM;YAAE,OAAO,sCAAsC,CAAC;QAC5E,IAAI,MAAM,CAAC,MAAM,KAAK,WAAW;YAAE,OAAO,qBAAqB,CAAC;QAChE,IAAI,MAAM,CAAC,IAAI,KAAK,QAAQ,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,CAAC,CAAC;QACpE,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS;YAAE,OAAO,KAAK,CAAC;QAC5C,OAAO,SAAS,CAAC;IACrB,CAAC;IAED,kGAAkG;IAC1F,MAAM,CAAC,SAAS,CAAC,KAA8B,EAAE,IAAY;QACjE,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,CAAC,IAAI,KAAK,CAAC,IAAI,CAAC,IAAI,IAAI;YACpD,CAAC,CAAC,I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