@event-driven-io/emmett-postgresql 0.43.0-beta.19 → 0.43.0-beta.20

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/dist/index.d.cts CHANGED
@@ -1,7 +1,7 @@
1
1
  import * as _$_event_driven_io_dumbo0 from "@event-driven-io/dumbo";
2
2
  import { AnyConnection, DatabaseTransaction, Dumbo, MigrationStyle, QueryResultRow, RunSQLMigrationsResult, SQL, SQLExecutor, SQLMigration } from "@event-driven-io/dumbo";
3
3
  import * as _$_event_driven_io_emmett0 from "@event-driven-io/emmett";
4
- import { AnyCommand, AnyEvent, AnyMessage, AnyReadEventMetadata, AnyRecordedMessageMetadata, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, AsyncAwaiter, BatchRecordedMessageHandlerWithContext, BatchRecordedMessageHandlerWithoutContext, CanHandle, Checkpointer, DefaultRecord, EmmettError, Event, EventStore, EventStoreReadSchemaOptions, EventStoreSessionFactory, JSONSerializationOptions, Message, MessageConsumer, MessageConsumerOptions, MessageProcessor, ProcessorCheckpoint, ProjectionDefinition, ProjectionHandler, ProjectionHandlingType, ProjectionInitOptions, ProjectionRegistration, ProjectorOptions, ReactorOptions, ReadEvent, ReadEventMetadataWithGlobalPosition, ReadStreamOptions, ReadStreamResult, RecordedMessage, RecordedMessageMetadata, RecordedMessageMetadataWithGlobalPosition, SingleRecordedMessageHandlerWithContext, StreamExistsResult, ThenThrows, TruncateProjection, WorkflowProcessorContext, WorkflowProcessorOptions } from "@event-driven-io/emmett";
4
+ import { AnyCommand, AnyEvent, AnyMessage, AnyReadEventMetadata, AnyRecordedMessageMetadata, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, AsyncAwaiter, BatchRecordedMessageHandlerWithContext, BatchRecordedMessageHandlerWithoutContext, CanHandle, Checkpointer, DefaultRecord, EmmettError, Event, EventStore, EventStoreReadSchemaOptions, EventStoreSessionFactory, JSONSerializationOptions, Message, MessageConsumer, MessageConsumerOptions, MessageHandlerContext, MessageProcessor, ProcessorCheckpoint, ProjectionDefinition, ProjectionHandler, ProjectionHandlerContext, ProjectionHandlingType, ProjectionInitOptions, ProjectionRegistration, ProjectorOptions, ReactorOptions, ReadEvent, ReadEventMetadataWithGlobalPosition, ReadStreamOptions, ReadStreamResult, RecordedMessage, RecordedMessageMetadata, RecordedMessageMetadataWithGlobalPosition, SingleRecordedMessageHandlerWithContext, StreamExistsResult, ThenThrows, TruncateProjection, WorkflowProcessorContext, WorkflowProcessorOptions } from "@event-driven-io/emmett";
5
5
  import { PgClient, PgClientConnection, PgConnection, PgDriverType, PgPool, PgPoolClientConnection, PgPoolOptions, PgTransaction } from "@event-driven-io/dumbo/pg";
6
6
  import pg from "pg";
7
7
  import { PongoClient, PongoDBCollectionOptions, PongoDocument, PongoFilter, WithId } from "@event-driven-io/pongo";
@@ -135,10 +135,10 @@ declare const toProjectionLockKey: ({
135
135
  }: Pick<TryAcquireProjectionLockOptions, "projectionName" | "partition" | "version">) => string;
136
136
  //#endregion
137
137
  //#region src/eventStore/projections/management/projectionManagement.d.ts
138
- declare const registerProjection: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord>(execute: SQLExecutor, options: {
138
+ declare const registerProjection: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext>(execute: SQLExecutor, options: {
139
139
  partition: string;
140
140
  status: "active" | "inactive";
141
- registration: ProjectionRegistration<ProjectionHandlingType, ReadEventMetadataType, ProjectionHandlerContext>;
141
+ registration: ProjectionRegistration<ProjectionHandlingType, ReadEventMetadataType, HandlerContext>;
142
142
  }) => Promise<{
143
143
  registered: boolean;
144
144
  }>;
@@ -533,7 +533,7 @@ type EventStoreSchemaMigrationOptions = {
533
533
  declare const createEventStoreSchema: (connectionString: string, pool: PgPool, hooks?: PostgresEventStoreOptions["hooks"], options?: CreateEventStoreSchemaOptions) => Promise<RunSQLMigrationsResult>;
534
534
  //#endregion
535
535
  //#region src/eventStore/projections/postgreSQLProjection.d.ts
536
- type PostgreSQLProjectionHandlerContext = {
536
+ type PostgreSQLProjectionHandlerContext = ProjectionHandlerContext<{
537
537
  execute: SQLExecutor;
538
538
  connection: {
539
539
  connectionString: string;
@@ -541,7 +541,7 @@ type PostgreSQLProjectionHandlerContext = {
541
541
  transaction: PgTransaction;
542
542
  pool: Dumbo;
543
543
  };
544
- } & EventStoreSchemaMigrationOptions;
544
+ } & EventStoreSchemaMigrationOptions>;
545
545
  declare const transactionToPostgreSQLProjectionHandlerContext: (connectionString: string, pool: Dumbo, transaction: PgTransaction | DatabaseTransaction<AnyConnection>) => Promise<PostgreSQLProjectionHandlerContext>;
546
546
  type PostgreSQLProjectionHandler<EventType extends Event = Event, EventMetaDataType extends PostgresReadEventMetadata = PostgresReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, PostgreSQLProjectionHandlerContext>;
547
547
  type PostgreSQLProjectionDefinition<EventType extends Event = Event, EventPayloadType extends Event = EventType> = ProjectionDefinition<EventType, PostgresReadEventMetadata, PostgreSQLProjectionHandlerContext, EventPayloadType>;
@@ -670,7 +670,7 @@ declare const PostgreSQLEventStoreDefaultStreamVersion = 0n;
670
670
  declare const getPostgreSQLEventStore: (connectionString: string, options?: PostgresEventStoreOptions) => PostgresEventStore;
671
671
  //#endregion
672
672
  //#region src/eventStore/consumers/postgreSQLProcessor.d.ts
673
- type PostgreSQLProcessorHandlerContext = {
673
+ type PostgreSQLProcessorHandlerContext = MessageHandlerContext<{
674
674
  partition: string;
675
675
  execute: SQLExecutor;
676
676
  connection: {
@@ -680,7 +680,7 @@ type PostgreSQLProcessorHandlerContext = {
680
680
  pool: Dumbo;
681
681
  messageStore: PostgresEventStore;
682
682
  };
683
- } & EventStoreSchemaMigrationOptions;
683
+ } & EventStoreSchemaMigrationOptions>;
684
684
  type PostgreSQLProcessor<MessageType extends Message = AnyMessage> = MessageProcessor<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
685
685
  type PostgreSQLProcessorEachMessageHandler<MessageType extends Message = Message> = SingleRecordedMessageHandlerWithContext<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
686
686
  type PostgreSQLProcessorEachBatchHandler<MessageType extends Message = Message> = BatchRecordedMessageHandlerWithContext<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import * as _$_event_driven_io_emmett0 from "@event-driven-io/emmett";
2
- import { AnyCommand, AnyEvent, AnyMessage, AnyReadEventMetadata, AnyRecordedMessageMetadata, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, AsyncAwaiter, BatchRecordedMessageHandlerWithContext, BatchRecordedMessageHandlerWithoutContext, CanHandle, Checkpointer, DefaultRecord, EmmettError, Event, EventStore, EventStoreReadSchemaOptions, EventStoreSessionFactory, JSONSerializationOptions, Message, MessageConsumer, MessageConsumerOptions, MessageProcessor, ProcessorCheckpoint, ProjectionDefinition, ProjectionHandler, ProjectionHandlingType, ProjectionInitOptions, ProjectionRegistration, ProjectorOptions, ReactorOptions, ReadEvent, ReadEventMetadataWithGlobalPosition, ReadStreamOptions, ReadStreamResult, RecordedMessage, RecordedMessageMetadata, RecordedMessageMetadataWithGlobalPosition, SingleRecordedMessageHandlerWithContext, StreamExistsResult, ThenThrows, TruncateProjection, WorkflowProcessorContext, WorkflowProcessorOptions } from "@event-driven-io/emmett";
2
+ import { AnyCommand, AnyEvent, AnyMessage, AnyReadEventMetadata, AnyRecordedMessageMetadata, AppendToStreamOptions, AppendToStreamResultWithGlobalPosition, AsyncAwaiter, BatchRecordedMessageHandlerWithContext, BatchRecordedMessageHandlerWithoutContext, CanHandle, Checkpointer, DefaultRecord, EmmettError, Event, EventStore, EventStoreReadSchemaOptions, EventStoreSessionFactory, JSONSerializationOptions, Message, MessageConsumer, MessageConsumerOptions, MessageHandlerContext, MessageProcessor, ProcessorCheckpoint, ProjectionDefinition, ProjectionHandler, ProjectionHandlerContext, ProjectionHandlingType, ProjectionInitOptions, ProjectionRegistration, ProjectorOptions, ReactorOptions, ReadEvent, ReadEventMetadataWithGlobalPosition, ReadStreamOptions, ReadStreamResult, RecordedMessage, RecordedMessageMetadata, RecordedMessageMetadataWithGlobalPosition, SingleRecordedMessageHandlerWithContext, StreamExistsResult, ThenThrows, TruncateProjection, WorkflowProcessorContext, WorkflowProcessorOptions } from "@event-driven-io/emmett";
3
3
  import * as _$_event_driven_io_dumbo0 from "@event-driven-io/dumbo";
4
4
  import { AnyConnection, DatabaseTransaction, Dumbo, MigrationStyle, QueryResultRow, RunSQLMigrationsResult, SQL, SQLExecutor, SQLMigration } from "@event-driven-io/dumbo";
5
5
  import { PongoClient, PongoDBCollectionOptions, PongoDocument, PongoFilter, WithId } from "@event-driven-io/pongo";
@@ -135,10 +135,10 @@ declare const toProjectionLockKey: ({
135
135
  }: Pick<TryAcquireProjectionLockOptions, "projectionName" | "partition" | "version">) => string;
136
136
  //#endregion
137
137
  //#region src/eventStore/projections/management/projectionManagement.d.ts
138
- declare const registerProjection: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, ProjectionHandlerContext extends DefaultRecord = DefaultRecord>(execute: SQLExecutor, options: {
138
+ declare const registerProjection: <ReadEventMetadataType extends AnyReadEventMetadata = AnyReadEventMetadata, HandlerContext extends ProjectionHandlerContext = ProjectionHandlerContext>(execute: SQLExecutor, options: {
139
139
  partition: string;
140
140
  status: "active" | "inactive";
141
- registration: ProjectionRegistration<ProjectionHandlingType, ReadEventMetadataType, ProjectionHandlerContext>;
141
+ registration: ProjectionRegistration<ProjectionHandlingType, ReadEventMetadataType, HandlerContext>;
142
142
  }) => Promise<{
143
143
  registered: boolean;
144
144
  }>;
@@ -533,7 +533,7 @@ type EventStoreSchemaMigrationOptions = {
533
533
  declare const createEventStoreSchema: (connectionString: string, pool: PgPool, hooks?: PostgresEventStoreOptions["hooks"], options?: CreateEventStoreSchemaOptions) => Promise<RunSQLMigrationsResult>;
534
534
  //#endregion
535
535
  //#region src/eventStore/projections/postgreSQLProjection.d.ts
536
- type PostgreSQLProjectionHandlerContext = {
536
+ type PostgreSQLProjectionHandlerContext = ProjectionHandlerContext<{
537
537
  execute: SQLExecutor;
538
538
  connection: {
539
539
  connectionString: string;
@@ -541,7 +541,7 @@ type PostgreSQLProjectionHandlerContext = {
541
541
  transaction: PgTransaction;
542
542
  pool: Dumbo;
543
543
  };
544
- } & EventStoreSchemaMigrationOptions;
544
+ } & EventStoreSchemaMigrationOptions>;
545
545
  declare const transactionToPostgreSQLProjectionHandlerContext: (connectionString: string, pool: Dumbo, transaction: PgTransaction | DatabaseTransaction<AnyConnection>) => Promise<PostgreSQLProjectionHandlerContext>;
546
546
  type PostgreSQLProjectionHandler<EventType extends Event = Event, EventMetaDataType extends PostgresReadEventMetadata = PostgresReadEventMetadata> = ProjectionHandler<EventType, EventMetaDataType, PostgreSQLProjectionHandlerContext>;
547
547
  type PostgreSQLProjectionDefinition<EventType extends Event = Event, EventPayloadType extends Event = EventType> = ProjectionDefinition<EventType, PostgresReadEventMetadata, PostgreSQLProjectionHandlerContext, EventPayloadType>;
@@ -670,7 +670,7 @@ declare const PostgreSQLEventStoreDefaultStreamVersion = 0n;
670
670
  declare const getPostgreSQLEventStore: (connectionString: string, options?: PostgresEventStoreOptions) => PostgresEventStore;
671
671
  //#endregion
672
672
  //#region src/eventStore/consumers/postgreSQLProcessor.d.ts
673
- type PostgreSQLProcessorHandlerContext = {
673
+ type PostgreSQLProcessorHandlerContext = MessageHandlerContext<{
674
674
  partition: string;
675
675
  execute: SQLExecutor;
676
676
  connection: {
@@ -680,7 +680,7 @@ type PostgreSQLProcessorHandlerContext = {
680
680
  pool: Dumbo;
681
681
  messageStore: PostgresEventStore;
682
682
  };
683
- } & EventStoreSchemaMigrationOptions;
683
+ } & EventStoreSchemaMigrationOptions>;
684
684
  type PostgreSQLProcessor<MessageType extends Message = AnyMessage> = MessageProcessor<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
685
685
  type PostgreSQLProcessorEachMessageHandler<MessageType extends Message = Message> = SingleRecordedMessageHandlerWithContext<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
686
686
  type PostgreSQLProcessorEachBatchHandler<MessageType extends Message = Message> = BatchRecordedMessageHandlerWithContext<MessageType, ReadEventMetadataWithGlobalPosition, PostgreSQLProcessorHandlerContext>;
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AssertionError, EmmettError, ExpectedVersionConflictError, JSONSerializer, NO_CONCURRENCY_CHECK, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, assertDeepEqual, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertIsNotNull, assertIsNull, assertThatArray, assertTrue, asyncAwaiter, asyncRetry, bigInt, bigIntProcessorCheckpoint, defaultProcessorPartition, defaultProcessorVersion, downcastRecordedMessages, getCheckpoint, getProcessorInstanceId, getProjectorId, getWorkflowId, hashText, isBigint, isErrorConstructor, projection, projector, reactor, reduceAsync, unknownTag, upcastRecordedMessage, workflowProcessor } from "@event-driven-io/emmett";
1
+ import { AssertionError, EmmettError, ExpectedVersionConflictError, JSONSerializer, NO_CONCURRENCY_CHECK, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, assertDeepEqual, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertIsNotNull, assertIsNull, assertThatArray, assertTrue, asyncAwaiter, asyncRetry, bigInt, bigIntProcessorCheckpoint, defaultProcessorPartition, defaultProcessorVersion, downcastRecordedMessages, getCheckpoint, getProcessorInstanceId, getProjectorId, getWorkflowId, hashText, isBigint, isErrorConstructor, noopScope, projection, projector, reactor, reduceAsync, unknownTag, upcastRecordedMessage, workflowProcessor } from "@event-driven-io/emmett";
2
2
  import { DumboError, JSONSerializer as JSONSerializer$1, SQL, UniqueConstraintError, dumbo, fromDatabaseDriverType, getFormatter, mapRows, runSQLMigrations, single, singleOrNull, sqlMigration } from "@event-driven-io/dumbo";
3
3
  import { pongoClient } from "@event-driven-io/pongo";
4
4
  import { pgDriver } from "@event-driven-io/pongo/pg";
@@ -778,7 +778,8 @@ const getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOp
778
778
  registrationType: "inline",
779
779
  context: {
780
780
  ...context,
781
- migrationOptions
781
+ migrationOptions,
782
+ observabilityScope: noopScope
782
783
  }
783
784
  });
784
785
  if (options.hooks?.onAfterSchemaCreated) await options.hooks.onAfterSchemaCreated(context);
@@ -812,7 +813,10 @@ const getPostgreSQLEventStore = (connectionString, options = defaultPostgreSQLOp
812
813
  await truncateTables(transaction.execute, truncateOptions);
813
814
  if (truncateOptions?.truncateProjections) {
814
815
  const projectionContext = await transactionToPostgreSQLProjectionHandlerContext(connectionString, pool, transaction);
815
- for (const projection of options?.projections ?? []) if (projection.projection.truncate) await projection.projection.truncate(projectionContext);
816
+ for (const projection of options?.projections ?? []) if (projection.projection.truncate) await projection.projection.truncate({
817
+ ...projectionContext,
818
+ observabilityScope: noopScope
819
+ });
816
820
  }
817
821
  }) }
818
822
  },
@@ -1010,7 +1014,8 @@ const transactionToPostgreSQLProjectionHandlerContext = async (connectionString,
1010
1014
  client: await transaction.connection.open(),
1011
1015
  transaction,
1012
1016
  pool
1013
- }
1017
+ },
1018
+ observabilityScope: noopScope
1014
1019
  });
1015
1020
  const handleProjections = async (options) => {
1016
1021
  const { projections: allProjections, events, connection: { pool, transaction, connectionString }, partition = defaultTag } = options;
@@ -1032,7 +1037,8 @@ const handleProjections = async (options) => {
1032
1037
  client,
1033
1038
  transaction
1034
1039
  },
1035
- execute: transaction.execute
1040
+ execute: transaction.execute,
1041
+ observabilityScope: noopScope
1036
1042
  });
1037
1043
  }
1038
1044
  };
@@ -3077,7 +3083,8 @@ const postgreSQLProcessingScope = (options) => {
3077
3083
  client,
3078
3084
  transaction,
3079
3085
  messageStore: getPostgreSQLEventStore(connectionString, { connectionOptions: { client } })
3080
- }
3086
+ },
3087
+ observabilityScope: partialContext?.observabilityScope ?? noopScope
3081
3088
  });
3082
3089
  });
3083
3090
  };