@cratis/chronicle 6.9.1 → 6.11.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 +270 -0
- package/connection/ChronicleConnection.ts +90 -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 +98 -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/eventSequences/AppendResult.d.ts +7 -0
- package/dist/eventSequences/AppendResult.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.d.ts.map +1 -1
- package/dist/eventSequences/EventSequence.js +26 -17
- package/dist/eventSequences/EventSequence.js.map +1 -1
- package/dist/eventSequences/WaitForCompletionOptions.d.ts +8 -0
- package/dist/eventSequences/WaitForCompletionOptions.d.ts.map +1 -0
- package/dist/eventSequences/WaitForCompletionOptions.js +4 -0
- package/dist/eventSequences/WaitForCompletionOptions.js.map +1 -0
- package/dist/eventSequences/index.d.ts +1 -0
- package/dist/eventSequences/index.d.ts.map +1 -1
- package/dist/eventSequences/index.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/IReadModels.d.ts +3 -2
- package/dist/readModels/IReadModels.d.ts.map +1 -1
- 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 +3 -5
- package/dist/readModels/ReadModels.d.ts.map +1 -1
- package/dist/readModels/ReadModels.js +17 -14
- 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/eventSequences/AppendResult.ts +8 -0
- package/eventSequences/EventSequence.spec.ts +76 -1
- package/eventSequences/EventSequence.ts +28 -20
- package/eventSequences/WaitForCompletionOptions.ts +11 -0
- package/eventSequences/index.ts +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/IReadModels.ts +3 -2
- package/readModels/MaterializedReadModels.spec.ts +22 -0
- package/readModels/MaterializedReadModels.ts +2 -4
- package/readModels/ReadModels.spec.ts +71 -6
- package/readModels/ReadModels.ts +18 -15
- 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
package/reducers/Reducers.ts
CHANGED
|
@@ -104,7 +104,9 @@ export class Reducers implements IReducers {
|
|
|
104
104
|
private readonly _lifecycle: ConnectionLifecycle;
|
|
105
105
|
private readonly _reducers = new Map<string, Constructor>();
|
|
106
106
|
private readonly _queues = new Map<string, AsyncQueue<ReducerMessage>>();
|
|
107
|
+
private readonly _observations = new Map<string, AbortController>();
|
|
107
108
|
private _registered = false;
|
|
109
|
+
private _disposed = false;
|
|
108
110
|
|
|
109
111
|
/**
|
|
110
112
|
* Creates a new {@link Reducers} instance.
|
|
@@ -131,6 +133,13 @@ export class Reducers implements IReducers {
|
|
|
131
133
|
});
|
|
132
134
|
}
|
|
133
135
|
|
|
136
|
+
/** Stops observations permanently when the owning client is disposed. */
|
|
137
|
+
dispose(): void {
|
|
138
|
+
this._disposed = true;
|
|
139
|
+
this._registered = false;
|
|
140
|
+
this.disconnectAll();
|
|
141
|
+
}
|
|
142
|
+
|
|
134
143
|
/** @inheritdoc */
|
|
135
144
|
async discover(): Promise<void> {
|
|
136
145
|
this._reducers.clear();
|
|
@@ -145,7 +154,7 @@ export class Reducers implements IReducers {
|
|
|
145
154
|
|
|
146
155
|
/** @inheritdoc */
|
|
147
156
|
async register(): Promise<void> {
|
|
148
|
-
if (this._registered) {
|
|
157
|
+
if (this._registered || this._disposed) {
|
|
149
158
|
return;
|
|
150
159
|
}
|
|
151
160
|
|
|
@@ -156,6 +165,7 @@ export class Reducers implements IReducers {
|
|
|
156
165
|
assertUniqueReadModelIds(this._clientArtifacts.readModels);
|
|
157
166
|
await this.registerReadModels();
|
|
158
167
|
|
|
168
|
+
if (this._disposed) return;
|
|
159
169
|
this._logger.info('Registering reducers', { count: this._reducers.size });
|
|
160
170
|
for (const [id, reducerType] of this._reducers) {
|
|
161
171
|
this.startObservation(id, reducerType);
|
|
@@ -226,6 +236,7 @@ export class Reducers implements IReducers {
|
|
|
226
236
|
}
|
|
227
237
|
|
|
228
238
|
private startObservation(id: string, reducerType: Constructor): void {
|
|
239
|
+
if (this._disposed) return;
|
|
229
240
|
const metadata = getReducerMetadata(reducerType)!;
|
|
230
241
|
const eventSequenceId = metadata.eventSequenceId ?? EventSequenceId.eventLog.value;
|
|
231
242
|
const eventTypes = this.getEventTypesFor(reducerType);
|
|
@@ -271,12 +282,12 @@ export class Reducers implements IReducers {
|
|
|
271
282
|
private scheduleReobserve(id: string, reducerType: Constructor): void {
|
|
272
283
|
// A disconnect clears the registration; the reconnect re-registers every
|
|
273
284
|
// reducer from scratch, so retrying here as well would double up.
|
|
274
|
-
if (!this._registered) {
|
|
285
|
+
if (!this._registered || this._disposed) {
|
|
275
286
|
return;
|
|
276
287
|
}
|
|
277
288
|
|
|
278
289
|
const handle = setTimeout(() => {
|
|
279
|
-
if (!this._registered) {
|
|
290
|
+
if (!this._registered || this._disposed) {
|
|
280
291
|
return;
|
|
281
292
|
}
|
|
282
293
|
|
|
@@ -304,7 +315,9 @@ export class Reducers implements IReducers {
|
|
|
304
315
|
readModelName: string
|
|
305
316
|
): Promise<void> {
|
|
306
317
|
const queue = new AsyncQueue<ReducerMessage>();
|
|
318
|
+
const controller = new AbortController();
|
|
307
319
|
this._queues.set(id, queue);
|
|
320
|
+
this._observations.set(id, controller);
|
|
308
321
|
const isActive = getReducerMetadata(reducerType)?.isActive ?? true;
|
|
309
322
|
|
|
310
323
|
queue.send({
|
|
@@ -338,7 +351,7 @@ export class Reducers implements IReducers {
|
|
|
338
351
|
try {
|
|
339
352
|
const reducerInstance = new (reducerType as new () => Record<string, Function>)();
|
|
340
353
|
|
|
341
|
-
for await (const operation of this._connection.reducers.observe(queue)) {
|
|
354
|
+
for await (const operation of this._connection.reducers.observe(queue, { signal: controller.signal })) {
|
|
342
355
|
let lastSuccessfullyObservedEvent = SEQUENCE_NUMBER_UNAVAILABLE;
|
|
343
356
|
let state = ObservationState.Success;
|
|
344
357
|
const exceptionMessages: string[] = [];
|
|
@@ -433,7 +446,9 @@ export class Reducers implements IReducers {
|
|
|
433
446
|
// leak a duplicate stream on every reconnect.
|
|
434
447
|
if (this._queues.get(id) === queue) {
|
|
435
448
|
this._queues.delete(id);
|
|
449
|
+
this._observations.delete(id);
|
|
436
450
|
}
|
|
451
|
+
queue.complete();
|
|
437
452
|
}
|
|
438
453
|
}
|
|
439
454
|
|
|
@@ -461,9 +476,9 @@ export class Reducers implements IReducers {
|
|
|
461
476
|
}
|
|
462
477
|
|
|
463
478
|
private disconnectAll(): void {
|
|
464
|
-
for (const
|
|
465
|
-
|
|
466
|
-
|
|
479
|
+
for (const controller of this._observations.values()) controller.abort();
|
|
480
|
+
for (const queue of this._queues.values()) queue.complete();
|
|
481
|
+
this._observations.clear();
|
|
467
482
|
this._queues.clear();
|
|
468
483
|
}
|
|
469
484
|
}
|
|
@@ -5,6 +5,8 @@ import 'reflect-metadata';
|
|
|
5
5
|
import { conceptAsTypeKey, Constructor, Fields, Guid, typeKeyOf } from '@cratis/fundamentals';
|
|
6
6
|
import { ComplianceSchemaMetadata, JsonSchema, SecuritySchemaMetadata } from './JsonSchema.js';
|
|
7
7
|
import { TypeIntrospector } from '../types/index.js';
|
|
8
|
+
import { conceptValueType } from '../types/conceptValueType.js';
|
|
9
|
+
import { getChildrenFromMetadata } from '../projections/modelBound/childrenFrom.js';
|
|
8
10
|
import { hasOwnStandardMetadata } from '../types/standardDecoratorMetadata.js';
|
|
9
11
|
import { ComplianceMetadata } from '../compliance/ComplianceMetadata.js';
|
|
10
12
|
import { ComplianceMetadataResolver } from '../compliance/ComplianceMetadataResolver.js';
|
|
@@ -124,9 +126,7 @@ export class JsonSchemaGenerator {
|
|
|
124
126
|
// TypeScript erases ConceptAs<T>'s primitive type. Prefer an explicit field or
|
|
125
127
|
// static hint; legacy emitDecoratorMetadata is the last available source.
|
|
126
128
|
if (this.isConceptAs(runtimeType)) {
|
|
127
|
-
const
|
|
128
|
-
const fieldType = Fields.getFieldsForType(concept as Constructor).find(field => field.name === 'value')?.type;
|
|
129
|
-
const valueType = fieldType ?? concept.valueType ?? Reflect.getMetadata('design:type', runtimeType.prototype, 'value') as Function | undefined;
|
|
129
|
+
const valueType = conceptValueType(runtimeType);
|
|
130
130
|
if (!valueType && !requireResolvedTypes) return { type: 'string' }; // Legacy schema compatibility.
|
|
131
131
|
const valueSchema = this.mapRuntimeTypeToSchema(valueType, undefined, undefined, requireResolvedTypes);
|
|
132
132
|
if (!valueType || !valueSchema.type || (requireResolvedTypes && valueSchema.type === 'object')) {
|
|
@@ -191,7 +191,7 @@ export class JsonSchemaGenerator {
|
|
|
191
191
|
}
|
|
192
192
|
|
|
193
193
|
const field = Fields.getFieldsForType(declaringType as Constructor).find(candidate => candidate.name === propertyName);
|
|
194
|
-
return field?.genericArguments?.[0];
|
|
194
|
+
return getChildrenFromMetadata(declaringType.prototype, propertyName).find(metadata => metadata.childType)?.childType ?? field?.genericArguments?.[0];
|
|
195
195
|
}
|
|
196
196
|
|
|
197
197
|
/**
|
|
@@ -7,6 +7,7 @@ import { ConceptAs, field, Guid } from '@cratis/fundamentals';
|
|
|
7
7
|
import ts from 'typescript';
|
|
8
8
|
import { describe, expect, it } from 'vitest';
|
|
9
9
|
import { JsonSchemaGenerator } from './JsonSchemaGenerator.js';
|
|
10
|
+
import { eventType, getEventTypeMetadata } from '../events/eventTypeDecorator.js';
|
|
10
11
|
|
|
11
12
|
const source = `
|
|
12
13
|
function mark() { return () => {}; }
|
|
@@ -16,7 +17,16 @@ class LegacyId extends ConceptAs {
|
|
|
16
17
|
class LegacyHolder {
|
|
17
18
|
@field(LegacyId) id!: LegacyId;
|
|
18
19
|
}
|
|
19
|
-
|
|
20
|
+
@eventType('no-defaults')
|
|
21
|
+
class NoDefaults {
|
|
22
|
+
constructor(readonly name: string, readonly when: Date, readonly count: number) {}
|
|
23
|
+
}
|
|
24
|
+
class ExplicitField {
|
|
25
|
+
constructor(readonly count: number) {}
|
|
26
|
+
}
|
|
27
|
+
field(Boolean)(ExplicitField.prototype, 'count');
|
|
28
|
+
eventType('explicit-field')(ExplicitField);
|
|
29
|
+
exports.types = { LegacyId, LegacyHolder, NoDefaults, ExplicitField };
|
|
20
30
|
`;
|
|
21
31
|
|
|
22
32
|
const compiled = ts.transpileModule(source, {
|
|
@@ -30,10 +40,22 @@ const compiled = ts.transpileModule(source, {
|
|
|
30
40
|
|
|
31
41
|
describe('legacy emitDecoratorMetadata compatibility', () => {
|
|
32
42
|
it('resolves a Guid-backed concept through emitted design:type', () => {
|
|
33
|
-
const sandbox = { exports: {} as { types?: { LegacyId: Function; LegacyHolder: Function } }, ConceptAs, field, Guid, Reflect };
|
|
43
|
+
const sandbox = { exports: {} as { types?: { LegacyId: Function; LegacyHolder: Function } }, ConceptAs, field, Guid, Reflect, eventType, String, Number, Boolean, Date };
|
|
34
44
|
runInNewContext(compiled, sandbox);
|
|
35
45
|
const { LegacyId, LegacyHolder } = sandbox.exports.types!;
|
|
36
46
|
expect(Reflect.getMetadata('design:type', LegacyId.prototype, 'value')).toBe(Guid);
|
|
37
47
|
expect(JsonSchemaGenerator.generate(LegacyHolder).properties?.id).toEqual({ type: 'string', format: 'guid' });
|
|
38
48
|
});
|
|
49
|
+
|
|
50
|
+
it('resolves constructor parameter properties without defaults from design:paramtypes', () => {
|
|
51
|
+
const sandbox = { exports: {} as { types?: { NoDefaults: Function; ExplicitField: Function } }, ConceptAs, field, Guid, Reflect, eventType, String, Number, Boolean, Date };
|
|
52
|
+
runInNewContext(compiled, sandbox);
|
|
53
|
+
const { NoDefaults, ExplicitField } = sandbox.exports.types!;
|
|
54
|
+
expect(getEventTypeMetadata(NoDefaults)?.schema.properties).toEqual({
|
|
55
|
+
name: { type: 'string' },
|
|
56
|
+
when: { type: 'string', format: 'date-time' },
|
|
57
|
+
count: { type: 'number' }
|
|
58
|
+
});
|
|
59
|
+
expect(getEventTypeMetadata(ExplicitField)?.schema.properties?.count).toEqual({ type: 'boolean' });
|
|
60
|
+
});
|
|
39
61
|
});
|
|
@@ -0,0 +1,57 @@
|
|
|
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 { mkdtemp, mkdir, rm, writeFile } from 'node:fs/promises';
|
|
5
|
+
import { tmpdir } from 'node:os';
|
|
6
|
+
import path from 'node:path';
|
|
7
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
8
|
+
import { TypeDiscoverer } from './TypeDiscoverer.js';
|
|
9
|
+
|
|
10
|
+
describe('TypeDiscoverer', () => {
|
|
11
|
+
it('passes included patterns and stripped exclusions to glob ignore', async () => {
|
|
12
|
+
const glob = vi.fn().mockResolvedValue([]);
|
|
13
|
+
await new TypeDiscoverer(glob).discover([
|
|
14
|
+
'**/*.ts', '!**/*.d.ts', '!**/node_modules', '!**/dist', '!**/build', '!**/.git', '!**/.vscode', '!**/*.spec.ts', '!**/*.test.ts'
|
|
15
|
+
]);
|
|
16
|
+
expect(glob).toHaveBeenCalledWith(['**/*.ts'], {
|
|
17
|
+
ignore: [
|
|
18
|
+
'**/*.d.ts', '**/*.d.ts/**', '**/node_modules', '**/node_modules/**',
|
|
19
|
+
'**/dist', '**/dist/**', '**/build', '**/build/**', '**/.git', '**/.git/**',
|
|
20
|
+
'**/.vscode', '**/.vscode/**', '**/*.spec.ts', '**/*.spec.ts/**',
|
|
21
|
+
'**/*.test.ts', '**/*.test.ts/**'
|
|
22
|
+
]
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('excludes declaration files, tests and directory contents with the real glob', async () => {
|
|
27
|
+
const directory = await mkdtemp(path.join(tmpdir(), 'chronicle-discovery-'));
|
|
28
|
+
try {
|
|
29
|
+
for (const subdirectory of ['node_modules', 'dist', 'build', '.git', '.vscode']) {
|
|
30
|
+
await mkdir(path.join(directory, subdirectory));
|
|
31
|
+
await writeFile(path.join(directory, subdirectory, 'excluded.ts'), '');
|
|
32
|
+
}
|
|
33
|
+
for (const file of ['included.ts', 'excluded.d.ts', 'excluded.spec.ts', 'excluded.test.ts']) {
|
|
34
|
+
await writeFile(path.join(directory, file), '');
|
|
35
|
+
}
|
|
36
|
+
const imported: string[] = [];
|
|
37
|
+
const discoverer = new TypeDiscoverer(undefined, async file => { imported.push(file); });
|
|
38
|
+
await discoverer.discover([
|
|
39
|
+
`${directory}/**/*.ts`, `!${directory}/**/*.d.ts`, `!${directory}/**/*.spec.ts`,
|
|
40
|
+
`!${directory}/**/*.test.ts`, ...['node_modules', 'dist', 'build', '.git', '.vscode'].map(name => `!${directory}/**/${name}`)
|
|
41
|
+
]);
|
|
42
|
+
expect(imported).toEqual([path.join(directory, 'included.ts')]);
|
|
43
|
+
} finally {
|
|
44
|
+
await rm(directory, { recursive: true, force: true });
|
|
45
|
+
}
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('reports the path and preserves the cause of a failed import', async () => {
|
|
49
|
+
const failure = new SyntaxError('invalid decorator');
|
|
50
|
+
const discoverer = new TypeDiscoverer(async () => ['broken.ts'], async () => { throw failure; });
|
|
51
|
+
const file = path.resolve('broken.ts');
|
|
52
|
+
await expect(discoverer.discover('*.ts')).rejects.toMatchObject({
|
|
53
|
+
message: expect.stringContaining(file),
|
|
54
|
+
cause: failure
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
});
|
package/types/TypeDiscoverer.ts
CHANGED
|
@@ -7,7 +7,7 @@ import { Constructor } from '@cratis/fundamentals';
|
|
|
7
7
|
import { TypeIntrospector } from './TypeIntrospector.js';
|
|
8
8
|
import { hasPropertyMetadata } from './propertyDecoratorMetadata.js';
|
|
9
9
|
|
|
10
|
-
type GlobFunction = (pattern: string | string[]) => Promise<string[]>;
|
|
10
|
+
type GlobFunction = (pattern: string | string[], options?: { ignore: string[] }) => Promise<string[]>;
|
|
11
11
|
type FileImporter = (filePath: string) => Promise<unknown>;
|
|
12
12
|
|
|
13
13
|
const modelBoundPropertyKeys = [
|
|
@@ -29,6 +29,7 @@ export class TypeDiscoverer {
|
|
|
29
29
|
static readonly default = new TypeDiscoverer();
|
|
30
30
|
|
|
31
31
|
private static readonly _registeredTypes: Map<DecoratorType, Map<string, Constructor>> = new Map();
|
|
32
|
+
private static readonly _propertyOnlyModels = new Set<Constructor>();
|
|
32
33
|
|
|
33
34
|
private readonly _glob: GlobFunction;
|
|
34
35
|
private readonly _importFile: FileImporter;
|
|
@@ -49,20 +50,39 @@ export class TypeDiscoverer {
|
|
|
49
50
|
*/
|
|
50
51
|
async discover(pattern: string | string[]): Promise<void> {
|
|
51
52
|
const patterns = Array.isArray(pattern) ? pattern : [pattern];
|
|
52
|
-
const
|
|
53
|
+
const included = patterns.filter(pattern => !pattern.startsWith('!'));
|
|
54
|
+
const excluded = patterns.filter(pattern => pattern.startsWith('!')).map(pattern => pattern.slice(1));
|
|
55
|
+
const ignore = excluded.flatMap(pattern => [pattern, `${pattern}/**`]);
|
|
56
|
+
const files = await this._glob(included, { ignore });
|
|
53
57
|
for (const file of files) {
|
|
54
|
-
const
|
|
58
|
+
const filePath = path.resolve(file);
|
|
59
|
+
let module: unknown;
|
|
60
|
+
try {
|
|
61
|
+
module = await this._importFile(filePath);
|
|
62
|
+
} catch (error) {
|
|
63
|
+
throw new Error(`Could not import discovered file '${filePath}'.`, { cause: error });
|
|
64
|
+
}
|
|
55
65
|
if (module && typeof module === 'object') {
|
|
56
66
|
for (const type of Object.values(module)) {
|
|
57
67
|
if (typeof type !== 'function' || !type.prototype) continue;
|
|
58
68
|
if (hasModelBoundProperties(type)) {
|
|
59
|
-
this.
|
|
69
|
+
this.trackModelBoundProperty(type as Constructor);
|
|
60
70
|
}
|
|
61
71
|
}
|
|
62
72
|
}
|
|
63
73
|
}
|
|
64
74
|
}
|
|
65
75
|
|
|
76
|
+
/** Collects property-bound models without registering child names as root model identifiers. */
|
|
77
|
+
trackModelBoundProperty(type: Constructor): void {
|
|
78
|
+
TypeDiscoverer._propertyOnlyModels.add(type);
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/** Returns models with property mappings for artifact registration-time root filtering. */
|
|
82
|
+
getPropertyOnlyModels(): Constructor[] {
|
|
83
|
+
return [...TypeDiscoverer._propertyOnlyModels];
|
|
84
|
+
}
|
|
85
|
+
|
|
66
86
|
/**
|
|
67
87
|
* Registers a discoverable type for a decorator category.
|
|
68
88
|
* @param decoratorType - The decorator category to register for.
|
|
@@ -116,9 +136,10 @@ export class TypeDiscoverer {
|
|
|
116
136
|
*/
|
|
117
137
|
clear(): void {
|
|
118
138
|
TypeDiscoverer._registeredTypes.clear();
|
|
139
|
+
TypeDiscoverer._propertyOnlyModels.clear();
|
|
119
140
|
}
|
|
120
141
|
|
|
121
|
-
private static async resolveWithGlobPackage(pattern: string | string[]): Promise<string[]> {
|
|
142
|
+
private static async resolveWithGlobPackage(pattern: string | string[], options?: { ignore: string[] }): Promise<string[]> {
|
|
122
143
|
let globFunction: unknown;
|
|
123
144
|
try {
|
|
124
145
|
const globModule = await import('glob') as { glob?: unknown };
|
|
@@ -131,7 +152,7 @@ export class TypeDiscoverer {
|
|
|
131
152
|
throw new Error('The "glob" module was loaded but does not export a function named "glob".');
|
|
132
153
|
}
|
|
133
154
|
|
|
134
|
-
const files = await globFunction(pattern);
|
|
155
|
+
const files = await globFunction(pattern, options);
|
|
135
156
|
if (!Array.isArray(files) || files.some(file => typeof file !== 'string')) {
|
|
136
157
|
throw new Error('Type discovery glob resolution did not return an array of file paths.');
|
|
137
158
|
}
|
|
@@ -82,11 +82,12 @@ export class TypeIntrospector {
|
|
|
82
82
|
|
|
83
83
|
for (let index = 0; index < constructorParameterNames.length; index++) {
|
|
84
84
|
const parameterName = constructorParameterNames[index];
|
|
85
|
-
|
|
85
|
+
const resolvedType = members.get(parameterName);
|
|
86
|
+
if (resolvedType && resolvedType !== Object) {
|
|
86
87
|
continue;
|
|
87
88
|
}
|
|
88
89
|
|
|
89
|
-
members.set(parameterName, constructorParameterTypes[index]);
|
|
90
|
+
members.set(parameterName, constructorParameterTypes[index] ?? resolvedType);
|
|
90
91
|
}
|
|
91
92
|
|
|
92
93
|
return members;
|
|
@@ -0,0 +1,11 @@
|
|
|
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 'reflect-metadata';
|
|
5
|
+
|
|
6
|
+
/** Resolves the runtime value type erased from ConceptAs<T>. */
|
|
7
|
+
export function conceptValueType(type: Function): Function | undefined {
|
|
8
|
+
return (type as Function & { valueType?: Function }).valueType ??
|
|
9
|
+
Reflect.getMetadata('design:type', type.prototype, 'value') as Function | undefined ??
|
|
10
|
+
(Reflect.getMetadata('design:paramtypes', type) as Function[] | undefined)?.[0];
|
|
11
|
+
}
|
|
@@ -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
|
+
|
|
4
|
+
import type { Constructor } from '@cratis/fundamentals';
|
|
5
|
+
import { TypeDiscoverer } from './TypeDiscoverer.js';
|
|
6
|
+
import { ChronicleClassOrPropertyDecorator, ChroniclePropertyDecorator, decorateClassOrProperty, decorateProperty } from './propertyDecoratorMetadata.js';
|
|
7
|
+
import { getStandardMetadata, hasOwnStandardMetadata } from './standardDecoratorMetadata.js';
|
|
8
|
+
|
|
9
|
+
const registered = new WeakSet<Function>();
|
|
10
|
+
|
|
11
|
+
function register(type: Function): void {
|
|
12
|
+
if (registered.has(type)) return;
|
|
13
|
+
TypeDiscoverer.default.trackModelBoundProperty(type as Constructor);
|
|
14
|
+
registered.add(type);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
function registerDeclaringClass(instance: object, metadata: object): void {
|
|
18
|
+
let type: Function | null = instance.constructor;
|
|
19
|
+
while (type && (!hasOwnStandardMetadata(type) || getStandardMetadata(type) !== metadata)) {
|
|
20
|
+
type = Object.getPrototypeOf(type) as Function | null;
|
|
21
|
+
}
|
|
22
|
+
if (type) register(type);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** Registers a mapped class when its property decorator can identify the constructor. */
|
|
26
|
+
export function decorateModelBoundProperty(legacy: PropertyDecorator): ChroniclePropertyDecorator {
|
|
27
|
+
const decorate = decorateProperty(legacy);
|
|
28
|
+
return (target: object | undefined, keyOrContext: string | symbol | ClassFieldDecoratorContext) => {
|
|
29
|
+
decorate(target as object, keyOrContext as string);
|
|
30
|
+
if (typeof keyOrContext === 'object') {
|
|
31
|
+
// Standard field decorators do not receive the class constructor. Their initializer
|
|
32
|
+
// runs when the first instance is created; direct queries can also register the type.
|
|
33
|
+
const metadata = keyOrContext.metadata;
|
|
34
|
+
keyOrContext.addInitializer(function () { if (metadata) registerDeclaringClass(this as object, metadata); });
|
|
35
|
+
} else {
|
|
36
|
+
register((target as { constructor: Function }).constructor);
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/** Registers property mappings without changing class-level decorator behavior. */
|
|
42
|
+
export function decorateModelBoundClassOrProperty(legacy: (target: object, property?: string | symbol) => void): ChronicleClassOrPropertyDecorator {
|
|
43
|
+
const decorate = decorateClassOrProperty(legacy);
|
|
44
|
+
return (target: object | undefined, keyOrContext?: string | symbol | ClassDecoratorContext | ClassFieldDecoratorContext) => {
|
|
45
|
+
decorate(target as object, keyOrContext as string);
|
|
46
|
+
if (typeof keyOrContext === 'object' && keyOrContext?.kind === 'field') {
|
|
47
|
+
const metadata = keyOrContext.metadata;
|
|
48
|
+
keyOrContext.addInitializer(function () { if (metadata) registerDeclaringClass(this as object, metadata); });
|
|
49
|
+
} else if (typeof keyOrContext === 'string' || typeof keyOrContext === 'symbol') {
|
|
50
|
+
register((target as { constructor: Function }).constructor);
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
}
|
|
@@ -1,137 +0,0 @@
|
|
|
1
|
-
import { BinaryReader, BinaryWriter } from '@bufbuild/protobuf/wire';
|
|
2
|
-
import type { CallOptions } from 'nice-grpc-common';
|
|
3
|
-
/**
|
|
4
|
-
* The type of endpoint an external service exposes.
|
|
5
|
-
*/
|
|
6
|
-
export declare enum ExternalServiceEndpointType {
|
|
7
|
-
Http = 0,
|
|
8
|
-
MsSql = 1,
|
|
9
|
-
PostgreSql = 2
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Basic authentication credentials for an HTTP endpoint.
|
|
13
|
-
*/
|
|
14
|
-
export interface BasicAuthorization {
|
|
15
|
-
Username: string;
|
|
16
|
-
Password: string;
|
|
17
|
-
}
|
|
18
|
-
/**
|
|
19
|
-
* A bearer token for an HTTP endpoint.
|
|
20
|
-
*/
|
|
21
|
-
export interface BearerTokenAuthorization {
|
|
22
|
-
Token: string;
|
|
23
|
-
}
|
|
24
|
-
/**
|
|
25
|
-
* OAuth client credentials for an HTTP endpoint.
|
|
26
|
-
*/
|
|
27
|
-
export interface OAuthAuthorization {
|
|
28
|
-
Authority: string;
|
|
29
|
-
ClientId: string;
|
|
30
|
-
ClientSecret: string;
|
|
31
|
-
}
|
|
32
|
-
/**
|
|
33
|
-
* The authorization configured for an HTTP endpoint - at most one of the three is set.
|
|
34
|
-
*/
|
|
35
|
-
export interface OneOfBasicAuthorizationBearerTokenAuthorizationOAuthAuthorization {
|
|
36
|
-
Value0: BasicAuthorization | undefined;
|
|
37
|
-
Value1: BearerTokenAuthorization | undefined;
|
|
38
|
-
Value2: OAuthAuthorization | undefined;
|
|
39
|
-
}
|
|
40
|
-
/**
|
|
41
|
-
* Configuration for an HTTP-based external service endpoint.
|
|
42
|
-
*/
|
|
43
|
-
export interface HttpEndpointConfiguration {
|
|
44
|
-
Url: string;
|
|
45
|
-
Authorization: OneOfBasicAuthorizationBearerTokenAuthorizationOAuthAuthorization | undefined;
|
|
46
|
-
Headers: {
|
|
47
|
-
[key: string]: string;
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
/**
|
|
51
|
-
* Configuration for a database-based external service endpoint.
|
|
52
|
-
*/
|
|
53
|
-
export interface DatabaseEndpointConfiguration {
|
|
54
|
-
Host: string;
|
|
55
|
-
Port: number;
|
|
56
|
-
Database: string;
|
|
57
|
-
Username: string;
|
|
58
|
-
Password: string;
|
|
59
|
-
Options: {
|
|
60
|
-
[key: string]: string;
|
|
61
|
-
};
|
|
62
|
-
}
|
|
63
|
-
/**
|
|
64
|
-
* The endpoint configured for an external service - either Http or Database, based on Type.
|
|
65
|
-
*/
|
|
66
|
-
export interface ExternalServiceEndpoint {
|
|
67
|
-
Type: ExternalServiceEndpointType;
|
|
68
|
-
Http: HttpEndpointConfiguration | undefined;
|
|
69
|
-
Database: DatabaseEndpointConfiguration | undefined;
|
|
70
|
-
}
|
|
71
|
-
/**
|
|
72
|
-
* The definition of an external service registration.
|
|
73
|
-
*/
|
|
74
|
-
export interface ExternalServiceDefinition {
|
|
75
|
-
Id: string;
|
|
76
|
-
Name: string;
|
|
77
|
-
Endpoint: ExternalServiceEndpoint | undefined;
|
|
78
|
-
}
|
|
79
|
-
/**
|
|
80
|
-
* Request for registering external services with the Kernel.
|
|
81
|
-
*/
|
|
82
|
-
export interface AddExternalServices {
|
|
83
|
-
EventStore: string;
|
|
84
|
-
ExternalServices: ExternalServiceDefinition[];
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* An empty protobuf message.
|
|
88
|
-
*/
|
|
89
|
-
export interface Empty {
|
|
90
|
-
}
|
|
91
|
-
type Builtin = Date | Function | Uint8Array | string | number | boolean | bigint | undefined;
|
|
92
|
-
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 {} ? {
|
|
93
|
-
[K in keyof T]?: DeepPartial<T[K]>;
|
|
94
|
-
} : Partial<T>;
|
|
95
|
-
interface MessageFns<T> {
|
|
96
|
-
encode(message: T, writer?: BinaryWriter): BinaryWriter;
|
|
97
|
-
decode(input: BinaryReader | Uint8Array, length?: number): T;
|
|
98
|
-
fromJSON(object: unknown): T;
|
|
99
|
-
toJSON(message: T): unknown;
|
|
100
|
-
create(base?: DeepPartial<T>): T;
|
|
101
|
-
fromPartial(object: DeepPartial<T>): T;
|
|
102
|
-
}
|
|
103
|
-
export declare const EmptyMessage: MessageFns<Empty>;
|
|
104
|
-
export declare const BasicAuthorizationMessage: MessageFns<BasicAuthorization>;
|
|
105
|
-
export declare const BearerTokenAuthorizationMessage: MessageFns<BearerTokenAuthorization>;
|
|
106
|
-
export declare const OAuthAuthorizationMessage: MessageFns<OAuthAuthorization>;
|
|
107
|
-
export declare const OneOfBasicAuthorizationBearerTokenAuthorizationOAuthAuthorizationMessage: MessageFns<OneOfBasicAuthorizationBearerTokenAuthorizationOAuthAuthorization>;
|
|
108
|
-
export declare const HttpEndpointConfigurationMessage: MessageFns<HttpEndpointConfiguration>;
|
|
109
|
-
export declare const DatabaseEndpointConfigurationMessage: MessageFns<DatabaseEndpointConfiguration>;
|
|
110
|
-
export declare const ExternalServiceEndpointMessage: MessageFns<ExternalServiceEndpoint>;
|
|
111
|
-
export declare const ExternalServiceDefinitionMessage: MessageFns<ExternalServiceDefinition>;
|
|
112
|
-
export declare const AddExternalServicesMessage: MessageFns<AddExternalServices>;
|
|
113
|
-
/**
|
|
114
|
-
* External services gRPC service definition, for use with nice-grpc's client factory.
|
|
115
|
-
*/
|
|
116
|
-
export declare const ExternalServicesDefinition: {
|
|
117
|
-
readonly name: 'ExternalServices';
|
|
118
|
-
readonly fullName: 'Cratis.Chronicle.Contracts.ExternalServices.ExternalServices';
|
|
119
|
-
readonly methods: {
|
|
120
|
-
readonly add: {
|
|
121
|
-
readonly name: 'Add';
|
|
122
|
-
readonly requestType: MessageFns<AddExternalServices>;
|
|
123
|
-
readonly requestStream: false;
|
|
124
|
-
readonly responseType: MessageFns<Empty>;
|
|
125
|
-
readonly responseStream: false;
|
|
126
|
-
readonly options: {};
|
|
127
|
-
};
|
|
128
|
-
};
|
|
129
|
-
};
|
|
130
|
-
/**
|
|
131
|
-
* External services service client interface.
|
|
132
|
-
*/
|
|
133
|
-
export interface ExternalServicesClient<CallOptionsExt = {}> {
|
|
134
|
-
add(request: DeepPartial<AddExternalServices>, options?: CallOptions & CallOptionsExt): Promise<Empty>;
|
|
135
|
-
}
|
|
136
|
-
export {};
|
|
137
|
-
//# sourceMappingURL=ExternalServicesContracts.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"ExternalServicesContracts.d.ts","sourceRoot":"","sources":["../../externalServices/ExternalServicesContracts.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,yBA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