@cratis/chronicle 3.0.0 → 3.1.1
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 +4 -3
- package/EventStore.ts +20 -3
- package/IEventStore.ts +16 -0
- package/README.md +40 -28
- package/auditing/CausationType.ts +10 -0
- package/compliance/ComplianceContracts.ts +84 -0
- package/compliance/IPIIManager.ts +17 -0
- package/compliance/PIIManager.ts +31 -0
- package/compliance/index.ts +2 -0
- package/connection/ChronicleConnection.ts +7 -1
- package/connection/ChronicleServices.ts +2 -0
- package/connection/Guid.ts +18 -0
- package/connection/callResults.spec.ts +90 -0
- package/connection/callResults.ts +112 -0
- package/dist/ChronicleClient.d.ts.map +1 -1
- package/dist/ChronicleClient.js +4 -3
- package/dist/ChronicleClient.js.map +1 -1
- package/dist/EventStore.d.ts +8 -0
- package/dist/EventStore.d.ts.map +1 -1
- package/dist/EventStore.js +16 -3
- package/dist/EventStore.js.map +1 -1
- package/dist/IEventStore.d.ts +12 -0
- package/dist/IEventStore.d.ts.map +1 -1
- package/dist/auditing/CausationType.d.ts +8 -0
- package/dist/auditing/CausationType.d.ts.map +1 -1
- package/dist/auditing/CausationType.js +8 -0
- package/dist/auditing/CausationType.js.map +1 -1
- package/dist/compliance/ComplianceContracts.d.ts +40 -0
- package/dist/compliance/ComplianceContracts.d.ts.map +1 -1
- package/dist/compliance/ComplianceContracts.js +71 -0
- package/dist/compliance/ComplianceContracts.js.map +1 -1
- package/dist/compliance/IPIIManager.d.ts +15 -0
- package/dist/compliance/IPIIManager.d.ts.map +1 -0
- package/dist/compliance/IPIIManager.js +4 -0
- package/dist/compliance/IPIIManager.js.map +1 -0
- package/dist/compliance/PIIManager.d.ts +20 -0
- package/dist/compliance/PIIManager.d.ts.map +1 -0
- package/dist/compliance/PIIManager.js +30 -0
- package/dist/compliance/PIIManager.js.map +1 -0
- package/dist/compliance/index.d.ts +2 -0
- package/dist/compliance/index.d.ts.map +1 -1
- package/dist/compliance/index.js +1 -0
- package/dist/compliance/index.js.map +1 -1
- package/dist/connection/ChronicleConnection.d.ts +1 -0
- package/dist/connection/ChronicleConnection.d.ts.map +1 -1
- package/dist/connection/ChronicleConnection.js +6 -1
- package/dist/connection/ChronicleConnection.js.map +1 -1
- package/dist/connection/ChronicleServices.d.ts +2 -0
- package/dist/connection/ChronicleServices.d.ts.map +1 -1
- package/dist/connection/Guid.d.ts +5 -0
- package/dist/connection/Guid.d.ts.map +1 -1
- package/dist/connection/Guid.js +15 -0
- package/dist/connection/Guid.js.map +1 -1
- package/dist/connection/callResults.d.ts +69 -0
- package/dist/connection/callResults.d.ts.map +1 -0
- package/dist/connection/callResults.js +74 -0
- package/dist/connection/callResults.js.map +1 -0
- package/dist/eventSequences/AppendOperationsBroadcaster.d.ts +16 -0
- package/dist/eventSequences/AppendOperationsBroadcaster.d.ts.map +1 -0
- package/dist/eventSequences/AppendOperationsBroadcaster.js +77 -0
- package/dist/eventSequences/AppendOperationsBroadcaster.js.map +1 -0
- package/dist/eventSequences/AppendOptions.d.ts +7 -0
- package/dist/eventSequences/AppendOptions.d.ts.map +1 -1
- package/dist/eventSequences/AppendResult.d.ts +14 -0
- package/dist/eventSequences/AppendResult.d.ts.map +1 -1
- package/dist/eventSequences/AppendedEventWithResult.d.ts +13 -0
- package/dist/eventSequences/AppendedEventWithResult.d.ts.map +1 -0
- package/dist/eventSequences/AppendedEventWithResult.js +4 -0
- package/dist/eventSequences/AppendedEventWithResult.js.map +1 -0
- package/dist/eventSequences/CompleteStreamError.d.ts +17 -0
- package/dist/eventSequences/CompleteStreamError.d.ts.map +1 -0
- package/dist/eventSequences/CompleteStreamError.js +20 -0
- package/dist/eventSequences/CompleteStreamError.js.map +1 -0
- package/dist/eventSequences/CompleteStreamResult.d.ts +14 -0
- package/dist/eventSequences/CompleteStreamResult.d.ts.map +1 -0
- package/dist/eventSequences/CompleteStreamResult.js +4 -0
- package/dist/eventSequences/CompleteStreamResult.js.map +1 -0
- package/dist/eventSequences/ConcurrencyViolation.d.ts +13 -0
- package/dist/eventSequences/ConcurrencyViolation.d.ts.map +1 -0
- package/dist/eventSequences/ConcurrencyViolation.js +4 -0
- package/dist/eventSequences/ConcurrencyViolation.js.map +1 -0
- package/dist/eventSequences/EventForEventSourceId.d.ts +8 -0
- package/dist/eventSequences/EventForEventSourceId.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.d.ts +35 -1
- package/dist/eventSequences/EventSequence.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.js +350 -19
- package/dist/eventSequences/EventSequence.js.map +1 -1
- package/dist/eventSequences/IEventSequence.d.ts +85 -1
- package/dist/eventSequences/IEventSequence.d.ts.map +1 -1
- package/dist/eventSequences/WaitForCompletionResult.d.ts +11 -0
- package/dist/eventSequences/WaitForCompletionResult.d.ts.map +1 -0
- package/dist/eventSequences/WaitForCompletionResult.js +4 -0
- package/dist/eventSequences/WaitForCompletionResult.js.map +1 -0
- package/dist/eventSequences/index.d.ts +5 -0
- package/dist/eventSequences/index.d.ts.map +1 -1
- package/dist/eventSequences/index.js +1 -0
- package/dist/eventSequences/index.js.map +1 -1
- package/dist/eventStoreSubscriptions/EventStoreSubscriptions.d.ts +3 -0
- package/dist/eventStoreSubscriptions/EventStoreSubscriptions.d.ts.map +1 -1
- package/dist/eventStoreSubscriptions/EventStoreSubscriptions.js +9 -0
- package/dist/eventStoreSubscriptions/EventStoreSubscriptions.js.map +1 -1
- package/dist/eventStoreSubscriptions/IEventStoreSubscriptions.d.ts +6 -0
- package/dist/eventStoreSubscriptions/IEventStoreSubscriptions.d.ts.map +1 -1
- package/dist/eventStoreSubscriptions/contracts.d.ts +18 -0
- package/dist/eventStoreSubscriptions/contracts.d.ts.map +1 -1
- package/dist/eventStoreSubscriptions/contracts.js +106 -0
- package/dist/eventStoreSubscriptions/contracts.js.map +1 -1
- package/dist/events/constraints/Constraints.js +4 -4
- package/dist/events/constraints/Constraints.js.map +1 -1
- package/dist/externalServices/ExternalServiceBuilder.d.ts +42 -0
- package/dist/externalServices/ExternalServiceBuilder.d.ts.map +1 -0
- package/dist/externalServices/ExternalServiceBuilder.js +110 -0
- package/dist/externalServices/ExternalServiceBuilder.js.map +1 -0
- package/dist/externalServices/ExternalServices.d.ts +19 -0
- package/dist/externalServices/ExternalServices.d.ts.map +1 -0
- package/dist/externalServices/ExternalServices.js +30 -0
- package/dist/externalServices/ExternalServices.js.map +1 -0
- package/dist/externalServices/ExternalServicesContracts.d.ts +137 -0
- package/dist/externalServices/ExternalServicesContracts.d.ts.map +1 -0
- package/dist/externalServices/ExternalServicesContracts.js +654 -0
- package/dist/externalServices/ExternalServicesContracts.js.map +1 -0
- package/dist/externalServices/IExternalServiceBuilder.d.ts +67 -0
- package/dist/externalServices/IExternalServiceBuilder.d.ts.map +1 -0
- package/dist/externalServices/IExternalServiceBuilder.js +4 -0
- package/dist/externalServices/IExternalServiceBuilder.js.map +1 -0
- package/dist/externalServices/IExternalServices.d.ts +13 -0
- package/dist/externalServices/IExternalServices.d.ts.map +1 -0
- package/dist/externalServices/IExternalServices.js +4 -0
- package/dist/externalServices/IExternalServices.js.map +1 -0
- package/dist/externalServices/index.d.ts +5 -0
- package/dist/externalServices/index.d.ts.map +1 -0
- package/dist/externalServices/index.js +5 -0
- package/dist/externalServices/index.js.map +1 -0
- package/dist/identities/IIdentityManager.d.ts +17 -0
- package/dist/identities/IIdentityManager.d.ts.map +1 -0
- package/dist/identities/IIdentityManager.js +4 -0
- package/dist/identities/IIdentityManager.js.map +1 -0
- package/dist/identities/IdentityManager.d.ts +20 -0
- package/dist/identities/IdentityManager.d.ts.map +1 -0
- package/dist/identities/IdentityManager.js +31 -0
- package/dist/identities/IdentityManager.js.map +1 -0
- package/dist/identities/index.d.ts +3 -0
- package/dist/identities/index.d.ts.map +1 -0
- package/dist/identities/index.js +4 -0
- package/dist/identities/index.js.map +1 -0
- package/dist/index.d.ts +5 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/jobs/IJobs.d.ts +4 -4
- package/dist/jobs/IJobs.d.ts.map +1 -1
- package/dist/jobs/Jobs.d.ts +4 -4
- package/dist/jobs/Jobs.d.ts.map +1 -1
- package/dist/jobs/Jobs.js +12 -10
- package/dist/jobs/Jobs.js.map +1 -1
- package/dist/observation/FailedPartition.d.ts +15 -0
- package/dist/observation/FailedPartition.d.ts.map +1 -0
- package/dist/observation/FailedPartition.js +4 -0
- package/dist/observation/FailedPartition.js.map +1 -0
- package/dist/observation/FailedPartitionAttempt.d.ts +15 -0
- package/dist/observation/FailedPartitionAttempt.d.ts.map +1 -0
- package/dist/observation/FailedPartitionAttempt.js +4 -0
- package/dist/observation/FailedPartitionAttempt.js.map +1 -0
- package/dist/observation/FailedPartitions.d.ts +24 -0
- package/dist/observation/FailedPartitions.d.ts.map +1 -0
- package/dist/observation/FailedPartitions.js +39 -0
- package/dist/observation/FailedPartitions.js.map +1 -0
- package/dist/observation/ICanBeNotifiedWhenPartitionReplayed.d.ts +19 -0
- package/dist/observation/ICanBeNotifiedWhenPartitionReplayed.d.ts.map +1 -0
- package/dist/observation/ICanBeNotifiedWhenPartitionReplayed.js +4 -0
- package/dist/observation/ICanBeNotifiedWhenPartitionReplayed.js.map +1 -0
- package/dist/observation/ICanBeNotifiedWhenReplay.d.ts +17 -0
- package/dist/observation/ICanBeNotifiedWhenReplay.d.ts.map +1 -0
- package/dist/observation/ICanBeNotifiedWhenReplay.js +4 -0
- package/dist/observation/ICanBeNotifiedWhenReplay.js.map +1 -0
- package/dist/observation/IFailedPartitions.d.ts +18 -0
- package/dist/observation/IFailedPartitions.d.ts.map +1 -0
- package/dist/observation/IFailedPartitions.js +4 -0
- package/dist/observation/IFailedPartitions.js.map +1 -0
- package/dist/observation/index.d.ts +6 -0
- package/dist/observation/index.d.ts.map +1 -1
- package/dist/observation/index.js +1 -0
- package/dist/observation/index.js.map +1 -1
- package/dist/observation/notifyReplayLifecycle.d.ts +13 -0
- package/dist/observation/notifyReplayLifecycle.d.ts.map +1 -0
- package/dist/observation/notifyReplayLifecycle.js +54 -0
- package/dist/observation/notifyReplayLifecycle.js.map +1 -0
- package/dist/observation/toClientFailedPartition.d.ts +9 -0
- package/dist/observation/toClientFailedPartition.d.ts.map +1 -0
- package/dist/observation/toClientFailedPartition.js +23 -0
- package/dist/observation/toClientFailedPartition.js.map +1 -0
- package/dist/projections/Projections.d.ts +0 -4
- package/dist/projections/Projections.d.ts.map +1 -1
- package/dist/projections/Projections.js +25 -103
- package/dist/projections/Projections.js.map +1 -1
- package/dist/projections/declarative/AddBuilder.d.ts +17 -0
- package/dist/projections/declarative/AddBuilder.d.ts.map +1 -0
- package/dist/projections/declarative/AddBuilder.js +28 -0
- package/dist/projections/declarative/AddBuilder.js.map +1 -0
- package/dist/projections/declarative/AddChildBuilder.d.ts +56 -0
- package/dist/projections/declarative/AddChildBuilder.d.ts.map +1 -0
- package/dist/projections/declarative/AddChildBuilder.js +72 -0
- package/dist/projections/declarative/AddChildBuilder.js.map +1 -0
- package/dist/projections/declarative/ChildrenBuilder.d.ts +28 -0
- package/dist/projections/declarative/ChildrenBuilder.d.ts.map +1 -0
- package/dist/projections/declarative/ChildrenBuilder.js +72 -0
- package/dist/projections/declarative/ChildrenBuilder.js.map +1 -0
- package/dist/projections/declarative/CompositeKeyBuilder.d.ts +16 -0
- package/dist/projections/declarative/CompositeKeyBuilder.d.ts.map +1 -0
- package/dist/projections/declarative/CompositeKeyBuilder.js +29 -0
- package/dist/projections/declarative/CompositeKeyBuilder.js.map +1 -0
- package/dist/projections/declarative/FromBuilder.d.ts +8 -6
- package/dist/projections/declarative/FromBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/FromBuilder.js +44 -14
- package/dist/projections/declarative/FromBuilder.js.map +1 -1
- package/dist/projections/declarative/ICompositeKeyBuilder.d.ts +5 -0
- package/dist/projections/declarative/ICompositeKeyBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/JoinBuilder.d.ts +7 -5
- package/dist/projections/declarative/JoinBuilder.d.ts.map +1 -1
- package/dist/projections/declarative/JoinBuilder.js +50 -16
- package/dist/projections/declarative/JoinBuilder.js.map +1 -1
- package/dist/projections/declarative/NestedBuilder.d.ts +24 -0
- package/dist/projections/declarative/NestedBuilder.d.ts.map +1 -0
- package/dist/projections/declarative/NestedBuilder.js +60 -0
- package/dist/projections/declarative/NestedBuilder.js.map +1 -0
- package/dist/projections/declarative/ProjectionBuilderCore.d.ts +127 -0
- package/dist/projections/declarative/ProjectionBuilderCore.d.ts.map +1 -0
- package/dist/projections/declarative/ProjectionBuilderCore.js +180 -0
- package/dist/projections/declarative/ProjectionBuilderCore.js.map +1 -0
- package/dist/projections/declarative/ProjectionBuilderFor.d.ts +6 -32
- package/dist/projections/declarative/ProjectionBuilderFor.d.ts.map +1 -1
- package/dist/projections/declarative/ProjectionBuilderFor.js +24 -118
- package/dist/projections/declarative/ProjectionBuilderFor.js.map +1 -1
- package/dist/projections/declarative/SubtractBuilder.d.ts +17 -0
- package/dist/projections/declarative/SubtractBuilder.d.ts.map +1 -0
- package/dist/projections/declarative/SubtractBuilder.js +28 -0
- package/dist/projections/declarative/SubtractBuilder.js.map +1 -0
- package/dist/projections/declarative/index.d.ts +9 -0
- package/dist/projections/declarative/index.d.ts.map +1 -1
- package/dist/projections/declarative/index.js +8 -0
- package/dist/projections/declarative/index.js.map +1 -1
- package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts +90 -0
- package/dist/projections/modelBound/childrenAndNestedBuilder.d.ts.map +1 -0
- package/dist/projections/modelBound/childrenAndNestedBuilder.js +290 -0
- package/dist/projections/modelBound/childrenAndNestedBuilder.js.map +1 -0
- package/dist/reactors/ReactorSideEffects.d.ts +29 -0
- package/dist/reactors/ReactorSideEffects.d.ts.map +1 -0
- package/dist/reactors/ReactorSideEffects.js +70 -0
- package/dist/reactors/ReactorSideEffects.js.map +1 -0
- package/dist/reactors/Reactors.d.ts +4 -1
- package/dist/reactors/Reactors.d.ts.map +1 -1
- package/dist/reactors/Reactors.js +23 -4
- package/dist/reactors/Reactors.js.map +1 -1
- package/dist/reducers/Reducers.d.ts.map +1 -1
- package/dist/reducers/Reducers.js +15 -3
- package/dist/reducers/Reducers.js.map +1 -1
- package/dist/reducers/reducer.d.ts +9 -1
- package/dist/reducers/reducer.d.ts.map +1 -1
- package/dist/reducers/reducer.js +4 -2
- package/dist/reducers/reducer.js.map +1 -1
- package/dist/transactions/IUnitOfWork.d.ts +18 -0
- package/dist/transactions/IUnitOfWork.d.ts.map +1 -1
- package/dist/transactions/UnitOfWork.d.ts +9 -0
- package/dist/transactions/UnitOfWork.d.ts.map +1 -1
- package/dist/transactions/UnitOfWork.js +14 -0
- package/dist/transactions/UnitOfWork.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/eventSequences/AppendOperationsBroadcaster.ts +83 -0
- package/eventSequences/AppendOptions.ts +8 -0
- package/eventSequences/AppendResult.ts +16 -0
- package/eventSequences/AppendedEventWithResult.ts +17 -0
- package/eventSequences/CompleteStreamError.ts +20 -0
- package/eventSequences/CompleteStreamResult.ts +13 -0
- package/eventSequences/ConcurrencyViolation.ts +18 -0
- package/eventSequences/EventForEventSourceId.ts +12 -0
- package/eventSequences/EventSequence.spec.ts +588 -0
- package/eventSequences/EventSequence.ts +406 -20
- package/eventSequences/IEventSequence.ts +109 -1
- package/eventSequences/WaitForCompletionResult.ts +15 -0
- package/eventSequences/index.ts +5 -0
- package/eventStoreSubscriptions/EventStoreSubscriptions.spec.ts +52 -0
- package/eventStoreSubscriptions/EventStoreSubscriptions.ts +19 -1
- package/eventStoreSubscriptions/IEventStoreSubscriptions.ts +7 -0
- package/eventStoreSubscriptions/contracts.ts +126 -0
- package/events/constraints/Constraints.ts +4 -4
- package/externalServices/ExternalServiceBuilder.ts +128 -0
- package/externalServices/ExternalServices.ts +34 -0
- package/externalServices/ExternalServicesContracts.ts +709 -0
- package/externalServices/IExternalServiceBuilder.ts +76 -0
- package/externalServices/IExternalServices.ts +16 -0
- package/externalServices/index.ts +7 -0
- package/identities/IIdentityManager.ts +19 -0
- package/identities/IdentityManager.ts +32 -0
- package/identities/index.ts +5 -0
- package/index.ts +6 -0
- package/jobs/IJobs.ts +4 -4
- package/jobs/Jobs.ts +16 -14
- package/observation/FailedPartition.ts +21 -0
- package/observation/FailedPartitionAttempt.ts +21 -0
- package/observation/FailedPartitions.spec.ts +75 -0
- package/observation/FailedPartitions.ts +44 -0
- package/observation/ICanBeNotifiedWhenPartitionReplayed.ts +22 -0
- package/observation/ICanBeNotifiedWhenReplay.ts +20 -0
- package/observation/IFailedPartitions.ts +22 -0
- package/observation/index.ts +6 -0
- package/observation/notifyReplayLifecycle.spec.ts +98 -0
- package/observation/notifyReplayLifecycle.ts +61 -0
- package/observation/toClientFailedPartition.ts +26 -0
- package/package.json +28 -3
- package/projections/Projections.childrenAndNested.spec.ts +188 -0
- package/projections/Projections.spec.ts +131 -0
- package/projections/Projections.ts +37 -119
- package/projections/declarative/AddBuilder.ts +28 -0
- package/projections/declarative/AddChildBuilder.ts +97 -0
- package/projections/declarative/ChildrenBuilder.spec.ts +157 -0
- package/projections/declarative/ChildrenBuilder.ts +90 -0
- package/projections/declarative/CompositeKeyBuilder.spec.ts +117 -0
- package/projections/declarative/CompositeKeyBuilder.ts +38 -0
- package/projections/declarative/FromBuilder.ts +60 -15
- package/projections/declarative/ICompositeKeyBuilder.ts +6 -0
- package/projections/declarative/JoinBuilder.ts +66 -17
- package/projections/declarative/NestedBuilder.ts +76 -0
- package/projections/declarative/ProjectionBuilderCore.ts +257 -0
- package/projections/declarative/ProjectionBuilderFor.spec.ts +115 -0
- package/projections/declarative/ProjectionBuilderFor.ts +29 -168
- package/projections/declarative/SubtractBuilder.ts +28 -0
- package/projections/declarative/index.ts +9 -0
- package/projections/modelBound/childrenAndNestedBuilder.ts +354 -0
- package/reactors/ReactorSideEffects.spec.ts +182 -0
- package/reactors/ReactorSideEffects.ts +97 -0
- package/reactors/Reactors.ts +29 -4
- package/reducers/Reducers.spec.ts +87 -0
- package/reducers/Reducers.ts +15 -3
- package/reducers/reducer.spec.ts +40 -0
- package/reducers/reducer.ts +11 -2
- package/transactions/IUnitOfWork.ts +21 -0
- package/transactions/UnitOfWork.spec.ts +82 -0
- package/transactions/UnitOfWork.ts +20 -0
package/ChronicleClient.ts
CHANGED
|
@@ -6,6 +6,7 @@ import { diag } from '@opentelemetry/api';
|
|
|
6
6
|
import { SpanStatusCode } from '@opentelemetry/api';
|
|
7
7
|
import { ChronicleOptions } from './ChronicleOptions';
|
|
8
8
|
import { ChronicleConnection } from './connection';
|
|
9
|
+
import { ensureCommandSuccess, ensureQuerySuccess, firstQueryResult } from './connection/callResults';
|
|
9
10
|
import { ConnectionLifecycle } from './connection/ConnectionLifecycle';
|
|
10
11
|
import { KernelKeepAlive } from './connection/KernelKeepAlive';
|
|
11
12
|
import { EventStore } from './EventStore';
|
|
@@ -131,7 +132,7 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
131
132
|
this._logger.debug('Ensuring event store exists in kernel', {
|
|
132
133
|
eventStore: storeName.value
|
|
133
134
|
});
|
|
134
|
-
await this._connection.eventStores.
|
|
135
|
+
ensureCommandSuccess('ensure event store', await this._connection.eventStores.ensureEventStore({ Name: storeName.value }));
|
|
135
136
|
|
|
136
137
|
const created = new EventStore(storeName, namespaceName, this._connection, this._lifecycle, this.options.defaultSinkTypeId);
|
|
137
138
|
this._stores.set(key, created);
|
|
@@ -167,9 +168,9 @@ export class ChronicleClient implements IChronicleClient {
|
|
|
167
168
|
try {
|
|
168
169
|
const response = await this.withReconnect('get_event_stores', async () => {
|
|
169
170
|
await this.ensureConnected();
|
|
170
|
-
return this._connection.eventStores.
|
|
171
|
+
return firstQueryResult('get event stores', this._connection.eventStores.allEventStores({}));
|
|
171
172
|
});
|
|
172
|
-
const result = (
|
|
173
|
+
const result = ensureQuerySuccess('get event stores', response).map((name: string) => new EventStoreName(name));
|
|
173
174
|
this._logger.verbose('Retrieved event stores from kernel', {
|
|
174
175
|
count: result.length
|
|
175
176
|
});
|
package/EventStore.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { diag } from '@opentelemetry/api';
|
|
|
5
5
|
import { SpanStatusCode } from '@opentelemetry/api';
|
|
6
6
|
import { ChronicleConnection } from './connection';
|
|
7
7
|
import { ConnectionLifecycle } from './connection/ConnectionLifecycle';
|
|
8
|
+
import { ensureQuerySuccess, firstQueryResult } from './connection/callResults';
|
|
8
9
|
import { EventLog } from './eventSequences/EventLog';
|
|
9
10
|
import { EventSequence } from './eventSequences/EventSequence';
|
|
10
11
|
import { EventSequenceId } from './eventSequences/EventSequenceId';
|
|
@@ -37,6 +38,14 @@ import { IWebhooks } from './webhooks/IWebhooks';
|
|
|
37
38
|
import { Webhooks } from './webhooks/Webhooks';
|
|
38
39
|
import { EventStoreSubscriptions } from './eventStoreSubscriptions/EventStoreSubscriptions';
|
|
39
40
|
import { IEventStoreSubscriptions } from './eventStoreSubscriptions/IEventStoreSubscriptions';
|
|
41
|
+
import { ExternalServices } from './externalServices/ExternalServices';
|
|
42
|
+
import { IExternalServices } from './externalServices/IExternalServices';
|
|
43
|
+
import { IdentityManager } from './identities/IdentityManager';
|
|
44
|
+
import { IIdentityManager } from './identities/IIdentityManager';
|
|
45
|
+
import { PIIManager } from './compliance/PIIManager';
|
|
46
|
+
import { IPIIManager } from './compliance/IPIIManager';
|
|
47
|
+
import { FailedPartitions } from './observation/FailedPartitions';
|
|
48
|
+
import { IFailedPartitions } from './observation/IFailedPartitions';
|
|
40
49
|
|
|
41
50
|
/**
|
|
42
51
|
* Implements {@link IEventStore} by communicating with the Chronicle Kernel
|
|
@@ -59,6 +68,10 @@ export class EventStore implements IEventStore {
|
|
|
59
68
|
readonly webhooks: IWebhooks;
|
|
60
69
|
readonly subscriptions: IEventStoreSubscriptions;
|
|
61
70
|
readonly seeding: IEventSeeding;
|
|
71
|
+
readonly externalServices: IExternalServices;
|
|
72
|
+
readonly identities: IIdentityManager;
|
|
73
|
+
readonly pii: IPIIManager;
|
|
74
|
+
readonly failedPartitions: IFailedPartitions;
|
|
62
75
|
|
|
63
76
|
private readonly _sequences: Map<string, IEventSequence> = new Map();
|
|
64
77
|
|
|
@@ -78,13 +91,17 @@ export class EventStore implements IEventStore {
|
|
|
78
91
|
this.eventTypes = new EventTypes(name.value, _connection, artifacts);
|
|
79
92
|
this.constraints = new Constraints(name.value, _connection, artifacts);
|
|
80
93
|
this.projections = new Projections(name.value, _connection, artifacts, defaultSinkTypeId);
|
|
81
|
-
this.reactors = new Reactors(artifacts, _connection, name.value, namespace.value, lifecycle);
|
|
94
|
+
this.reactors = new Reactors(artifacts, _connection, name.value, namespace.value, lifecycle, this.eventLog);
|
|
82
95
|
this.reducers = new Reducers(artifacts, _connection, name.value, namespace.value, lifecycle, defaultSinkTypeId);
|
|
83
96
|
this.readModels = new ReadModels(name.value, namespace.value, _connection, artifacts, defaultSinkTypeId);
|
|
84
97
|
this.jobs = new Jobs(name.value, namespace.value, _connection);
|
|
85
98
|
this.webhooks = new Webhooks(name.value, _connection, this.eventTypes, artifacts);
|
|
86
99
|
this.subscriptions = new EventStoreSubscriptions(this.eventTypes, name.value, _connection);
|
|
87
100
|
this.seeding = new EventSeeding(name.value, _connection, artifacts);
|
|
101
|
+
this.externalServices = new ExternalServices(name.value, _connection);
|
|
102
|
+
this.identities = new IdentityManager(name.value, namespace.value, _connection);
|
|
103
|
+
this.pii = new PIIManager(name.value, namespace.value, _connection);
|
|
104
|
+
this.failedPartitions = new FailedPartitions(name.value, namespace.value, _connection);
|
|
88
105
|
}
|
|
89
106
|
|
|
90
107
|
/**
|
|
@@ -147,8 +164,8 @@ export class EventStore implements IEventStore {
|
|
|
147
164
|
return ChronicleTracer.startActiveSpan('chronicle.event_store.get_namespaces', async span => {
|
|
148
165
|
span.setAttribute('chronicle.event_store', this.name.value);
|
|
149
166
|
try {
|
|
150
|
-
const response = await this._connection.namespaces.
|
|
151
|
-
const result = (
|
|
167
|
+
const response = await firstQueryResult('get namespaces', this._connection.namespaces.allNamespaces({ EventStore: this.name.value }));
|
|
168
|
+
const result = ensureQuerySuccess('get namespaces', response).map((namespace: string) => new EventStoreNamespaceName(namespace));
|
|
152
169
|
span.setStatus({ code: SpanStatusCode.OK });
|
|
153
170
|
return result;
|
|
154
171
|
} catch (error) {
|
package/IEventStore.ts
CHANGED
|
@@ -17,6 +17,10 @@ import { IWebhooks } from './webhooks/IWebhooks';
|
|
|
17
17
|
import { IEventSeeding } from './seeding/IEventSeeding';
|
|
18
18
|
import { IEventStoreSubscriptions } from './eventStoreSubscriptions/IEventStoreSubscriptions';
|
|
19
19
|
import { IReadModels } from './readModels/IReadModels';
|
|
20
|
+
import { IExternalServices } from './externalServices/IExternalServices';
|
|
21
|
+
import { IIdentityManager } from './identities/IIdentityManager';
|
|
22
|
+
import { IPIIManager } from './compliance/IPIIManager';
|
|
23
|
+
import { IFailedPartitions } from './observation/IFailedPartitions';
|
|
20
24
|
|
|
21
25
|
/**
|
|
22
26
|
* Defines the API surface for an event store.
|
|
@@ -65,6 +69,18 @@ export interface IEventStore {
|
|
|
65
69
|
/** The event seeding manager for this event store. */
|
|
66
70
|
readonly seeding: IEventSeeding;
|
|
67
71
|
|
|
72
|
+
/** The external services manager for this event store. */
|
|
73
|
+
readonly externalServices: IExternalServices;
|
|
74
|
+
|
|
75
|
+
/** The identities manager for this event store. */
|
|
76
|
+
readonly identities: IIdentityManager;
|
|
77
|
+
|
|
78
|
+
/** The PII (Personal Identifiable Information) compliance manager for this event store. */
|
|
79
|
+
readonly pii: IPIIManager;
|
|
80
|
+
|
|
81
|
+
/** The failed partitions manager for this event store. */
|
|
82
|
+
readonly failedPartitions: IFailedPartitions;
|
|
83
|
+
|
|
68
84
|
/**
|
|
69
85
|
* Gets an event sequence by its identifier.
|
|
70
86
|
* @param id - The identifier of the event sequence to retrieve.
|
package/README.md
CHANGED
|
@@ -1,38 +1,42 @@
|
|
|
1
1
|
# Chronicle TypeScript Client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
**Event sourcing for TypeScript and Node.js — the idiomatic client for [Cratis Chronicle](https://github.com/Cratis/Chronicle).**
|
|
4
|
+
|
|
5
|
+
[](https://www.npmjs.com/package/@cratis/chronicle)
|
|
6
|
+
[](https://github.com/Cratis/Chronicle.TypeScript/actions/workflows/build.yml)
|
|
7
|
+
[](https://github.com/Cratis/Chronicle.TypeScript/blob/main/LICENSE)
|
|
8
|
+
[](https://discord.gg/kt4AMpV8WV)
|
|
9
|
+
|
|
10
|
+
Chronicle is an event-sourcing database and processing runtime with a first-class .NET SDK and additional TypeScript, Kotlin/Java (JVM), and Elixir clients — with a Python client coming soon — plus pluggable storage-provider implementations including MongoDB (default), PostgreSQL, SQL Server, and SQLite. This package is the **TypeScript client**.
|
|
4
11
|
|
|
5
12
|
## Overview
|
|
6
13
|
|
|
7
14
|
`@cratis/chronicle` provides a clean, type-safe TypeScript API for interacting with the Chronicle Kernel. It builds on top of [`@cratis/chronicle.contracts`](https://www.npmjs.com/package/@cratis/chronicle.contracts) (the gRPC contracts package) and exposes idiomatic TypeScript constructs including:
|
|
8
15
|
|
|
9
|
-
- **Decorators** — `@eventType`, `@eventTypeMigration`, `@readModel`, `@reactor`, `@reducer`, `@constraint`, `@projection`, and model-bound decorators such as `@fromEvent`
|
|
16
|
+
- **Decorators** — `@eventType`, `@eventTypeMigration`, `@readModel`, `@reactor`, `@reducer`, `@seeder`, `@constraint`, `@projection`, and model-bound decorators such as `@fromEvent`
|
|
10
17
|
- **Value objects** — `EventSequenceNumber`, `EventTypeId`, `EventStoreName`, etc.
|
|
11
18
|
- **Fluent client** — `ChronicleClient` → `EventStore` → `EventLog` → `append()`
|
|
12
19
|
|
|
13
|
-
|
|
20
|
+
Beyond appending and observing events, the client covers the full Chronicle surface:
|
|
14
21
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
```
|
|
22
|
+
- **Transactions** — group appends into a unit of work with a single commit
|
|
23
|
+
- **Jobs** — inspect and control long-running kernel jobs
|
|
24
|
+
- **Webhooks** — push events to HTTP endpoints
|
|
25
|
+
- **Compliance / PII** — classify event data and handle personally identifiable information
|
|
26
|
+
- **OpenTelemetry** — built-in metrics and tracing instrumentation
|
|
21
27
|
|
|
22
|
-
##
|
|
28
|
+
## Installation
|
|
23
29
|
|
|
24
|
-
|
|
30
|
+
```bash
|
|
31
|
+
npm install @cratis/chronicle reflect-metadata
|
|
32
|
+
```
|
|
25
33
|
|
|
26
|
-
The easiest local setup is the development Docker image:
|
|
34
|
+
You need a Chronicle Kernel available. The easiest local setup is the development Docker image:
|
|
27
35
|
|
|
28
36
|
```bash
|
|
29
37
|
docker run -p 35000:35000 cratis/chronicle:latest-development
|
|
30
38
|
```
|
|
31
39
|
|
|
32
|
-
## Getting Started
|
|
33
|
-
|
|
34
|
-
See [Documentation/getting-started.md](./Documentation/getting-started.md) for installation and usage instructions.
|
|
35
|
-
|
|
36
40
|
## Quick Example
|
|
37
41
|
|
|
38
42
|
```typescript
|
|
@@ -51,19 +55,27 @@ console.log(`Appended at sequence number ${result.sequenceNumber.value}`);
|
|
|
51
55
|
client.dispose();
|
|
52
56
|
```
|
|
53
57
|
|
|
54
|
-
##
|
|
58
|
+
## Documentation
|
|
55
59
|
|
|
56
|
-
|
|
57
|
-
yarn install
|
|
58
|
-
yarn workspace @cratis/chronicle compile
|
|
59
|
-
```
|
|
60
|
+
See the [getting started guide](https://github.com/Cratis/Chronicle.TypeScript/blob/main/Documentation/getting-started.md) and the rest of the [documentation](https://github.com/Cratis/Chronicle.TypeScript/tree/main/Documentation) for installation and usage instructions, or visit [cratis.io](https://www.cratis.io/chronicle/).
|
|
60
61
|
|
|
61
|
-
##
|
|
62
|
+
## The Cratis ecosystem
|
|
62
63
|
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
64
|
+
This package is part of [Cratis](https://www.cratis.io) — free, MIT-licensed tools for building event-sourced and CQRS applications.
|
|
65
|
+
|
|
66
|
+
- **[Chronicle](https://github.com/Cratis/Chronicle)** — event-sourcing database and runtime. Orleans-based kernel, pluggable storage (MongoDB default; PostgreSQL, SQL Server, SQLite, in-memory), language-agnostic gRPC contracts. [Docs](https://www.cratis.io/chronicle/)
|
|
67
|
+
- **Chronicle clients** — first-class [.NET SDK](https://github.com/Cratis/Chronicle), plus [TypeScript](https://github.com/Cratis/Chronicle.TypeScript), [Kotlin/Java](https://github.com/Cratis/Chronicle.Kotlin), and [Elixir](https://github.com/Cratis/Chronicle.Elixir); [Python](https://github.com/Cratis/Chronicle.Python) coming soon (pre-alpha). AI agents connect through the [Chronicle MCP server](https://github.com/Cratis/Chronicle.Mcp).
|
|
68
|
+
- **[Arc](https://github.com/Cratis/Arc)** — opinionated CQRS framework for ASP.NET Core with commands, queries, validation, authorization, and TypeScript proxy generation. Works without event sourcing. [Docs](https://www.cratis.io/arc/)
|
|
69
|
+
- **[Components](https://github.com/Cratis/Components)** — React components aligned with Arc patterns. [Docs](https://www.cratis.io/components/)
|
|
70
|
+
- **[CLI](https://github.com/Cratis/cli) + Workbench** — inspect and diagnose Chronicle from the terminal or the browser. [Docs](https://www.cratis.io/cli/)
|
|
71
|
+
- **[Samples](https://github.com/Cratis/Samples)** — runnable event sourcing and CQRS samples for the whole stack
|
|
72
|
+
|
|
73
|
+
Everything Cratis publishes today is MIT licensed and free to use.
|
|
74
|
+
|
|
75
|
+
---
|
|
76
|
+
|
|
77
|
+
<div align="center">
|
|
78
|
+
|
|
79
|
+
*Part of the [Cratis](https://www.cratis.io) platform · Licensed under the [MIT license](https://github.com/Cratis/Chronicle.TypeScript/blob/main/LICENSE)*
|
|
68
80
|
|
|
69
|
-
|
|
81
|
+
</div>
|
|
@@ -25,6 +25,16 @@ export class CausationType {
|
|
|
25
25
|
*/
|
|
26
26
|
static readonly appendManyEvents = new CausationType('TypeScriptClient.AppendMany');
|
|
27
27
|
|
|
28
|
+
/**
|
|
29
|
+
* Represents the causation type for redacting a single event via the TypeScript client.
|
|
30
|
+
*/
|
|
31
|
+
static readonly redact = new CausationType('TypeScriptClient.Redact');
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents the causation type for redacting all events for an event source via the TypeScript client.
|
|
35
|
+
*/
|
|
36
|
+
static readonly redactForEventSource = new CausationType('TypeScriptClient.RedactForEventSource');
|
|
37
|
+
|
|
28
38
|
/**
|
|
29
39
|
* Initializes a new instance of the {@link CausationType} class.
|
|
30
40
|
* @param name - The name of the causation type.
|
|
@@ -24,6 +24,20 @@ export interface ReleaseResponse {
|
|
|
24
24
|
Error: string;
|
|
25
25
|
}
|
|
26
26
|
|
|
27
|
+
/**
|
|
28
|
+
* Request to delete the encryption key for a PII encryption key identifier (GDPR right-to-erasure).
|
|
29
|
+
*/
|
|
30
|
+
export interface DeleteEncryptionKeyRequest {
|
|
31
|
+
EventStore: string;
|
|
32
|
+
Namespace: string;
|
|
33
|
+
Identifier: string;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* An empty protobuf message.
|
|
38
|
+
*/
|
|
39
|
+
export interface Empty {}
|
|
40
|
+
|
|
27
41
|
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
|
|
28
42
|
export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<infer U> ? globalThis.Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
|
|
29
43
|
[K in keyof T]?: DeepPartial<T[K]>;
|
|
@@ -34,6 +48,7 @@ export type DeepPartial<T> = T extends Builtin ? T : T extends globalThis.Array<
|
|
|
34
48
|
*/
|
|
35
49
|
export interface ComplianceClient<CallOptionsExt = {}> {
|
|
36
50
|
release(request: DeepPartial<ReleaseRequest>, options?: CallOptions & CallOptionsExt): Promise<ReleaseResponse>;
|
|
51
|
+
deleteEncryptionKey(request: DeepPartial<DeleteEncryptionKeyRequest>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
|
|
37
52
|
}
|
|
38
53
|
|
|
39
54
|
export const ReleaseRequest = {
|
|
@@ -126,6 +141,67 @@ export const ReleaseResponse = {
|
|
|
126
141
|
}
|
|
127
142
|
};
|
|
128
143
|
|
|
144
|
+
export const DeleteEncryptionKeyRequest = {
|
|
145
|
+
encode(message: DeleteEncryptionKeyRequest, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
146
|
+
if (message.EventStore !== '') {
|
|
147
|
+
writer.uint32(10).string(message.EventStore);
|
|
148
|
+
}
|
|
149
|
+
if (message.Namespace !== '') {
|
|
150
|
+
writer.uint32(18).string(message.Namespace);
|
|
151
|
+
}
|
|
152
|
+
if (message.Identifier !== '') {
|
|
153
|
+
writer.uint32(26).string(message.Identifier);
|
|
154
|
+
}
|
|
155
|
+
return writer;
|
|
156
|
+
},
|
|
157
|
+
|
|
158
|
+
decode(input: BinaryReader | Uint8Array, length?: number): DeleteEncryptionKeyRequest {
|
|
159
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
160
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
161
|
+
const message: DeleteEncryptionKeyRequest = { EventStore: '', Namespace: '', Identifier: '' };
|
|
162
|
+
while (reader.pos < end) {
|
|
163
|
+
const tag = reader.uint32();
|
|
164
|
+
switch (tag >>> 3) {
|
|
165
|
+
case 1: message.EventStore = reader.string(); continue;
|
|
166
|
+
case 2: message.Namespace = reader.string(); continue;
|
|
167
|
+
case 3: message.Identifier = reader.string(); continue;
|
|
168
|
+
}
|
|
169
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
170
|
+
reader.skip(tag & 7);
|
|
171
|
+
}
|
|
172
|
+
return message;
|
|
173
|
+
},
|
|
174
|
+
|
|
175
|
+
fromPartial(object: DeepPartial<DeleteEncryptionKeyRequest>): DeleteEncryptionKeyRequest {
|
|
176
|
+
return {
|
|
177
|
+
EventStore: object.EventStore ?? '',
|
|
178
|
+
Namespace: object.Namespace ?? '',
|
|
179
|
+
Identifier: object.Identifier ?? ''
|
|
180
|
+
};
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
|
|
184
|
+
export const Empty = {
|
|
185
|
+
encode(_: Empty, writer: BinaryWriter = new BinaryWriter()): BinaryWriter {
|
|
186
|
+
return writer;
|
|
187
|
+
},
|
|
188
|
+
|
|
189
|
+
decode(input: BinaryReader | Uint8Array, length?: number): Empty {
|
|
190
|
+
const reader = input instanceof BinaryReader ? input : new BinaryReader(input);
|
|
191
|
+
const end = length === undefined ? reader.len : reader.pos + length;
|
|
192
|
+
while (reader.pos < end) {
|
|
193
|
+
const tag = reader.uint32();
|
|
194
|
+
if ((tag & 7) === 4 || tag === 0) break;
|
|
195
|
+
reader.skip(tag & 7);
|
|
196
|
+
}
|
|
197
|
+
return {};
|
|
198
|
+
},
|
|
199
|
+
|
|
200
|
+
fromPartial(_: DeepPartial<Empty>): Empty {
|
|
201
|
+
return {};
|
|
202
|
+
}
|
|
203
|
+
};
|
|
204
|
+
|
|
129
205
|
/**
|
|
130
206
|
* Compliance service definition for nice-grpc.
|
|
131
207
|
*/
|
|
@@ -140,6 +216,14 @@ export const ComplianceDefinition = {
|
|
|
140
216
|
responseType: ReleaseResponse,
|
|
141
217
|
responseStream: false as const,
|
|
142
218
|
options: {}
|
|
219
|
+
},
|
|
220
|
+
deleteEncryptionKey: {
|
|
221
|
+
name: 'DeleteEncryptionKey',
|
|
222
|
+
requestType: DeleteEncryptionKeyRequest,
|
|
223
|
+
requestStream: false as const,
|
|
224
|
+
responseType: Empty,
|
|
225
|
+
responseStream: false as const,
|
|
226
|
+
options: {}
|
|
143
227
|
}
|
|
144
228
|
}
|
|
145
229
|
} as const;
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
/**
|
|
5
|
+
* Defines a manager for working with Personal Identifiable Information (PII) compliance concerns.
|
|
6
|
+
*/
|
|
7
|
+
export interface IPIIManager {
|
|
8
|
+
/**
|
|
9
|
+
* Deletes the encryption key for a given PII encryption key identifier, effectively performing
|
|
10
|
+
* a GDPR right-to-erasure for all data encrypted with that key.
|
|
11
|
+
* @param identifier - The identifier of the encryption key to delete.
|
|
12
|
+
* @remarks
|
|
13
|
+
* Once the encryption key is deleted, any data encrypted with it can no longer be decrypted -
|
|
14
|
+
* this operation cannot be undone.
|
|
15
|
+
*/
|
|
16
|
+
deleteEncryptionKey(identifier: string): Promise<void>;
|
|
17
|
+
}
|
|
@@ -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 { ChronicleConnection } from '../connection';
|
|
5
|
+
import { IPIIManager } from './IPIIManager';
|
|
6
|
+
|
|
7
|
+
/**
|
|
8
|
+
* Implements {@link IPIIManager} by proxying to the Chronicle Kernel over the client connection.
|
|
9
|
+
*/
|
|
10
|
+
export class PIIManager implements IPIIManager {
|
|
11
|
+
/**
|
|
12
|
+
* Creates a new {@link PIIManager} instance.
|
|
13
|
+
* @param _eventStore - Event store name.
|
|
14
|
+
* @param _namespace - Event store namespace.
|
|
15
|
+
* @param _connection - Chronicle connection.
|
|
16
|
+
*/
|
|
17
|
+
constructor(
|
|
18
|
+
private readonly _eventStore: string,
|
|
19
|
+
private readonly _namespace: string,
|
|
20
|
+
private readonly _connection: ChronicleConnection
|
|
21
|
+
) {}
|
|
22
|
+
|
|
23
|
+
/** @inheritdoc */
|
|
24
|
+
async deleteEncryptionKey(identifier: string): Promise<void> {
|
|
25
|
+
await this._connection.compliance.deleteEncryptionKey({
|
|
26
|
+
EventStore: this._eventStore,
|
|
27
|
+
Namespace: this._namespace,
|
|
28
|
+
Identifier: identifier
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
}
|
package/compliance/index.ts
CHANGED
|
@@ -5,3 +5,5 @@ export { ComplianceMetadataType } from './ComplianceMetadataType';
|
|
|
5
5
|
export type { ComplianceMetadata } from './ComplianceMetadata';
|
|
6
6
|
export { pii, getPIIMetadata, hasPIIMetadata, getTypePIIMetadata, isPII } from './pii';
|
|
7
7
|
export { ComplianceMetadataResolver } from './ComplianceMetadataResolver';
|
|
8
|
+
export type { IPIIManager } from './IPIIManager';
|
|
9
|
+
export { PIIManager } from './PIIManager';
|
|
@@ -29,6 +29,7 @@ import { createChannel, createClientFactory, waitForChannelReady } from 'nice-gr
|
|
|
29
29
|
import type { ClientMiddleware } from 'nice-grpc-common';
|
|
30
30
|
import { Metadata } from 'nice-grpc-common';
|
|
31
31
|
import { EventStoreSubscriptionsDefinition } from '../eventStoreSubscriptions/contracts';
|
|
32
|
+
import { ExternalServicesDefinition } from '../externalServices/ExternalServicesContracts';
|
|
32
33
|
import { AuthenticationMode, ChronicleConnectionString } from './ChronicleConnectionString';
|
|
33
34
|
import { ChronicleServerAddressResolver } from './ChronicleServerAddressResolver';
|
|
34
35
|
import { ChronicleServices } from './ChronicleServices';
|
|
@@ -207,6 +208,10 @@ export class ChronicleConnection implements ChronicleServices {
|
|
|
207
208
|
return this._services.compliance;
|
|
208
209
|
}
|
|
209
210
|
|
|
211
|
+
get externalServices() {
|
|
212
|
+
return this._services.externalServices;
|
|
213
|
+
}
|
|
214
|
+
|
|
210
215
|
get connections(): ConnectionServiceClient {
|
|
211
216
|
return this._connections;
|
|
212
217
|
}
|
|
@@ -286,7 +291,8 @@ export class ChronicleConnection implements ChronicleServices {
|
|
|
286
291
|
webhooks: factory.create(WebhooksDefinition, this._channel),
|
|
287
292
|
eventSeeding: factory.create(EventSeedingDefinition, this._channel),
|
|
288
293
|
server: factory.create(ServerDefinition, this._channel),
|
|
289
|
-
compliance: factory.create(ComplianceDefinition as any, this._channel) as any
|
|
294
|
+
compliance: factory.create(ComplianceDefinition as any, this._channel) as any,
|
|
295
|
+
externalServices: factory.create(ExternalServicesDefinition, this._channel)
|
|
290
296
|
};
|
|
291
297
|
this._connections = factory.create(ConnectionServiceDefinition, this._channel);
|
|
292
298
|
}
|
|
@@ -23,6 +23,7 @@ import type {
|
|
|
23
23
|
} from '@cratis/chronicle.contracts';
|
|
24
24
|
import type { ComplianceClient } from '../compliance/ComplianceContracts';
|
|
25
25
|
import type { EventStoreSubscriptionsClient } from '../eventStoreSubscriptions/contracts';
|
|
26
|
+
import type { ExternalServicesClient } from '../externalServices/ExternalServicesContracts';
|
|
26
27
|
|
|
27
28
|
/**
|
|
28
29
|
* Represents all Chronicle gRPC services.
|
|
@@ -48,4 +49,5 @@ export interface ChronicleServices {
|
|
|
48
49
|
eventSeeding: EventSeedingClient;
|
|
49
50
|
server: ServerClient;
|
|
50
51
|
compliance: ComplianceClient;
|
|
52
|
+
externalServices: ExternalServicesClient;
|
|
51
53
|
}
|
package/connection/Guid.ts
CHANGED
|
@@ -27,4 +27,22 @@ export function toContractsGuid(guid: FundamentalGuid): ContractsGuid {
|
|
|
27
27
|
lo,
|
|
28
28
|
hi
|
|
29
29
|
};
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Converts a protobuf-net bcl.Guid from the contracts package into a Chronicle Guid.
|
|
34
|
+
* The reverse of {@link toContractsGuid}.
|
|
35
|
+
*/
|
|
36
|
+
export function fromContractsGuid(guid: ContractsGuid | undefined): FundamentalGuid {
|
|
37
|
+
if (!guid) {
|
|
38
|
+
return FundamentalGuid.empty;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
const bytes = new Array<number>(16).fill(0);
|
|
42
|
+
for (let index = 0; index < 8; index++) {
|
|
43
|
+
bytes[index] = Number((guid.lo >> BigInt(index * 8)) & 0xffn);
|
|
44
|
+
bytes[index + 8] = Number((guid.hi >> BigInt(index * 8)) & 0xffn);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
return new FundamentalGuid(bytes);
|
|
30
48
|
}
|
|
@@ -0,0 +1,90 @@
|
|
|
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 { ChronicleCallFailed, ensureCommandSuccess, ensureQuerySuccess, firstQueryResult, isCallSuccess } from './callResults';
|
|
6
|
+
|
|
7
|
+
const successfulResult = {
|
|
8
|
+
ValidationResults: [],
|
|
9
|
+
ExceptionMessages: [],
|
|
10
|
+
AuthorizationFailureReason: ''
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
describe('callResults', () => {
|
|
14
|
+
describe('when checking a successful result', () => {
|
|
15
|
+
it('should report success', () => {
|
|
16
|
+
expect(isCallSuccess(successfulResult)).toBe(true);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
19
|
+
|
|
20
|
+
describe('when checking a result with an authorization failure reason', () => {
|
|
21
|
+
it('should report failure', () => {
|
|
22
|
+
expect(isCallSuccess({ ...successfulResult, AuthorizationFailureReason: 'no access' })).toBe(false);
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe('when checking a result with validation results', () => {
|
|
27
|
+
it('should report failure', () => {
|
|
28
|
+
expect(isCallSuccess({ ...successfulResult, ValidationResults: [{ Message: 'invalid', Members: [] }] })).toBe(false);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
describe('when checking a result with exception messages', () => {
|
|
33
|
+
it('should report failure', () => {
|
|
34
|
+
expect(isCallSuccess({ ...successfulResult, ExceptionMessages: ['boom'] })).toBe(false);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
describe('when ensuring a successful command', () => {
|
|
39
|
+
it('should not throw', () => {
|
|
40
|
+
expect(() => ensureCommandSuccess('operation', successfulResult)).not.toThrow();
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
describe('when ensuring a failed command', () => {
|
|
45
|
+
it('should throw with the failure reasons', () => {
|
|
46
|
+
expect(() => ensureCommandSuccess('operation', { ...successfulResult, ExceptionMessages: ['boom'] }))
|
|
47
|
+
.toThrow(ChronicleCallFailed);
|
|
48
|
+
expect(() => ensureCommandSuccess('operation', { ...successfulResult, ExceptionMessages: ['boom'] }))
|
|
49
|
+
.toThrow(/operation.*boom/);
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
describe('when ensuring a successful query', () => {
|
|
54
|
+
it('should return the data', () => {
|
|
55
|
+
expect(ensureQuerySuccess('operation', { ...successfulResult, Data: ['a', 'b'] })).toEqual(['a', 'b']);
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
describe('when ensuring a failed query', () => {
|
|
60
|
+
it('should throw with the failure reasons', () => {
|
|
61
|
+
expect(() => ensureQuerySuccess('operation', { ...successfulResult, AuthorizationFailureReason: 'no access', Data: [] }))
|
|
62
|
+
.toThrow(/no access/);
|
|
63
|
+
});
|
|
64
|
+
});
|
|
65
|
+
|
|
66
|
+
describe('when taking the first result from a stream', () => {
|
|
67
|
+
it('should return the first item and cancel the stream', async () => {
|
|
68
|
+
let cleanedUp = false;
|
|
69
|
+
async function* stream() {
|
|
70
|
+
try {
|
|
71
|
+
yield 'first';
|
|
72
|
+
yield 'second';
|
|
73
|
+
} finally {
|
|
74
|
+
cleanedUp = true;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const result = await firstQueryResult('operation', stream());
|
|
79
|
+
expect(result).toBe('first');
|
|
80
|
+
expect(cleanedUp).toBe(true);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
|
|
84
|
+
describe('when taking the first result from an empty stream', () => {
|
|
85
|
+
it('should throw', async () => {
|
|
86
|
+
async function* stream() { /* produces nothing */ }
|
|
87
|
+
await expect(firstQueryResult('operation', stream())).rejects.toThrow(/completed without producing a result/);
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
});
|