@event-driven-io/emmett-sqlite 0.43.0-beta.1 → 0.43.0-beta.3

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,5 +1,5 @@
1
- import { a as SQLiteEventStore, b as SQLiteReadEventMetadata, A as AnyEventStoreDriver, c as SQLiteProjectionDefinition, I as InferOptionsFromEventStoreDriver } from './sqliteProjection-V1lU-4KS.cjs';
2
- export { C as CreateEventStoreSchemaOptions, v as EventHandler, t as EventStoreSchemaMigrationOptions, w as SQLiteEventStoreDefaultStreamVersion, S as SQLiteEventStoreOptions, e as SQLiteProjectionHandler, d as SQLiteProjectionHandlerContext, f as SQLiteProjectionHandlerOptions, g as SQLiteRawBatchSQLProjection, j as SQLiteRawSQLProjection, x as SQLiteReadEvent, l as SQLiteStreamExistsOptions, u as createEventStoreSchema, y as getSQLiteEventStore, h as handleProjections, o as messagesTableSQL, p as processorsTableSQL, q as projectionsTableSQL, r as schemaSQL, s as sqliteProjection, i as sqliteRawBatchSQLProjection, k as sqliteRawSQLProjection, m as streamExists, n as streamsTableSQL } from './sqliteProjection-V1lU-4KS.cjs';
1
+ import { a as SQLiteEventStore, b as SQLiteReadEventMetadata, A as AnyEventStoreDriver, c as SQLiteProjectionDefinition, I as InferOptionsFromEventStoreDriver } from './sqliteProjection-BJ6uAnzZ.cjs';
2
+ export { C as CreateEventStoreSchemaOptions, v as EventHandler, t as EventStoreSchemaMigrationOptions, w as SQLiteEventStoreDefaultStreamVersion, S as SQLiteEventStoreOptions, e as SQLiteProjectionHandler, d as SQLiteProjectionHandlerContext, f as SQLiteProjectionHandlerOptions, g as SQLiteRawBatchSQLProjection, j as SQLiteRawSQLProjection, x as SQLiteReadEvent, l as SQLiteStreamExistsOptions, u as createEventStoreSchema, y as getSQLiteEventStore, h as handleProjections, o as messagesTableSQL, p as processorsTableSQL, q as projectionsTableSQL, r as schemaSQL, s as sqliteProjection, i as sqliteRawBatchSQLProjection, k as sqliteRawSQLProjection, m as streamExists, n as streamsTableSQL } from './sqliteProjection-BJ6uAnzZ.cjs';
3
3
  import * as _event_driven_io_emmett from '@event-driven-io/emmett';
4
4
  import { Event, AppendToStreamOptions, BeforeEventStoreCommitHandler, Message, RecordedMessageMetadata, RecordedMessage, RecordedMessageMetadataWithGlobalPosition, ProcessorCheckpoint, ReadStreamOptions, ReadStreamResult, ReadEventMetadataWithGlobalPosition, ThenThrows } from '@event-driven-io/emmett';
5
5
  import { SQL, SQLExecutor, Dumbo, QueryResultRow } from '@event-driven-io/dumbo';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
- import { a as SQLiteEventStore, b as SQLiteReadEventMetadata, A as AnyEventStoreDriver, c as SQLiteProjectionDefinition, I as InferOptionsFromEventStoreDriver } from './sqliteProjection-V1lU-4KS.js';
2
- export { C as CreateEventStoreSchemaOptions, v as EventHandler, t as EventStoreSchemaMigrationOptions, w as SQLiteEventStoreDefaultStreamVersion, S as SQLiteEventStoreOptions, e as SQLiteProjectionHandler, d as SQLiteProjectionHandlerContext, f as SQLiteProjectionHandlerOptions, g as SQLiteRawBatchSQLProjection, j as SQLiteRawSQLProjection, x as SQLiteReadEvent, l as SQLiteStreamExistsOptions, u as createEventStoreSchema, y as getSQLiteEventStore, h as handleProjections, o as messagesTableSQL, p as processorsTableSQL, q as projectionsTableSQL, r as schemaSQL, s as sqliteProjection, i as sqliteRawBatchSQLProjection, k as sqliteRawSQLProjection, m as streamExists, n as streamsTableSQL } from './sqliteProjection-V1lU-4KS.js';
1
+ import { a as SQLiteEventStore, b as SQLiteReadEventMetadata, A as AnyEventStoreDriver, c as SQLiteProjectionDefinition, I as InferOptionsFromEventStoreDriver } from './sqliteProjection-BJ6uAnzZ.js';
2
+ export { C as CreateEventStoreSchemaOptions, v as EventHandler, t as EventStoreSchemaMigrationOptions, w as SQLiteEventStoreDefaultStreamVersion, S as SQLiteEventStoreOptions, e as SQLiteProjectionHandler, d as SQLiteProjectionHandlerContext, f as SQLiteProjectionHandlerOptions, g as SQLiteRawBatchSQLProjection, j as SQLiteRawSQLProjection, x as SQLiteReadEvent, l as SQLiteStreamExistsOptions, u as createEventStoreSchema, y as getSQLiteEventStore, h as handleProjections, o as messagesTableSQL, p as processorsTableSQL, q as projectionsTableSQL, r as schemaSQL, s as sqliteProjection, i as sqliteRawBatchSQLProjection, k as sqliteRawSQLProjection, m as streamExists, n as streamsTableSQL } from './sqliteProjection-BJ6uAnzZ.js';
3
3
  import * as _event_driven_io_emmett from '@event-driven-io/emmett';
4
4
  import { Event, AppendToStreamOptions, BeforeEventStoreCommitHandler, Message, RecordedMessageMetadata, RecordedMessage, RecordedMessageMetadataWithGlobalPosition, ProcessorCheckpoint, ReadStreamOptions, ReadStreamResult, ReadEventMetadataWithGlobalPosition, ThenThrows } from '@event-driven-io/emmett';
5
5
  import { SQL, SQLExecutor, Dumbo, QueryResultRow } from '@event-driven-io/dumbo';
package/dist/index.js CHANGED
@@ -52,9 +52,20 @@ import { v7 as uuid } from "uuid";
52
52
  import retry from "async-retry";
53
53
  import { v7 as uuid2 } from "uuid";
54
54
  import { v4 as uuid3 } from "uuid";
55
+ import { v7 as uuid5 } from "uuid";
55
56
  var emmettPrefix = "emt";
56
57
  var defaultTag = `${emmettPrefix}:default`;
57
58
  var unknownTag = `${emmettPrefix}:unknown`;
59
+ var canCreateEventStoreSession = (eventStore) => "withSession" in eventStore;
60
+ var nulloSessionFactory = (eventStore) => ({
61
+ withSession: (callback) => {
62
+ const nulloSession = {
63
+ eventStore,
64
+ close: () => Promise.resolve()
65
+ };
66
+ return callback(nulloSession);
67
+ }
68
+ });
58
69
  var STREAM_EXISTS = "STREAM_EXISTS";
59
70
  var STREAM_DOES_NOT_EXIST = "STREAM_DOES_NOT_EXIST";
60
71
  var NO_CONCURRENCY_CHECK = "NO_CONCURRENCY_CHECK";
@@ -75,8 +86,8 @@ var ExpectedVersionConflictError = class _ExpectedVersionConflictError extends C
75
86
  Object.setPrototypeOf(this, _ExpectedVersionConflictError.prototype);
76
87
  }
77
88
  };
78
- var isExpectedVersionConflictError = (error2) => error2 instanceof ExpectedVersionConflictError || EmmettError.isInstanceOf(
79
- error2,
89
+ var isExpectedVersionConflictError = (error) => error instanceof ExpectedVersionConflictError || EmmettError.isInstanceOf(
90
+ error,
80
91
  ExpectedVersionConflictError.Codes.ConcurrencyError
81
92
  );
82
93
  var isPrimitive = (value) => {
@@ -305,6 +316,30 @@ var JSONParser = {
305
316
  return options?.map ? options.map(parsed) : parsed;
306
317
  }
307
318
  };
319
+ var NoRetries = { retries: 0 };
320
+ var asyncRetry = async (fn, opts) => {
321
+ if (opts === void 0 || opts.retries === 0) return fn();
322
+ return retry(
323
+ async (bail) => {
324
+ try {
325
+ const result = await fn();
326
+ if (opts?.shouldRetryResult && opts.shouldRetryResult(result)) {
327
+ throw new EmmettError(
328
+ `Retrying because of result: ${JSONParser.stringify(result)}`
329
+ );
330
+ }
331
+ return result;
332
+ } catch (error) {
333
+ if (opts?.shouldRetryError && !opts.shouldRetryError(error)) {
334
+ bail(error);
335
+ return void 0;
336
+ }
337
+ throw error;
338
+ }
339
+ },
340
+ opts ?? { retries: 0 }
341
+ );
342
+ };
308
343
  var onShutdown = (handler) => {
309
344
  const signals = ["SIGTERM", "SIGINT"];
310
345
  if (typeof process !== "undefined" && typeof process.on === "function") {
@@ -395,12 +430,13 @@ var reactor = (options) => {
395
430
  id: processorId,
396
431
  instanceId,
397
432
  type,
433
+ canHandle,
398
434
  init,
399
435
  start: async (startOptions) => {
400
436
  if (isActive) return;
401
437
  await init(startOptions);
402
438
  isActive = true;
403
- closeSignal = onShutdown(() => close({}));
439
+ closeSignal = onShutdown(() => close(startOptions));
404
440
  if (lastCheckpoint !== null)
405
441
  return {
406
442
  lastCheckpoint
@@ -649,6 +685,243 @@ var upcastRecordedMessage = (recordedMessage, options) => {
649
685
  };
650
686
  };
651
687
  var projection = (definition) => definition;
688
+ var WorkflowHandlerStreamVersionConflictRetryOptions = {
689
+ retries: 3,
690
+ minTimeout: 100,
691
+ factor: 1.5,
692
+ shouldRetryError: isExpectedVersionConflictError
693
+ };
694
+ var fromWorkflowHandlerRetryOptions = (retryOptions) => {
695
+ if (retryOptions === void 0) return NoRetries;
696
+ if ("onVersionConflict" in retryOptions) {
697
+ if (typeof retryOptions.onVersionConflict === "boolean")
698
+ return WorkflowHandlerStreamVersionConflictRetryOptions;
699
+ else if (typeof retryOptions.onVersionConflict === "number")
700
+ return {
701
+ ...WorkflowHandlerStreamVersionConflictRetryOptions,
702
+ retries: retryOptions.onVersionConflict
703
+ };
704
+ else return retryOptions.onVersionConflict;
705
+ }
706
+ return retryOptions;
707
+ };
708
+ var emptyHandlerResult = (nextExpectedStreamVersion = 0n) => ({
709
+ newMessages: [],
710
+ createdNewStream: false,
711
+ nextExpectedStreamVersion
712
+ });
713
+ var createInputMetadata = (originalMessageId, action) => ({
714
+ originalMessageId,
715
+ input: true,
716
+ action
717
+ });
718
+ var tagOutputMessage = (msg, action) => {
719
+ const existingMetadata = "metadata" in msg && msg.metadata ? msg.metadata : {};
720
+ return {
721
+ ...msg,
722
+ metadata: {
723
+ ...existingMetadata,
724
+ action
725
+ }
726
+ };
727
+ };
728
+ var createWrappedInitialState = (initialState) => {
729
+ return () => ({
730
+ userState: initialState(),
731
+ processedInputIds: /* @__PURE__ */ new Set()
732
+ });
733
+ };
734
+ var createWrappedEvolve = (evolve, workflowName, separateInputInboxFromProcessing) => {
735
+ return (state, event2) => {
736
+ const metadata = event2.metadata;
737
+ let processedInputIds = state.processedInputIds;
738
+ if (metadata?.input === true && typeof metadata?.originalMessageId === "string") {
739
+ processedInputIds = new Set(state.processedInputIds);
740
+ processedInputIds.add(metadata.originalMessageId);
741
+ }
742
+ if (separateInputInboxFromProcessing && metadata?.input === true) {
743
+ return {
744
+ userState: state.userState,
745
+ processedInputIds
746
+ };
747
+ }
748
+ const eventType = event2.type;
749
+ const eventForEvolve = eventType.startsWith(`${workflowName}:`) ? {
750
+ ...event2,
751
+ type: eventType.replace(`${workflowName}:`, "")
752
+ } : event2;
753
+ return {
754
+ userState: evolve(state.userState, eventForEvolve),
755
+ processedInputIds
756
+ };
757
+ };
758
+ };
759
+ var workflowStreamName = ({
760
+ workflowName,
761
+ workflowId
762
+ }) => `emt:workflow:${workflowName}:${workflowId}`;
763
+ var WorkflowHandler = (options) => async (store, message2, handleOptions) => asyncRetry(
764
+ async () => {
765
+ const result = await withSession2(store, async ({ eventStore }) => {
766
+ const {
767
+ workflow: { evolve, initialState, decide, name: workflowName },
768
+ getWorkflowId: getWorkflowId2
769
+ } = options;
770
+ const inputMessageId = (
771
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
772
+ ("metadata" in message2 && message2.metadata?.messageId ? (
773
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
774
+ message2.metadata.messageId
775
+ ) : void 0) ?? uuid5()
776
+ );
777
+ const messageWithMetadata = {
778
+ ...message2,
779
+ // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment
780
+ metadata: {
781
+ messageId: inputMessageId,
782
+ ...message2.metadata
783
+ }
784
+ };
785
+ const workflowId = getWorkflowId2(messageWithMetadata);
786
+ if (!workflowId) {
787
+ return emptyHandlerResult();
788
+ }
789
+ const streamName = options.mapWorkflowId ? options.mapWorkflowId(workflowId) : workflowStreamName({ workflowName, workflowId });
790
+ const messageType = messageWithMetadata.type;
791
+ const hasWorkflowPrefix = messageType.startsWith(`${workflowName}:`);
792
+ if (options.separateInputInboxFromProcessing && !hasWorkflowPrefix) {
793
+ const inputMetadata2 = createInputMetadata(
794
+ inputMessageId,
795
+ "InitiatedBy"
796
+ );
797
+ const inputToStore2 = {
798
+ type: `${workflowName}:${messageWithMetadata.type}`,
799
+ data: messageWithMetadata.data,
800
+ kind: messageWithMetadata.kind,
801
+ metadata: inputMetadata2
802
+ };
803
+ const appendResult2 = await eventStore.appendToStream(
804
+ streamName,
805
+ [inputToStore2],
806
+ {
807
+ ...handleOptions,
808
+ expectedStreamVersion: handleOptions?.expectedStreamVersion ?? NO_CONCURRENCY_CHECK
809
+ }
810
+ );
811
+ return {
812
+ ...appendResult2,
813
+ newMessages: []
814
+ };
815
+ }
816
+ const wrappedInitialState = createWrappedInitialState(initialState);
817
+ const wrappedEvolve = createWrappedEvolve(
818
+ evolve,
819
+ workflowName,
820
+ options.separateInputInboxFromProcessing ?? false
821
+ );
822
+ const aggregationResult = await eventStore.aggregateStream(streamName, {
823
+ evolve: wrappedEvolve,
824
+ initialState: wrappedInitialState,
825
+ read: {
826
+ ...handleOptions,
827
+ // expected stream version is passed to fail fast
828
+ // if stream is in the wrong state
829
+ expectedStreamVersion: handleOptions?.expectedStreamVersion ?? NO_CONCURRENCY_CHECK
830
+ }
831
+ });
832
+ const { currentStreamVersion } = aggregationResult;
833
+ const { userState: state, processedInputIds } = aggregationResult.state;
834
+ if (processedInputIds.has(inputMessageId)) {
835
+ return emptyHandlerResult(currentStreamVersion);
836
+ }
837
+ const messageForDecide = hasWorkflowPrefix ? {
838
+ ...messageWithMetadata,
839
+ type: messageType.replace(`${workflowName}:`, "")
840
+ } : messageWithMetadata;
841
+ const result2 = decide(messageForDecide, state);
842
+ const inputMetadata = createInputMetadata(
843
+ inputMessageId,
844
+ aggregationResult.streamExists ? "Received" : "InitiatedBy"
845
+ );
846
+ const inputToStore = {
847
+ type: `${workflowName}:${messageWithMetadata.type}`,
848
+ data: messageWithMetadata.data,
849
+ kind: messageWithMetadata.kind,
850
+ metadata: inputMetadata
851
+ };
852
+ const outputMessages = (Array.isArray(result2) ? result2 : [result2]).filter((msg) => msg !== void 0 && msg !== null);
853
+ const outputCommandTypes = options.outputs?.commands ?? [];
854
+ const taggedOutputMessages = outputMessages.map((msg) => {
855
+ const action = outputCommandTypes.includes(
856
+ msg.type
857
+ ) ? "Sent" : "Published";
858
+ return tagOutputMessage(msg, action);
859
+ });
860
+ const messagesToAppend = options.separateInputInboxFromProcessing && hasWorkflowPrefix ? [...taggedOutputMessages] : [inputToStore, ...taggedOutputMessages];
861
+ if (messagesToAppend.length === 0) {
862
+ return emptyHandlerResult(currentStreamVersion);
863
+ }
864
+ const expectedStreamVersion = handleOptions?.expectedStreamVersion ?? (aggregationResult.streamExists ? currentStreamVersion : STREAM_DOES_NOT_EXIST);
865
+ const appendResult = await eventStore.appendToStream(
866
+ streamName,
867
+ // TODO: Fix this cast
868
+ messagesToAppend,
869
+ {
870
+ ...handleOptions,
871
+ expectedStreamVersion
872
+ }
873
+ );
874
+ return {
875
+ ...appendResult,
876
+ newMessages: outputMessages
877
+ };
878
+ });
879
+ return result;
880
+ },
881
+ fromWorkflowHandlerRetryOptions(
882
+ handleOptions && "retry" in handleOptions ? handleOptions.retry : options.retry
883
+ )
884
+ );
885
+ var withSession2 = (eventStore, callback) => {
886
+ const sessionFactory = canCreateEventStoreSession(eventStore) ? eventStore : nulloSessionFactory(eventStore);
887
+ return sessionFactory.withSession(callback);
888
+ };
889
+ var getWorkflowId = (options) => `emt:processor:workflow:${options.workflowName}`;
890
+ var workflowProcessor = (options) => {
891
+ const { workflow, ...rest } = options;
892
+ const canHandle = options.separateInputInboxFromProcessing ? [
893
+ ...options.inputs.commands,
894
+ ...options.inputs.events,
895
+ ...options.inputs.commands.map((t) => `${workflow.name}:${t}`),
896
+ ...options.inputs.events.map((t) => `${workflow.name}:${t}`)
897
+ ] : [...options.inputs.commands, ...options.inputs.events];
898
+ const handle = WorkflowHandler(options);
899
+ return reactor({
900
+ ...rest,
901
+ processorId: options.processorId ?? getWorkflowId({ workflowName: workflow.name }),
902
+ canHandle,
903
+ type: MessageProcessorType.PROJECTOR,
904
+ eachMessage: async (message2, context) => {
905
+ const messageType = message2.type;
906
+ if (!canHandle.includes(messageType)) return;
907
+ const result = await handle(
908
+ context.connection.messageStore,
909
+ message2,
910
+ context
911
+ );
912
+ if (options.stopAfter && result.newMessages.length > 0) {
913
+ for (const outputMessage of result.newMessages) {
914
+ if (options.stopAfter(
915
+ outputMessage
916
+ )) {
917
+ return { type: "STOP", reason: "Stop condition reached" };
918
+ }
919
+ }
920
+ }
921
+ return;
922
+ }
923
+ });
924
+ };
652
925
 
653
926
  // src/eventStore/projections/sqliteProjection.ts
654
927
  var handleProjections = async (options) => {
@@ -715,7 +988,7 @@ var sqliteRawSQLProjection = (options) => {
715
988
 
716
989
  // src/eventStore/projections/sqliteProjectionSpec.ts
717
990
  import { dumbo } from "@event-driven-io/dumbo";
718
- import { v4 as uuid5 } from "uuid";
991
+ import { v4 as uuid6 } from "uuid";
719
992
  var SQLiteProjectionSpec = {
720
993
  for: (options) => {
721
994
  {
@@ -740,8 +1013,8 @@ var SQLiteProjectionSpec = {
740
1013
  checkpoint: bigIntProcessorCheckpoint(++globalPosition),
741
1014
  globalPosition,
742
1015
  streamPosition: globalPosition,
743
- streamName: `test-${uuid5()}`,
744
- messageId: uuid5()
1016
+ streamName: `test-${uuid6()}`,
1017
+ messageId: uuid6()
745
1018
  };
746
1019
  allEvents.push({
747
1020
  ...event,
@@ -856,7 +1129,7 @@ import {
856
1129
  SQL,
857
1130
  UniqueConstraintError
858
1131
  } from "@event-driven-io/dumbo";
859
- import { v4 as uuid6 } from "uuid";
1132
+ import { v4 as uuid7 } from "uuid";
860
1133
 
861
1134
  // src/eventStore/schema/typing.ts
862
1135
  var emmettPrefix2 = "emt";
@@ -906,7 +1179,7 @@ var appendToStream = async (connection, streamName, streamType, messages, option
906
1179
  kind: m.kind ?? "Event",
907
1180
  metadata: {
908
1181
  streamName,
909
- messageId: uuid6(),
1182
+ messageId: uuid7(),
910
1183
  streamPosition: BigInt(i + 1),
911
1184
  ..."metadata" in m ? m.metadata ?? {} : {}
912
1185
  }
@@ -1337,7 +1610,7 @@ var zipSQLiteEventStoreMessageBatchPullerStartFrom = (options) => {
1337
1610
 
1338
1611
  // src/eventStore/consumers/sqliteEventStoreConsumer.ts
1339
1612
  import { dumbo as dumbo2 } from "@event-driven-io/dumbo";
1340
- import { v7 as uuid7 } from "uuid";
1613
+ import { v7 as uuid8 } from "uuid";
1341
1614
 
1342
1615
  // src/eventStore/consumers/sqliteCheckpointer.ts
1343
1616
  var sqliteCheckpointer = () => ({
@@ -1376,6 +1649,49 @@ var sqliteProcessingScope = () => {
1376
1649
  };
1377
1650
  return processingScope;
1378
1651
  };
1652
+ var sqliteWorkflowProcessingScope = (messageStore) => {
1653
+ const processingScope = async (handler, partialContext) => {
1654
+ const connection = partialContext?.connection;
1655
+ if (!connection)
1656
+ throw new EmmettError("Connection is required in context or options");
1657
+ return connection.withTransaction(
1658
+ async (transaction) => {
1659
+ return handler({
1660
+ ...partialContext,
1661
+ connection: Object.assign(connection, { messageStore }),
1662
+ execute: transaction.execute
1663
+ });
1664
+ }
1665
+ );
1666
+ };
1667
+ return processingScope;
1668
+ };
1669
+ var sqliteWorkflowProcessor = (options) => {
1670
+ const {
1671
+ processorId = options.processorId ?? getWorkflowId({
1672
+ workflowName: options.workflow.name ?? "unknown"
1673
+ }),
1674
+ processorInstanceId = getProcessorInstanceId(processorId),
1675
+ version = defaultProcessorVersion,
1676
+ partition = defaultProcessorPartition
1677
+ } = options;
1678
+ const hooks = {
1679
+ ...options.hooks ?? {},
1680
+ onClose: options.hooks?.onClose
1681
+ };
1682
+ return workflowProcessor({
1683
+ ...options,
1684
+ processorId,
1685
+ processorInstanceId,
1686
+ version,
1687
+ partition,
1688
+ hooks,
1689
+ processingScope: sqliteWorkflowProcessingScope(
1690
+ options.messageStore
1691
+ ),
1692
+ checkpoints: sqliteCheckpointer()
1693
+ });
1694
+ };
1379
1695
  var sqliteReactor = (options) => {
1380
1696
  const {
1381
1697
  processorId = options.processorId,
@@ -1509,7 +1825,7 @@ var sqliteEventStoreConsumer = (options) => {
1509
1825
  isInitialized = true;
1510
1826
  };
1511
1827
  return {
1512
- consumerId: options.consumerId ?? uuid7(),
1828
+ consumerId: options.consumerId ?? uuid8(),
1513
1829
  get isRunning() {
1514
1830
  return isRunning;
1515
1831
  },
@@ -1531,6 +1847,22 @@ var sqliteEventStoreConsumer = (options) => {
1531
1847
  );
1532
1848
  return processor;
1533
1849
  },
1850
+ workflowProcessor: (processorOptions) => {
1851
+ const messageStore = getSQLiteEventStore({
1852
+ ...options,
1853
+ pool,
1854
+ schema: { autoMigration: "None" }
1855
+ });
1856
+ const processor = sqliteWorkflowProcessor({
1857
+ ...processorOptions,
1858
+ messageStore
1859
+ });
1860
+ processors.push(
1861
+ // TODO: change that
1862
+ processor
1863
+ );
1864
+ return processor;
1865
+ },
1534
1866
  start: () => {
1535
1867
  if (isRunning) return start;
1536
1868
  if (processors.length === 0)