@cratis/chronicle 6.9.1 → 6.10.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 +52 -13
- package/ChronicleOptions.spec.ts +54 -0
- package/ChronicleOptions.ts +20 -5
- package/EventStore.ts +7 -1
- package/README.md +2 -3
- package/artifacts/DefaultClientArtifactsProvider.ts +4 -1
- package/connection/ChronicleConnection.auth.spec.ts +219 -0
- package/connection/ChronicleConnection.ts +70 -31
- package/connection/ChronicleServices.ts +1 -1
- package/connection/CompatibilityPreflight.ts +1 -1
- package/connection/RejectedChronicleCredentials.ts +10 -0
- package/connection/TokenProvider.spec.ts +5 -6
- package/connection/TokenProvider.ts +26 -17
- package/connection/clientVersion.spec.ts +27 -0
- package/connection/clientVersion.ts +9 -0
- package/connection/describeRequestError.spec.ts +22 -0
- package/connection/fetchOAuthAccessToken.ts +33 -2
- package/dist/ChronicleClient.d.ts +3 -0
- package/dist/ChronicleClient.d.ts.map +1 -1
- package/dist/ChronicleClient.js +55 -13
- package/dist/ChronicleClient.js.map +1 -1
- package/dist/ChronicleOptions.d.ts +5 -1
- package/dist/ChronicleOptions.d.ts.map +1 -1
- package/dist/ChronicleOptions.js +20 -5
- package/dist/ChronicleOptions.js.map +1 -1
- package/dist/EventStore.d.ts +2 -0
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +6 -1
- package/dist/EventStore.js.map +1 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.d.ts.map +1 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.js +4 -1
- package/dist/artifacts/DefaultClientArtifactsProvider.js.map +1 -1
- package/dist/connection/ChronicleConnection.d.ts +3 -3
- package/dist/connection/ChronicleConnection.d.ts.map +1 -1
- package/dist/connection/ChronicleConnection.js +74 -26
- package/dist/connection/ChronicleConnection.js.map +1 -1
- package/dist/connection/ChronicleServices.d.ts +1 -2
- package/dist/connection/ChronicleServices.d.ts.map +1 -1
- package/dist/connection/CompatibilityPreflight.js +1 -1
- package/dist/connection/CompatibilityPreflight.js.map +1 -1
- package/dist/connection/RejectedChronicleCredentials.d.ts +5 -0
- package/dist/connection/RejectedChronicleCredentials.d.ts.map +1 -0
- package/dist/connection/RejectedChronicleCredentials.js +10 -0
- package/dist/connection/RejectedChronicleCredentials.js.map +1 -0
- package/dist/connection/TokenProvider.d.ts +8 -6
- package/dist/connection/TokenProvider.d.ts.map +1 -1
- package/dist/connection/TokenProvider.js +25 -11
- package/dist/connection/TokenProvider.js.map +1 -1
- package/dist/connection/clientVersion.d.ts +3 -0
- package/dist/connection/clientVersion.d.ts.map +1 -0
- package/dist/connection/clientVersion.js +7 -0
- package/dist/connection/clientVersion.js.map +1 -0
- package/dist/connection/fetchOAuthAccessToken.d.ts +12 -0
- package/dist/connection/fetchOAuthAccessToken.d.ts.map +1 -1
- package/dist/connection/fetchOAuthAccessToken.js +37 -2
- package/dist/connection/fetchOAuthAccessToken.js.map +1 -1
- package/dist/externalServices/ExternalServiceBuilder.d.ts +1 -1
- package/dist/externalServices/ExternalServiceBuilder.d.ts.map +1 -1
- package/dist/externalServices/ExternalServiceBuilder.js +1 -1
- package/dist/externalServices/ExternalServiceBuilder.js.map +1 -1
- package/dist/externalServices/ExternalServices.d.ts.map +1 -1
- package/dist/externalServices/ExternalServices.js +3 -1
- package/dist/externalServices/ExternalServices.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/projections/Projections.d.ts.map +1 -1
- package/dist/projections/Projections.js +9 -7
- package/dist/projections/Projections.js.map +1 -1
- package/dist/projections/constantValueExpression.d.ts +3 -0
- package/dist/projections/constantValueExpression.d.ts.map +1 -0
- package/dist/projections/constantValueExpression.js +26 -0
- package/dist/projections/constantValueExpression.js.map +1 -0
- package/dist/projections/declarative/ChildrenBuilder.d.ts +2 -0
- package/dist/projections/declarative/ChildrenBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/ChildrenBuilder.js +5 -0
- package/dist/projections/declarative/ChildrenBuilder.js.map +1 -1
- package/dist/projections/declarative/FromBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/FromBuilder.js +3 -2
- package/dist/projections/declarative/FromBuilder.js.map +1 -1
- package/dist/projections/declarative/JoinBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/JoinBuilder.js +2 -1
- package/dist/projections/declarative/JoinBuilder.js.map +1 -1
- package/dist/projections/declarative/NestedBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/NestedBuilder.js +3 -1
- package/dist/projections/declarative/NestedBuilder.js.map +1 -1
- package/dist/projections/declarative/ProjectionBuilderCore.d.ts +5 -0
- package/dist/projections/declarative/ProjectionBuilderCore.d.ts.map +1 -1
- package/dist/projections/declarative/ProjectionBuilderCore.js +18 -2
- package/dist/projections/declarative/ProjectionBuilderCore.js.map +1 -1
- package/dist/projections/declarative/ProjectionBuilderFor.d.ts +6 -0
- package/dist/projections/declarative/ProjectionBuilderFor.d.ts.map +1 -1
- package/dist/projections/declarative/ProjectionBuilderFor.js +5 -0
- package/dist/projections/declarative/ProjectionBuilderFor.js.map +1 -1
- package/dist/projections/declarative/SetBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/SetBuilder.js +2 -1
- package/dist/projections/declarative/SetBuilder.js.map +1 -1
- package/dist/projections/modelBound/addFrom.d.ts.map +1 -1
- package/dist/projections/modelBound/addFrom.js +3 -2
- package/dist/projections/modelBound/addFrom.js.map +1 -1
- package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts +20 -0
- package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts.map +1 -1
- package/dist/projections/modelBound/childrenAndNestedBuilder.js +14 -11
- package/dist/projections/modelBound/childrenAndNestedBuilder.js.map +1 -1
- package/dist/projections/modelBound/childrenFrom.d.ts +4 -2
- package/dist/projections/modelBound/childrenFrom.d.ts.map +1 -1
- package/dist/projections/modelBound/childrenFrom.js +8 -4
- package/dist/projections/modelBound/childrenFrom.js.map +1 -1
- package/dist/projections/modelBound/clearWith.d.ts.map +1 -1
- package/dist/projections/modelBound/clearWith.js +3 -2
- package/dist/projections/modelBound/clearWith.js.map +1 -1
- package/dist/projections/modelBound/count.d.ts.map +1 -1
- package/dist/projections/modelBound/count.js +3 -2
- package/dist/projections/modelBound/count.js.map +1 -1
- package/dist/projections/modelBound/decrement.d.ts.map +1 -1
- package/dist/projections/modelBound/decrement.js +3 -2
- package/dist/projections/modelBound/decrement.js.map +1 -1
- package/dist/projections/modelBound/fromAll.d.ts.map +1 -1
- package/dist/projections/modelBound/fromAll.js +3 -2
- package/dist/projections/modelBound/fromAll.js.map +1 -1
- package/dist/projections/modelBound/fromEvery.d.ts.map +1 -1
- package/dist/projections/modelBound/fromEvery.js +3 -2
- package/dist/projections/modelBound/fromEvery.js.map +1 -1
- package/dist/projections/modelBound/increment.d.ts.map +1 -1
- package/dist/projections/modelBound/increment.js +3 -2
- package/dist/projections/modelBound/increment.js.map +1 -1
- package/dist/projections/modelBound/join.d.ts.map +1 -1
- package/dist/projections/modelBound/join.js +3 -2
- package/dist/projections/modelBound/join.js.map +1 -1
- package/dist/projections/modelBound/nested.d.ts.map +1 -1
- package/dist/projections/modelBound/nested.js +3 -2
- package/dist/projections/modelBound/nested.js.map +1 -1
- package/dist/projections/modelBound/noAutoMap.d.ts.map +1 -1
- package/dist/projections/modelBound/noAutoMap.js +3 -2
- package/dist/projections/modelBound/noAutoMap.js.map +1 -1
- package/dist/projections/modelBound/removedWith.d.ts.map +1 -1
- package/dist/projections/modelBound/removedWith.js +3 -2
- package/dist/projections/modelBound/removedWith.js.map +1 -1
- package/dist/projections/modelBound/removedWithJoin.d.ts.map +1 -1
- package/dist/projections/modelBound/removedWithJoin.js +3 -2
- package/dist/projections/modelBound/removedWithJoin.js.map +1 -1
- package/dist/projections/modelBound/setFrom.d.ts.map +1 -1
- package/dist/projections/modelBound/setFrom.js +3 -2
- package/dist/projections/modelBound/setFrom.js.map +1 -1
- package/dist/projections/modelBound/setFromContext.d.ts.map +1 -1
- package/dist/projections/modelBound/setFromContext.js +3 -2
- package/dist/projections/modelBound/setFromContext.js.map +1 -1
- package/dist/projections/modelBound/setValue.d.ts.map +1 -1
- package/dist/projections/modelBound/setValue.js +3 -2
- package/dist/projections/modelBound/setValue.js.map +1 -1
- package/dist/projections/modelBound/subtractFrom.d.ts.map +1 -1
- package/dist/projections/modelBound/subtractFrom.js +3 -2
- package/dist/projections/modelBound/subtractFrom.js.map +1 -1
- package/dist/projections/notSetPropertyPath.d.ts +3 -0
- package/dist/projections/notSetPropertyPath.d.ts.map +1 -0
- package/dist/projections/notSetPropertyPath.js +5 -0
- package/dist/projections/notSetPropertyPath.js.map +1 -0
- package/dist/reactors/Reactors.d.ts +4 -0
- package/dist/reactors/Reactors.d.ts.map +1 -1
- package/dist/reactors/Reactors.js +24 -6
- package/dist/reactors/Reactors.js.map +1 -1
- package/dist/reactors/reactor.d.ts +2 -2
- package/dist/reactors/reactor.js +2 -2
- package/dist/readModels/MaterializedReadModels.d.ts.map +1 -1
- package/dist/readModels/MaterializedReadModels.js +2 -4
- package/dist/readModels/MaterializedReadModels.js.map +1 -1
- package/dist/readModels/ReadModels.d.ts +2 -1
- package/dist/readModels/ReadModels.d.ts.map +1 -1
- package/dist/readModels/ReadModels.js +16 -10
- package/dist/readModels/ReadModels.js.map +1 -1
- package/dist/readModels/deserializeReadModel.d.ts +5 -0
- package/dist/readModels/deserializeReadModel.d.ts.map +1 -0
- package/dist/readModels/deserializeReadModel.js +84 -0
- package/dist/readModels/deserializeReadModel.js.map +1 -0
- package/dist/readModels/rootReadModelTypes.d.ts +5 -0
- package/dist/readModels/rootReadModelTypes.d.ts.map +1 -0
- package/dist/readModels/rootReadModelTypes.js +69 -0
- package/dist/readModels/rootReadModelTypes.js.map +1 -0
- package/dist/reducers/Reducers.d.ts +4 -0
- package/dist/reducers/Reducers.d.ts.map +1 -1
- package/dist/reducers/Reducers.js +24 -6
- package/dist/reducers/Reducers.js.map +1 -1
- package/dist/schemas/JsonSchemaGenerator.d.ts.map +1 -1
- package/dist/schemas/JsonSchemaGenerator.js +4 -4
- package/dist/schemas/JsonSchemaGenerator.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types/TypeDiscoverer.d.ts +8 -1
- package/dist/types/TypeDiscoverer.d.ts.map +1 -1
- package/dist/types/TypeDiscoverer.js +25 -5
- package/dist/types/TypeDiscoverer.js.map +1 -1
- package/dist/types/TypeIntrospector.d.ts.map +1 -1
- package/dist/types/TypeIntrospector.js +3 -2
- package/dist/types/TypeIntrospector.js.map +1 -1
- package/dist/types/conceptValueType.d.ts +4 -0
- package/dist/types/conceptValueType.d.ts.map +1 -0
- package/dist/types/conceptValueType.js +10 -0
- package/dist/types/conceptValueType.js.map +1 -0
- package/dist/types/modelBoundProperty.d.ts +6 -0
- package/dist/types/modelBoundProperty.d.ts.map +1 -0
- package/dist/types/modelBoundProperty.js +53 -0
- package/dist/types/modelBoundProperty.js.map +1 -0
- package/externalServices/ExternalServiceBuilder.ts +4 -4
- package/externalServices/ExternalServices.spec.ts +87 -0
- package/externalServices/ExternalServices.ts +3 -1
- package/for_ChronicleClient/connectionAuthentication.spec.ts +67 -0
- package/index.ts +1 -0
- package/observation/observationDisposal.spec.ts +74 -0
- package/package.json +2 -1
- package/projections/Projections.childrenAndNested.spec.ts +2 -0
- package/projections/Projections.modelBoundCompleteness.spec.ts +47 -0
- package/projections/Projections.ts +9 -7
- package/projections/constantValueExpression.spec.ts +31 -0
- package/projections/constantValueExpression.ts +28 -0
- package/projections/declarative/ChildrenBuilder.spec.ts +46 -1
- package/projections/declarative/ChildrenBuilder.ts +6 -0
- package/projections/declarative/FromBuilder.ts +3 -2
- package/projections/declarative/JoinBuilder.ts +2 -1
- package/projections/declarative/NestedBuilder.ts +3 -1
- package/projections/declarative/ProjectionBuilderCore.ts +20 -2
- package/projections/declarative/ProjectionBuilderFor.spec.ts +61 -4
- package/projections/declarative/ProjectionBuilderFor.ts +7 -0
- package/projections/declarative/SetBuilder.ts +2 -1
- package/projections/modelBound/addFrom.ts +3 -2
- package/projections/modelBound/childrenAndNestedBuilder.ts +14 -11
- package/projections/modelBound/childrenFrom.ts +11 -5
- package/projections/modelBound/clearWith.ts +3 -2
- package/projections/modelBound/count.ts +3 -2
- package/projections/modelBound/decorators.standard.spec.ts +45 -0
- package/projections/modelBound/decrement.ts +3 -2
- package/projections/modelBound/fromAll.ts +3 -2
- package/projections/modelBound/fromEvery.ts +3 -2
- package/projections/modelBound/increment.ts +3 -2
- package/projections/modelBound/join.ts +3 -2
- package/projections/modelBound/nested.ts +3 -2
- package/projections/modelBound/noAutoMap.ts +3 -2
- package/projections/modelBound/removedWith.ts +3 -2
- package/projections/modelBound/removedWithJoin.ts +3 -2
- package/projections/modelBound/setFrom.ts +3 -2
- package/projections/modelBound/setFromContext.ts +3 -2
- package/projections/modelBound/setValue.ts +3 -2
- package/projections/modelBound/subtractFrom.ts +3 -2
- package/projections/notSetPropertyPath.ts +5 -0
- package/reactors/Reactors.ts +22 -7
- package/reactors/reactor.ts +2 -2
- package/readModels/MaterializedReadModels.spec.ts +22 -0
- package/readModels/MaterializedReadModels.ts +2 -4
- package/readModels/ReadModels.spec.ts +58 -1
- package/readModels/ReadModels.ts +17 -11
- package/readModels/conceptValueType.spec.ts +20 -0
- package/readModels/deserializeReadModel.spec.ts +84 -0
- package/readModels/deserializeReadModel.ts +82 -0
- package/readModels/discovery.spec.ts +27 -0
- package/readModels/rootReadModelTypes.spec.ts +115 -0
- package/readModels/rootReadModelTypes.ts +65 -0
- package/reducers/Reducers.ts +22 -7
- package/schemas/JsonSchemaGenerator.ts +4 -4
- package/schemas/legacyDesignMetadata.spec.ts +24 -2
- package/types/TypeDiscoverer.spec.ts +57 -0
- package/types/TypeDiscoverer.ts +27 -6
- package/types/TypeIntrospector.ts +3 -2
- package/types/conceptValueType.ts +11 -0
- package/types/modelBoundProperty.ts +53 -0
- package/dist/externalServices/ExternalServicesContracts.d.ts +0 -137
- package/dist/externalServices/ExternalServicesContracts.d.ts.map +0 -1
- package/dist/externalServices/ExternalServicesContracts.js +0 -654
- package/dist/externalServices/ExternalServicesContracts.js.map +0 -1
- package/externalServices/ExternalServicesContracts.ts +0 -709
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TypeIntrospector.js","sourceRoot":"","sources":["../../types/TypeIntrospector.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,kBAAkB,CAAC;AAC1B,OAAO,EAAe,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC3D,OAAO,EAAE,mBAAmB,EAAE,MAAM,gCAAgC,CAAC;AAErE,mEAAmE;AACnE,MAAM,+BAA+B,GAAG,wCAAwC,CAAC;AAEjF;;GAEG;AACH,MAAM,OAAO,gBAAgB;IACzB;;;;OAIG;IACH,MAAM,CAAC,aAAa,CAAC,MAAgB,EAAE,YAAoB;QACvD,MAAM,iBAAiB,GAAG,IAAI,CAAC,oBAAoB,CAAC,MAAM,CAAC,CAAC;QAC5D,IAAI,iBAAiB,CAAC,QAAQ,CAAC,YAAY,CAAC,EAAE,CAAC;YAC3C,OAAO;QACX,CAAC;QAED,OAAO,CAAC,cAAc,CAAC,+BAA+B,EAAE,CAAC,GAAG,iBAAiB,EAAE,YAAY,CAAC,EAAE,MAAM,CAAC,CAAC;IAC1G,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,MAAgB;QACxC,MAAM,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC,+BAA+B,EAAE,MAAM,CAAyB,IAAI,EAAE,CAAC;QAC1G,MAAM,QAAQ,GAAG,mBAAmB,CAAC,MAAM,CAAC,CAAC;QAC7C,MAAM,QAAQ,GAAG,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,WAAW,CAAC,+BAA+B,EAAE,QAAQ,CAAyB,IAAI,EAAE,CAAC,CAAC,CAAC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CAAC,IAAI,CAAC,CAAC;aAC5C,MAAM,CAAC,IAAI,CAAC,EAAE,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC;IACzC,CAAC;IAEO,MAAM,CAAC,oBAAoB,CAAC,YAAoB;QACpD,IAAI,UAAU,CAAC,IAAI,CAAC,YAAY,CAAC,EAAE,CAAC;YAChC,OAAO,EAAE,CAAC;QACd,CAAC;QAED,MAAM,WAAW,GAAG,YAAY,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC;QAC9F,MAAM,WAAW,GAAG,WAAW,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QAC7C,MAAM,mBAAmB,GAAG,WAAW,IAAI,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,CAAC;QACnG,MAAM,UAAU,GAAG,mBAAmB,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC;QACpD,MAAM,qBAAqB,GAAG,UAAU,IAAI,CAAC;YACzC,CAAC,CAAC,mBAAmB,CAAC,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC;YAC9C,CAAC,CAAC,mBAAmB,CAAC;QAC1B,OAAO,qBAAqB,CAAC,IAAI,EAAE,CAAC;IACxC,CAAC;CACJ"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conceptValueType.d.ts","sourceRoot":"","sources":["../../types/conceptValueType.ts"],"names":[],"mappings":"AAGA,OAAO,kBAAkB,CAAC;AAE1B,gEAAgE;AAChE,wBAAgB,gBAAgB,CAAC,IAAI,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAIrE"}
|
|
@@ -0,0 +1,10 @@
|
|
|
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 'reflect-metadata';
|
|
4
|
+
/** Resolves the runtime value type erased from ConceptAs<T>. */
|
|
5
|
+
export function conceptValueType(type) {
|
|
6
|
+
return type.valueType ??
|
|
7
|
+
Reflect.getMetadata('design:type', type.prototype, 'value') ??
|
|
8
|
+
Reflect.getMetadata('design:paramtypes', type)?.[0];
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=conceptValueType.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conceptValueType.js","sourceRoot":"","sources":["../../types/conceptValueType.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAErG,OAAO,kBAAkB,CAAC;AAE1B,gEAAgE;AAChE,MAAM,UAAU,gBAAgB,CAAC,IAAc;IAC3C,OAAQ,IAA4C,CAAC,SAAS;QAC1D,OAAO,CAAC,WAAW,CAAC,aAAa,EAAE,IAAI,CAAC,SAAS,EAAE,OAAO,CAAyB;QAClF,OAAO,CAAC,WAAW,CAAC,mBAAmB,EAAE,IAAI,CAA4B,EAAE,CAAC,CAAC,CAAC,CAAC;AACxF,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { ChronicleClassOrPropertyDecorator, ChroniclePropertyDecorator } from './propertyDecoratorMetadata.js';
|
|
2
|
+
/** Registers a mapped class when its property decorator can identify the constructor. */
|
|
3
|
+
export declare function decorateModelBoundProperty(legacy: PropertyDecorator): ChroniclePropertyDecorator;
|
|
4
|
+
/** Registers property mappings without changing class-level decorator behavior. */
|
|
5
|
+
export declare function decorateModelBoundClassOrProperty(legacy: (target: object, property?: string | symbol) => void): ChronicleClassOrPropertyDecorator;
|
|
6
|
+
//# sourceMappingURL=modelBoundProperty.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelBoundProperty.d.ts","sourceRoot":"","sources":["../../types/modelBoundProperty.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,iCAAiC,EAAE,0BAA0B,EAA6C,MAAM,gCAAgC,CAAC;AAmB1J,yFAAyF;AACzF,wBAAgB,0BAA0B,CAAC,MAAM,EAAE,iBAAiB,GAAG,0BAA0B,CAahG;AAED,mFAAmF;AACnF,wBAAgB,iCAAiC,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,GAAG,iCAAiC,CAWjJ"}
|
|
@@ -0,0 +1,53 @@
|
|
|
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 { TypeDiscoverer } from './TypeDiscoverer.js';
|
|
4
|
+
import { decorateClassOrProperty, decorateProperty } from './propertyDecoratorMetadata.js';
|
|
5
|
+
import { getStandardMetadata, hasOwnStandardMetadata } from './standardDecoratorMetadata.js';
|
|
6
|
+
const registered = new WeakSet();
|
|
7
|
+
function register(type) {
|
|
8
|
+
if (registered.has(type))
|
|
9
|
+
return;
|
|
10
|
+
TypeDiscoverer.default.trackModelBoundProperty(type);
|
|
11
|
+
registered.add(type);
|
|
12
|
+
}
|
|
13
|
+
function registerDeclaringClass(instance, metadata) {
|
|
14
|
+
let type = instance.constructor;
|
|
15
|
+
while (type && (!hasOwnStandardMetadata(type) || getStandardMetadata(type) !== metadata)) {
|
|
16
|
+
type = Object.getPrototypeOf(type);
|
|
17
|
+
}
|
|
18
|
+
if (type)
|
|
19
|
+
register(type);
|
|
20
|
+
}
|
|
21
|
+
/** Registers a mapped class when its property decorator can identify the constructor. */
|
|
22
|
+
export function decorateModelBoundProperty(legacy) {
|
|
23
|
+
const decorate = decorateProperty(legacy);
|
|
24
|
+
return (target, keyOrContext) => {
|
|
25
|
+
decorate(target, keyOrContext);
|
|
26
|
+
if (typeof keyOrContext === 'object') {
|
|
27
|
+
// Standard field decorators do not receive the class constructor. Their initializer
|
|
28
|
+
// runs when the first instance is created; direct queries can also register the type.
|
|
29
|
+
const metadata = keyOrContext.metadata;
|
|
30
|
+
keyOrContext.addInitializer(function () { if (metadata)
|
|
31
|
+
registerDeclaringClass(this, metadata); });
|
|
32
|
+
}
|
|
33
|
+
else {
|
|
34
|
+
register(target.constructor);
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
/** Registers property mappings without changing class-level decorator behavior. */
|
|
39
|
+
export function decorateModelBoundClassOrProperty(legacy) {
|
|
40
|
+
const decorate = decorateClassOrProperty(legacy);
|
|
41
|
+
return (target, keyOrContext) => {
|
|
42
|
+
decorate(target, keyOrContext);
|
|
43
|
+
if (typeof keyOrContext === 'object' && keyOrContext?.kind === 'field') {
|
|
44
|
+
const metadata = keyOrContext.metadata;
|
|
45
|
+
keyOrContext.addInitializer(function () { if (metadata)
|
|
46
|
+
registerDeclaringClass(this, metadata); });
|
|
47
|
+
}
|
|
48
|
+
else if (typeof keyOrContext === 'string' || typeof keyOrContext === 'symbol') {
|
|
49
|
+
register(target.constructor);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
//# sourceMappingURL=modelBoundProperty.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelBoundProperty.js","sourceRoot":"","sources":["../../types/modelBoundProperty.ts"],"names":[],"mappings":"AAAA,6CAA6C;AAC7C,qGAAqG;AAGrG,OAAO,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AACrD,OAAO,EAAiE,uBAAuB,EAAE,gBAAgB,EAAE,MAAM,gCAAgC,CAAC;AAC1J,OAAO,EAAE,mBAAmB,EAAE,sBAAsB,EAAE,MAAM,gCAAgC,CAAC;AAE7F,MAAM,UAAU,GAAG,IAAI,OAAO,EAAY,CAAC;AAE3C,SAAS,QAAQ,CAAC,IAAc;IAC5B,IAAI,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC;QAAE,OAAO;IACjC,cAAc,CAAC,OAAO,CAAC,uBAAuB,CAAC,IAAmB,CAA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;QACnD,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,YAAY,EAAE,IAAI,KAAK,OAAO,EAAE,CAAC;YACrE,MAAM,QAAQ,GAAG,YAAY,CAAC,QAAQ,CAAC;YACvC,YAAY,CAAC,cAAc,CAAC,cAAc,IAAI,QAAQ;gBAAE,sBAAsB,CAAC,IAAc,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;QACjH,CAAC;aAAM,IAAI,OAAO,YAAY,KAAK,QAAQ,IAAI,OAAO,YAAY,KAAK,QAAQ,EAAE,CAAC;YAC9E,QAAQ,CAAE,MAAoC,CAAC,WAAW,CAAC,CAAC;QAChE,CAAC;IACL,CAAC,CAAC;AACN,CAAC"}
|
|
@@ -2,11 +2,11 @@
|
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
4
|
import {
|
|
5
|
-
ExternalServiceDefinition,
|
|
6
|
-
ExternalServiceEndpoint,
|
|
5
|
+
type ExternalServiceDefinition,
|
|
6
|
+
type ExternalServiceEndpoint,
|
|
7
7
|
ExternalServiceEndpointType,
|
|
8
|
-
OneOfBasicAuthorizationBearerTokenAuthorizationOAuthAuthorization
|
|
9
|
-
} from '
|
|
8
|
+
type OneOfBasicAuthorizationBearerTokenAuthorizationOAuthAuthorization
|
|
9
|
+
} from '@cratis/chronicle.contracts';
|
|
10
10
|
import { IExternalServiceBuilder } from './IExternalServiceBuilder.js';
|
|
11
11
|
|
|
12
12
|
/**
|
|
@@ -0,0 +1,87 @@
|
|
|
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
|
+
|
|
4
|
+
import { AddExternalServicesRequest, ExternalServiceEndpointType } from '@cratis/chronicle.contracts';
|
|
5
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
6
|
+
import type { ChronicleConnection } from '../connection/index.js';
|
|
7
|
+
import { ChronicleCallFailed } from '../connection/callResults.js';
|
|
8
|
+
import type { IExternalServiceBuilder } from './IExternalServiceBuilder.js';
|
|
9
|
+
import { ExternalServices } from './ExternalServices.js';
|
|
10
|
+
|
|
11
|
+
function createServices(result = { IsAuthorized: true, ValidationResults: [], ExceptionMessages: [], AuthorizationFailureReason: '' }) {
|
|
12
|
+
const addExternalServices = vi.fn().mockResolvedValue(result);
|
|
13
|
+
const connection = { externalServices: { addExternalServices } } as unknown as ChronicleConnection;
|
|
14
|
+
return { services: new ExternalServices('my-event-store', connection), addExternalServices };
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
async function requestFor(configure: (builder: IExternalServiceBuilder) => void): Promise<AddExternalServicesRequest> {
|
|
18
|
+
const { services, addExternalServices } = createServices();
|
|
19
|
+
await services.register('Customers', configure);
|
|
20
|
+
expect(addExternalServices).toHaveBeenCalledTimes(1);
|
|
21
|
+
// Round-trip through the generated codec to assert the actual wire request, not just the in-memory object.
|
|
22
|
+
const request = AddExternalServicesRequest.fromPartial(addExternalServices.mock.calls[0][0]);
|
|
23
|
+
return AddExternalServicesRequest.decode(AddExternalServicesRequest.encode(request).finish());
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
describe('ExternalServices registration', () => {
|
|
27
|
+
it('sends an HTTP bearer endpoint with headers', async () => {
|
|
28
|
+
expect(await requestFor(builder => builder.http('https://example.com')
|
|
29
|
+
.withBearerToken('secret').withHeader('X-Tenant', 'acme').withHeader('X-Trace', 'enabled'))).toEqual({
|
|
30
|
+
EventStore: 'my-event-store',
|
|
31
|
+
ExternalServices: [{
|
|
32
|
+
Id: 'Customers', Name: 'Customers', Endpoint: {
|
|
33
|
+
Type: ExternalServiceEndpointType.Http,
|
|
34
|
+
Http: {
|
|
35
|
+
Url: 'https://example.com', Headers: { 'X-Tenant': 'acme', 'X-Trace': 'enabled' },
|
|
36
|
+
Authorization: { Value0: undefined, Value1: { Token: 'secret' }, Value2: undefined }
|
|
37
|
+
},
|
|
38
|
+
Database: undefined
|
|
39
|
+
}
|
|
40
|
+
}]
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('sends basic authorization', async () => {
|
|
45
|
+
const request = await requestFor(builder => builder.http('https://example.com').withBasicAuth('user', 'password'));
|
|
46
|
+
expect(request.ExternalServices[0].Endpoint?.Http?.Authorization).toEqual({
|
|
47
|
+
Value0: { Username: 'user', Password: 'password' }, Value1: undefined, Value2: undefined
|
|
48
|
+
});
|
|
49
|
+
expect(request.ExternalServices[0].Endpoint?.Http?.Headers).toEqual({});
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('sends OAuth authorization', async () => {
|
|
53
|
+
const request = await requestFor(builder => builder.http('https://example.com').withOAuth('https://auth', 'client', 'secret'));
|
|
54
|
+
expect(request.ExternalServices[0].Endpoint?.Http?.Authorization).toEqual({
|
|
55
|
+
Value0: undefined, Value1: undefined,
|
|
56
|
+
Value2: { Authority: 'https://auth', ClientId: 'client', ClientSecret: 'secret' }
|
|
57
|
+
});
|
|
58
|
+
});
|
|
59
|
+
|
|
60
|
+
it.each([
|
|
61
|
+
['msSql', ExternalServiceEndpointType.MsSql, 1433],
|
|
62
|
+
['postgreSql', ExternalServiceEndpointType.PostgreSql, 5432]
|
|
63
|
+
] as const)('sends %s with a port and options', async (method, type, port) => {
|
|
64
|
+
const request = await requestFor(builder => builder[method]('db.example.com', 'customers', 'user', 'password', port)
|
|
65
|
+
.withOption('sslmode', 'require'));
|
|
66
|
+
expect(request.ExternalServices[0]).toEqual({
|
|
67
|
+
Id: 'Customers', Name: 'Customers', Endpoint: {
|
|
68
|
+
Type: type, Http: undefined,
|
|
69
|
+
Database: {
|
|
70
|
+
Host: 'db.example.com', Port: port, Database: 'customers',
|
|
71
|
+
Username: 'user', Password: 'password', Options: { sslmode: 'require' }
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
|
|
77
|
+
it('rejects a failed command result', async () => {
|
|
78
|
+
const { services } = createServices({
|
|
79
|
+
IsAuthorized: true, ValidationResults: [{ Message: 'invalid endpoint', Members: ['Endpoint'] }],
|
|
80
|
+
ExceptionMessages: [], AuthorizationFailureReason: ''
|
|
81
|
+
});
|
|
82
|
+
await expect(services.register('Customers', builder => builder.http('https://example.com')))
|
|
83
|
+
.rejects.toThrow(ChronicleCallFailed);
|
|
84
|
+
await expect(services.register('Customers', builder => builder.http('https://example.com')))
|
|
85
|
+
.rejects.toThrow(/register external service.*invalid endpoint/);
|
|
86
|
+
});
|
|
87
|
+
});
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
// Licensed under the MIT license. See LICENSE file in the project root for full license information.
|
|
3
3
|
|
|
4
4
|
import { ChronicleConnection } from '../connection/index.js';
|
|
5
|
+
import { ensureCommandSuccess } from '../connection/callResults.js';
|
|
5
6
|
import { ExternalServiceBuilder } from './ExternalServiceBuilder.js';
|
|
6
7
|
import { IExternalServiceBuilder } from './IExternalServiceBuilder.js';
|
|
7
8
|
import { IExternalServices } from './IExternalServices.js';
|
|
@@ -26,9 +27,10 @@ export class ExternalServices implements IExternalServices {
|
|
|
26
27
|
configure(builder);
|
|
27
28
|
const definition = builder.build(name, name);
|
|
28
29
|
|
|
29
|
-
await this._connection.externalServices.
|
|
30
|
+
const result = await this._connection.externalServices.addExternalServices({
|
|
30
31
|
EventStore: this._eventStore,
|
|
31
32
|
ExternalServices: [definition]
|
|
32
33
|
});
|
|
34
|
+
ensureCommandSuccess('register external service', result);
|
|
33
35
|
}
|
|
34
36
|
}
|
|
@@ -0,0 +1,67 @@
|
|
|
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
|
+
|
|
4
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import { ChronicleClient } from '../ChronicleClient.js';
|
|
6
|
+
import { ChronicleOptions } from '../ChronicleOptions.js';
|
|
7
|
+
import { RejectedChronicleCredentials } from '../connection/RejectedChronicleCredentials.js';
|
|
8
|
+
|
|
9
|
+
const transport = vi.hoisted(() => ({ connect: vi.fn(), resetChannel: vi.fn(), disconnect: vi.fn(), getVersionInfo: vi.fn(), allEventStores: vi.fn() }));
|
|
10
|
+
vi.mock('../connection/ChronicleConnection.js', () => ({
|
|
11
|
+
ChronicleConnection: class {
|
|
12
|
+
connect = transport.connect;
|
|
13
|
+
resetChannel = transport.resetChannel;
|
|
14
|
+
disconnect = transport.disconnect;
|
|
15
|
+
server = { getVersionInfo: transport.getVersionInfo };
|
|
16
|
+
eventStores = { allEventStores: transport.allEventStores };
|
|
17
|
+
}
|
|
18
|
+
}));
|
|
19
|
+
vi.mock('../connection/KernelKeepAlive.js', () => ({ KernelKeepAlive: class { async start() {} } }));
|
|
20
|
+
|
|
21
|
+
let client: ChronicleClient;
|
|
22
|
+
beforeEach(() => {
|
|
23
|
+
vi.useFakeTimers();
|
|
24
|
+
vi.clearAllMocks();
|
|
25
|
+
transport.connect.mockResolvedValue(undefined);
|
|
26
|
+
transport.resetChannel.mockResolvedValue(undefined);
|
|
27
|
+
transport.getVersionInfo.mockResolvedValue({});
|
|
28
|
+
transport.allEventStores.mockResolvedValue({ IsAuthorized: true, Data: [] });
|
|
29
|
+
client = new ChronicleClient(ChronicleOptions.fromConnectionString('chronicle://localhost:35000', { discoveryPatterns: [] }));
|
|
30
|
+
});
|
|
31
|
+
afterEach(() => { client.dispose(); vi.useRealTimers(); });
|
|
32
|
+
|
|
33
|
+
describe('client authentication recovery', () => {
|
|
34
|
+
it('connects when an anonymous kernel accepts calls despite an unavailable token endpoint', async () => {
|
|
35
|
+
await expect(client.getEventStores()).resolves.toEqual([]);
|
|
36
|
+
expect(transport.connect).toHaveBeenCalledTimes(1);
|
|
37
|
+
});
|
|
38
|
+
|
|
39
|
+
it('preserves a typed terminal error when an established call enters withReconnect', async () => {
|
|
40
|
+
await client.getEventStores();
|
|
41
|
+
transport.allEventStores.mockRejectedValue(new RejectedChronicleCredentials('rejected'));
|
|
42
|
+
await expect(client.getEventStores()).rejects.toBeInstanceOf(RejectedChronicleCredentials);
|
|
43
|
+
await expect(client.getEventStores()).rejects.toThrow('rejected');
|
|
44
|
+
expect(transport.connect).toHaveBeenCalledTimes(1);
|
|
45
|
+
});
|
|
46
|
+
|
|
47
|
+
it('makes a terminal error on the retried call permanent', async () => {
|
|
48
|
+
await client.getEventStores();
|
|
49
|
+
const rejection = new RejectedChronicleCredentials('rejected after reconnect');
|
|
50
|
+
transport.allEventStores.mockRejectedValueOnce(Object.assign(new Error('unavailable'), { code: 14 }))
|
|
51
|
+
.mockRejectedValueOnce(rejection);
|
|
52
|
+
await expect(client.getEventStores()).rejects.toBe(rejection);
|
|
53
|
+
const calls = transport.allEventStores.mock.calls.length;
|
|
54
|
+
await expect(client.getEventStores()).rejects.toBe(rejection);
|
|
55
|
+
expect(transport.allEventStores).toHaveBeenCalledTimes(calls);
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
it('continues retrying a network outage until disposed', async () => {
|
|
59
|
+
transport.connect.mockRejectedValue(new Error('UNAVAILABLE: connection refused'));
|
|
60
|
+
const pending = client.getEventStores().then(() => undefined, error => error as Error);
|
|
61
|
+
await vi.advanceTimersByTimeAsync(4500);
|
|
62
|
+
expect(transport.connect.mock.calls.length).toBeGreaterThan(1);
|
|
63
|
+
client.dispose();
|
|
64
|
+
await vi.runAllTimersAsync();
|
|
65
|
+
expect((await pending).message).toMatch(/disposed/);
|
|
66
|
+
});
|
|
67
|
+
});
|
package/index.ts
CHANGED
|
@@ -27,6 +27,7 @@ import * as confidentiality from './confidentiality/index.js';
|
|
|
27
27
|
|
|
28
28
|
export { ChronicleClient } from './ChronicleClient.js';
|
|
29
29
|
export { IncompatibleChronicleServer } from './connection/IncompatibleChronicleServer.js';
|
|
30
|
+
export { RejectedChronicleCredentials } from './connection/RejectedChronicleCredentials.js';
|
|
30
31
|
export type { IChronicleClient } from './IChronicleClient.js';
|
|
31
32
|
export { ChronicleOptions } from './ChronicleOptions.js';
|
|
32
33
|
export { EventStore } from './EventStore.js';
|
|
@@ -0,0 +1,74 @@
|
|
|
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
|
+
|
|
4
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
5
|
+
import type { Constructor } from '@cratis/fundamentals';
|
|
6
|
+
import type { IClientArtifactsProvider } from '../artifacts/index.js';
|
|
7
|
+
import { ChronicleClient } from '../ChronicleClient.js';
|
|
8
|
+
import { ChronicleOptions } from '../ChronicleOptions.js';
|
|
9
|
+
import type { ChronicleConnection } from '../connection/index.js';
|
|
10
|
+
import { ConnectionLifecycle } from '../connection/ConnectionLifecycle.js';
|
|
11
|
+
import type { EventStore } from '../EventStore.js';
|
|
12
|
+
import type { IEventLog } from '../eventSequences/IEventLog.js';
|
|
13
|
+
import { Reactors } from '../reactors/Reactors.js';
|
|
14
|
+
import { reactor } from '../reactors/reactor.js';
|
|
15
|
+
import { Reducers } from '../reducers/Reducers.js';
|
|
16
|
+
import { reducer } from '../reducers/reducer.js';
|
|
17
|
+
|
|
18
|
+
class ExampleReactor {}
|
|
19
|
+
reactor('disposal-reactor')(ExampleReactor);
|
|
20
|
+
class ExampleReducer {}
|
|
21
|
+
reducer('disposal-reducer')(ExampleReducer);
|
|
22
|
+
|
|
23
|
+
const artifacts = {
|
|
24
|
+
reactors: [ExampleReactor as Constructor], reducers: [ExampleReducer as Constructor],
|
|
25
|
+
eventTypes: [], readModels: []
|
|
26
|
+
} as unknown as IClientArtifactsProvider;
|
|
27
|
+
|
|
28
|
+
function stream() {
|
|
29
|
+
const signals: AbortSignal[] = [];
|
|
30
|
+
const observe = vi.fn((_queue: AsyncIterable<unknown>, options: { signal: AbortSignal }) => {
|
|
31
|
+
signals.push(options.signal);
|
|
32
|
+
return {
|
|
33
|
+
async *[Symbol.asyncIterator]() {
|
|
34
|
+
await new Promise<void>(resolve => options.signal.addEventListener('abort', () => resolve(), { once: true }));
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
});
|
|
38
|
+
return { observe, signals };
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
describe('observation disposal', () => {
|
|
42
|
+
it('aborts reactor and reducer streams even without a connected lifecycle and prevents re-observation', async () => {
|
|
43
|
+
const reactorStream = stream();
|
|
44
|
+
const reducerStream = stream();
|
|
45
|
+
const connection = {
|
|
46
|
+
reactors: { observe: reactorStream.observe }, reducers: { observe: reducerStream.observe },
|
|
47
|
+
readModels: { registerMany: vi.fn().mockResolvedValue({}) }
|
|
48
|
+
} as unknown as ChronicleConnection;
|
|
49
|
+
const lifecycle = new ConnectionLifecycle();
|
|
50
|
+
const reactors = new Reactors(artifacts, connection, 'store', 'Default', lifecycle, {} as IEventLog);
|
|
51
|
+
const reducers = new Reducers(artifacts, connection, 'store', 'Default', lifecycle, 'sink');
|
|
52
|
+
await reactors.register();
|
|
53
|
+
await reducers.register();
|
|
54
|
+
expect(reactorStream.observe).toHaveBeenCalledOnce();
|
|
55
|
+
expect(reducerStream.observe).toHaveBeenCalledOnce();
|
|
56
|
+
|
|
57
|
+
reactors.dispose();
|
|
58
|
+
reducers.dispose();
|
|
59
|
+
expect(reactorStream.signals[0].aborted).toBe(true);
|
|
60
|
+
expect(reducerStream.signals[0].aborted).toBe(true);
|
|
61
|
+
await reactors.register();
|
|
62
|
+
await reducers.register();
|
|
63
|
+
expect(reactorStream.observe).toHaveBeenCalledOnce();
|
|
64
|
+
expect(reducerStream.observe).toHaveBeenCalledOnce();
|
|
65
|
+
});
|
|
66
|
+
|
|
67
|
+
it('disposes cached store observations even when the lifecycle is not connected', () => {
|
|
68
|
+
const client = new ChronicleClient(ChronicleOptions.fromConnectionString('chronicle://localhost:35000', { discoveryPatterns: [] }));
|
|
69
|
+
const disposeObservations = vi.fn();
|
|
70
|
+
(client as unknown as { _stores: Map<string, EventStore> })._stores.set('store/Default', { disposeObservations } as unknown as EventStore);
|
|
71
|
+
client.dispose();
|
|
72
|
+
expect(disposeObservations).toHaveBeenCalledOnce();
|
|
73
|
+
});
|
|
74
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cratis/chronicle",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.10.0",
|
|
4
4
|
"description": "Event sourcing for TypeScript and Node.js — the idiomatic client for Cratis Chronicle, the open-source event-sourcing database",
|
|
5
5
|
"author": "Cratis",
|
|
6
6
|
"license": "MIT",
|
|
@@ -170,6 +170,7 @@
|
|
|
170
170
|
"@cratis/chronicle.contracts": "19.4.0",
|
|
171
171
|
"@grpc/grpc-js": "^1.14.4",
|
|
172
172
|
"@opentelemetry/api": "^1.9.1",
|
|
173
|
+
"glob": "^13.0.6",
|
|
173
174
|
"nice-grpc": "^2.1.17",
|
|
174
175
|
"nice-grpc-common": "^2.0.4",
|
|
175
176
|
"reflect-metadata": "^0.2.2",
|
|
@@ -167,6 +167,7 @@ describe('Projections with childrenFrom, nested and clearWith', () => {
|
|
|
167
167
|
const definition = registerMock.mock.calls[0][0].Projections[0] as BuiltDefinition;
|
|
168
168
|
const summary = definition.Nested.summary;
|
|
169
169
|
|
|
170
|
+
expect(summary.IdentifiedBy).toBe('*NotSet*');
|
|
170
171
|
const updateEntry = summary.From.find(candidate => candidate.Key.Id === 'SummaryUpdated')!;
|
|
171
172
|
expect(updateEntry.Value.Properties.total).toBe('total');
|
|
172
173
|
expect(summary.RemovedWith.some(candidate => candidate.Key.Id === 'SummaryCleared')).toBe(true);
|
|
@@ -179,6 +180,7 @@ describe('Projections with childrenFrom, nested and clearWith', () => {
|
|
|
179
180
|
const definition = registerMock.mock.calls[0][0].Projections[0] as BuiltDefinition;
|
|
180
181
|
const note = definition.Nested.note;
|
|
181
182
|
|
|
183
|
+
expect(note.IdentifiedBy).toBe('*NotSet*');
|
|
182
184
|
const updateEntry = note.From.find(candidate => candidate.Key.Id === 'NoteAdded')!;
|
|
183
185
|
expect(updateEntry.Value.Properties.text).toBe('text');
|
|
184
186
|
expect(note.RemovedWith.some(candidate => candidate.Key.Id === 'NoteCleared')).toBe(true);
|
|
@@ -12,7 +12,9 @@ import { eventLog, eventSequence } from './modelBound/eventSequence.js';
|
|
|
12
12
|
import { fromAll } from './modelBound/fromAll.js';
|
|
13
13
|
import { fromEvent } from './modelBound/fromEvent.js';
|
|
14
14
|
import { noAutoMap } from './modelBound/noAutoMap.js';
|
|
15
|
+
import { join } from './modelBound/join.js';
|
|
15
16
|
import { setFrom } from './modelBound/setFrom.js';
|
|
17
|
+
import { setValue } from './modelBound/setValue.js';
|
|
16
18
|
import { Projections } from './Projections.js';
|
|
17
19
|
|
|
18
20
|
// Decorators are applied as plain function calls (rather than `@decorator` syntax) so these
|
|
@@ -112,6 +114,28 @@ setFrom(MbProjectNoted, 'note')(MbProjectNotes.prototype, 'note');
|
|
|
112
114
|
clearWith(MbProjectNoteCleared)(MbProjectNotes.prototype, 'note');
|
|
113
115
|
fromEvent(MbProjectNoted)(MbProjectNotes);
|
|
114
116
|
|
|
117
|
+
class MbConstants {
|
|
118
|
+
active!: boolean;
|
|
119
|
+
status!: string;
|
|
120
|
+
total!: number;
|
|
121
|
+
started!: Date;
|
|
122
|
+
cleared!: string | null;
|
|
123
|
+
wrapped!: string;
|
|
124
|
+
}
|
|
125
|
+
setValue(MbProjectNoted, true)(MbConstants.prototype, 'active');
|
|
126
|
+
setValue(MbProjectNoted, 'on-loan')(MbConstants.prototype, 'status');
|
|
127
|
+
setValue(MbProjectNoted, 2.5)(MbConstants.prototype, 'total');
|
|
128
|
+
setValue(MbProjectNoted, new Date('2025-01-02T03:04:05.006Z'))(MbConstants.prototype, 'started');
|
|
129
|
+
setValue(MbProjectNoted, null)(MbConstants.prototype, 'cleared');
|
|
130
|
+
setValue(MbProjectNoted, { value: 'wrapped' })(MbConstants.prototype, 'wrapped');
|
|
131
|
+
fromEvent(MbProjectNoted, { constantKey: 'singleton' })(MbConstants);
|
|
132
|
+
|
|
133
|
+
class MbJoinedNote {
|
|
134
|
+
id!: string;
|
|
135
|
+
note!: string;
|
|
136
|
+
}
|
|
137
|
+
join(MbProjectNoted)(MbJoinedNote.prototype, 'note');
|
|
138
|
+
|
|
115
139
|
interface BuiltFromEntry {
|
|
116
140
|
Key: { Id: string };
|
|
117
141
|
Value: { Properties: Record<string, string>; Key: string; ParentKey: string };
|
|
@@ -121,6 +145,7 @@ interface BuiltDefinition {
|
|
|
121
145
|
EventSequenceId: string;
|
|
122
146
|
AutoMap: AutoMap;
|
|
123
147
|
NoAutoMapProperties: string[];
|
|
148
|
+
Join: Array<{ Value: { On: string } }>;
|
|
124
149
|
All: { Properties: Record<string, string> };
|
|
125
150
|
From: BuiltFromEntry[];
|
|
126
151
|
}
|
|
@@ -208,6 +233,28 @@ describe('Projections model-bound completeness', () => {
|
|
|
208
233
|
});
|
|
209
234
|
});
|
|
210
235
|
|
|
236
|
+
describe('when a property is set to a constant', () => {
|
|
237
|
+
it('should send value and null expressions for model-bound mappings', async () => {
|
|
238
|
+
const definition = await registerAndGetDefinition(MbConstants);
|
|
239
|
+
expect(findFromEntry(definition, 'MbProjectNoted').Value.Properties).toMatchObject({
|
|
240
|
+
active: '$value(true)',
|
|
241
|
+
status: '$value(on-loan)',
|
|
242
|
+
total: '$value(2.5)',
|
|
243
|
+
started: '$value(2025-01-02T03:04:05.006Z)',
|
|
244
|
+
cleared: '$null',
|
|
245
|
+
wrapped: '$value(wrapped)'
|
|
246
|
+
});
|
|
247
|
+
expect(findFromEntry(definition, 'MbProjectNoted').Value.Key).toBe('$value(singleton)');
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
|
|
251
|
+
describe('when a model-bound join has no explicit on property', () => {
|
|
252
|
+
it('should use the mapped property as the join path', async () => {
|
|
253
|
+
const definition = await registerAndGetDefinition(MbJoinedNote);
|
|
254
|
+
expect(definition.Join[0].Value.On).toBe('note');
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
|
|
211
258
|
describe('when a root scalar property is cleared with an event', () => {
|
|
212
259
|
it('should add a $null mapping for that property on the clearing event', async () => {
|
|
213
260
|
const definition = await registerAndGetDefinition(MbProjectNotes);
|
|
@@ -20,10 +20,12 @@ import { toObserverRunningState } from '../observation/toObserverRunningState.js
|
|
|
20
20
|
import { getReadModelMetadata } from '../readModels/index.js';
|
|
21
21
|
import { getReadModelId } from '../readModels/readModel.js';
|
|
22
22
|
import { assertUniqueReadModelIds } from '../readModels/assertUniqueReadModelIds.js';
|
|
23
|
+
import { rootReadModelTypes } from '../readModels/rootReadModelTypes.js';
|
|
23
24
|
import { JsonSchemaGenerator } from '../schemas/index.js';
|
|
24
25
|
import { TypeIntrospector } from '../types/index.js';
|
|
25
26
|
import { hasModelBoundProperties } from '../types/TypeDiscoverer.js';
|
|
26
27
|
import { IProjections } from './IProjections.js';
|
|
28
|
+
import { constantValueExpression } from './constantValueExpression.js';
|
|
27
29
|
import { getProjectionMetadata } from './declarative/projection.js';
|
|
28
30
|
import { ProjectionBuilderFor } from './declarative/ProjectionBuilderFor.js';
|
|
29
31
|
import type { IProjectionFor } from './declarative/IProjectionFor.js';
|
|
@@ -101,7 +103,7 @@ export class Projections implements IProjections {
|
|
|
101
103
|
this._modelBound.clear();
|
|
102
104
|
|
|
103
105
|
const declarativeTypes = this._clientArtifacts.projections;
|
|
104
|
-
const readModelTypes = this._clientArtifacts
|
|
106
|
+
const readModelTypes = rootReadModelTypes(this._clientArtifacts);
|
|
105
107
|
this._logger.debug('Discovering projections', { declarativeCount: declarativeTypes.length, readModelCount: readModelTypes.length });
|
|
106
108
|
|
|
107
109
|
for (const type of declarativeTypes) {
|
|
@@ -143,7 +145,7 @@ export class Projections implements IProjections {
|
|
|
143
145
|
const inferred = this._clientArtifacts.projections
|
|
144
146
|
.map(type => getProjectionMetadata(type)?.readModelType)
|
|
145
147
|
.filter((type): type is Constructor => type !== undefined);
|
|
146
|
-
assertUniqueReadModelIds([...this._clientArtifacts
|
|
148
|
+
assertUniqueReadModelIds([...rootReadModelTypes(this._clientArtifacts), ...inferred]);
|
|
147
149
|
const builtProjections: BuiltProjection[] = [
|
|
148
150
|
...Array.from(this._declarative.values()).map(type => this.buildDeclarativeDefinition(type)),
|
|
149
151
|
...Array.from(this._modelBound.values()).map(type => this.buildModelBoundDefinition(type))
|
|
@@ -396,7 +398,7 @@ export class Projections implements IProjections {
|
|
|
396
398
|
|
|
397
399
|
private getReadModelSchema(readModelIdentifier: string): string {
|
|
398
400
|
const types = [
|
|
399
|
-
...this._clientArtifacts
|
|
401
|
+
...rootReadModelTypes(this._clientArtifacts),
|
|
400
402
|
...this._clientArtifacts.projections
|
|
401
403
|
.map(projectionType => getProjectionMetadata(projectionType)?.readModelType)
|
|
402
404
|
.filter((type): type is Constructor => type !== undefined)
|
|
@@ -457,7 +459,7 @@ export class Projections implements IProjections {
|
|
|
457
459
|
return undefined;
|
|
458
460
|
}
|
|
459
461
|
|
|
460
|
-
const matchingReadModels = this._clientArtifacts
|
|
462
|
+
const matchingReadModels = rootReadModelTypes(this._clientArtifacts)
|
|
461
463
|
.map(type => ({ type, metadata: getReadModelMetadata(type) }))
|
|
462
464
|
.filter(candidate => candidate.metadata)
|
|
463
465
|
.filter(candidate => {
|
|
@@ -496,7 +498,7 @@ export class Projections implements IProjections {
|
|
|
496
498
|
Key: eventType,
|
|
497
499
|
Value: {
|
|
498
500
|
Properties: {},
|
|
499
|
-
Key: fromEvent.constantKey
|
|
501
|
+
Key: fromEvent.constantKey ? constantValueExpression(fromEvent.constantKey) : (fromEvent.key ?? '$eventSourceId'),
|
|
500
502
|
ParentKey: fromEvent.parentKey ?? ''
|
|
501
503
|
}
|
|
502
504
|
});
|
|
@@ -525,7 +527,7 @@ export class Projections implements IProjections {
|
|
|
525
527
|
|
|
526
528
|
for (const mapping of getJoinMetadata(prototype, property)) {
|
|
527
529
|
const entry = this.ensureJoinEntry(joinByEventType, mapping.eventType);
|
|
528
|
-
entry.Value.On = mapping.on ?? entry.Value.On;
|
|
530
|
+
entry.Value.On = mapping.on ?? (entry.Value.On || property);
|
|
529
531
|
entry.Value.Properties[property] = mapping.eventPropertyName ?? property;
|
|
530
532
|
}
|
|
531
533
|
|
|
@@ -652,7 +654,7 @@ export class Projections implements IProjections {
|
|
|
652
654
|
Key: eventType,
|
|
653
655
|
Value: {
|
|
654
656
|
Properties: {},
|
|
655
|
-
Key: fromEvent.constantKey
|
|
657
|
+
Key: fromEvent.constantKey ? constantValueExpression(fromEvent.constantKey) : (fromEvent.key ?? '$eventSourceId'),
|
|
656
658
|
ParentKey: fromEvent.parentKey ?? ''
|
|
657
659
|
}
|
|
658
660
|
});
|
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
|
|
4
|
+
import { describe, expect, it } from 'vitest';
|
|
5
|
+
import { constantValueExpression } from './constantValueExpression.js';
|
|
6
|
+
|
|
7
|
+
describe('constantValueExpression', () => {
|
|
8
|
+
it.each([
|
|
9
|
+
[true, '$value(true)'],
|
|
10
|
+
[false, '$value(false)'],
|
|
11
|
+
[42, '$value(42)'],
|
|
12
|
+
[-1.5, '$value(-1.5)'],
|
|
13
|
+
['on-loan', '$value(on-loan)'],
|
|
14
|
+
['å', '$value(å)'],
|
|
15
|
+
['', '$value()'],
|
|
16
|
+
[new Date('2025-01-02T03:04:05.006Z'), '$value(2025-01-02T03:04:05.006Z)'],
|
|
17
|
+
[null, '$null'],
|
|
18
|
+
[undefined, '$null'],
|
|
19
|
+
[{ value: 'wrapped' }, '$value(wrapped)'],
|
|
20
|
+
[{ value: { value: 17 } }, '$value(17)'],
|
|
21
|
+
[{ value: null }, '$null'],
|
|
22
|
+
['$null', '$null'],
|
|
23
|
+
['$value(already)', '$value(already)']
|
|
24
|
+
])('should encode %s as %s', (value, expression) => {
|
|
25
|
+
expect(constantValueExpression(value)).toBe(expression);
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
it.each(['a(b)', 'a,b', 'a\nb', '$bad', 'a)', '$value(a,b)', '$value(a(b))', '$value(a', '$value(a)garbage'])('rejects unsupported characters in %s', value => {
|
|
29
|
+
expect(() => constantValueExpression(value)).toThrow(/unsupported by the kernel/);
|
|
30
|
+
});
|
|
31
|
+
});
|