@motiadev/core 0.13.2-beta.164-110989 → 0.14.0-beta.164
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 +30 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +72 -0
- package/dist/jest.config.d.ts +8 -0
- package/dist/jest.config.d.ts.map +1 -0
- package/dist/src/adapters/defaults/cron/in-memory-cron-adapter.d.ts +13 -0
- package/dist/src/adapters/defaults/cron/in-memory-cron-adapter.d.ts.map +1 -0
- package/dist/src/adapters/defaults/cron/in-memory-cron-adapter.js +53 -0
- package/dist/src/adapters/defaults/event/in-memory-queue-event-adapter.d.ts +15 -0
- package/dist/src/adapters/defaults/event/in-memory-queue-event-adapter.d.ts.map +1 -0
- package/dist/src/adapters/defaults/event/in-memory-queue-event-adapter.js +49 -0
- package/dist/src/adapters/defaults/index.d.ts +9 -0
- package/dist/src/adapters/defaults/index.d.ts.map +1 -0
- package/dist/src/adapters/defaults/index.js +19 -0
- package/dist/src/adapters/defaults/state/file-state-adapter.d.ts +23 -0
- package/dist/src/adapters/defaults/state/file-state-adapter.d.ts.map +1 -0
- package/dist/src/adapters/defaults/state/file-state-adapter.js +149 -0
- package/dist/src/adapters/defaults/state/memory-state-adapter.d.ts +16 -0
- package/dist/src/adapters/defaults/state/memory-state-adapter.d.ts.map +1 -0
- package/dist/src/adapters/defaults/state/memory-state-adapter.js +69 -0
- package/dist/src/adapters/defaults/state/utils.d.ts +4 -0
- package/dist/src/adapters/defaults/state/utils.d.ts.map +1 -0
- package/dist/src/adapters/defaults/state/utils.js +66 -0
- package/dist/src/adapters/defaults/stream/file-stream-adapter-manager.d.ts +9 -0
- package/dist/src/adapters/defaults/stream/file-stream-adapter-manager.d.ts.map +1 -0
- package/dist/src/adapters/defaults/stream/file-stream-adapter-manager.js +14 -0
- package/dist/src/adapters/defaults/stream/file-stream-adapter.d.ts +22 -0
- package/dist/src/adapters/defaults/stream/file-stream-adapter.d.ts.map +1 -0
- package/dist/src/adapters/defaults/stream/file-stream-adapter.js +125 -0
- package/dist/src/adapters/defaults/stream/index.d.ts +5 -0
- package/dist/src/adapters/defaults/stream/index.d.ts.map +1 -0
- package/dist/src/adapters/defaults/stream/index.js +11 -0
- package/dist/src/adapters/defaults/stream/memory-stream-adapter-manager.d.ts +6 -0
- package/dist/src/adapters/defaults/stream/memory-stream-adapter-manager.d.ts.map +1 -0
- package/dist/src/adapters/defaults/stream/memory-stream-adapter-manager.js +10 -0
- package/dist/src/adapters/defaults/stream/memory-stream-adapter.d.ts +16 -0
- package/dist/src/adapters/defaults/stream/memory-stream-adapter.d.ts.map +1 -0
- package/dist/src/adapters/defaults/stream/memory-stream-adapter.js +55 -0
- package/dist/src/adapters/interfaces/cron-adapter.interface.d.ts +29 -0
- package/dist/src/adapters/interfaces/cron-adapter.interface.d.ts.map +1 -0
- package/dist/src/adapters/interfaces/cron-adapter.interface.js +2 -0
- package/dist/src/adapters/interfaces/event-adapter.interface.d.ts +15 -0
- package/dist/src/adapters/interfaces/event-adapter.interface.d.ts.map +1 -0
- package/dist/src/adapters/interfaces/event-adapter.interface.js +2 -0
- package/dist/src/adapters/interfaces/index.d.ts +7 -0
- package/dist/src/adapters/interfaces/index.d.ts.map +1 -0
- package/dist/src/adapters/interfaces/index.js +5 -0
- package/dist/src/adapters/interfaces/observability-adapter.interface.d.ts +23 -0
- package/dist/src/adapters/interfaces/observability-adapter.interface.d.ts.map +1 -0
- package/dist/src/adapters/interfaces/observability-adapter.interface.js +2 -0
- package/dist/src/adapters/interfaces/state-adapter.interface.d.ts +24 -0
- package/dist/src/adapters/interfaces/state-adapter.interface.d.ts.map +1 -0
- package/dist/src/adapters/interfaces/state-adapter.interface.js +2 -0
- package/dist/src/adapters/interfaces/stream-adapter-manager.interface.d.ts +6 -0
- package/dist/src/adapters/interfaces/stream-adapter-manager.interface.d.ts.map +1 -0
- package/dist/src/adapters/interfaces/stream-adapter-manager.interface.js +2 -0
- package/dist/src/adapters/interfaces/stream-adapter.interface.d.ts +22 -0
- package/dist/src/adapters/interfaces/stream-adapter.interface.d.ts.map +1 -0
- package/dist/src/adapters/interfaces/stream-adapter.interface.js +16 -0
- package/dist/src/analytics/utils.d.ts +6 -0
- package/dist/src/analytics/utils.d.ts.map +1 -0
- package/dist/src/analytics/utils.js +51 -0
- package/dist/src/call-step-file.d.ts +16 -0
- package/dist/src/call-step-file.d.ts.map +1 -0
- package/dist/src/call-step-file.js +198 -0
- package/dist/src/config.d.ts +3 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +5 -0
- package/dist/src/config.types.d.ts +17 -0
- package/dist/src/config.types.d.ts.map +1 -0
- package/dist/src/config.types.js +2 -0
- package/dist/src/cron-handler.d.ts +14 -0
- package/dist/src/cron-handler.d.ts.map +1 -0
- package/dist/src/cron-handler.js +132 -0
- package/dist/src/endpoints/analytics-endpoint.d.ts +3 -0
- package/dist/src/endpoints/analytics-endpoint.d.ts.map +1 -0
- package/dist/src/endpoints/analytics-endpoint.js +28 -0
- package/dist/src/endpoints/flows-config-endpoint.d.ts +4 -0
- package/dist/src/endpoints/flows-config-endpoint.d.ts.map +1 -0
- package/dist/src/endpoints/flows-config-endpoint.js +34 -0
- package/dist/src/endpoints/flows-endpoint.d.ts +3 -0
- package/dist/src/endpoints/flows-endpoint.d.ts.map +1 -0
- package/dist/src/endpoints/flows-endpoint.js +29 -0
- package/dist/src/endpoints/step-endpoint.d.ts +4 -0
- package/dist/src/endpoints/step-endpoint.d.ts.map +1 -0
- package/dist/src/endpoints/step-endpoint.js +45 -0
- package/dist/src/generate-trace-id.d.ts +3 -0
- package/dist/src/generate-trace-id.d.ts.map +1 -0
- package/dist/src/generate-trace-id.js +14 -0
- package/dist/src/get-step-config.d.ts +5 -0
- package/dist/src/get-step-config.d.ts.map +1 -0
- package/dist/src/get-step-config.js +68 -0
- package/dist/src/get-step-language.d.ts +2 -0
- package/dist/src/get-step-language.d.ts.map +1 -0
- package/dist/src/get-step-language.js +27 -0
- package/dist/src/guards.d.ts +6 -0
- package/dist/src/guards.d.ts.map +1 -0
- package/dist/src/guards.js +11 -0
- package/dist/src/helper/flows-helper.d.ts +6 -0
- package/dist/src/helper/flows-helper.d.ts.map +1 -0
- package/dist/src/helper/flows-helper.js +143 -0
- package/dist/src/infrastructure-validator/defaults.d.ts +4 -0
- package/dist/src/infrastructure-validator/defaults.d.ts.map +1 -0
- package/dist/src/infrastructure-validator/defaults.js +16 -0
- package/dist/src/infrastructure-validator/index.d.ts +4 -0
- package/dist/src/infrastructure-validator/index.d.ts.map +1 -0
- package/dist/src/infrastructure-validator/index.js +13 -0
- package/dist/src/infrastructure-validator/schemas.d.ts +45 -0
- package/dist/src/infrastructure-validator/schemas.d.ts.map +1 -0
- package/dist/src/infrastructure-validator/schemas.js +100 -0
- package/dist/src/infrastructure-validator/types.d.ts +21 -0
- package/dist/src/infrastructure-validator/types.d.ts.map +1 -0
- package/dist/src/infrastructure-validator/types.js +2 -0
- package/dist/src/infrastructure-validator/validations.d.ts +4 -0
- package/dist/src/infrastructure-validator/validations.d.ts.map +1 -0
- package/dist/src/infrastructure-validator/validations.js +62 -0
- package/dist/src/language-runner.d.ts +15 -0
- package/dist/src/language-runner.d.ts.map +1 -0
- package/dist/src/language-runner.js +31 -0
- package/dist/src/locked-data.d.ts +78 -0
- package/dist/src/locked-data.d.ts.map +1 -0
- package/dist/src/locked-data.js +284 -0
- package/dist/src/logger-factory.d.ts +19 -0
- package/dist/src/logger-factory.d.ts.map +1 -0
- package/dist/src/logger-factory.js +27 -0
- package/dist/src/logger.d.ts +26 -0
- package/dist/src/logger.d.ts.map +1 -0
- package/dist/src/logger.js +60 -0
- package/dist/src/mermaid-generator.d.ts +5 -0
- package/dist/src/mermaid-generator.d.ts.map +1 -0
- package/dist/src/mermaid-generator.js +203 -0
- package/dist/src/motia.d.ts +33 -0
- package/dist/src/motia.d.ts.map +1 -0
- package/dist/src/motia.js +4 -0
- package/dist/src/node/can-access.d.ts +2 -0
- package/dist/src/node/can-access.d.ts.map +1 -0
- package/dist/src/node/can-access.js +44 -0
- package/dist/src/node/get-config.d.ts +2 -0
- package/dist/src/node/get-config.d.ts.map +1 -0
- package/dist/src/node/get-config.js +64 -0
- package/dist/src/node/logger.d.ts +16 -0
- package/dist/src/node/logger.d.ts.map +1 -0
- package/dist/src/node/logger.js +48 -0
- package/dist/src/node/middleware-compose.d.ts +2 -0
- package/dist/src/node/middleware-compose.d.ts.map +1 -0
- package/dist/src/node/middleware-compose.js +10 -0
- package/dist/src/node/node-runner.d.ts +2 -0
- package/dist/src/node/node-runner.d.ts.map +1 -0
- package/dist/src/node/node-runner.js +83 -0
- package/dist/src/node/rpc-state-manager.d.ts +12 -0
- package/dist/src/node/rpc-state-manager.d.ts.map +1 -0
- package/dist/src/node/rpc-state-manager.js +24 -0
- package/dist/src/node/rpc.d.ts +10 -0
- package/dist/src/node/rpc.d.ts.map +1 -0
- package/dist/src/node/rpc.js +50 -0
- package/dist/src/observability/create-trace.d.ts +4 -0
- package/dist/src/observability/create-trace.d.ts.map +1 -0
- package/dist/src/observability/create-trace.js +22 -0
- package/dist/src/observability/index.d.ts +4 -0
- package/dist/src/observability/index.d.ts.map +1 -0
- package/dist/src/observability/index.js +2 -0
- package/dist/src/observability/no-tracer.d.ts +10 -0
- package/dist/src/observability/no-tracer.d.ts.map +1 -0
- package/dist/src/observability/no-tracer.js +22 -0
- package/dist/src/observability/redis-trace-stream-adapter.d.ts +17 -0
- package/dist/src/observability/redis-trace-stream-adapter.d.ts.map +1 -0
- package/dist/src/observability/redis-trace-stream-adapter.js +65 -0
- package/dist/src/observability/stream-tracer.d.ts +23 -0
- package/dist/src/observability/stream-tracer.d.ts.map +1 -0
- package/dist/src/observability/stream-tracer.js +114 -0
- package/dist/src/observability/trace-manager.d.ts +14 -0
- package/dist/src/observability/trace-manager.d.ts.map +1 -0
- package/dist/src/observability/trace-manager.js +26 -0
- package/dist/src/observability/tracer.d.ts +19 -0
- package/dist/src/observability/tracer.d.ts.map +1 -0
- package/dist/src/observability/tracer.js +98 -0
- package/dist/src/observability/types.d.ts +75 -0
- package/dist/src/observability/types.d.ts.map +1 -0
- package/dist/src/observability/types.js +2 -0
- package/dist/src/pretty-print.d.ts +2 -0
- package/dist/src/pretty-print.d.ts.map +1 -0
- package/dist/src/pretty-print.js +63 -0
- package/dist/src/printer.d.ts +61 -0
- package/dist/src/printer.d.ts.map +1 -0
- package/dist/src/printer.js +164 -0
- package/dist/src/process-communication/communication-config.d.ts +8 -0
- package/dist/src/process-communication/communication-config.d.ts.map +1 -0
- package/dist/src/process-communication/communication-config.js +18 -0
- package/dist/src/process-communication/process-manager.d.ts +32 -0
- package/dist/src/process-communication/process-manager.d.ts.map +1 -0
- package/dist/src/process-communication/process-manager.js +88 -0
- package/dist/src/process-communication/rpc-processor-interface.d.ts +10 -0
- package/dist/src/process-communication/rpc-processor-interface.d.ts.map +1 -0
- package/dist/src/process-communication/rpc-processor-interface.js +2 -0
- package/dist/src/queue-manager.d.ts +42 -0
- package/dist/src/queue-manager.d.ts.map +1 -0
- package/dist/src/queue-manager.js +252 -0
- package/dist/src/ruby/get-ruby-config.d.ts +3 -0
- package/dist/src/ruby/get-ruby-config.d.ts.map +1 -0
- package/dist/src/ruby/get-ruby-config.js +34 -0
- package/dist/src/run-stream-can-access.d.ts +10 -0
- package/dist/src/run-stream-can-access.d.ts.map +1 -0
- package/dist/src/run-stream-can-access.js +59 -0
- package/dist/src/schema-utils.d.ts +9 -0
- package/dist/src/schema-utils.d.ts.map +1 -0
- package/dist/src/schema-utils.js +80 -0
- package/dist/src/server.d.ts +37 -0
- package/dist/src/server.d.ts.map +1 -0
- package/dist/src/server.js +344 -0
- package/dist/src/socket-server/helpers.d.ts +53 -0
- package/dist/src/socket-server/helpers.d.ts.map +1 -0
- package/dist/src/socket-server/helpers.js +28 -0
- package/dist/src/socket-server.d.ts +21 -0
- package/dist/src/socket-server.d.ts.map +1 -0
- package/dist/src/socket-server.js +127 -0
- package/dist/src/state/create-state-adapter.d.ts +8 -0
- package/dist/src/state/create-state-adapter.d.ts.map +1 -0
- package/dist/src/state/create-state-adapter.js +8 -0
- package/dist/src/step-handler-rpc-processor.d.ts +22 -0
- package/dist/src/step-handler-rpc-processor.d.ts.map +1 -0
- package/dist/src/step-handler-rpc-processor.js +63 -0
- package/dist/src/step-handler-rpc-stdin-processor.d.ts +23 -0
- package/dist/src/step-handler-rpc-stdin-processor.d.ts.map +1 -0
- package/dist/src/step-handler-rpc-stdin-processor.js +83 -0
- package/dist/src/step-handlers.d.ts +9 -0
- package/dist/src/step-handlers.d.ts.map +1 -0
- package/dist/src/step-handlers.js +77 -0
- package/dist/src/step-validator.d.ts +15 -0
- package/dist/src/step-validator.d.ts.map +1 -0
- package/dist/src/step-validator.js +135 -0
- package/dist/src/steps/emit.step.d.ts +12 -0
- package/dist/src/steps/emit.step.d.ts.map +1 -0
- package/dist/src/steps/emit.step.js +27 -0
- package/dist/src/steps/index.d.ts +3 -0
- package/dist/src/steps/index.d.ts.map +1 -0
- package/dist/src/steps/index.js +16 -0
- package/dist/src/streams/flows-config-stream.d.ts +14 -0
- package/dist/src/streams/flows-config-stream.d.ts.map +1 -0
- package/dist/src/streams/flows-config-stream.js +49 -0
- package/dist/src/streams/flows-stream.d.ts +12 -0
- package/dist/src/streams/flows-stream.d.ts.map +1 -0
- package/dist/src/streams/flows-stream.js +35 -0
- package/dist/src/streams/redis-logs-stream.d.ts +31 -0
- package/dist/src/streams/redis-logs-stream.d.ts.map +1 -0
- package/dist/src/streams/redis-logs-stream.js +84 -0
- package/dist/src/streams/stream-factory.d.ts +3 -0
- package/dist/src/streams/stream-factory.d.ts.map +1 -0
- package/dist/src/streams/stream-factory.js +2 -0
- package/dist/src/types/app-config-types.d.ts +45 -0
- package/dist/src/types/app-config-types.d.ts.map +1 -0
- package/dist/src/types/app-config-types.js +2 -0
- package/dist/src/types/flows-config-types.d.ts +10 -0
- package/dist/src/types/flows-config-types.d.ts.map +1 -0
- package/dist/src/types/flows-config-types.js +2 -0
- package/dist/src/types/flows-types.d.ts +39 -0
- package/dist/src/types/flows-types.d.ts.map +1 -0
- package/dist/src/types/flows-types.js +2 -0
- package/dist/src/types/generate-type-from-schema.d.ts +3 -0
- package/dist/src/types/generate-type-from-schema.d.ts.map +1 -0
- package/dist/src/types/generate-type-from-schema.js +49 -0
- package/dist/src/types/generate-types-from-response.d.ts +3 -0
- package/dist/src/types/generate-types-from-response.d.ts.map +1 -0
- package/dist/src/types/generate-types-from-response.js +13 -0
- package/dist/src/types/generate-types.d.ts +13 -0
- package/dist/src/types/generate-types.d.ts.map +1 -0
- package/dist/src/types/generate-types.js +127 -0
- package/dist/src/types/merge-schemas.d.ts +5 -0
- package/dist/src/types/merge-schemas.d.ts.map +1 -0
- package/dist/src/types/merge-schemas.js +183 -0
- package/dist/src/types/schema.types.d.ts +9 -0
- package/dist/src/types/schema.types.d.ts.map +1 -0
- package/dist/src/types/schema.types.js +14 -0
- package/dist/src/types-stream.d.ts +42 -0
- package/dist/src/types-stream.d.ts.map +1 -0
- package/dist/src/types-stream.js +2 -0
- package/dist/src/types.d.ts +190 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +17 -0
- package/dist/src/utils.d.ts +3 -0
- package/dist/src/utils.d.ts.map +1 -0
- package/dist/src/utils.js +12 -0
- package/dist/src/validate-event-input.d.ts +3 -0
- package/dist/src/validate-event-input.d.ts.map +1 -0
- package/dist/src/validate-event-input.js +74 -0
- package/package.json +8 -21
- package/dist/index.d.mts +0 -38
- package/dist/index.mjs +0 -30
- package/dist/src/adapters/defaults/cron/in-memory-cron-adapter.d.mts +0 -17
- package/dist/src/adapters/defaults/cron/in-memory-cron-adapter.d.mts.map +0 -1
- package/dist/src/adapters/defaults/cron/in-memory-cron-adapter.mjs +0 -51
- package/dist/src/adapters/defaults/cron/in-memory-cron-adapter.mjs.map +0 -1
- package/dist/src/adapters/defaults/event/in-memory-queue-event-adapter.d.mts +0 -19
- package/dist/src/adapters/defaults/event/in-memory-queue-event-adapter.d.mts.map +0 -1
- package/dist/src/adapters/defaults/event/in-memory-queue-event-adapter.mjs +0 -54
- package/dist/src/adapters/defaults/event/in-memory-queue-event-adapter.mjs.map +0 -1
- package/dist/src/adapters/defaults/index.d.mts +0 -8
- package/dist/src/adapters/defaults/index.mjs +0 -10
- package/dist/src/adapters/defaults/state/file-state-adapter.d.mts +0 -27
- package/dist/src/adapters/defaults/state/file-state-adapter.d.mts.map +0 -1
- package/dist/src/adapters/defaults/state/file-state-adapter.mjs +0 -105
- package/dist/src/adapters/defaults/state/file-state-adapter.mjs.map +0 -1
- package/dist/src/adapters/defaults/state/memory-state-adapter.d.mts +0 -20
- package/dist/src/adapters/defaults/state/memory-state-adapter.d.mts.map +0 -1
- package/dist/src/adapters/defaults/state/memory-state-adapter.mjs +0 -58
- package/dist/src/adapters/defaults/state/memory-state-adapter.mjs.map +0 -1
- package/dist/src/adapters/defaults/state/utils.mjs +0 -40
- package/dist/src/adapters/defaults/state/utils.mjs.map +0 -1
- package/dist/src/adapters/defaults/stream/file-stream-adapter-manager.d.mts +0 -13
- package/dist/src/adapters/defaults/stream/file-stream-adapter-manager.d.mts.map +0 -1
- package/dist/src/adapters/defaults/stream/file-stream-adapter-manager.mjs +0 -16
- package/dist/src/adapters/defaults/stream/file-stream-adapter-manager.mjs.map +0 -1
- package/dist/src/adapters/defaults/stream/file-stream-adapter.d.mts +0 -24
- package/dist/src/adapters/defaults/stream/file-stream-adapter.d.mts.map +0 -1
- package/dist/src/adapters/defaults/stream/file-stream-adapter.mjs +0 -84
- package/dist/src/adapters/defaults/stream/file-stream-adapter.mjs.map +0 -1
- package/dist/src/adapters/defaults/stream/memory-stream-adapter-manager.d.mts +0 -10
- package/dist/src/adapters/defaults/stream/memory-stream-adapter-manager.d.mts.map +0 -1
- package/dist/src/adapters/defaults/stream/memory-stream-adapter-manager.mjs +0 -12
- package/dist/src/adapters/defaults/stream/memory-stream-adapter-manager.mjs.map +0 -1
- package/dist/src/adapters/defaults/stream/memory-stream-adapter.d.mts +0 -20
- package/dist/src/adapters/defaults/stream/memory-stream-adapter.d.mts.map +0 -1
- package/dist/src/adapters/defaults/stream/memory-stream-adapter.mjs +0 -58
- package/dist/src/adapters/defaults/stream/memory-stream-adapter.mjs.map +0 -1
- package/dist/src/adapters/interfaces/cron-adapter.interface.d.mts +0 -32
- package/dist/src/adapters/interfaces/cron-adapter.interface.d.mts.map +0 -1
- package/dist/src/adapters/interfaces/event-adapter.interface.d.mts +0 -19
- package/dist/src/adapters/interfaces/event-adapter.interface.d.mts.map +0 -1
- package/dist/src/adapters/interfaces/observability-adapter.interface.d.mts +0 -27
- package/dist/src/adapters/interfaces/observability-adapter.interface.d.mts.map +0 -1
- package/dist/src/adapters/interfaces/state-adapter.interface.d.mts +0 -28
- package/dist/src/adapters/interfaces/state-adapter.interface.d.mts.map +0 -1
- package/dist/src/adapters/interfaces/stream-adapter-manager.interface.d.mts +0 -10
- package/dist/src/adapters/interfaces/stream-adapter-manager.interface.d.mts.map +0 -1
- package/dist/src/adapters/interfaces/stream-adapter.interface.d.mts +0 -26
- package/dist/src/adapters/interfaces/stream-adapter.interface.d.mts.map +0 -1
- package/dist/src/adapters/interfaces/stream-adapter.interface.mjs +0 -17
- package/dist/src/adapters/interfaces/stream-adapter.interface.mjs.map +0 -1
- package/dist/src/analytics/utils.d.mts +0 -9
- package/dist/src/analytics/utils.d.mts.map +0 -1
- package/dist/src/analytics/utils.mjs +0 -35
- package/dist/src/analytics/utils.mjs.map +0 -1
- package/dist/src/call-step-file.mjs +0 -213
- package/dist/src/call-step-file.mjs.map +0 -1
- package/dist/src/config.d.mts +0 -7
- package/dist/src/config.d.mts.map +0 -1
- package/dist/src/config.mjs +0 -6
- package/dist/src/config.mjs.map +0 -1
- package/dist/src/cron-handler.d.mts +0 -18
- package/dist/src/cron-handler.d.mts.map +0 -1
- package/dist/src/cron-handler.mjs +0 -103
- package/dist/src/cron-handler.mjs.map +0 -1
- package/dist/src/endpoints/analytics-endpoint.mjs +0 -29
- package/dist/src/endpoints/analytics-endpoint.mjs.map +0 -1
- package/dist/src/endpoints/flows-config-endpoint.mjs +0 -38
- package/dist/src/endpoints/flows-config-endpoint.mjs.map +0 -1
- package/dist/src/endpoints/flows-endpoint.mjs +0 -39
- package/dist/src/endpoints/flows-endpoint.mjs.map +0 -1
- package/dist/src/endpoints/step-endpoint.mjs +0 -41
- package/dist/src/endpoints/step-endpoint.mjs.map +0 -1
- package/dist/src/generate-trace-id.mjs +0 -13
- package/dist/src/generate-trace-id.mjs.map +0 -1
- package/dist/src/get-step-config.d.mts +0 -9
- package/dist/src/get-step-config.d.mts.map +0 -1
- package/dist/src/get-step-config.mjs +0 -63
- package/dist/src/get-step-config.mjs.map +0 -1
- package/dist/src/get-step-language.mjs +0 -14
- package/dist/src/get-step-language.mjs.map +0 -1
- package/dist/src/guards.d.mts +0 -10
- package/dist/src/guards.d.mts.map +0 -1
- package/dist/src/guards.mjs +0 -9
- package/dist/src/guards.mjs.map +0 -1
- package/dist/src/helper/flows-helper.mjs +0 -126
- package/dist/src/helper/flows-helper.mjs.map +0 -1
- package/dist/src/infrastructure-validator/defaults.mjs +0 -17
- package/dist/src/infrastructure-validator/defaults.mjs.map +0 -1
- package/dist/src/infrastructure-validator/index.d.mts +0 -3
- package/dist/src/infrastructure-validator/index.mjs +0 -4
- package/dist/src/infrastructure-validator/schemas.d.mts +0 -1
- package/dist/src/infrastructure-validator/schemas.mjs +0 -77
- package/dist/src/infrastructure-validator/schemas.mjs.map +0 -1
- package/dist/src/infrastructure-validator/types.d.mts +0 -14
- package/dist/src/infrastructure-validator/types.d.mts.map +0 -1
- package/dist/src/infrastructure-validator/validations.d.mts +0 -7
- package/dist/src/infrastructure-validator/validations.d.mts.map +0 -1
- package/dist/src/infrastructure-validator/validations.mjs +0 -29
- package/dist/src/infrastructure-validator/validations.mjs.map +0 -1
- package/dist/src/language-runner.mjs +0 -55
- package/dist/src/language-runner.mjs.map +0 -1
- package/dist/src/locked-data.d.mts +0 -81
- package/dist/src/locked-data.d.mts.map +0 -1
- package/dist/src/locked-data.mjs +0 -223
- package/dist/src/locked-data.mjs.map +0 -1
- package/dist/src/logger-factory.d.mts +0 -16
- package/dist/src/logger-factory.d.mts.map +0 -1
- package/dist/src/logger-factory.mjs +0 -33
- package/dist/src/logger-factory.mjs.map +0 -1
- package/dist/src/logger.d.mts +0 -28
- package/dist/src/logger.d.mts.map +0 -1
- package/dist/src/logger.mjs +0 -64
- package/dist/src/logger.mjs.map +0 -1
- package/dist/src/mermaid-generator.d.mts +0 -9
- package/dist/src/mermaid-generator.d.mts.map +0 -1
- package/dist/src/mermaid-generator.mjs +0 -126
- package/dist/src/mermaid-generator.mjs.map +0 -1
- package/dist/src/motia.d.mts +0 -36
- package/dist/src/motia.d.mts.map +0 -1
- package/dist/src/motia.mjs +0 -6
- package/dist/src/motia.mjs.map +0 -1
- package/dist/src/node/can-access.d.mts +0 -1
- package/dist/src/node/can-access.mjs +0 -36
- package/dist/src/node/can-access.mjs.map +0 -1
- package/dist/src/node/get-config.d.mts +0 -1
- package/dist/src/node/get-config.mjs +0 -49
- package/dist/src/node/get-config.mjs.map +0 -1
- package/dist/src/node/logger.mjs +0 -47
- package/dist/src/node/logger.mjs.map +0 -1
- package/dist/src/node/middleware-compose.mjs +0 -10
- package/dist/src/node/middleware-compose.mjs.map +0 -1
- package/dist/src/node/node-runner.d.mts +0 -1
- package/dist/src/node/node-runner.mjs +0 -94
- package/dist/src/node/node-runner.mjs.map +0 -1
- package/dist/src/node/rpc-state-manager.mjs +0 -35
- package/dist/src/node/rpc-state-manager.mjs.map +0 -1
- package/dist/src/node/rpc.mjs +0 -55
- package/dist/src/node/rpc.mjs.map +0 -1
- package/dist/src/observability/create-trace.mjs +0 -26
- package/dist/src/observability/create-trace.mjs.map +0 -1
- package/dist/src/observability/index.d.mts +0 -7
- package/dist/src/observability/index.d.mts.map +0 -1
- package/dist/src/observability/no-tracer.d.mts +0 -15
- package/dist/src/observability/no-tracer.d.mts.map +0 -1
- package/dist/src/observability/no-tracer.mjs +0 -15
- package/dist/src/observability/no-tracer.mjs.map +0 -1
- package/dist/src/observability/redis-trace-stream-adapter.mjs +0 -76
- package/dist/src/observability/redis-trace-stream-adapter.mjs.map +0 -1
- package/dist/src/observability/stream-tracer.mjs +0 -87
- package/dist/src/observability/stream-tracer.mjs.map +0 -1
- package/dist/src/observability/trace-manager.mjs +0 -24
- package/dist/src/observability/trace-manager.mjs.map +0 -1
- package/dist/src/observability/tracer.mjs +0 -87
- package/dist/src/observability/tracer.mjs.map +0 -1
- package/dist/src/observability/types.d.mts +0 -14
- package/dist/src/observability/types.d.mts.map +0 -1
- package/dist/src/pretty-print.mjs +0 -50
- package/dist/src/pretty-print.mjs.map +0 -1
- package/dist/src/printer.d.mts +0 -65
- package/dist/src/printer.d.mts.map +0 -1
- package/dist/src/printer.mjs +0 -147
- package/dist/src/printer.mjs.map +0 -1
- package/dist/src/process-communication/communication-config.mjs +0 -26
- package/dist/src/process-communication/communication-config.mjs.map +0 -1
- package/dist/src/process-communication/process-manager.mjs +0 -67
- package/dist/src/process-communication/process-manager.mjs.map +0 -1
- package/dist/src/queue-manager.d.mts +0 -37
- package/dist/src/queue-manager.d.mts.map +0 -1
- package/dist/src/queue-manager.mjs +0 -209
- package/dist/src/queue-manager.mjs.map +0 -1
- package/dist/src/run-stream-can-access.mjs +0 -59
- package/dist/src/run-stream-can-access.mjs.map +0 -1
- package/dist/src/schema-utils.mjs +0 -30
- package/dist/src/schema-utils.mjs.map +0 -1
- package/dist/src/server.d.mts +0 -40
- package/dist/src/server.d.mts.map +0 -1
- package/dist/src/server.mjs +0 -352
- package/dist/src/server.mjs.map +0 -1
- package/dist/src/socket-server/helpers.mjs +0 -35
- package/dist/src/socket-server/helpers.mjs.map +0 -1
- package/dist/src/socket-server.mjs +0 -127
- package/dist/src/socket-server.mjs.map +0 -1
- package/dist/src/state/create-state-adapter.d.mts +0 -11
- package/dist/src/state/create-state-adapter.d.mts.map +0 -1
- package/dist/src/state/create-state-adapter.mjs +0 -11
- package/dist/src/state/create-state-adapter.mjs.map +0 -1
- package/dist/src/step-handler-rpc-processor.mjs +0 -56
- package/dist/src/step-handler-rpc-processor.mjs.map +0 -1
- package/dist/src/step-handler-rpc-stdin-processor.mjs +0 -71
- package/dist/src/step-handler-rpc-stdin-processor.mjs.map +0 -1
- package/dist/src/step-handlers.d.mts +0 -13
- package/dist/src/step-handlers.d.mts.map +0 -1
- package/dist/src/step-handlers.mjs +0 -93
- package/dist/src/step-handlers.mjs.map +0 -1
- package/dist/src/step-validator.d.mts +0 -15
- package/dist/src/step-validator.d.mts.map +0 -1
- package/dist/src/step-validator.mjs +0 -118
- package/dist/src/step-validator.mjs.map +0 -1
- package/dist/src/steps/emit.step.mjs +0 -20
- package/dist/src/steps/emit.step.mjs.map +0 -1
- package/dist/src/steps/index.mjs +0 -14
- package/dist/src/steps/index.mjs.map +0 -1
- package/dist/src/streams/flows-config-stream.mjs +0 -46
- package/dist/src/streams/flows-config-stream.mjs.map +0 -1
- package/dist/src/streams/flows-stream.mjs +0 -33
- package/dist/src/streams/flows-stream.mjs.map +0 -1
- package/dist/src/streams/redis-logs-stream.d.mts +0 -3
- package/dist/src/streams/redis-logs-stream.mjs +0 -97
- package/dist/src/streams/redis-logs-stream.mjs.map +0 -1
- package/dist/src/streams/stream-factory.d.mts +0 -7
- package/dist/src/streams/stream-factory.d.mts.map +0 -1
- package/dist/src/types/app-config-types.d.mts +0 -48
- package/dist/src/types/app-config-types.d.mts.map +0 -1
- package/dist/src/types/generate-type-from-schema.mjs +0 -30
- package/dist/src/types/generate-type-from-schema.mjs.map +0 -1
- package/dist/src/types/generate-types-from-response.mjs +0 -12
- package/dist/src/types/generate-types-from-response.mjs.map +0 -1
- package/dist/src/types/generate-types.mjs +0 -101
- package/dist/src/types/generate-types.mjs.map +0 -1
- package/dist/src/types/merge-schemas.mjs +0 -102
- package/dist/src/types/merge-schemas.mjs.map +0 -1
- package/dist/src/types/schema.types.d.mts +0 -13
- package/dist/src/types/schema.types.d.mts.map +0 -1
- package/dist/src/types/schema.types.mjs +0 -14
- package/dist/src/types/schema.types.mjs.map +0 -1
- package/dist/src/types-stream.d.mts +0 -46
- package/dist/src/types-stream.d.mts.map +0 -1
- package/dist/src/types.d.mts +0 -194
- package/dist/src/types.d.mts.map +0 -1
- package/dist/src/utils.mjs +0 -13
- package/dist/src/utils.mjs.map +0 -1
- package/dist/src/validate-event-input.mjs +0 -76
- package/dist/src/validate-event-input.mjs.map +0 -1
- package/jest.config.cjs +0 -20
- package/tsdown.config.ts +0 -53
package/dist/src/printer.d.mts
DELETED
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import { Stream } from "./types-stream.mjs";
|
|
2
|
-
import { ValidationError } from "./step-validator.mjs";
|
|
3
|
-
import { Step } from "./types.mjs";
|
|
4
|
-
|
|
5
|
-
//#region src/printer.d.ts
|
|
6
|
-
declare class Printer {
|
|
7
|
-
private readonly baseDir;
|
|
8
|
-
constructor(baseDir: string);
|
|
9
|
-
stepTag: string;
|
|
10
|
-
flowTag: string;
|
|
11
|
-
registered: string;
|
|
12
|
-
building: string;
|
|
13
|
-
built: string;
|
|
14
|
-
updated: string;
|
|
15
|
-
removed: string;
|
|
16
|
-
printEventInputValidationError(emit: {
|
|
17
|
-
topic: string;
|
|
18
|
-
}, details: {
|
|
19
|
-
missingFields?: string[];
|
|
20
|
-
extraFields?: string[];
|
|
21
|
-
typeMismatches?: string[];
|
|
22
|
-
}): void;
|
|
23
|
-
printInvalidEmit(step: Step, emit: string): void;
|
|
24
|
-
printStepCreated(step: Step): void;
|
|
25
|
-
printStepUpdated(step: Step): void;
|
|
26
|
-
printStepRemoved(step: Step): void;
|
|
27
|
-
printFlowCreated(flowName: string): void;
|
|
28
|
-
printFlowUpdated(flowName: string): void;
|
|
29
|
-
printFlowRemoved(flowName: string): void;
|
|
30
|
-
printStreamCreated(stream: Stream): void;
|
|
31
|
-
printStreamUpdated(stream: Stream): void;
|
|
32
|
-
printStreamRemoved(stream: Stream): void;
|
|
33
|
-
printInvalidEmitConfiguration(step: Step, emit: string): void;
|
|
34
|
-
printInvalidSchema(topic: string, step: Step[]): void;
|
|
35
|
-
printValidationError(stepPath: string, validationError: ValidationError): void;
|
|
36
|
-
getRelativePath(filePath: string): string;
|
|
37
|
-
getStepType(step: Step): string;
|
|
38
|
-
getStepPath(step: Step): string;
|
|
39
|
-
getStreamPath(stream: Stream): string;
|
|
40
|
-
printPluginLog(message: string): void;
|
|
41
|
-
printPluginWarn(message: string): void;
|
|
42
|
-
printPluginError(message: string, ...args: unknown[]): void;
|
|
43
|
-
}
|
|
44
|
-
declare class NoPrinter extends Printer {
|
|
45
|
-
constructor();
|
|
46
|
-
printEventInputValidationError(): void;
|
|
47
|
-
printInvalidEmit(): void;
|
|
48
|
-
printStepCreated(): void;
|
|
49
|
-
printStepUpdated(): void;
|
|
50
|
-
printStepRemoved(): void;
|
|
51
|
-
printFlowCreated(): void;
|
|
52
|
-
printFlowUpdated(): void;
|
|
53
|
-
printFlowRemoved(): void;
|
|
54
|
-
printStepType(): void;
|
|
55
|
-
printStepPath(): void;
|
|
56
|
-
printStreamCreated(): void;
|
|
57
|
-
printStreamUpdated(): void;
|
|
58
|
-
printStreamRemoved(): void;
|
|
59
|
-
printPluginLog(): void;
|
|
60
|
-
printPluginWarn(): void;
|
|
61
|
-
printPluginError(): void;
|
|
62
|
-
}
|
|
63
|
-
//#endregion
|
|
64
|
-
export { NoPrinter, Printer };
|
|
65
|
-
//# sourceMappingURL=printer.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"printer.d.mts","names":[],"sources":["../../src/printer.ts"],"sourcesContent":[],"mappings":";;;;;cAsBa,OAAA;;EAAA,WAAO,CAAA,OAAA,EAAA,MAAA;EA0CK,OAAA,EAAA,MAAA;EAMA,OAAA,EAAA,MAAA;EAIA,UAAA,EAAA,MAAA;EAIA,QAAA,EAAA,MAAA;EAgBI,KAAA,EAAA,MAAA;EAIA,OAAA,EAAA,MAAA;EAIA,OAAA,EAAA,MAAA;EAIS,8BAAA,CAAA,IAAA,EAAA;IAMI,KAAA,EAAA,MAAA;EAOgB,CAAA,EAAA,OAAA,EAAA;IAkBtC,aAAA,CAAA,EAAA,MAAA,EAAA;IASA,WAAA,CAAA,EAAA,MAAA,EAAA;IAKI,cAAA,CAAA,EAAA,MAAA,EAAA;EAAM,CAAA,CAAA,EAAA,IAAA;EAqBjB,gBAAU,CAAA,IAAA,EA5GE,IA4GM,EAAA,IAAO,EAAA,MAAA,CAAA,EAAA,IAAA;yBAtGb;yBAIA;yBAIA;;;;6BAgBI;6BAIA;6BAIA;sCAIS;0CAMI;0DAOgB;;oBAkBtC;oBASA;wBAKI;;;;;cAqBX,SAAA,SAAkB,OAAA"}
|
package/dist/src/printer.mjs
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { isApiStep, isCronStep, isEventStep, isNoopStep } from "./guards.mjs";
|
|
2
|
-
import pc from "picocolors";
|
|
3
|
-
import path from "path";
|
|
4
|
-
|
|
5
|
-
//#region src/printer.ts
|
|
6
|
-
const stepTag = pc.bold(pc.magenta("Step"));
|
|
7
|
-
const flowTag = pc.bold(pc.blue("Flow"));
|
|
8
|
-
const streamTag = pc.bold(pc.green("Stream"));
|
|
9
|
-
const registered = pc.green("➜ [REGISTERED]");
|
|
10
|
-
const building = pc.yellow("⚡ [BUILDING]");
|
|
11
|
-
const built = pc.green("✓ [BUILT]");
|
|
12
|
-
const updated = pc.yellow("➜ [UPDATED]");
|
|
13
|
-
const removed = pc.red("➜ [REMOVED]");
|
|
14
|
-
const invalidEmit = pc.red("➜ [INVALID EMIT]");
|
|
15
|
-
const error = pc.red("[ERROR]");
|
|
16
|
-
const warning = pc.yellow("[WARNING]");
|
|
17
|
-
const warnIcon = pc.yellow("⚠");
|
|
18
|
-
const infoIcon = pc.blue("ℹ");
|
|
19
|
-
const errorIcon = pc.red("✖");
|
|
20
|
-
var Printer = class {
|
|
21
|
-
constructor(baseDir) {
|
|
22
|
-
this.baseDir = baseDir;
|
|
23
|
-
this.stepTag = stepTag;
|
|
24
|
-
this.flowTag = flowTag;
|
|
25
|
-
this.registered = registered;
|
|
26
|
-
this.building = building;
|
|
27
|
-
this.built = built;
|
|
28
|
-
this.updated = updated;
|
|
29
|
-
this.removed = removed;
|
|
30
|
-
}
|
|
31
|
-
printEventInputValidationError(emit, details) {
|
|
32
|
-
const emitPath = pc.bold(pc.cyan(`Emit ${emit.topic}`));
|
|
33
|
-
console.log(`${warnIcon} ${warning} ${emitPath} validation issues:`);
|
|
34
|
-
if (!(details.missingFields?.length || details.extraFields?.length || details.typeMismatches?.length)) {
|
|
35
|
-
console.log(`${pc.yellow("│")} No issues found.`);
|
|
36
|
-
console.log(`${pc.yellow("└─")} Validation passed.`);
|
|
37
|
-
return;
|
|
38
|
-
}
|
|
39
|
-
if (details.missingFields?.length) console.log(`${pc.yellow("│")} ${pc.yellow(`⚠ Missing fields: ${details.missingFields.join(", ")}`)}`);
|
|
40
|
-
if (details.extraFields?.length) console.log(`${pc.yellow("│")} ${pc.yellow(`⚠ Extra fields: ${details.extraFields.join(", ")}`)}`);
|
|
41
|
-
if (details.typeMismatches?.length) console.log(`${pc.yellow("│")} ${pc.yellow(`⚠ Type mismatches: ${details.typeMismatches.join(", ")}`)}`);
|
|
42
|
-
console.log(`${pc.yellow("└─")} ${pc.yellow("Payload does not match schema.")}`);
|
|
43
|
-
}
|
|
44
|
-
printInvalidEmit(step, emit) {
|
|
45
|
-
console.log(`${invalidEmit} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} tried to emit an event not defined in the step config: ${pc.yellow(emit)}`);
|
|
46
|
-
}
|
|
47
|
-
printStepCreated(step) {
|
|
48
|
-
console.log(`${registered} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} registered`);
|
|
49
|
-
}
|
|
50
|
-
printStepUpdated(step) {
|
|
51
|
-
console.log(`${updated} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} updated`);
|
|
52
|
-
}
|
|
53
|
-
printStepRemoved(step) {
|
|
54
|
-
console.log(`${removed} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} removed`);
|
|
55
|
-
}
|
|
56
|
-
printFlowCreated(flowName) {
|
|
57
|
-
console.log(`${registered} ${flowTag} ${pc.bold(pc.cyan(flowName))} registered`);
|
|
58
|
-
}
|
|
59
|
-
printFlowUpdated(flowName) {
|
|
60
|
-
console.log(`${updated} ${flowTag} ${pc.bold(pc.cyan(flowName))} updated`);
|
|
61
|
-
}
|
|
62
|
-
printFlowRemoved(flowName) {
|
|
63
|
-
console.log(`${removed} ${flowTag} ${pc.bold(pc.cyan(flowName))} removed`);
|
|
64
|
-
}
|
|
65
|
-
printStreamCreated(stream) {
|
|
66
|
-
console.log(`${registered} ${streamTag} ${this.getStreamPath(stream)} registered`);
|
|
67
|
-
}
|
|
68
|
-
printStreamUpdated(stream) {
|
|
69
|
-
console.log(`${updated} ${streamTag} ${this.getStreamPath(stream)} updated`);
|
|
70
|
-
}
|
|
71
|
-
printStreamRemoved(stream) {
|
|
72
|
-
console.log(`${removed} ${streamTag} ${this.getStreamPath(stream)} removed`);
|
|
73
|
-
}
|
|
74
|
-
printInvalidEmitConfiguration(step, emit) {
|
|
75
|
-
console.log(`${warnIcon} ${warning} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} emits to ${pc.yellow(emit)}, but there is no subscriber defined`);
|
|
76
|
-
}
|
|
77
|
-
printInvalidSchema(topic, step) {
|
|
78
|
-
console.log(`${error} Topic ${pc.bold(pc.blue(topic))} has incompatible schemas in the following steps:`);
|
|
79
|
-
step.forEach((step$1) => {
|
|
80
|
-
console.log(`${pc.red(" ✖")} ${this.getStepPath(step$1)}`);
|
|
81
|
-
});
|
|
82
|
-
}
|
|
83
|
-
printValidationError(stepPath, validationError) {
|
|
84
|
-
const relativePath = this.getRelativePath(stepPath);
|
|
85
|
-
console.log(`${error} ${pc.bold(pc.cyan(relativePath))}`);
|
|
86
|
-
validationError.errors?.forEach((error$1) => {
|
|
87
|
-
if (error$1.path) console.log(`${pc.red("│")} ${pc.yellow(`✖ ${error$1.path}`)}: ${error$1.message}`);
|
|
88
|
-
else console.log(`${pc.red("│")} ${pc.yellow("✖")} ${error$1.message}`);
|
|
89
|
-
});
|
|
90
|
-
console.log(`${pc.red("└─")} ${pc.red(validationError.error)} `);
|
|
91
|
-
}
|
|
92
|
-
getRelativePath(filePath) {
|
|
93
|
-
return path.relative(this.baseDir, filePath);
|
|
94
|
-
}
|
|
95
|
-
getStepType(step) {
|
|
96
|
-
if (isApiStep(step)) return pc.gray("(API)");
|
|
97
|
-
if (isEventStep(step)) return pc.gray("(Event)");
|
|
98
|
-
if (isCronStep(step)) return pc.gray("(Cron)");
|
|
99
|
-
if (isNoopStep(step)) return pc.gray("(Noop)");
|
|
100
|
-
return pc.gray("(Unknown)");
|
|
101
|
-
}
|
|
102
|
-
getStepPath(step) {
|
|
103
|
-
const stepPath = this.getRelativePath(step.filePath);
|
|
104
|
-
return pc.bold(pc.cyan(stepPath));
|
|
105
|
-
}
|
|
106
|
-
getStreamPath(stream) {
|
|
107
|
-
const streamPath = this.getRelativePath(stream.filePath);
|
|
108
|
-
return pc.bold(pc.magenta(streamPath));
|
|
109
|
-
}
|
|
110
|
-
printPluginLog(message) {
|
|
111
|
-
const pluginTag = pc.bold(pc.cyan("[motia-plugins]"));
|
|
112
|
-
console.log(`${infoIcon} ${pluginTag} ${message}`);
|
|
113
|
-
}
|
|
114
|
-
printPluginWarn(message) {
|
|
115
|
-
const pluginTag = pc.bold(pc.cyan("[motia-plugins]"));
|
|
116
|
-
console.warn(`${warnIcon} ${pluginTag} ${pc.yellow(message)}`);
|
|
117
|
-
}
|
|
118
|
-
printPluginError(message, ...args) {
|
|
119
|
-
const pluginTag = pc.bold(pc.cyan("[motia-plugins]"));
|
|
120
|
-
console.error(`${errorIcon} ${pluginTag} ${pc.red(message)}`, ...args);
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
var NoPrinter = class extends Printer {
|
|
124
|
-
constructor() {
|
|
125
|
-
super("");
|
|
126
|
-
}
|
|
127
|
-
printEventInputValidationError() {}
|
|
128
|
-
printInvalidEmit() {}
|
|
129
|
-
printStepCreated() {}
|
|
130
|
-
printStepUpdated() {}
|
|
131
|
-
printStepRemoved() {}
|
|
132
|
-
printFlowCreated() {}
|
|
133
|
-
printFlowUpdated() {}
|
|
134
|
-
printFlowRemoved() {}
|
|
135
|
-
printStepType() {}
|
|
136
|
-
printStepPath() {}
|
|
137
|
-
printStreamCreated() {}
|
|
138
|
-
printStreamUpdated() {}
|
|
139
|
-
printStreamRemoved() {}
|
|
140
|
-
printPluginLog() {}
|
|
141
|
-
printPluginWarn() {}
|
|
142
|
-
printPluginError() {}
|
|
143
|
-
};
|
|
144
|
-
|
|
145
|
-
//#endregion
|
|
146
|
-
export { NoPrinter, Printer };
|
|
147
|
-
//# sourceMappingURL=printer.mjs.map
|
package/dist/src/printer.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"printer.mjs","names":["baseDir: string","step","error"],"sources":["../../src/printer.ts"],"sourcesContent":["import path from 'path'\nimport pc from 'picocolors'\nimport { isApiStep, isCronStep, isEventStep, isNoopStep } from './guards'\nimport type { ValidationError } from './step-validator'\nimport type { Step } from './types'\nimport type { Stream } from './types-stream'\n\nconst stepTag = pc.bold(pc.magenta('Step'))\nconst flowTag = pc.bold(pc.blue('Flow'))\nconst streamTag = pc.bold(pc.green('Stream'))\nconst registered = pc.green('➜ [REGISTERED]')\nconst building = pc.yellow('⚡ [BUILDING]')\nconst built = pc.green('✓ [BUILT]')\nconst updated = pc.yellow('➜ [UPDATED]')\nconst removed = pc.red('➜ [REMOVED]')\nconst invalidEmit = pc.red('➜ [INVALID EMIT]')\nconst error = pc.red('[ERROR]')\nconst warning = pc.yellow('[WARNING]')\nconst warnIcon = pc.yellow('⚠')\nconst infoIcon = pc.blue('ℹ')\nconst errorIcon = pc.red('✖')\n\nexport class Printer {\n constructor(private readonly baseDir: string) {}\n\n stepTag = stepTag\n flowTag = flowTag\n registered = registered\n building = building\n built = built\n updated = updated\n removed = removed\n\n printEventInputValidationError(\n emit: { topic: string },\n details: { missingFields?: string[]; extraFields?: string[]; typeMismatches?: string[] },\n ) {\n const emitPath = pc.bold(pc.cyan(`Emit ${emit.topic}`))\n\n console.log(`${warnIcon} ${warning} ${emitPath} validation issues:`)\n\n const hasAny = details.missingFields?.length || details.extraFields?.length || details.typeMismatches?.length\n\n if (!hasAny) {\n console.log(`${pc.yellow('│')} No issues found.`)\n console.log(`${pc.yellow('└─')} Validation passed.`)\n return\n }\n\n if (details.missingFields?.length) {\n console.log(`${pc.yellow('│')} ${pc.yellow(`⚠ Missing fields: ${details.missingFields.join(', ')}`)}`)\n }\n\n if (details.extraFields?.length) {\n console.log(`${pc.yellow('│')} ${pc.yellow(`⚠ Extra fields: ${details.extraFields.join(', ')}`)}`)\n }\n\n if (details.typeMismatches?.length) {\n console.log(`${pc.yellow('│')} ${pc.yellow(`⚠ Type mismatches: ${details.typeMismatches.join(', ')}`)}`)\n }\n\n console.log(`${pc.yellow('└─')} ${pc.yellow('Payload does not match schema.')}`)\n }\n\n printInvalidEmit(step: Step, emit: string) {\n console.log(\n `${invalidEmit} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} tried to emit an event not defined in the step config: ${pc.yellow(emit)}`,\n )\n }\n\n printStepCreated(step: Step) {\n console.log(`${registered} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} registered`)\n }\n\n printStepUpdated(step: Step) {\n console.log(`${updated} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} updated`)\n }\n\n printStepRemoved(step: Step) {\n console.log(`${removed} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} removed`)\n }\n\n printFlowCreated(flowName: string) {\n console.log(`${registered} ${flowTag} ${pc.bold(pc.cyan(flowName))} registered`)\n }\n\n printFlowUpdated(flowName: string) {\n console.log(`${updated} ${flowTag} ${pc.bold(pc.cyan(flowName))} updated`)\n }\n\n printFlowRemoved(flowName: string) {\n console.log(`${removed} ${flowTag} ${pc.bold(pc.cyan(flowName))} removed`)\n }\n\n printStreamCreated(stream: Stream) {\n console.log(`${registered} ${streamTag} ${this.getStreamPath(stream)} registered`)\n }\n\n printStreamUpdated(stream: Stream) {\n console.log(`${updated} ${streamTag} ${this.getStreamPath(stream)} updated`)\n }\n\n printStreamRemoved(stream: Stream) {\n console.log(`${removed} ${streamTag} ${this.getStreamPath(stream)} removed`)\n }\n\n printInvalidEmitConfiguration(step: Step, emit: string) {\n console.log(\n `${warnIcon} ${warning} ${stepTag} ${this.getStepType(step)} ${this.getStepPath(step)} emits to ${pc.yellow(emit)}, but there is no subscriber defined`,\n )\n }\n\n printInvalidSchema(topic: string, step: Step[]) {\n console.log(`${error} Topic ${pc.bold(pc.blue(topic))} has incompatible schemas in the following steps:`)\n step.forEach((step) => {\n console.log(`${pc.red(' ✖')} ${this.getStepPath(step)}`)\n })\n }\n\n printValidationError(stepPath: string, validationError: ValidationError) {\n const relativePath = this.getRelativePath(stepPath)\n\n console.log(`${error} ${pc.bold(pc.cyan(relativePath))}`)\n validationError.errors?.forEach((error) => {\n if (error.path) {\n console.log(`${pc.red('│')} ${pc.yellow(`✖ ${error.path}`)}: ${error.message}`)\n } else {\n console.log(`${pc.red('│')} ${pc.yellow('✖')} ${error.message}`)\n }\n })\n console.log(`${pc.red('└─')} ${pc.red(validationError.error)} `)\n }\n\n getRelativePath(filePath: string) {\n return path.relative(this.baseDir, filePath)\n }\n\n getStepType(step: Step) {\n if (isApiStep(step)) return pc.gray('(API)')\n if (isEventStep(step)) return pc.gray('(Event)')\n if (isCronStep(step)) return pc.gray('(Cron)')\n if (isNoopStep(step)) return pc.gray('(Noop)')\n\n return pc.gray('(Unknown)')\n }\n\n getStepPath(step: Step) {\n const stepPath = this.getRelativePath(step.filePath)\n return pc.bold(pc.cyan(stepPath))\n }\n\n getStreamPath(stream: Stream) {\n const streamPath = this.getRelativePath(stream.filePath)\n return pc.bold(pc.magenta(streamPath))\n }\n\n printPluginLog(message: string) {\n const pluginTag = pc.bold(pc.cyan('[motia-plugins]'))\n console.log(`${infoIcon} ${pluginTag} ${message}`)\n }\n\n printPluginWarn(message: string) {\n const pluginTag = pc.bold(pc.cyan('[motia-plugins]'))\n console.warn(`${warnIcon} ${pluginTag} ${pc.yellow(message)}`)\n }\n\n printPluginError(message: string, ...args: unknown[]) {\n const pluginTag = pc.bold(pc.cyan('[motia-plugins]'))\n console.error(`${errorIcon} ${pluginTag} ${pc.red(message)}`, ...args)\n }\n}\n\nexport class NoPrinter extends Printer {\n constructor() {\n super('')\n }\n\n printEventInputValidationError() {}\n\n printInvalidEmit() {}\n printStepCreated() {}\n printStepUpdated() {}\n printStepRemoved() {}\n printFlowCreated() {}\n printFlowUpdated() {}\n printFlowRemoved() {}\n printStepType() {}\n printStepPath() {}\n\n printStreamCreated() {}\n printStreamUpdated() {}\n printStreamRemoved() {}\n\n printPluginLog() {}\n printPluginWarn() {}\n printPluginError() {}\n}\n"],"mappings":";;;;;AAOA,MAAM,UAAU,GAAG,KAAK,GAAG,QAAQ,OAAO,CAAC;AAC3C,MAAM,UAAU,GAAG,KAAK,GAAG,KAAK,OAAO,CAAC;AACxC,MAAM,YAAY,GAAG,KAAK,GAAG,MAAM,SAAS,CAAC;AAC7C,MAAM,aAAa,GAAG,MAAM,iBAAiB;AAC7C,MAAM,WAAW,GAAG,OAAO,eAAe;AAC1C,MAAM,QAAQ,GAAG,MAAM,YAAY;AACnC,MAAM,UAAU,GAAG,OAAO,cAAc;AACxC,MAAM,UAAU,GAAG,IAAI,cAAc;AACrC,MAAM,cAAc,GAAG,IAAI,mBAAmB;AAC9C,MAAM,QAAQ,GAAG,IAAI,UAAU;AAC/B,MAAM,UAAU,GAAG,OAAO,YAAY;AACtC,MAA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C;;CAGnC,cAAc,QAAgB;EAC5B,MAAM,aAAa,KAAK,gBAAgB,OAAO,SAAS;AACxD,SAAO,GAAG,KAAK,GAAG,QAAQ,WAAW,CAAC;;CAGxC,eAAe,SAAiB;EAC9B,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,kBAAkB,CAAC;AACrD,UAAQ,IAAI,GAAG,SAAS,GAAG,UAAU,GAAG,UAAU;;CAGpD,gBAAgB,SAAiB;EAC/B,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,kBAAkB,CAAC;AACrD,UAAQ,KAAK,GAAG,SAAS,GAAG,UAAU,GAAG,GAAG,OAAO,QAAQ,GAAG;;CAGhE,iBAAiB,SAAiB,GAAG,MAAiB;EACpD,MAAM,YAAY,GAAG,KAAK,GAAG,KAAK,kBAAkB,CAAC;AACrD,UAAQ,MAAM,GAAG,UAAU,GAAG,UAAU,GAAG,GAAG,IAAI,QAAQ,IAAI,GAAG,KAAK;;;AAI1E,IAAa,YAAb,cAA+B,QAAQ;CACrC,cAAc;AACZ,QAAM,GAAG;;CAGX,iCAAiC;CAEjC,mBAAmB;CACnB,mBAAmB;CACnB,mBAAmB;CACnB,mBAAmB;CACnB,mBAAmB;CACnB,mBAAmB;CACnB,mBAAmB;CACnB,gBAAgB;CAChB,gBAAgB;CAEhB,qBAAqB;CACrB,qBAAqB;CACrB,qBAAqB;CAErB,iBAAiB;CACjB,kBAAkB;CAClB,mBAAmB"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
//#region src/process-communication/communication-config.ts
|
|
2
|
-
function createCommunicationConfig(command, projectRoot) {
|
|
3
|
-
const type = command === "python" && process.platform === "win32" ? "rpc" : "ipc";
|
|
4
|
-
const spawnOptions = { stdio: type === "rpc" ? [
|
|
5
|
-
"pipe",
|
|
6
|
-
"pipe",
|
|
7
|
-
"inherit"
|
|
8
|
-
] : [
|
|
9
|
-
"inherit",
|
|
10
|
-
"inherit",
|
|
11
|
-
"inherit",
|
|
12
|
-
"ipc"
|
|
13
|
-
] };
|
|
14
|
-
if (command === "python") spawnOptions.env = {
|
|
15
|
-
...process.env,
|
|
16
|
-
PYTHONPATH: projectRoot || process.cwd()
|
|
17
|
-
};
|
|
18
|
-
return {
|
|
19
|
-
type,
|
|
20
|
-
spawnOptions
|
|
21
|
-
};
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
//#endregion
|
|
25
|
-
export { createCommunicationConfig };
|
|
26
|
-
//# sourceMappingURL=communication-config.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"communication-config.mjs","names":["spawnOptions: SpawnOptions"],"sources":["../../../src/process-communication/communication-config.ts"],"sourcesContent":["import type { SpawnOptions } from 'child_process'\n\nexport type CommunicationType = 'rpc' | 'ipc'\n\nexport interface CommunicationConfig {\n type: CommunicationType\n spawnOptions: SpawnOptions\n}\n\nexport function createCommunicationConfig(command: string, projectRoot?: string): CommunicationConfig {\n const type = command === 'python' && process.platform === 'win32' ? 'rpc' : 'ipc'\n\n const spawnOptions: SpawnOptions = {\n stdio:\n type === 'rpc'\n ? ['pipe', 'pipe', 'inherit'] // RPC: capture stdout\n : ['inherit', 'inherit', 'inherit', 'ipc'], // IPC: include IPC channel\n }\n\n if (command === 'python') {\n spawnOptions.env = {\n ...process.env,\n PYTHONPATH: projectRoot || process.cwd(),\n }\n }\n\n return { type, spawnOptions }\n}\n"],"mappings":";AASA,SAAgB,0BAA0B,SAAiB,aAA2C;CACpG,MAAM,OAAO,YAAY,YAAY,QAAQ,aAAa,UAAU,QAAQ;CAE5E,MAAMA,eAA6B,EACjC,OACE,SAAS,QACL;EAAC;EAAQ;EAAQ;EAAU,GAC3B;EAAC;EAAW;EAAW;EAAW;EAAM,EAC/C;AAED,KAAI,YAAY,SACd,cAAa,MAAM;EACjB,GAAG,QAAQ;EACX,YAAY,eAAe,QAAQ,KAAK;EACzC;AAGH,QAAO;EAAE;EAAM;EAAc"}
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import { RpcProcessor } from "../step-handler-rpc-processor.mjs";
|
|
2
|
-
import { RpcStdinProcessor } from "../step-handler-rpc-stdin-processor.mjs";
|
|
3
|
-
import { createCommunicationConfig } from "./communication-config.mjs";
|
|
4
|
-
import { spawn } from "child_process";
|
|
5
|
-
|
|
6
|
-
//#region src/process-communication/process-manager.ts
|
|
7
|
-
var ProcessManager = class {
|
|
8
|
-
constructor(options) {
|
|
9
|
-
this.options = options;
|
|
10
|
-
}
|
|
11
|
-
async spawn() {
|
|
12
|
-
const { command, args, logger, context = "Process", projectRoot } = this.options;
|
|
13
|
-
const commConfig = createCommunicationConfig(command, projectRoot);
|
|
14
|
-
this.communicationType = commConfig.type;
|
|
15
|
-
logger.debug(`[${context}] Spawning process`, {
|
|
16
|
-
command,
|
|
17
|
-
args,
|
|
18
|
-
communicationType: this.communicationType
|
|
19
|
-
});
|
|
20
|
-
this.child = spawn(command, args, commConfig.spawnOptions);
|
|
21
|
-
this.processor = this.communicationType === "rpc" ? new RpcStdinProcessor(this.child) : new RpcProcessor(this.child);
|
|
22
|
-
await this.processor.init();
|
|
23
|
-
return this.child;
|
|
24
|
-
}
|
|
25
|
-
handler(method, handler) {
|
|
26
|
-
if (!this.processor) throw new Error("Process not spawned yet. Call spawn() first.");
|
|
27
|
-
this.processor.handler(method, handler);
|
|
28
|
-
}
|
|
29
|
-
onMessage(callback) {
|
|
30
|
-
if (!this.processor) throw new Error("Process not spawned yet. Call spawn() first.");
|
|
31
|
-
this.processor.onMessage(callback);
|
|
32
|
-
}
|
|
33
|
-
onProcessClose(callback) {
|
|
34
|
-
if (!this.child) throw new Error("Process not spawned yet. Call spawn() first.");
|
|
35
|
-
this.child.on("close", callback);
|
|
36
|
-
}
|
|
37
|
-
onProcessError(callback) {
|
|
38
|
-
if (!this.child) throw new Error("Process not spawned yet. Call spawn() first.");
|
|
39
|
-
this.child.on("error", callback);
|
|
40
|
-
}
|
|
41
|
-
onStderr(callback) {
|
|
42
|
-
if (!this.child) throw new Error("Process not spawned yet. Call spawn() first.");
|
|
43
|
-
this.child.stderr?.on("data", callback);
|
|
44
|
-
}
|
|
45
|
-
onStdout(callback) {
|
|
46
|
-
if (!this.child) throw new Error("Process not spawned yet. Call spawn() first.");
|
|
47
|
-
if (this.communicationType !== "rpc") this.child.stdout?.on("data", callback);
|
|
48
|
-
}
|
|
49
|
-
kill() {
|
|
50
|
-
if (this.child) this.child.kill("SIGKILL");
|
|
51
|
-
}
|
|
52
|
-
close() {
|
|
53
|
-
if (this.processor) this.processor.close();
|
|
54
|
-
this.processor = void 0;
|
|
55
|
-
this.child = void 0;
|
|
56
|
-
}
|
|
57
|
-
get process() {
|
|
58
|
-
return this.child;
|
|
59
|
-
}
|
|
60
|
-
get commType() {
|
|
61
|
-
return this.communicationType;
|
|
62
|
-
}
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
//#endregion
|
|
66
|
-
export { ProcessManager };
|
|
67
|
-
//# sourceMappingURL=process-manager.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"process-manager.mjs","names":["options: ProcessManagerOptions"],"sources":["../../../src/process-communication/process-manager.ts"],"sourcesContent":["import { type ChildProcess, spawn } from 'child_process'\nimport type { Logger } from '../logger'\nimport { RpcProcessor } from '../step-handler-rpc-processor'\nimport { RpcStdinProcessor } from '../step-handler-rpc-stdin-processor'\nimport { type CommunicationType, createCommunicationConfig } from './communication-config'\nimport type { MessageCallback, RpcHandler, RpcProcessorInterface } from './rpc-processor-interface'\n\nexport interface ProcessManagerOptions {\n command: string\n args: string[]\n logger: Logger\n context?: string\n projectRoot?: string\n}\n\nexport class ProcessManager {\n private child?: ChildProcess\n private processor?: RpcProcessorInterface\n private communicationType?: CommunicationType\n\n constructor(private options: ProcessManagerOptions) {}\n\n async spawn(): Promise<ChildProcess> {\n const { command, args, logger, context = 'Process', projectRoot } = this.options\n\n // Get communication configuration\n const commConfig = createCommunicationConfig(command, projectRoot)\n this.communicationType = commConfig.type\n\n logger.debug(`[${context}] Spawning process`, {\n command,\n args,\n communicationType: this.communicationType,\n })\n\n // Spawn the process\n this.child = spawn(command, args, commConfig.spawnOptions)\n\n // Create appropriate processor based on communication type\n this.processor = this.communicationType === 'rpc' ? new RpcStdinProcessor(this.child) : new RpcProcessor(this.child)\n\n // Initialize the processor\n await this.processor.init()\n\n return this.child\n }\n\n handler<TInput, TOutput = unknown>(method: string, handler: RpcHandler<TInput, TOutput>): void {\n if (!this.processor) {\n throw new Error('Process not spawned yet. Call spawn() first.')\n }\n this.processor.handler(method, handler)\n }\n\n onMessage<T = unknown>(callback: MessageCallback<T>): void {\n if (!this.processor) {\n throw new Error('Process not spawned yet. Call spawn() first.')\n }\n this.processor.onMessage(callback)\n }\n\n onProcessClose(callback: (code: number | null) => void): void {\n if (!this.child) {\n throw new Error('Process not spawned yet. Call spawn() first.')\n }\n this.child.on('close', callback)\n }\n\n onProcessError(callback: (error: Error & { code?: string }) => void): void {\n if (!this.child) {\n throw new Error('Process not spawned yet. Call spawn() first.')\n }\n this.child.on('error', callback)\n }\n\n onStderr(callback: (data: Buffer) => void): void {\n if (!this.child) {\n throw new Error('Process not spawned yet. Call spawn() first.')\n }\n this.child.stderr?.on('data', callback)\n }\n\n onStdout(callback: (data: Buffer) => void): void {\n if (!this.child) {\n throw new Error('Process not spawned yet. Call spawn() first.')\n }\n // Only for non-RPC mode (in RPC mode, stdout is used for communication)\n if (this.communicationType !== 'rpc') {\n this.child.stdout?.on('data', callback)\n }\n }\n\n kill(): void {\n if (this.child) {\n this.child.kill('SIGKILL')\n }\n }\n\n close(): void {\n if (this.processor) {\n this.processor.close()\n }\n this.processor = undefined\n this.child = undefined\n }\n\n get process(): ChildProcess | undefined {\n return this.child\n }\n\n get commType(): CommunicationType | undefined {\n return this.communicationType\n }\n}\n"],"mappings":";;;;;;AAeA,IAAa,iBAAb,MAA4B;CAK1B,YAAY,AAAQA,SAAgC;EAAhC;;CAEpB,MAAM,QAA+B;EACnC,MAAM,EAAE,S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AAK,UAAU,OAAO;AAExB,OAAK,YAAY;AACjB,OAAK,QAAQ;;CAGf,IAAI,UAAoC;AACtC,SAAO,KAAK;;CAGd,IAAI,WAA0C;AAC5C,SAAO,KAAK"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import { Logger } from "./logger.mjs";
|
|
2
|
-
import { Event, Handler, QueueConfig } from "./types.mjs";
|
|
3
|
-
|
|
4
|
-
//#region src/queue-manager.d.ts
|
|
5
|
-
|
|
6
|
-
type QueueMetrics = {
|
|
7
|
-
queueDepth: number;
|
|
8
|
-
processingCount: number;
|
|
9
|
-
retriesCount: number;
|
|
10
|
-
dlqCount: number;
|
|
11
|
-
};
|
|
12
|
-
declare class QueueManager {
|
|
13
|
-
private logger;
|
|
14
|
-
private queues;
|
|
15
|
-
private subscriptions;
|
|
16
|
-
private lockedGroups;
|
|
17
|
-
private queueEmitter;
|
|
18
|
-
private scheduledTimeouts;
|
|
19
|
-
private metrics;
|
|
20
|
-
private processingMessages;
|
|
21
|
-
constructor(logger?: Logger);
|
|
22
|
-
private initMetrics;
|
|
23
|
-
private updateMetric;
|
|
24
|
-
private processQueue;
|
|
25
|
-
private processMessage;
|
|
26
|
-
private removeMessageFromQueue;
|
|
27
|
-
private scheduleProcessing;
|
|
28
|
-
enqueue<TData>(topic: string, event: Event<TData>, messageGroupId?: string): Promise<void>;
|
|
29
|
-
subscribe(topic: string, handler: Handler, queueConfig: QueueConfig, subscriptionId: string): void;
|
|
30
|
-
unsubscribe(topic: string, handler: Handler): void;
|
|
31
|
-
getMetrics(topic: string): QueueMetrics | undefined;
|
|
32
|
-
getAllMetrics(): Record<string, QueueMetrics>;
|
|
33
|
-
reset(): void;
|
|
34
|
-
}
|
|
35
|
-
//#endregion
|
|
36
|
-
export { QueueManager, QueueMetrics };
|
|
37
|
-
//# sourceMappingURL=queue-manager.d.mts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue-manager.d.mts","names":[],"sources":["../../src/queue-manager.ts"],"sourcesContent":[],"mappings":";;;;;AAmRsC,KApO1B,YAAA,GAoO0B;EAoBT,UAAA,EAAA,MAAA;EAIK,eAAA,EAAA,MAAA;EAAf,YAAA,EAAA,MAAA;EAAM,QAAA,EAAA,MAAA;;cArPZ,YAAA;;;;;;;;;uBAUU;;;;;;;uCAyJsB,MAAM,kCAAkC;oCAmCjD,sBAAsB;sCAuBpB;6BAoBT;mBAIV,eAAe"}
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { globalLogger } from "./logger.mjs";
|
|
2
|
-
import { randomUUID } from "crypto";
|
|
3
|
-
import { EventEmitter } from "events";
|
|
4
|
-
|
|
5
|
-
//#region src/queue-manager.ts
|
|
6
|
-
var QueueError = class extends Error {
|
|
7
|
-
constructor(message) {
|
|
8
|
-
super(message);
|
|
9
|
-
this.name = "QueueError";
|
|
10
|
-
}
|
|
11
|
-
};
|
|
12
|
-
var MaxRetriesError = class extends QueueError {
|
|
13
|
-
constructor(message, attempts) {
|
|
14
|
-
super(message);
|
|
15
|
-
this.attempts = attempts;
|
|
16
|
-
this.name = "MaxRetriesError";
|
|
17
|
-
}
|
|
18
|
-
};
|
|
19
|
-
var QueueManager = class {
|
|
20
|
-
constructor(logger) {
|
|
21
|
-
this.queues = {};
|
|
22
|
-
this.subscriptions = {};
|
|
23
|
-
this.lockedGroups = /* @__PURE__ */ new Set();
|
|
24
|
-
this.queueEmitter = new EventEmitter();
|
|
25
|
-
this.scheduledTimeouts = /* @__PURE__ */ new Map();
|
|
26
|
-
this.metrics = /* @__PURE__ */ new Map();
|
|
27
|
-
this.processingMessages = /* @__PURE__ */ new Set();
|
|
28
|
-
this.logger = logger || globalLogger;
|
|
29
|
-
this.queueEmitter.on("process", (topic) => {
|
|
30
|
-
this.processQueue(topic);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
initMetrics(topic) {
|
|
34
|
-
if (!this.metrics.has(topic)) this.metrics.set(topic, {
|
|
35
|
-
queueDepth: 0,
|
|
36
|
-
processingCount: 0,
|
|
37
|
-
retriesCount: 0,
|
|
38
|
-
dlqCount: 0
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
updateMetric(topic, key, delta) {
|
|
42
|
-
this.initMetrics(topic);
|
|
43
|
-
const metrics = this.metrics.get(topic);
|
|
44
|
-
metrics[key] = Math.max(0, metrics[key] + delta);
|
|
45
|
-
}
|
|
46
|
-
processQueue(topic) {
|
|
47
|
-
const queue = this.queues[topic];
|
|
48
|
-
if (!queue || queue.length === 0) return;
|
|
49
|
-
const now = Date.now();
|
|
50
|
-
const visibleMessages = queue.filter((msg) => msg.visibleAt <= now && !this.processingMessages.has(msg.id));
|
|
51
|
-
for (const message of visibleMessages) if (message.queueConfig.type === "fifo" && message.messageGroupId) {
|
|
52
|
-
const lockKey = `${topic}:${message.messageGroupId}`;
|
|
53
|
-
if (this.lockedGroups.has(lockKey)) continue;
|
|
54
|
-
this.processingMessages.add(message.id);
|
|
55
|
-
this.lockedGroups.add(lockKey);
|
|
56
|
-
this.processMessage(topic, message, lockKey);
|
|
57
|
-
} else {
|
|
58
|
-
this.processingMessages.add(message.id);
|
|
59
|
-
this.processMessage(topic, message);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
async processMessage(topic, message, lockKey) {
|
|
63
|
-
const handlers = this.subscriptions[topic] || [];
|
|
64
|
-
const handler = handlers.find((s) => s.internalSubscriptionId === message.internalSubscriptionId) || handlers.find((s) => s.subscriptionId === message.subscriptionId) || handlers[0];
|
|
65
|
-
if (!handler) {
|
|
66
|
-
this.processingMessages.delete(message.id);
|
|
67
|
-
this.removeMessageFromQueue(topic, message.id);
|
|
68
|
-
if (lockKey) this.lockedGroups.delete(lockKey);
|
|
69
|
-
return;
|
|
70
|
-
}
|
|
71
|
-
if (message.internalSubscriptionId !== handler.internalSubscriptionId && message.attempts > 0) {
|
|
72
|
-
message.attempts = 0;
|
|
73
|
-
message.internalSubscriptionId = handler.internalSubscriptionId;
|
|
74
|
-
message.subscriptionId = handler.subscriptionId;
|
|
75
|
-
message.visibleAt = Date.now();
|
|
76
|
-
}
|
|
77
|
-
this.updateMetric(topic, "processingCount", 1);
|
|
78
|
-
try {
|
|
79
|
-
await handler.handler(message.event);
|
|
80
|
-
this.updateMetric(topic, "processingCount", -1);
|
|
81
|
-
this.processingMessages.delete(message.id);
|
|
82
|
-
this.removeMessageFromQueue(topic, message.id);
|
|
83
|
-
if (lockKey) this.lockedGroups.delete(lockKey);
|
|
84
|
-
this.scheduleProcessing(topic, 0);
|
|
85
|
-
} catch (error) {
|
|
86
|
-
this.updateMetric(topic, "processingCount", -1);
|
|
87
|
-
this.processingMessages.delete(message.id);
|
|
88
|
-
message.attempts++;
|
|
89
|
-
if (message.attempts >= handler.queueConfig.maxRetries) {
|
|
90
|
-
const maxRetriesError = new MaxRetriesError(`Message failed after ${message.attempts} attempts`, message.attempts);
|
|
91
|
-
this.logger.error("[Queue DLQ] Message moved to dead-letter queue after max retries", {
|
|
92
|
-
topic,
|
|
93
|
-
messageId: message.id,
|
|
94
|
-
attempts: message.attempts,
|
|
95
|
-
originalError: error instanceof Error ? error.message : "Unknown error",
|
|
96
|
-
error: maxRetriesError.message
|
|
97
|
-
});
|
|
98
|
-
this.updateMetric(topic, "dlqCount", 1);
|
|
99
|
-
this.removeMessageFromQueue(topic, message.id);
|
|
100
|
-
if (lockKey) this.lockedGroups.delete(lockKey);
|
|
101
|
-
this.scheduleProcessing(topic, 0);
|
|
102
|
-
} else {
|
|
103
|
-
this.updateMetric(topic, "retriesCount", 1);
|
|
104
|
-
message.visibleAt = Date.now() + handler.queueConfig.visibilityTimeout * 1e3;
|
|
105
|
-
if (lockKey) this.lockedGroups.delete(lockKey);
|
|
106
|
-
this.scheduleProcessing(topic, handler.queueConfig.visibilityTimeout * 1e3);
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
removeMessageFromQueue(topic, messageId) {
|
|
111
|
-
const queue = this.queues[topic];
|
|
112
|
-
if (!queue) return;
|
|
113
|
-
const index = queue.findIndex((msg) => msg.id === messageId);
|
|
114
|
-
if (index !== -1) {
|
|
115
|
-
queue.splice(index, 1);
|
|
116
|
-
this.updateMetric(topic, "queueDepth", -1);
|
|
117
|
-
}
|
|
118
|
-
if (queue.length === 0) delete this.queues[topic];
|
|
119
|
-
}
|
|
120
|
-
scheduleProcessing(topic, delayMs) {
|
|
121
|
-
const existingTimeout = this.scheduledTimeouts.get(topic);
|
|
122
|
-
if (existingTimeout) clearTimeout(existingTimeout);
|
|
123
|
-
const timeout = setTimeout(() => {
|
|
124
|
-
this.queueEmitter.emit("process", topic);
|
|
125
|
-
this.scheduledTimeouts.delete(topic);
|
|
126
|
-
}, delayMs);
|
|
127
|
-
this.scheduledTimeouts.set(topic, timeout);
|
|
128
|
-
}
|
|
129
|
-
async enqueue(topic, event, messageGroupId) {
|
|
130
|
-
const handlers = this.subscriptions[topic] || [];
|
|
131
|
-
if (handlers.length === 0) return;
|
|
132
|
-
const effectiveMessageGroupId = messageGroupId ?? event.messageGroupId;
|
|
133
|
-
for (const subscription of handlers) {
|
|
134
|
-
const delayMs = subscription.queueConfig.delaySeconds * 1e3;
|
|
135
|
-
const visibleAt = Date.now() + delayMs;
|
|
136
|
-
const queuedMessage = {
|
|
137
|
-
id: randomUUID(),
|
|
138
|
-
event,
|
|
139
|
-
attempts: 0,
|
|
140
|
-
visibleAt,
|
|
141
|
-
messageGroupId: effectiveMessageGroupId,
|
|
142
|
-
queueConfig: subscription.queueConfig,
|
|
143
|
-
subscriptionId: subscription.subscriptionId,
|
|
144
|
-
internalSubscriptionId: subscription.internalSubscriptionId
|
|
145
|
-
};
|
|
146
|
-
if (!this.queues[topic]) this.queues[topic] = [];
|
|
147
|
-
this.queues[topic].push(queuedMessage);
|
|
148
|
-
this.updateMetric(topic, "queueDepth", 1);
|
|
149
|
-
this.scheduleProcessing(topic, delayMs);
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
subscribe(topic, handler, queueConfig, subscriptionId) {
|
|
153
|
-
if (!this.subscriptions[topic]) this.subscriptions[topic] = [];
|
|
154
|
-
const internalSubscriptionId = randomUUID();
|
|
155
|
-
this.subscriptions[topic].push({
|
|
156
|
-
handler,
|
|
157
|
-
queueConfig,
|
|
158
|
-
subscriptionId,
|
|
159
|
-
internalSubscriptionId
|
|
160
|
-
});
|
|
161
|
-
if (this.queues[topic] && this.queues[topic].length > 0) {
|
|
162
|
-
const now = Date.now();
|
|
163
|
-
let madeVisible = false;
|
|
164
|
-
for (const message of this.queues[topic]) if (message.internalSubscriptionId !== internalSubscriptionId && message.attempts > 0) {
|
|
165
|
-
message.visibleAt = now;
|
|
166
|
-
madeVisible = true;
|
|
167
|
-
}
|
|
168
|
-
if (madeVisible) this.scheduleProcessing(topic, 0);
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
unsubscribe(topic, handler) {
|
|
172
|
-
if (!this.subscriptions[topic]) return;
|
|
173
|
-
this.subscriptions[topic] = this.subscriptions[topic].filter((sub) => sub.handler !== handler);
|
|
174
|
-
if (this.subscriptions[topic].length === 0) {
|
|
175
|
-
delete this.subscriptions[topic];
|
|
176
|
-
if (!(this.queues[topic] && this.queues[topic].length > 0)) {
|
|
177
|
-
const timeout = this.scheduledTimeouts.get(topic);
|
|
178
|
-
if (timeout) {
|
|
179
|
-
clearTimeout(timeout);
|
|
180
|
-
this.scheduledTimeouts.delete(topic);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
}
|
|
185
|
-
getMetrics(topic) {
|
|
186
|
-
return this.metrics.get(topic);
|
|
187
|
-
}
|
|
188
|
-
getAllMetrics() {
|
|
189
|
-
const result = {};
|
|
190
|
-
this.metrics.forEach((metrics, topic) => {
|
|
191
|
-
result[topic] = { ...metrics };
|
|
192
|
-
});
|
|
193
|
-
return result;
|
|
194
|
-
}
|
|
195
|
-
reset() {
|
|
196
|
-
this.scheduledTimeouts.forEach((timeout) => clearTimeout(timeout));
|
|
197
|
-
this.scheduledTimeouts.clear();
|
|
198
|
-
this.queueEmitter.removeAllListeners();
|
|
199
|
-
this.queues = {};
|
|
200
|
-
this.subscriptions = {};
|
|
201
|
-
this.lockedGroups = /* @__PURE__ */ new Set();
|
|
202
|
-
this.processingMessages = /* @__PURE__ */ new Set();
|
|
203
|
-
this.metrics.clear();
|
|
204
|
-
}
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
//#endregion
|
|
208
|
-
export { QueueManager };
|
|
209
|
-
//# sourceMappingURL=queue-manager.mjs.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"queue-manager.mjs","names":["attempts: number","queuedMessage: QueuedMessage<TData>","result: Record<string, QueueMetrics>"],"sources":["../../src/queue-manager.ts"],"sourcesContent":["import { randomUUID } from 'crypto'\nimport { EventEmitter } from 'events'\nimport { globalLogger, type Logger } from './logger'\nimport type { Event, Handler, QueueConfig } from './types'\n\nexport class QueueError extends Error {\n constructor(message: string) {\n super(message)\n this.name = 'QueueError'\n }\n}\n\nexport class HandlerTimeoutError extends QueueError {\n constructor(message: string) {\n super(message)\n this.name = 'HandlerTimeoutError'\n }\n}\n\nexport class MaxRetriesError extends QueueError {\n constructor(\n message: string,\n public readonly attempts: number,\n ) {\n super(message)\n this.name = 'MaxRetriesError'\n }\n}\n\ntype QueuedMessage<TData = unknown> = {\n id: string\n event: Event<TData>\n attempts: number\n visibleAt: number\n messageGroupId?: string\n queueConfig: QueueConfig\n subscriptionId: string\n internalSubscriptionId: string\n}\n\ntype QueueSubscription = {\n handler: Handler\n queueConfig: QueueConfig\n subscriptionId: string\n internalSubscriptionId: string\n}\n\nexport type QueueMetrics = {\n queueDepth: number\n processingCount: number\n retriesCount: number\n dlqCount: number\n}\n\nexport class QueueManager {\n private logger: Logger\n private queues: Record<string, QueuedMessage[]> = {}\n private subscriptions: Record<string, QueueSubscription[]> = {}\n private lockedGroups: Set<string> = new Set()\n private queueEmitter = new EventEmitter()\n private scheduledTimeouts: Map<string, NodeJS.Timeout> = new Map()\n private metrics: Map<string, QueueMetrics> = new Map()\n private processingMessages: Set<string> = new Set()\n\n constructor(logger?: Logger) {\n this.logger = logger || globalLogger\n this.queueEmitter.on('process', (topic: string) => {\n this.processQueue(topic)\n })\n }\n\n private initMetrics(topic: string): void {\n if (!this.metrics.has(topic)) {\n this.metrics.set(topic, {\n queueDepth: 0,\n processingCount: 0,\n retriesCount: 0,\n dlqCount: 0,\n })\n }\n }\n\n private updateMetric(topic: string, key: keyof QueueMetrics, delta: number): void {\n this.initMetrics(topic)\n const metrics = this.metrics.get(topic)!\n metrics[key] = Math.max(0, metrics[key] + delta)\n }\n\n private processQueue(topic: string): void {\n const queue = this.queues[topic]\n if (!queue || queue.length === 0) {\n return\n }\n\n const now = Date.now()\n const visibleMessages = queue.filter((msg) => msg.visibleAt <= now && !this.processingMessages.has(msg.id))\n\n for (const message of visibleMessages) {\n if (message.queueConfig.type === 'fifo' && message.messageGroupId) {\n const lockKey = `${topic}:${message.messageGroupId}`\n if (this.lockedGroups.has(lockKey)) {\n continue\n }\n\n this.processingMessages.add(message.id)\n this.lockedGroups.add(lockKey)\n void this.processMessage(topic, message, lockKey)\n } else {\n this.processingMessages.add(message.id)\n void this.processMessage(topic, message)\n }\n }\n }\n\n private async processMessage(topic: string, message: QueuedMessage, lockKey?: string): Promise<void> {\n const handlers = this.subscriptions[topic] || []\n const handler =\n handlers.find((s) => s.internalSubscriptionId === message.internalSubscriptionId) ||\n handlers.find((s) => s.subscriptionId === message.subscriptionId) ||\n handlers[0]\n\n if (!handler) {\n this.processingMessages.delete(message.id)\n this.removeMessageFromQueue(topic, message.id)\n if (lockKey) {\n this.lockedGroups.delete(lockKey)\n }\n return\n }\n\n const handlerChanged = message.internalSubscriptionId !== handler.internalSubscriptionId\n if (handlerChanged && message.attempts > 0) {\n message.attempts = 0\n message.internalSubscriptionId = handler.internalSubscriptionId\n message.subscriptionId = handler.subscriptionId\n message.visibleAt = Date.now()\n }\n\n this.updateMetric(topic, 'processingCount', 1)\n\n try {\n await handler.handler(message.event)\n this.updateMetric(topic, 'processingCount', -1)\n this.processingMessages.delete(message.id)\n this.removeMessageFromQueue(topic, message.id)\n\n if (lockKey) {\n this.lockedGroups.delete(lockKey)\n }\n this.scheduleProcessing(topic, 0)\n } catch (error) {\n this.updateMetric(topic, 'processingCount', -1)\n this.processingMessages.delete(message.id)\n message.attempts++\n\n if (message.attempts >= handler.queueConfig.maxRetries) {\n const maxRetriesError = new MaxRetriesError(\n `Message failed after ${message.attempts} attempts`,\n message.attempts,\n )\n this.logger.error('[Queue DLQ] Message moved to dead-letter queue after max retries', {\n topic,\n messageId: message.id,\n attempts: message.attempts,\n originalError: error instanceof Error ? error.message : 'Unknown error',\n error: maxRetriesError.message,\n })\n\n this.updateMetric(topic, 'dlqCount', 1)\n this.removeMessageFromQueue(topic, message.id)\n\n if (lockKey) {\n this.lockedGroups.delete(lockKey)\n }\n this.scheduleProcessing(topic, 0)\n } else {\n this.updateMetric(topic, 'retriesCount', 1)\n message.visibleAt = Date.now() + handler.queueConfig.visibilityTimeout * 1000\n if (lockKey) {\n this.lockedGroups.delete(lockKey)\n }\n this.scheduleProcessing(topic, handler.queueConfig.visibilityTimeout * 1000)\n }\n }\n }\n\n private removeMessageFromQueue(topic: string, messageId: string): void {\n const queue = this.queues[topic]\n if (!queue) {\n return\n }\n\n const index = queue.findIndex((msg) => msg.id === messageId)\n if (index !== -1) {\n queue.splice(index, 1)\n this.updateMetric(topic, 'queueDepth', -1)\n }\n\n if (queue.length === 0) {\n delete this.queues[topic]\n }\n }\n\n private scheduleProcessing(topic: string, delayMs: number): void {\n const existingTimeout = this.scheduledTimeouts.get(topic)\n if (existingTimeout) {\n clearTimeout(existingTimeout)\n }\n\n const timeout = setTimeout(() => {\n this.queueEmitter.emit('process', topic)\n this.scheduledTimeouts.delete(topic)\n }, delayMs)\n\n this.scheduledTimeouts.set(topic, timeout)\n }\n\n async enqueue<TData>(topic: string, event: Event<TData>, messageGroupId?: string): Promise<void> {\n const handlers = this.subscriptions[topic] || []\n\n if (handlers.length === 0) {\n return\n }\n\n const effectiveMessageGroupId = messageGroupId ?? event.messageGroupId\n\n for (const subscription of handlers) {\n const delayMs = subscription.queueConfig.delaySeconds * 1000\n const visibleAt = Date.now() + delayMs\n\n const queuedMessage: QueuedMessage<TData> = {\n id: randomUUID(),\n event,\n attempts: 0,\n visibleAt,\n messageGroupId: effectiveMessageGroupId,\n queueConfig: subscription.queueConfig,\n subscriptionId: subscription.subscriptionId,\n internalSubscriptionId: subscription.internalSubscriptionId,\n }\n\n if (!this.queues[topic]) {\n this.queues[topic] = []\n }\n\n this.queues[topic].push(queuedMessage as QueuedMessage)\n this.updateMetric(topic, 'queueDepth', 1)\n\n this.scheduleProcessing(topic, delayMs)\n }\n }\n\n subscribe(topic: string, handler: Handler, queueConfig: QueueConfig, subscriptionId: string): void {\n if (!this.subscriptions[topic]) {\n this.subscriptions[topic] = []\n }\n\n const internalSubscriptionId = randomUUID()\n this.subscriptions[topic].push({ handler, queueConfig, subscriptionId, internalSubscriptionId })\n\n if (this.queues[topic] && this.queues[topic].length > 0) {\n const now = Date.now()\n let madeVisible = false\n for (const message of this.queues[topic]) {\n if (message.internalSubscriptionId !== internalSubscriptionId && message.attempts > 0) {\n message.visibleAt = now\n madeVisible = true\n }\n }\n if (madeVisible) {\n this.scheduleProcessing(topic, 0)\n }\n }\n }\n\n unsubscribe(topic: string, handler: Handler): void {\n if (!this.subscriptions[topic]) {\n return\n }\n\n this.subscriptions[topic] = this.subscriptions[topic].filter((sub) => sub.handler !== handler)\n\n if (this.subscriptions[topic].length === 0) {\n delete this.subscriptions[topic]\n const hasQueuedMessages = this.queues[topic] && this.queues[topic].length > 0\n if (!hasQueuedMessages) {\n const timeout = this.scheduledTimeouts.get(topic)\n if (timeout) {\n clearTimeout(timeout)\n this.scheduledTimeouts.delete(topic)\n }\n }\n }\n }\n\n getMetrics(topic: string): QueueMetrics | undefined {\n return this.metrics.get(topic)\n }\n\n getAllMetrics(): Record<string, QueueMetrics> {\n const result: Record<string, QueueMetrics> = {}\n this.metrics.forEach((metrics, topic) => {\n result[topic] = { ...metrics }\n })\n return result\n }\n\n reset(): void {\n this.scheduledTimeouts.forEach((timeout) => clearTimeout(timeout))\n this.scheduledTimeouts.clear()\n this.queueEmitter.removeAllListeners()\n this.queues = {}\n this.subscriptions = {}\n this.lockedGroups = new Set()\n this.processingMessages = new Set()\n this.metrics.clear()\n }\n}\n"],"mappings":";;;;;AAKA,IAAa,aAAb,cAAgC,MAAM;CACpC,YAAY,SAAiB;AAC3B,QAAM,QAAQ;AACd,OAAK,OAAO;;;AAWhB,IAAa,kBAAb,cAAqC,WAAW;CAC9C,YACE,SACA,AAAgBA,UAChB;AACA,QAAM,QAAQ;EAFE;AAGhB,OAAK,OAAO;;;AA6BhB,IAAa,eAAb,MAA0B;CAUxB,YAAY,QAAiB;gBARqB,EAAE;uBACS,EAAE;sCAC3B,IAAI,KAAK;sBACtB,IAAI,cAAc;2CACgB,IAAI,KAAK;iCACrB,IAAI,KAAK;4CACZ,IAAI,KAAK;AAGjD,OAAK,SAAS,UAAU;AACxB,OAAK,aAAa,GAAG,YAAY,UAAkB;AACjD,QAAK,aAAa,MAAM;IACxB;;CAGJ,AAAQ,YAAY,OAAqB;AACvC,MAAI,CAAC,KAAK,QAAQ,IAAI,MAAM,CAC1B,MAAK,QAAQ,IAAI,OAAO;GACtB,YAAY;GACZ,iBAAiB;GACjB,cAAc;GACd,UAAU;GACX,CAAC;;CAIN,AAAQ,aAAa,OAAe,KAAyB,OAAqB;AAChF,OAAK,YAAY,MAAM;EACvB,MAAM,UAAU,KAAK,QAAQ,IAAI,MAAM;AACvC,UAAQ,OAAO,KAAK,IAAI,GAAG,QAAQ,OAAO,MAAM;;CAGlD,AAAQ,aAAa,OAAqB;EACxC,MAAM,QAAQ,KAAK,OAAO;AAC1B,MAAI,CAAC,SAAS,MAAM,WAAW,EAC7B;EAGF,MAAM,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