@cratis/chronicle 6.54.0 → 6.56.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.
Files changed (170) hide show
  1. package/ChronicleClient.ts +16 -3
  2. package/ChronicleOptions.ts +11 -0
  3. package/EventStore.ts +8 -3
  4. package/WellKnownTelemetryNames.ts +2 -0
  5. package/artifacts/refuseClientHostedObservers.ts +16 -0
  6. package/connection/ChronicleConnection.auth.spec.ts +2 -0
  7. package/connection/ChronicleConnection.ts +21 -9
  8. package/connection/ChronicleConnectionString.ts +26 -1
  9. package/connection/ClientObserversRequireKeepAlive.ts +10 -0
  10. package/connection/for_ChronicleConnection/when_deferring_client_creation/and_connecting.spec.ts +83 -0
  11. package/connection/for_TraceContextMiddleware/when_calling/with_active_context.spec.ts +1 -0
  12. package/connection/for_TraceContextMiddleware/when_calling/with_grpc_instrumentation.spec.ts +1 -0
  13. package/dist/ChronicleClient.d.ts +1 -0
  14. package/dist/ChronicleClient.d.ts.map +1 -1
  15. package/dist/ChronicleClient.js +16 -3
  16. package/dist/ChronicleClient.js.map +1 -1
  17. package/dist/ChronicleOptions.d.ts +4 -0
  18. package/dist/ChronicleOptions.d.ts.map +1 -1
  19. package/dist/ChronicleOptions.js +7 -0
  20. package/dist/ChronicleOptions.js.map +1 -1
  21. package/dist/EventStore.d.ts +2 -1
  22. package/dist/EventStore.d.ts.map +1 -1
  23. package/dist/EventStore.js +10 -3
  24. package/dist/EventStore.js.map +1 -1
  25. package/dist/WellKnownTelemetryNames.d.ts +2 -0
  26. package/dist/WellKnownTelemetryNames.d.ts.map +1 -1
  27. package/dist/WellKnownTelemetryNames.js +2 -0
  28. package/dist/WellKnownTelemetryNames.js.map +1 -1
  29. package/dist/artifacts/refuseClientHostedObservers.d.ts +4 -0
  30. package/dist/artifacts/refuseClientHostedObservers.d.ts.map +1 -0
  31. package/dist/artifacts/refuseClientHostedObservers.js +15 -0
  32. package/dist/artifacts/refuseClientHostedObservers.js.map +1 -0
  33. package/dist/connection/ChronicleConnection.d.ts +7 -1
  34. package/dist/connection/ChronicleConnection.d.ts.map +1 -1
  35. package/dist/connection/ChronicleConnection.js +13 -8
  36. package/dist/connection/ChronicleConnection.js.map +1 -1
  37. package/dist/connection/ChronicleConnectionString.d.ts +8 -0
  38. package/dist/connection/ChronicleConnectionString.d.ts.map +1 -1
  39. package/dist/connection/ChronicleConnectionString.js +21 -1
  40. package/dist/connection/ChronicleConnectionString.js.map +1 -1
  41. package/dist/connection/ClientObserversRequireKeepAlive.d.ts +7 -0
  42. package/dist/connection/ClientObserversRequireKeepAlive.d.ts.map +1 -0
  43. package/dist/connection/ClientObserversRequireKeepAlive.js +14 -0
  44. package/dist/connection/ClientObserversRequireKeepAlive.js.map +1 -0
  45. package/dist/eventSequences/EventSequence.d.ts +3 -0
  46. package/dist/eventSequences/EventSequence.d.ts.map +1 -1
  47. package/dist/eventSequences/EventSequence.js +29 -1
  48. package/dist/eventSequences/EventSequence.js.map +1 -1
  49. package/dist/eventSequences/IEventSequence.d.ts +12 -0
  50. package/dist/eventSequences/IEventSequence.d.ts.map +1 -1
  51. package/dist/eventSequences/ITransactionalEventSequence.d.ts +6 -0
  52. package/dist/eventSequences/ITransactionalEventSequence.d.ts.map +1 -1
  53. package/dist/eventSequences/TransactionalEventSequence.d.ts.map +1 -1
  54. package/dist/eventSequences/TransactionalEventSequence.js +3 -1
  55. package/dist/eventSequences/TransactionalEventSequence.js.map +1 -1
  56. package/dist/externalServices/ExternalServiceBuilder.js +1 -1
  57. package/dist/externalServices/ExternalServiceBuilder.js.map +1 -1
  58. package/dist/for_ChronicleClient/when_skipping_keep_alive/native-exit-probe.d.ts +2 -0
  59. package/dist/for_ChronicleClient/when_skipping_keep_alive/native-exit-probe.d.ts.map +1 -0
  60. package/dist/for_ChronicleClient/when_skipping_keep_alive/native-exit-probe.js +107 -0
  61. package/dist/for_ChronicleClient/when_skipping_keep_alive/native-exit-probe.js.map +1 -0
  62. package/dist/index.d.ts +1 -0
  63. package/dist/index.d.ts.map +1 -1
  64. package/dist/index.js +1 -0
  65. package/dist/index.js.map +1 -1
  66. package/dist/reactors/Reactors.d.ts +2 -1
  67. package/dist/reactors/Reactors.d.ts.map +1 -1
  68. package/dist/reactors/Reactors.js +12 -3
  69. package/dist/reactors/Reactors.js.map +1 -1
  70. package/dist/readModels/for_ReadModels/given/a_stored_read_model.d.ts.map +1 -1
  71. package/dist/readModels/for_ReadModels/given/a_stored_read_model.js +1 -1
  72. package/dist/readModels/for_ReadModels/given/a_stored_read_model.js.map +1 -1
  73. package/dist/readModels/indexDecorator.js +1 -1
  74. package/dist/readModels/indexDecorator.js.map +1 -1
  75. package/dist/reducers/Reducers.d.ts +2 -1
  76. package/dist/reducers/Reducers.d.ts.map +1 -1
  77. package/dist/reducers/Reducers.js +8 -2
  78. package/dist/reducers/Reducers.js.map +1 -1
  79. package/dist/reducers/ReductionOutcome.d.ts.map +1 -1
  80. package/dist/reducers/ReductionOutcome.js +4 -1
  81. package/dist/reducers/ReductionOutcome.js.map +1 -1
  82. package/dist/testing/InProcessEventSequence.d.ts +2 -1
  83. package/dist/testing/InProcessEventSequence.d.ts.map +1 -1
  84. package/dist/testing/InProcessEventSequence.js +1 -0
  85. package/dist/testing/InProcessEventSequence.js.map +1 -1
  86. package/dist/transactions/AppendOptionNotSupportedInUnitOfWork.d.ts +13 -0
  87. package/dist/transactions/AppendOptionNotSupportedInUnitOfWork.d.ts.map +1 -0
  88. package/dist/transactions/AppendOptionNotSupportedInUnitOfWork.js +19 -0
  89. package/dist/transactions/AppendOptionNotSupportedInUnitOfWork.js.map +1 -0
  90. package/dist/transactions/ConflictingAppendOptionNamesInUnitOfWork.d.ts +14 -0
  91. package/dist/transactions/ConflictingAppendOptionNamesInUnitOfWork.d.ts.map +1 -0
  92. package/dist/transactions/ConflictingAppendOptionNamesInUnitOfWork.js +21 -0
  93. package/dist/transactions/ConflictingAppendOptionNamesInUnitOfWork.js.map +1 -0
  94. package/dist/transactions/IUnitOfWork.d.ts +3 -0
  95. package/dist/transactions/IUnitOfWork.d.ts.map +1 -1
  96. package/dist/transactions/TransactionalAppendOptions.d.ts +8 -0
  97. package/dist/transactions/TransactionalAppendOptions.d.ts.map +1 -1
  98. package/dist/transactions/UnitOfWork.d.ts.map +1 -1
  99. package/dist/transactions/UnitOfWork.js +4 -2
  100. package/dist/transactions/UnitOfWork.js.map +1 -1
  101. package/dist/transactions/concurrencyScopesAreEqual.d.ts.map +1 -1
  102. package/dist/transactions/concurrencyScopesAreEqual.js +4 -3
  103. package/dist/transactions/concurrencyScopesAreEqual.js.map +1 -1
  104. package/dist/transactions/index.d.ts +2 -0
  105. package/dist/transactions/index.d.ts.map +1 -1
  106. package/dist/transactions/index.js +2 -0
  107. package/dist/transactions/index.js.map +1 -1
  108. package/dist/transactions/resolveTransactionalAppendOptions.d.ts +8 -0
  109. package/dist/transactions/resolveTransactionalAppendOptions.d.ts.map +1 -0
  110. package/dist/transactions/resolveTransactionalAppendOptions.js +58 -0
  111. package/dist/transactions/resolveTransactionalAppendOptions.js.map +1 -0
  112. package/dist/tsconfig.tsbuildinfo +1 -1
  113. package/dist/webhooks/WebhookDefinitionBuilder.d.ts.map +1 -1
  114. package/dist/webhooks/WebhookDefinitionBuilder.js +4 -2
  115. package/dist/webhooks/WebhookDefinitionBuilder.js.map +1 -1
  116. package/dist/webhooks/Webhooks.d.ts.map +1 -1
  117. package/dist/webhooks/Webhooks.js +2 -1
  118. package/dist/webhooks/Webhooks.js.map +1 -1
  119. package/eventSequences/EventSequence.spec.ts +55 -0
  120. package/eventSequences/EventSequence.ts +30 -1
  121. package/eventSequences/IEventSequence.ts +13 -0
  122. package/eventSequences/ITransactionalEventSequence.ts +6 -0
  123. package/eventSequences/TransactionalEventSequence.ts +3 -1
  124. package/eventSequences/for_TransactionalEventSequence/when_appending_many_with_append_option_names.spec.ts +26 -0
  125. package/eventSequences/for_TransactionalEventSequence/when_appending_many_with_unsupported_options.spec.ts +35 -0
  126. package/externalServices/ExternalServiceBuilder.ts +1 -1
  127. package/externalServices/ExternalServices.spec.ts +1 -1
  128. package/for_ChronicleClient/against_a_kernel/when_skipping_keep_alive.integration.spec.ts +80 -0
  129. package/for_ChronicleClient/when_skipping_keep_alive/and_connecting.spec.ts +158 -0
  130. package/for_ChronicleClient/when_skipping_keep_alive/native-exit-probe.ts +84 -0
  131. package/for_ChronicleClient/when_starting_background_work/with_a_correlated_caller.spec.ts +1 -0
  132. package/for_ChronicleOptions/when_configuring_keep_alive/with_skip_keep_alive.spec.ts +35 -0
  133. package/for_EventStore/when_skipping_keep_alive/when_registering_artifacts.spec.ts +51 -0
  134. package/index.ts +1 -0
  135. package/package.json +2 -2
  136. package/reactors/Reactors.ts +10 -3
  137. package/reactors/for_Reactors/when_skipping_keep_alive/with_a_reactor.spec.ts +48 -0
  138. package/readModels/for_ReadModels/given/a_stored_read_model.ts +1 -1
  139. package/readModels/indexDecorator.legacy.spec.ts +7 -7
  140. package/readModels/indexDecorator.ts +1 -1
  141. package/readModels/indexRegistration.spec.ts +4 -4
  142. package/readModels/standardFallbacks.standard.spec.ts +2 -2
  143. package/reducers/Reducers.ts +6 -2
  144. package/reducers/ReductionOutcome.ts +4 -1
  145. package/reducers/for_Reducers/when_skipping_keep_alive/with_a_reducer.spec.ts +53 -0
  146. package/telemetry/for_ChronicleTelemetry/given/a_client.fixture.ts +1 -0
  147. package/telemetry/for_ChronicleTelemetry/given/a_span_name_registry.fixture.ts +2 -0
  148. package/telemetry/for_ChronicleTelemetry/given/an_event_sequence.fixture.ts +2 -1
  149. package/telemetry/for_ChronicleTelemetry/when_naming_spans/with_convention_names.spec.ts +1 -0
  150. package/telemetry/for_ChronicleTelemetry/when_recording_identifiers/with_per_client_privacy.spec.ts +2 -1
  151. package/testing/InProcessEventSequence.ts +1 -0
  152. package/transactions/AppendOptionNotSupportedInUnitOfWork.ts +17 -0
  153. package/transactions/ConflictingAppendOptionNamesInUnitOfWork.ts +17 -0
  154. package/transactions/IUnitOfWork.ts +3 -0
  155. package/transactions/TransactionalAppendOptions.ts +11 -0
  156. package/transactions/UnitOfWork.ts +4 -2
  157. package/transactions/concurrencyScopesAreEqual.ts +4 -3
  158. package/transactions/for_UnitOfWork/when_adding_events_with_append_option_names/and_both_names_have_different_values.spec.ts +65 -0
  159. package/transactions/for_UnitOfWork/when_adding_events_with_append_option_names/and_both_names_have_the_same_value.spec.ts +22 -0
  160. package/transactions/for_UnitOfWork/when_adding_events_with_append_option_names/and_the_append_option_names_are_used.spec.ts +25 -0
  161. package/transactions/for_UnitOfWork/when_adding_events_with_concurrency_scopes/and_a_routing_field_is_empty_versus_named.spec.ts +40 -0
  162. package/transactions/for_UnitOfWork/when_adding_events_with_concurrency_scopes/and_routing_fields_are_undefined_or_empty.spec.ts +39 -0
  163. package/transactions/for_UnitOfWork/when_adding_events_with_unsupported_append_options/and_a_correlation_id_is_given.spec.ts +38 -0
  164. package/transactions/for_UnitOfWork/when_adding_events_with_unsupported_append_options/and_an_event_source_id_is_given.spec.ts +38 -0
  165. package/transactions/for_UnitOfWork/when_adding_events_with_unsupported_append_options/and_concurrency_scopes_are_given.spec.ts +38 -0
  166. package/transactions/for_UnitOfWork/when_adding_events_with_unsupported_append_options/and_the_option_is_undefined.spec.ts +24 -0
  167. package/transactions/index.ts +2 -0
  168. package/transactions/resolveTransactionalAppendOptions.ts +68 -0
  169. package/webhooks/WebhookDefinitionBuilder.ts +4 -2
  170. package/webhooks/Webhooks.ts +2 -1
@@ -53,7 +53,7 @@ describe('ExternalServices registration', () => {
53
53
  const request = await requestFor(builder => builder.http('https://example.com').withOAuth('https://auth', 'client', 'secret'));
54
54
  expect(request.ExternalServices[0].Endpoint?.Http?.Authorization).toEqual({
55
55
  Value0: undefined, Value1: undefined,
56
- Value2: { Authority: 'https://auth', ClientId: 'client', ClientSecret: 'secret' }
56
+ Value2: { Authority: 'https://auth', ClientId: 'client', ClientSecret: 'secret', Scope: '' }
57
57
  });
58
58
  });
59
59
 
@@ -0,0 +1,80 @@
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 { randomUUID } from 'node:crypto';
5
+ import { spawn } from 'node:child_process';
6
+ import { afterAll, beforeAll, chai, describe, it } from 'vitest';
7
+ import { field } from '@cratis/fundamentals';
8
+ import { ChronicleClient, ChronicleOptions, eventType, fromEvent, reactor, reducer, ClientObserversRequireKeepAlive,
9
+ type IClientArtifactsProvider, type IEventStore } from '../../index.js';
10
+ import { ChronicleConnection } from '../../connection/ChronicleConnection.js';
11
+
12
+ chai.should();
13
+ const connectionString = process.env.CHRONICLE_INTEGRATION_CONNECTION_STRING;
14
+ @eventType('skip-integration-item')
15
+ class Item { @field(String) value = ''; }
16
+ @fromEvent(Item)
17
+ class Model { @field(String) value = ''; }
18
+ @reactor('skip-integration-reactor')
19
+ class Observer {}
20
+ @reducer('skip-integration-reducer')
21
+ class Reducer {}
22
+ const artifacts = (): IClientArtifactsProvider => ({ eventTypes: [Item], readModels: [Model], reactors: [], reducers: [],
23
+ constraints: [], projections: [], seeders: [], webhooks: [], eventTypeMigrations: [], globalForHandlers: [] });
24
+ const connections: ChronicleClient[] = [];
25
+ function create(skipKeepAlive: boolean, provider = artifacts()) {
26
+ const client = new ChronicleClient(ChronicleOptions.fromConnectionString(connectionString!, {
27
+ skipKeepAlive, discoveryPatterns: [], clientArtifactsProvider: provider
28
+ }));
29
+ connections.push(client);
30
+ return client;
31
+ }
32
+ function transport(client: ChronicleClient) {
33
+ return (client as unknown as { _connection: ChronicleConnection })._connection;
34
+ }
35
+
36
+ describe.skipIf(!connectionString)('when skipping keep alive against a kernel', () => {
37
+ let client: ChronicleClient;
38
+ let store: IEventStore;
39
+ // MongoDB caps database names at 63 bytes, and the kernel appends '+es+<namespace>' to the event store name.
40
+ const name = `skip-${randomUUID().slice(0, 8)}`;
41
+ beforeAll(async () => { client = create(true); store = await client.getEventStore(name); }, 30_000);
42
+ afterAll(() => connections.forEach(client => client.dispose()));
43
+ it('should append and query without a connected-client entry', async () => {
44
+ const item = new Item();
45
+ item.value = randomUUID();
46
+ await store.eventLog.append(randomUUID(), item);
47
+ (await store.eventLog.getTailSequenceNumber()).value.should.be.greaterThanOrEqual(0n);
48
+ const after = await transport(client).connections.getConnectedClients({});
49
+ const id = (client as unknown as { _lifecycle: { connectionId: string } })._lifecycle.connectionId;
50
+ after.items.some(entry => entry.ConnectionId === id).should.be.false;
51
+ });
52
+ it('should leave read model watch streams available', async () => {
53
+ const watcher = store.readModels.createWatcher(Model);
54
+ try { await watcher.subscribed; } finally { watcher.dispose(); }
55
+ });
56
+ for (const kind of ['reactors', 'reducers'] as const) {
57
+ it(`should refuse ${kind} without creating a store`, async () => {
58
+ const provider = artifacts();
59
+ provider[kind].push(kind === 'reactors' ? Observer : Reducer);
60
+ const candidate = create(true, provider);
61
+ const [result] = await Promise.allSettled([candidate.getEventStore(`refused-${randomUUID().slice(0, 8)}`)]);
62
+ result.status.should.equal('rejected');
63
+ if (result.status === 'rejected') result.reason.should.be.instanceOf(ClientObserversRequireKeepAlive);
64
+ });
65
+ }
66
+ it('should retain the default connected-client entry', async () => {
67
+ const candidate = create(false, { ...artifacts(), readModels: [] });
68
+ await candidate.getEventStore(`${name}-default`);
69
+ const id = (candidate as unknown as { _lifecycle: { connectionId: string } })._lifecycle.connectionId;
70
+ const clients = await transport(candidate).connections.getConnectedClients({});
71
+ clients.items.some(entry => entry.ConnectionId === id).should.be.true;
72
+ });
73
+ it('should exit naturally in plain Node only when keep alive is skipped', async () => {
74
+ await new Promise<void>((resolve, reject) => {
75
+ const child = spawn(process.execPath, ['scripts/check-skip-keepalive-exit.mjs'], { stdio: 'inherit' });
76
+ child.once('error', reject);
77
+ child.once('exit', (code, signal) => code === 0 && !signal ? resolve() : reject(new Error(`Native probe failed: ${code}/${signal}`)));
78
+ });
79
+ }, 90_000);
80
+ });
@@ -0,0 +1,158 @@
1
+ // Copyright (c) Cratis. All rights reserved.
2
+ // Licensed under the MIT license. See LICENSE file in the project root for full license information.
3
+
4
+ import { afterEach, beforeEach, chai, describe, it, vi } from 'vitest';
5
+ import { ChronicleClient } from '../../ChronicleClient.js';
6
+ import { ChronicleOptions } from '../../ChronicleOptions.js';
7
+ import { IClientArtifactsProvider } from '../../artifacts/IClientArtifactsProvider.js';
8
+ import { eventType } from '../../events/eventTypeDecorator.js';
9
+ import { fromEvent } from '../../projections/modelBound/fromEvent.js';
10
+ import { reactor } from '../../reactors/reactor.js';
11
+ import { reducer } from '../../reducers/reducer.js';
12
+ import { TypeDiscoverer } from '../../types/TypeDiscoverer.js';
13
+ import { ClientObserversRequireKeepAlive } from '../../connection/ClientObserversRequireKeepAlive.js';
14
+
15
+ chai.should();
16
+ const transport = vi.hoisted(() => ({
17
+ constructor: vi.fn(), resetChannel: vi.fn(), connect: vi.fn(), disconnect: vi.fn(),
18
+ getVersionInfo: vi.fn(), ensureEventStore: vi.fn(), register: vi.fn(), observe: vi.fn(),
19
+ allEventStores: vi.fn(), kernelConstructor: vi.fn(), start: vi.fn(),
20
+ connectStream: vi.fn(), connectionKeepAlive: vi.fn(), registerModels: vi.fn(), registerProjection: vi.fn()
21
+ }));
22
+ vi.mock('../../connection/ChronicleConnection', () => ({
23
+ ChronicleConnection: class {
24
+ constructor(options: unknown) { transport.constructor(options); }
25
+ resetChannel = transport.resetChannel;
26
+ connect = transport.connect;
27
+ disconnect = transport.disconnect;
28
+ server = { getVersionInfo: transport.getVersionInfo };
29
+ eventStores = { ensureEventStore: transport.ensureEventStore, allEventStores: transport.allEventStores };
30
+ eventTypes = new Proxy({}, { get: () => transport.register });
31
+ constraints = new Proxy({}, { get: () => transport.register });
32
+ projections = { register: transport.registerProjection };
33
+ readModels = { registerMany: transport.registerModels };
34
+ webhooks = new Proxy({}, { get: () => transport.register });
35
+ eventSeeding = new Proxy({}, { get: () => transport.register });
36
+ reactors = { observe: transport.observe };
37
+ reducers = { observe: transport.observe };
38
+ connections = { connect: transport.connectStream, connectionKeepAlive: transport.connectionKeepAlive };
39
+ }
40
+ }));
41
+ vi.mock('../../connection/KernelKeepAlive', () => ({
42
+ KernelKeepAlive: class {
43
+ constructor() { transport.kernelConstructor(); }
44
+ start = transport.start;
45
+ }
46
+ }));
47
+ @eventType('skip-item')
48
+ class Item {}
49
+ @fromEvent(Item)
50
+ class ItemModel {}
51
+ @reactor('skip-reactor')
52
+ class ItemReactor { item() {} }
53
+ @reducer('skip-reducer')
54
+ class ItemReducer { item() {} }
55
+
56
+ let client: ChronicleClient;
57
+ let artifacts: IClientArtifactsProvider;
58
+ let interval: ReturnType<typeof vi.spyOn>;
59
+ let timeout: ReturnType<typeof vi.spyOn>;
60
+ function create(skipKeepAlive = true, discoveryPatterns: string[] = []) {
61
+ client = new ChronicleClient(ChronicleOptions.fromConnectionString('chronicle://localhost:35000', {
62
+ skipKeepAlive, discoveryPatterns, clientArtifactsProvider: artifacts
63
+ }));
64
+ return client;
65
+ }
66
+ beforeEach(() => {
67
+ vi.clearAllMocks();
68
+ transport.ensureEventStore.mockResolvedValue({ IsAuthorized: true });
69
+ transport.register.mockResolvedValue({});
70
+ transport.registerModels.mockResolvedValue({});
71
+ transport.registerProjection.mockResolvedValue({});
72
+ transport.allEventStores.mockResolvedValue({ Data: [] });
73
+ artifacts = { eventTypes: [Item], readModels: [ItemModel], reactors: [], reducers: [], seeders: [],
74
+ constraints: [], projections: [], webhooks: [], eventTypeMigrations: [], globalForHandlers: [] };
75
+ interval = vi.spyOn(globalThis, 'setInterval');
76
+ timeout = vi.spyOn(globalThis, 'setTimeout');
77
+ });
78
+ afterEach(() => { client?.dispose(); vi.restoreAllMocks(); });
79
+
80
+ describe('when skipping keep alive and connecting', () => {
81
+ it('should connect and register event types and model-bound projections without streams or timers', async () => {
82
+ await create().getEventStore('store');
83
+ transport.constructor.mock.calls[0][0].deferClientCreation.should.be.true;
84
+ transport.getVersionInfo.mock.calls.should.have.lengthOf(1);
85
+ transport.register.mock.calls.length.should.be.greaterThan(0);
86
+ transport.registerModels.mock.calls.length.should.be.greaterThan(0);
87
+ transport.registerProjection.mock.calls.length.should.be.greaterThan(0);
88
+ transport.kernelConstructor.mock.calls.should.have.lengthOf(0);
89
+ transport.start.mock.calls.should.have.lengthOf(0);
90
+ transport.connectStream.mock.calls.should.have.lengthOf(0);
91
+ transport.connectionKeepAlive.mock.calls.should.have.lengthOf(0);
92
+ interval.mock.calls.should.have.lengthOf(0);
93
+ timeout.mock.calls.should.have.lengthOf(0);
94
+ });
95
+ it('should preserve the default watchdog and keep alive', async () => {
96
+ await create(false).getEventStore('store');
97
+ Boolean(transport.constructor.mock.calls[0][0].deferClientCreation).should.be.false;
98
+ transport.kernelConstructor.mock.calls.should.have.lengthOf(1);
99
+ transport.start.mock.calls.should.have.lengthOf(1);
100
+ interval.mock.calls.some(call => call[1] === 5000).should.be.true;
101
+ });
102
+ it('should reconnect unary calls without starting keep alive', async () => {
103
+ transport.allEventStores.mockRejectedValueOnce({ code: 14 });
104
+ await create().getEventStores();
105
+ transport.resetChannel.mock.calls.should.have.lengthOf(2);
106
+ transport.getVersionInfo.mock.calls.should.have.lengthOf(2);
107
+ transport.kernelConstructor.mock.calls.should.have.lengthOf(0);
108
+ interval.mock.calls.should.have.lengthOf(0);
109
+ });
110
+ it('should dispose before connecting and repeatedly without starting anything', async () => {
111
+ create().dispose();
112
+ client.dispose();
113
+ const [result] = await Promise.allSettled([client.getEventStore('store')]);
114
+ result.status.should.equal('rejected');
115
+ for (const spy of [transport.resetChannel, transport.connect, transport.getVersionInfo,
116
+ transport.connectStream, transport.connectionKeepAlive, transport.kernelConstructor, interval, timeout]) {
117
+ spy.mock.calls.should.have.lengthOf(0);
118
+ }
119
+ });
120
+ it('should dispose repeatedly after connecting without starting streams or timers', async () => {
121
+ await create().getEventStore('store');
122
+ client.dispose();
123
+ client.dispose();
124
+ transport.connect.mock.calls.should.have.lengthOf(1);
125
+ transport.resetChannel.mock.calls.should.have.lengthOf(1);
126
+ for (const spy of [transport.connectStream, transport.connectionKeepAlive, transport.kernelConstructor, interval, timeout]) {
127
+ spy.mock.calls.should.have.lengthOf(0);
128
+ }
129
+ });
130
+ for (const [kind, type, id] of [['Reactor', ItemReactor, 'skip-reactor'], ['Reducer', ItemReducer, 'skip-reducer']] as const) {
131
+ it(`should refuse a ${kind} before any transport side effects on repeated retrieval`, async () => {
132
+ artifacts[kind === 'Reactor' ? 'reactors' : 'reducers'].push(type);
133
+ create();
134
+ for (let attempt = 0; attempt < 2; attempt++) {
135
+ const [result] = await Promise.allSettled([client.getEventStore('store')]);
136
+ result.status.should.equal('rejected');
137
+ if (result.status === 'rejected') {
138
+ result.reason.should.be.instanceOf(ClientObserversRequireKeepAlive);
139
+ result.reason.observerKind.should.equal(kind);
140
+ result.reason.observerId.should.equal(id);
141
+ result.reason.name.should.equal('ClientObserversRequireKeepAlive');
142
+ }
143
+ }
144
+ for (const spy of [transport.resetChannel, transport.connect, transport.getVersionInfo,
145
+ transport.ensureEventStore, transport.register, transport.observe]) spy.mock.calls.should.have.lengthOf(0);
146
+ });
147
+ }
148
+ it('should await discovery before refusing an observer', async () => {
149
+ vi.spyOn(TypeDiscoverer.default, 'discover').mockImplementation(async () => {
150
+ await Promise.resolve();
151
+ artifacts.reactors.push(ItemReactor);
152
+ });
153
+ const [result] = await Promise.allSettled([create(true, ['fixture']).getEventStore('store')]);
154
+ result.status.should.equal('rejected');
155
+ if (result.status === 'rejected') result.reason.should.be.instanceOf(ClientObserversRequireKeepAlive);
156
+ transport.resetChannel.mock.calls.should.have.lengthOf(0);
157
+ });
158
+ });
@@ -0,0 +1,84 @@
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
+ // This file is emitted by the ordinary build and run by plain Node, never by a TS loader.
5
+ import assert from 'node:assert/strict';
6
+ import { randomUUID } from 'node:crypto';
7
+ import { mock } from 'node:test';
8
+ import { field } from '@cratis/fundamentals';
9
+ import { ChronicleClient, ChronicleOptions, ClientObserversRequireKeepAlive, eventType, reactor, reducer,
10
+ type IClientArtifactsProvider } from '../../index.js';
11
+ import { ChronicleConnection } from '../../connection/ChronicleConnection.js';
12
+
13
+ @eventType('skip-keep-alive-exit-item')
14
+ class ExitItem {
15
+ @field(String) value = 'probe';
16
+ }
17
+ @reactor('exit-reactor')
18
+ class ExitReactor {}
19
+ @reducer('exit-reducer')
20
+ class ExitReducer {}
21
+
22
+ const connectionString = process.env.CHRONICLE_INTEGRATION_CONNECTION_STRING;
23
+ if (!connectionString) throw new Error('CHRONICLE_INTEGRATION_CONNECTION_STRING is required');
24
+ const mode = process.argv[2];
25
+ const skipKeepAlive = !mode.startsWith('default');
26
+ const intervals = mock.method(globalThis, 'setInterval');
27
+ const streamSpies: ReturnType<typeof spyOnConnectStream>[] = [];
28
+ function spyOnConnectStream(connection: ChronicleConnection) {
29
+ // The spy delegates to the real RPC; it never substitutes a stream or owns the channel.
30
+ return mock.method(connection.connections, 'connect');
31
+ }
32
+ const connect = ChronicleConnection.prototype.connect;
33
+ mock.method(ChronicleConnection.prototype, 'connect', async function (this: ChronicleConnection) {
34
+ await connect.call(this);
35
+ streamSpies.push(spyOnConnectStream(this));
36
+ });
37
+ function connectionCounts() {
38
+ const connectCalls = streamSpies.reduce((total, spy) => total + spy.mock.callCount(), 0);
39
+ const watchdogTimers = intervals.mock.calls.filter(call => call.arguments[1] === 5000).length;
40
+ assert.equal(connectCalls > 0, !skipKeepAlive);
41
+ assert.equal(watchdogTimers > 0, !skipKeepAlive);
42
+ return { connectCalls, watchdogTimers };
43
+ }
44
+ const artifacts: IClientArtifactsProvider = {
45
+ eventTypes: [ExitItem], reactors: mode === 'reactor' ? [ExitReactor] : [], reducers: mode === 'reducer' ? [ExitReducer] : [],
46
+ readModels: [], seeders: [], constraints: [], projections: [], webhooks: [], eventTypeMigrations: [], globalForHandlers: []
47
+ };
48
+ const client = new ChronicleClient(ChronicleOptions.fromConnectionString(connectionString, {
49
+ skipKeepAlive, discoveryPatterns: [], clientArtifactsProvider: artifacts
50
+ }));
51
+ if (mode === 'preconnect-dispose') {
52
+ client.dispose();
53
+ client.dispose();
54
+ assert.equal(streamSpies.length, 0);
55
+ console.log(JSON.stringify({ marker: 'disposed-before-connect', mode, ...connectionCounts() }));
56
+ } else if (mode === 'reactor' || mode === 'reducer') {
57
+ try {
58
+ await client.getEventStore('skip-exit-refusal');
59
+ throw new Error('Observer was not refused');
60
+ } catch (error) {
61
+ if (!(error instanceof ClientObserversRequireKeepAlive)) throw error;
62
+ assert.equal(streamSpies.length, 0);
63
+ console.log(JSON.stringify({ marker: 'observer-refused', mode, kind: error.observerKind, id: error.observerId,
64
+ ...connectionCounts() }));
65
+ }
66
+ } else {
67
+ const store = await client.getEventStore(`skip-exit-${randomUUID()}`);
68
+ const source = randomUUID();
69
+ const item = new ExitItem();
70
+ item.value = randomUUID();
71
+ await store.eventLog.append(source, item);
72
+ const events = await store.eventLog.getForEventSourceIdAndEventTypes(source, [ExitItem]);
73
+ assert.deepEqual(events.map(event => event.content.value), [item.value]);
74
+ const counts = connectionCounts();
75
+ if (mode.endsWith('-dispose')) {
76
+ client.dispose();
77
+ client.dispose();
78
+ }
79
+ console.log(JSON.stringify({ marker: 'operations-completed', mode, source, expected: item.value,
80
+ actual: events[0].content.value, ...counts }));
81
+ }
82
+ mock.restoreAll();
83
+ // The skip/default no-dispose variants deliberately leave all real client resources untouched.
84
+ // No variant calls process.exit(), unref(), or manually closes a stream or channel.
@@ -74,6 +74,7 @@ beforeEach(async () => {
74
74
  getVersionInfo: async () => ({})
75
75
  } as ServiceImplementation<typeof ServerDefinition>);
76
76
  server.add(EventStoresDefinition, {
77
+ ...Object.fromEntries(Object.keys(EventStoresDefinition.methods).map(name => [name, unused])),
77
78
  allEventStores: unused, ensureEventStore: success, observeEventStores: unused
78
79
  } as ServiceImplementation<typeof EventStoresDefinition>);
79
80
  server.add(ReadModelsDefinition, {
@@ -0,0 +1,35 @@
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 { chai, describe, it } from 'vitest';
5
+ import { ChronicleOptions } from '../../ChronicleOptions.js';
6
+ import { ChronicleConnectionStringBuilder, ChronicleConnectionString } from '../../connection/ChronicleConnectionString.js';
7
+
8
+ chai.should();
9
+
10
+ describe('when configuring keep alive', () => {
11
+ it('should preserve the default', () => ChronicleOptions.development().skipKeepAlive.should.be.false);
12
+ it('should accept the factory option', () => ChronicleOptions.development({ skipKeepAlive: true }).skipKeepAlive.should.be.true);
13
+ for (const [query, option, expected] of [
14
+ ['true', undefined, true], ['true', false, true], ['false', false, false], ['false', true, true], ['TRUE', false, false]
15
+ ] as const) {
16
+ it(`should combine string ${query} and option ${option} with OR precedence`, () => {
17
+ ChronicleOptions.fromConnectionString(`chronicle://localhost:35000?skipKeepAlive=${query}`, {
18
+ skipKeepAlive: option
19
+ }).skipKeepAlive.should.equal(expected);
20
+ });
21
+ }
22
+ it('should emit and round trip the enabled key exactly once', () => {
23
+ const builder = new ChronicleConnectionStringBuilder();
24
+ builder.skipKeepAlive = true;
25
+ builder.build().should.equal('chronicle://localhost:35000?skipKeepAlive=true');
26
+ new ChronicleConnectionString(builder.build()).skipKeepAlive.should.be.true;
27
+ new ChronicleConnectionStringBuilder(builder.build()).skipKeepAlive.should.be.true;
28
+ });
29
+ it('should omit the disabled key', () => {
30
+ const builder = new ChronicleConnectionStringBuilder('chronicle://localhost:35000?skipKeepAlive=true');
31
+ builder.skipKeepAlive = false;
32
+ builder.build().should.equal('chronicle://localhost:35000');
33
+ new ChronicleConnectionString(builder.build()).skipKeepAlive.should.be.false;
34
+ });
35
+ });
@@ -0,0 +1,51 @@
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 { chai, describe, it, vi } from 'vitest';
5
+ import { EventStore } from '../../EventStore.js';
6
+ import { EventStoreName } from '../../EventStoreName.js';
7
+ import { EventStoreNamespaceName } from '../../EventStoreNamespaceName.js';
8
+ import { ChronicleConnection } from '../../connection/ChronicleConnection.js';
9
+ import { ConnectionLifecycle } from '../../connection/ConnectionLifecycle.js';
10
+ import { ClientObserversRequireKeepAlive } from '../../connection/ClientObserversRequireKeepAlive.js';
11
+ import { eventType } from '../../events/eventTypeDecorator.js';
12
+ import { fromEvent } from '../../projections/modelBound/fromEvent.js';
13
+ import { reactor } from '../../reactors/reactor.js';
14
+
15
+ chai.should();
16
+ @eventType('store-skip-item')
17
+ class Item {}
18
+ @fromEvent(Item)
19
+ class Model {}
20
+ @reactor('store-skip-reactor')
21
+ class Observer { item() {} }
22
+
23
+ describe('when registering store artifacts while skipping keep alive', () => {
24
+ for (const withObserver of [true, false]) {
25
+ it(`should ${withObserver ? 'refuse observers before registration' : 'allow projections read models and watchers'}`, async () => {
26
+ const register = vi.fn().mockResolvedValue({});
27
+ const watch = vi.fn().mockImplementation(async function* () {});
28
+ const connection = new Proxy({}, { get: (_target, property) => property === 'logger' ? undefined
29
+ : new Proxy({}, { get: (_service, method) => method === 'watch' ? watch : register }) }) as ChronicleConnection;
30
+ const lifecycle = new ConnectionLifecycle();
31
+ const store = new EventStore(new EventStoreName('store'), EventStoreNamespaceName.default, connection, lifecycle, 'sink', {
32
+ eventTypes: [Item], readModels: [Model], reactors: withObserver ? [Observer] : [], reducers: [], seeders: [],
33
+ constraints: [], projections: [], webhooks: [], eventTypeMigrations: [], globalForHandlers: []
34
+ }, undefined, undefined, undefined, undefined, true);
35
+ try {
36
+ const [result] = await Promise.allSettled([store.registerArtifacts()]);
37
+ result.status.should.equal(withObserver ? 'rejected' : 'fulfilled');
38
+ if (result.status === 'rejected') {
39
+ result.reason.should.be.instanceOf(ClientObserversRequireKeepAlive);
40
+ register.mock.calls.should.have.lengthOf(0);
41
+ } else {
42
+ register.mock.calls.length.should.be.greaterThan(0);
43
+ await lifecycle.connected(() => {});
44
+ const watcher = store.readModels.createWatcher(Model);
45
+ watch.mock.calls.should.have.lengthOf(1);
46
+ watcher.dispose();
47
+ }
48
+ } finally { store.disposeObservations(); }
49
+ });
50
+ }
51
+ });
package/index.ts CHANGED
@@ -30,6 +30,7 @@ import * as confidentiality from './confidentiality/index.js';
30
30
  export { ChronicleClient } from './ChronicleClient.js';
31
31
  export { IncompatibleChronicleServer } from './connection/IncompatibleChronicleServer.js';
32
32
  export { RejectedChronicleCredentials } from './connection/RejectedChronicleCredentials.js';
33
+ export { ClientObserversRequireKeepAlive } from './connection/ClientObserversRequireKeepAlive.js';
33
34
  export type { IChronicleClient } from './IChronicleClient.js';
34
35
  export { ChronicleOptions } from './ChronicleOptions.js';
35
36
  export { EventStore } from './EventStore.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cratis/chronicle",
3
- "version": "6.54.0",
3
+ "version": "6.56.0",
4
4
  "description": "Event sourcing for TypeScript and Node.js — the idiomatic client for Cratis Chronicle, the open-source event-sourcing database",
5
5
  "author": "Cratis",
6
6
  "license": "MIT",
@@ -178,7 +178,7 @@
178
178
  },
179
179
  "dependencies": {
180
180
  "@bufbuild/protobuf": "^2.16.0",
181
- "@cratis/chronicle.contracts": "19.70.0",
181
+ "@cratis/chronicle.contracts": "19.123.0",
182
182
  "@grpc/grpc-js": "^1.14.5",
183
183
  "@opentelemetry/api": "^1.9.1",
184
184
  "glob": "^13.0.6",
@@ -35,6 +35,7 @@ import { ArtifactKind } from '../artifacts/ArtifactKind.js';
35
35
  import { ArtifactDelivery } from '../artifacts/ArtifactDelivery.js';
36
36
  import { withActivatedArtifact, runActivated } from '../artifacts/withActivatedArtifact.js';
37
37
  import { ArtifactCompletionFailed } from '../artifacts/ArtifactCompletionFailed.js';
38
+ import { refuseClientHostedObservers } from '../artifacts/refuseClientHostedObservers.js';
38
39
 
39
40
  /** Expression used to partition reactor observations by event source ID. */
40
41
  const EVENT_SOURCE_ID_KEY = '$eventSourceId';
@@ -135,7 +136,8 @@ export class Reactors implements IReactors {
135
136
  private readonly _eventLog: IEventLog,
136
137
  private readonly _resultHandler?: ReactorResultHandler,
137
138
  private readonly _eventStore?: IEventStore,
138
- private readonly _artifactActivator?: ClientArtifactsActivator
139
+ private readonly _artifactActivator?: ClientArtifactsActivator,
140
+ private readonly _skipKeepAlive: boolean = false
139
141
  ) {
140
142
  this._logger = createLogger('@cratis/chronicle/reactors', _connection.logger);
141
143
  this._lifecycle = lifecycle;
@@ -168,6 +170,7 @@ export class Reactors implements IReactors {
168
170
 
169
171
  /** @inheritdoc */
170
172
  async register(): Promise<void> {
173
+ if (this._skipKeepAlive) refuseClientHostedObservers({ reactors: this._clientArtifacts.reactors, reducers: [] });
171
174
  if (this._registered || this._disposed) {
172
175
  return;
173
176
  }
@@ -286,7 +289,8 @@ export class Reactors implements IReactors {
286
289
  EventSourceType: getEventSourceTypeFor(reactorType),
287
290
  EventStreamType: getEventStreamTypeFor(reactorType)
288
291
  }
289
- }
292
+ },
293
+ PageDelivery: undefined
290
294
  },
291
295
  Value1: undefined
292
296
  }
@@ -438,7 +442,10 @@ export class Reactors implements IReactors {
438
442
  State: state,
439
443
  LastSuccessfulObservation: lastSuccessfullyObservedEvent,
440
444
  ExceptionMessages: exceptionMessages,
441
- ExceptionStackTrace: exceptionStackTrace
445
+ ExceptionStackTrace: exceptionStackTrace,
446
+ DeliveryId: 0n,
447
+ RetryAfterMilliseconds: 0n,
448
+ Partitions: []
442
449
  }
443
450
  }
444
451
  });
@@ -0,0 +1,48 @@
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 { chai, describe, it, vi } from 'vitest';
5
+ import { Reactors } from '../../Reactors.js';
6
+ import { reactor } from '../../reactor.js';
7
+ import { eventType } from '../../../events/eventTypeDecorator.js';
8
+ import { ConnectionLifecycle } from '../../../connection/ConnectionLifecycle.js';
9
+ import { ChronicleConnection } from '../../../connection/ChronicleConnection.js';
10
+ import { ClientObserversRequireKeepAlive } from '../../../connection/ClientObserversRequireKeepAlive.js';
11
+ import { IClientArtifactsProvider } from '../../../artifacts/IClientArtifactsProvider.js';
12
+ import { IEventLog } from '../../../eventSequences/IEventLog.js';
13
+
14
+ chai.should();
15
+ @eventType('reactor-skip-item')
16
+ class Item {}
17
+ @reactor('late-reactor')
18
+ class Observer { item() {} }
19
+
20
+ describe('when registering reactors while skipping keep alive', () => {
21
+ for (const scenario of ['initial', 'late', 'discovered', 'default']) {
22
+ it(`should enforce the keep alive requirement for ${scenario} registration`, async () => {
23
+ const observe = vi.fn().mockImplementation(async function* () {});
24
+ const artifacts: IClientArtifactsProvider = { eventTypes: [Item], reactors: scenario === 'initial' ? [Observer] : [],
25
+ reducers: [], readModels: [], seeders: [], constraints: [], projections: [], webhooks: [], eventTypeMigrations: [], globalForHandlers: [] };
26
+ const lifecycle = new ConnectionLifecycle();
27
+ const connection = { reactors: { observe } } as unknown as ChronicleConnection;
28
+ const manager = new Reactors(artifacts, connection, 'store', 'Default', lifecycle, {} as IEventLog,
29
+ undefined, undefined, undefined, scenario !== 'default');
30
+ try {
31
+ if (scenario !== 'initial') {
32
+ await manager.register();
33
+ artifacts.reactors.push(Observer);
34
+ await lifecycle.disconnected(() => {});
35
+ if (scenario === 'discovered') await manager.discover();
36
+ }
37
+ const [result] = await Promise.allSettled([manager.register()]);
38
+ result.status.should.equal(scenario === 'default' ? 'fulfilled' : 'rejected');
39
+ if (result.status === 'rejected') {
40
+ result.reason.should.be.instanceOf(ClientObserversRequireKeepAlive);
41
+ result.reason.observerKind.should.equal('Reactor');
42
+ result.reason.observerId.should.equal('late-reactor');
43
+ observe.mock.calls.should.have.lengthOf(0);
44
+ } else observe.mock.calls.should.have.lengthOf(1);
45
+ } finally { manager.dispose(); }
46
+ });
47
+ }
48
+ });
@@ -44,7 +44,7 @@ export class AccountDocument {
44
44
 
45
45
  export class a_stored_read_model {
46
46
  readonly release = vi.fn<(request: ReleaseRequest) => Promise<ReleaseResponse>>()
47
- .mockImplementation(async request => ({ HasError: false, Error: '', Payload: request.Payload }));
47
+ .mockImplementation(async request => ({ HasError: false, Error: '', Payload: request.Payload, FailedProperties: [], Strict: false }));
48
48
  readonly readModels: IReadModels;
49
49
 
50
50
  constructor() {
@@ -57,15 +57,15 @@ describe('read-model index registration with legacy decorators', () => {
57
57
  expect.objectContaining({
58
58
  ObserverIdentifier: 'indexed-orders',
59
59
  Indexes: [
60
- { PropertyPath: 'customerId' },
61
- { PropertyPath: 'number' },
62
- { PropertyPath: 'address.zipCode' },
63
- { PropertyPath: 'lines.productId' }
60
+ { PropertyPath: 'customerId', Properties: [] },
61
+ { PropertyPath: 'number', Properties: [] },
62
+ { PropertyPath: 'address.zipCode', Properties: [] },
63
+ { PropertyPath: 'lines.productId', Properties: [] }
64
64
  ]
65
65
  }),
66
66
  expect.objectContaining({
67
67
  ObserverIdentifier: 'reduced-orders',
68
- Indexes: [{ PropertyPath: 'number' }]
68
+ Indexes: [{ PropertyPath: 'number', Properties: [] }]
69
69
  })
70
70
  ]
71
71
  }));
@@ -76,8 +76,8 @@ describe('read-model index registration with legacy decorators', () => {
76
76
  const connection = { readModels: { registerMany } } as unknown as ChronicleConnection;
77
77
  await new ReadModels('test', 'Default', connection, artifacts, 'sink').register(Order);
78
78
  expect(registerMany.mock.calls[0][0].ReadModels[0].Indexes).toEqual([
79
- { PropertyPath: 'customerId' }, { PropertyPath: 'number' },
80
- { PropertyPath: 'address.zipCode' }, { PropertyPath: 'lines.productId' }
79
+ { PropertyPath: 'customerId', Properties: [] }, { PropertyPath: 'number', Properties: [] },
80
+ { PropertyPath: 'address.zipCode', Properties: [] }, { PropertyPath: 'lines.productId', Properties: [] }
81
81
  ]);
82
82
  });
83
83
  });
@@ -41,7 +41,7 @@ export function getIndexesForType(type: Function): IndexDefinition[] {
41
41
  for (const [name, memberType] of TypeIntrospector.getMembers(current)) {
42
42
  const path = prefix ? `${prefix}.${name}` : name;
43
43
  if (hasPropertyMetadata(INDEX_METADATA_KEY, current.prototype, name)) {
44
- indexes.push({ PropertyPath: path });
44
+ indexes.push({ PropertyPath: path, Properties: [] });
45
45
  }
46
46
 
47
47
  const nestedType = memberType === Array
@@ -74,19 +74,19 @@ describe('when registering indexed read models through the startup paths', () =>
74
74
  it('should send indexes for a declarative projection', async () => {
75
75
  const { value, registerMany } = connection();
76
76
  await new Projections('store', 'Default', value, artifacts([], [DeclarativeProjection]), 'sink').register();
77
- expect(indexesFor(registerMany, 'DeclarativeModel')).toEqual([{ PropertyPath: 'reference' }]);
77
+ expect(indexesFor(registerMany, 'DeclarativeModel')).toEqual([{ PropertyPath: 'reference', Properties: [] }]);
78
78
  });
79
79
 
80
80
  it('should send indexes for a model-bound projection', async () => {
81
81
  const { value, registerMany } = connection();
82
82
  await new Projections('store', 'Default', value, artifacts([ModelBoundModel]), 'sink').register();
83
- expect(indexesFor(registerMany, 'ModelBoundModel')).toEqual([{ PropertyPath: 'reference' }]);
83
+ expect(indexesFor(registerMany, 'ModelBoundModel')).toEqual([{ PropertyPath: 'reference', Properties: [] }]);
84
84
  });
85
85
 
86
86
  it('should send indexes for a model-bound variant', async () => {
87
87
  const { value, registerMany } = connection();
88
88
  await new Projections('store', 'Default', value, artifacts([IndexedVariant]), 'sink').register();
89
- expect(indexesFor(registerMany, 'IndexedVariant')).toEqual([{ PropertyPath: 'reference' }]);
89
+ expect(indexesFor(registerMany, 'IndexedVariant')).toEqual([{ PropertyPath: 'reference', Properties: [] }]);
90
90
  });
91
91
 
92
92
  it('should send indexes for a reducer read model', async () => {
@@ -94,6 +94,6 @@ describe('when registering indexed read models through the startup paths', () =>
94
94
  const reducers = new Reducers(artifacts([], [], [IndexedReducer]), value, 'store', 'Default', new ConnectionLifecycle(), 'sink');
95
95
  await reducers.register();
96
96
  reducers.dispose();
97
- expect(indexesFor(registerMany, 'ReducedModel')).toEqual([{ PropertyPath: 'reference' }]);
97
+ expect(indexesFor(registerMany, 'ReducedModel')).toEqual([{ PropertyPath: 'reference', Properties: [] }]);
98
98
  });
99
99
  });