@event-driven-io/emmett 0.23.0-alpha.3 → 0.23.0-alpha.4

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.ts CHANGED
@@ -485,6 +485,7 @@ declare const isSubset: (superObj: unknown, subObj: unknown) => boolean;
485
485
  declare const assertFails: (message?: string) => never;
486
486
  declare const assertThrowsAsync: <TError extends Error>(fun: () => Promise<void>, errorCheck?: (error: Error) => boolean) => Promise<TError>;
487
487
  declare const assertThrows: <TError extends Error>(fun: () => void, errorCheck?: (error: Error) => boolean) => TError;
488
+ declare const assertDoesNotThrow: <TError extends Error>(fun: () => void, errorCheck?: (error: Error) => boolean) => TError | null;
488
489
  declare const assertRejects: <T, TError extends Error = Error>(promise: Promise<T>, errorCheck?: ((error: TError) => boolean) | TError) => Promise<void>;
489
490
  declare const assertMatches: (actual: unknown, expected: unknown, message?: string) => void;
490
491
  declare const assertDeepEqual: <T = unknown>(actual: T, expected: T, message?: string) => void;
@@ -546,6 +547,7 @@ type ThenThrows<ErrorType extends Error> = (() => void) | ((errorConstructor: Er
546
547
  type DeciderSpecfication<Command, Event> = (givenEvents: Event | Event[]) => {
547
548
  when: (command: Command) => {
548
549
  then: (expectedEvents: Event | Event[]) => void;
550
+ thenDoesNothing: () => void;
549
551
  thenThrows: <ErrorType extends Error = Error>(...args: Parameters<ThenThrows<ErrorType>>) => void;
550
552
  };
551
553
  };
@@ -582,4 +584,4 @@ declare const assertNotEmptyString: (value: unknown) => string;
582
584
  declare const assertPositiveNumber: (value: unknown) => number;
583
585
  declare const assertUnsignedBigInt: (value: string) => bigint;
584
586
 
585
- export { type AggregateStreamOptions, type AggregateStreamResult, type AggregateStreamResultOfEventStore, type AggregateStreamResultWithGlobalPosition, type AppendStreamResultOfEventStore, type AppendToStreamOptions, type AppendToStreamResult, type AppendToStreamResultWithGlobalPosition, type ArgumentMatcher, AssertionError, type AsyncRetryOptions, type BigIntGlobalPosition, type BigIntStreamPosition, BinaryJsonDecoder, type Brand, type CanHandle, CaughtUpTransformStream, type Command, type CommandBus, type CommandDataOf, CommandHandler$1 as CommandHandler, type CommandHandlerOptions, type CommandHandlerResult, type CommandHandlerRetryOptions, CommandHandlerStreamVersionConflictRetryOptions, type CommandMetaDataOf, type CommandProcessor, type CommandSender, type CommandTypeOf, CompositeDecoder, ConcurrencyError, type CreateCommandType, type CreateEventType, type Decider, DeciderCommandHandler, type DeciderCommandHandlerOptions, type DeciderSpecfication, DeciderSpecification, type Decoder, type DeepReadonly, type DefaultCommandMetadata, DefaultDecoder, type DefaultRecord, type Equatable, ErrorConstructor, type Event, type EventBus, type EventDataOf, type EventHandler$1 as EventHandler, type EventMetaDataOf, type EventProcessor, type EventStore, type EventStoreReadEventMetadata, type EventStoreSession, type EventStoreSessionFactory, type EventStoreWrapper, type EventTypeOf, type EventsPublisher, type ExpectedStreamVersion, type ExpectedStreamVersionGeneral, type ExpectedStreamVersionWithValue, ExpectedVersionConflictError, type Flavour, type GlobalPositionTypeOfEventStore, type GlobalPositionTypeOfReadEventMetadata, type GlobalStreamCaughtUp, GlobalStreamCaughtUpType, type GlobalSubscriptionEvent, type HandleOptions, type InMemoryEventStore, InMemoryEventStoreDefaultStreamVersion, JSONParser, JsonDecoder, type Mapper, type MapperArgs, type MessageBus, type MessageHandler, type MessageProcessor, type MessageScheduler, type MockedFunction, type Mutable, NO_CONCURRENCY_CHECK, NoRetries, type NonNullable, ObjectDecoder, ParseError, type ParseOptions, type ProjectionDefinition, type ProjectionHandler, type ProjectionHandlingType, type ProjectionRegistration, type ReadEvent, type ReadEventMetadata, type ReadEventMetadataWithGlobalPosition, type ReadEventMetadataWithoutGlobalPosition, type ReadStreamOptions, type ReadStreamResult, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, type ScheduleOptions, type ScheduledMessage, type ScheduledMessageProcessor, type StreamPositionTypeOfEventStore, type StreamPositionTypeOfReadEventMetadata, StreamingCoordinator, StringDecoder, type StringifyOptions, type TestEventStream, type ThenThrows, type TypedProjectionDefinition, ValidationErrors, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, WrapEventStore, accept, argMatches, argValue, assertDeepEqual, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUnsignedBigInt, asyncProjections, asyncRetry, canCreateEventStoreSession, caughtUpEventFrom, collect, command, complete, concatUint8Arrays, deepEquals, error, event, formatDateToUtcYYYYMMDD, getInMemoryEventStore, getInMemoryMessageBus, globalStreamCaughtUp, ignore, inlineProjections, isEquatable, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, matchesExpectedVersion, merge, nulloSessionFactory, parseDateFromUtcYYYYMMDD, projection, projections, publish, reply, restream, schedule, send, streamGenerators, streamTrackingGlobalPosition, streamTransformations, sum, verifyThat };
587
+ export { type AggregateStreamOptions, type AggregateStreamResult, type AggregateStreamResultOfEventStore, type AggregateStreamResultWithGlobalPosition, type AppendStreamResultOfEventStore, type AppendToStreamOptions, type AppendToStreamResult, type AppendToStreamResultWithGlobalPosition, type ArgumentMatcher, AssertionError, type AsyncRetryOptions, type BigIntGlobalPosition, type BigIntStreamPosition, BinaryJsonDecoder, type Brand, type CanHandle, CaughtUpTransformStream, type Command, type CommandBus, type CommandDataOf, CommandHandler$1 as CommandHandler, type CommandHandlerOptions, type CommandHandlerResult, type CommandHandlerRetryOptions, CommandHandlerStreamVersionConflictRetryOptions, type CommandMetaDataOf, type CommandProcessor, type CommandSender, type CommandTypeOf, CompositeDecoder, ConcurrencyError, type CreateCommandType, type CreateEventType, type Decider, DeciderCommandHandler, type DeciderCommandHandlerOptions, type DeciderSpecfication, DeciderSpecification, type Decoder, type DeepReadonly, type DefaultCommandMetadata, DefaultDecoder, type DefaultRecord, type Equatable, ErrorConstructor, type Event, type EventBus, type EventDataOf, type EventHandler$1 as EventHandler, type EventMetaDataOf, type EventProcessor, type EventStore, type EventStoreReadEventMetadata, type EventStoreSession, type EventStoreSessionFactory, type EventStoreWrapper, type EventTypeOf, type EventsPublisher, type ExpectedStreamVersion, type ExpectedStreamVersionGeneral, type ExpectedStreamVersionWithValue, ExpectedVersionConflictError, type Flavour, type GlobalPositionTypeOfEventStore, type GlobalPositionTypeOfReadEventMetadata, type GlobalStreamCaughtUp, GlobalStreamCaughtUpType, type GlobalSubscriptionEvent, type HandleOptions, type InMemoryEventStore, InMemoryEventStoreDefaultStreamVersion, JSONParser, JsonDecoder, type Mapper, type MapperArgs, type MessageBus, type MessageHandler, type MessageProcessor, type MessageScheduler, type MockedFunction, type Mutable, NO_CONCURRENCY_CHECK, NoRetries, type NonNullable, ObjectDecoder, ParseError, type ParseOptions, type ProjectionDefinition, type ProjectionHandler, type ProjectionHandlingType, type ProjectionRegistration, type ReadEvent, type ReadEventMetadata, type ReadEventMetadataWithGlobalPosition, type ReadEventMetadataWithoutGlobalPosition, type ReadStreamOptions, type ReadStreamResult, STREAM_DOES_NOT_EXIST, STREAM_EXISTS, type ScheduleOptions, type ScheduledMessage, type ScheduledMessageProcessor, type StreamPositionTypeOfEventStore, type StreamPositionTypeOfReadEventMetadata, StreamingCoordinator, StringDecoder, type StringifyOptions, type TestEventStream, type ThenThrows, type TypedProjectionDefinition, ValidationErrors, type Workflow, type WorkflowCommand, type WorkflowEvent, type WorkflowOutput, WrapEventStore, accept, argMatches, argValue, assertDeepEqual, assertDoesNotThrow, assertEqual, assertExpectedVersionMatchesCurrent, assertFails, assertFalse, assertIsNotNull, assertIsNull, assertMatches, assertNotDeepEqual, assertNotEmptyString, assertNotEqual, assertOk, assertPositiveNumber, assertRejects, assertThat, assertThatArray, assertThrows, assertThrowsAsync, assertTrue, assertUnsignedBigInt, asyncProjections, asyncRetry, canCreateEventStoreSession, caughtUpEventFrom, collect, command, complete, concatUint8Arrays, deepEquals, error, event, formatDateToUtcYYYYMMDD, getInMemoryEventStore, getInMemoryMessageBus, globalStreamCaughtUp, ignore, inlineProjections, isEquatable, isExpectedVersionConflictError, isGlobalStreamCaughtUp, isNotInternalEvent, isNumber, isString, isSubscriptionEvent, isSubset, isValidYYYYMMDD, matchesExpectedVersion, merge, nulloSessionFactory, parseDateFromUtcYYYYMMDD, projection, projections, publish, reply, restream, schedule, send, streamGenerators, streamTrackingGlobalPosition, streamTransformations, sum, verifyThat };
package/dist/index.js CHANGED
@@ -976,7 +976,7 @@ var assertThrowsAsync = async (fun, errorCheck) => {
976
976
  }
977
977
  assertTrue(
978
978
  errorCheck(typedError),
979
- `Error doesn't match the expected condition: ${JSON.stringify(error2)}`
979
+ `Error doesn't match the expected condition: ${JSONParser.stringify(error2)}`
980
980
  );
981
981
  return typedError;
982
982
  }
@@ -990,7 +990,7 @@ var assertThrows = (fun, errorCheck) => {
990
990
  if (errorCheck) {
991
991
  assertTrue(
992
992
  errorCheck(typedError),
993
- `Error doesn't match the expected condition: ${JSON.stringify(error2)}`
993
+ `Error doesn't match the expected condition: ${JSONParser.stringify(error2)}`
994
994
  );
995
995
  } else if (typedError instanceof AssertionError) {
996
996
  assertFalse(
@@ -1002,6 +1002,23 @@ var assertThrows = (fun, errorCheck) => {
1002
1002
  }
1003
1003
  throw new AssertionError("Function didn't throw expected error");
1004
1004
  };
1005
+ var assertDoesNotThrow = (fun, errorCheck) => {
1006
+ try {
1007
+ fun();
1008
+ return null;
1009
+ } catch (error2) {
1010
+ const typedError = error2;
1011
+ if (errorCheck) {
1012
+ assertFalse(
1013
+ errorCheck(typedError),
1014
+ `Error matching the expected condition was thrown!: ${JSONParser.stringify(error2)}`
1015
+ );
1016
+ } else {
1017
+ assertFails(`Function threw an error: ${JSONParser.stringify(error2)}`);
1018
+ }
1019
+ return typedError;
1020
+ }
1021
+ };
1005
1022
  var assertRejects = async (promise, errorCheck) => {
1006
1023
  try {
1007
1024
  await promise;
@@ -1060,7 +1077,7 @@ function assertEqual(expected, actual, message) {
1060
1077
  throw new AssertionError(
1061
1078
  `${message ?? "Objects are not equal"}:
1062
1079
  Expected: ${JSONParser.stringify(expected)}
1063
- Actual:${JSONParser.stringify(actual)}`
1080
+ Actual: ${JSONParser.stringify(actual)}`
1064
1081
  );
1065
1082
  }
1066
1083
  function assertNotEqual(obj, other, message) {
@@ -1122,8 +1139,12 @@ function verifyThat(fn) {
1122
1139
  }
1123
1140
  var assertThatArray = (array) => {
1124
1141
  return {
1125
- isEmpty: () => assertEqual(array.length, 0),
1126
- isNotEmpty: () => assertNotEqual(array.length, 0),
1142
+ isEmpty: () => assertEqual(
1143
+ array.length,
1144
+ 0,
1145
+ `Array is not empty ${JSONParser.stringify(array)}`
1146
+ ),
1147
+ isNotEmpty: () => assertNotEqual(array.length, 0, `Array is empty`),
1127
1148
  hasSize: (length) => assertEqual(array.length, length),
1128
1149
  containsElements: (other) => {
1129
1150
  assertTrue(other.every((ts) => array.some((o) => deepEquals(ts, o))));
@@ -1132,7 +1153,7 @@ var assertThatArray = (array) => {
1132
1153
  assertTrue(other.every((ts) => array.some((o) => isSubset(o, ts))));
1133
1154
  },
1134
1155
  containsOnlyElementsMatching: (other) => {
1135
- assertEqual(array.length, other.length);
1156
+ assertEqual(array.length, other.length, `Arrays lengths don't match`);
1136
1157
  assertTrue(other.every((ts) => array.some((o) => isSubset(o, ts))));
1137
1158
  },
1138
1159
  containsExactlyInAnyOrder: (other) => {
@@ -1198,7 +1219,14 @@ var DeciderSpecification = {
1198
1219
  const resultEvents = handle();
1199
1220
  const resultEventsArray = Array.isArray(resultEvents) ? resultEvents : [resultEvents];
1200
1221
  const expectedEventsArray = Array.isArray(expectedEvents) ? expectedEvents : [expectedEvents];
1201
- assertMatches(resultEventsArray, expectedEventsArray);
1222
+ assertThatArray(resultEventsArray).containsOnlyElementsMatching(
1223
+ expectedEventsArray
1224
+ );
1225
+ },
1226
+ thenDoesNothing: () => {
1227
+ const resultEvents = handle();
1228
+ const resultEventsArray = Array.isArray(resultEvents) ? resultEvents : [resultEvents];
1229
+ assertThatArray(resultEventsArray).isEmpty();
1202
1230
  },
1203
1231
  thenThrows: (...args) => {
1204
1232
  try {
@@ -1307,6 +1335,7 @@ export {
1307
1335
  argMatches,
1308
1336
  argValue,
1309
1337
  assertDeepEqual,
1338
+ assertDoesNotThrow,
1310
1339
  assertEqual,
1311
1340
  assertExpectedVersionMatchesCurrent,
1312
1341
  assertFails,