@pattern-stack/codegen 0.10.0 → 0.11.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +135 -0
- package/README.md +5 -5
- package/consumer-skills/codegen/SKILL.md +2 -2
- package/consumer-skills/events/typed-bus-and-outbox.md +1 -1
- package/consumer-skills/{sync → integration}/SKILL.md +29 -29
- package/consumer-skills/{sync → integration}/audit-and-detection.md +22 -22
- package/consumer-skills/{sync → integration}/change-sources-and-sinks.md +60 -60
- package/consumer-skills/subsystems/SKILL.md +64 -8
- package/consumer-skills/subsystems/wiring-and-order.md +7 -7
- package/dist/runtime/base-classes/index.d.ts +4 -4
- package/dist/runtime/base-classes/index.js +35 -35
- package/dist/runtime/base-classes/index.js.map +1 -1
- package/dist/runtime/base-classes/{synced-entity-repository.d.ts → integrated-entity-repository.d.ts} +15 -15
- package/dist/runtime/base-classes/{synced-entity-repository.js → integrated-entity-repository.js} +21 -21
- package/dist/runtime/base-classes/integrated-entity-repository.js.map +1 -0
- package/dist/runtime/base-classes/{synced-entity-service.d.ts → integrated-entity-service.d.ts} +6 -6
- package/dist/runtime/base-classes/{synced-entity-service.js → integrated-entity-service.js} +4 -4
- package/dist/runtime/base-classes/integrated-entity-service.js.map +1 -0
- package/dist/runtime/base-classes/{sync-upsert-config.d.ts → integration-upsert-config.d.ts} +13 -13
- package/dist/runtime/base-classes/integration-upsert-config.js +1 -0
- package/dist/runtime/base-classes/{junction-sync-repository.d.ts → junction-integration-repository.d.ts} +11 -11
- package/dist/runtime/base-classes/{junction-sync-repository.js → junction-integration-repository.js} +15 -15
- package/dist/runtime/base-classes/junction-integration-repository.js.map +1 -0
- package/dist/runtime/subsystems/auth/auth-oauth-state.schema.js.map +1 -1
- package/dist/runtime/subsystems/auth/auth.module.d.ts +4 -4
- package/dist/runtime/subsystems/auth/auth.module.js +3 -3
- package/dist/runtime/subsystems/auth/auth.module.js.map +1 -1
- package/dist/runtime/subsystems/auth/auth.tokens.d.ts +8 -8
- package/dist/runtime/subsystems/auth/auth.tokens.js +6 -6
- package/dist/runtime/subsystems/auth/auth.tokens.js.map +1 -1
- package/dist/runtime/subsystems/auth/backends/state-store.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/auth/controllers/auth.controller.d.ts +2 -2
- package/dist/runtime/subsystems/auth/controllers/auth.controller.js +3 -3
- package/dist/runtime/subsystems/auth/controllers/auth.controller.js.map +1 -1
- package/dist/runtime/subsystems/auth/index.d.ts +3 -3
- package/dist/runtime/subsystems/auth/index.js +40 -40
- package/dist/runtime/subsystems/auth/index.js.map +1 -1
- package/dist/runtime/subsystems/auth/middleware/requester-context.js.map +1 -1
- package/dist/runtime/subsystems/auth/protocols/auth-strategy.d.ts +3 -3
- package/dist/runtime/subsystems/auth/protocols/{integration-store.d.ts → connection-store.d.ts} +20 -20
- package/dist/runtime/subsystems/auth/protocols/connection-store.js +1 -0
- package/dist/runtime/subsystems/auth/protocols/provider-strategy.d.ts +3 -3
- package/dist/runtime/subsystems/auth/runtime/{integration-broken.error.d.ts → connection-broken.error.d.ts} +5 -5
- package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js +19 -0
- package/dist/runtime/subsystems/auth/runtime/connection-broken.error.js.map +1 -0
- package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.d.ts +10 -10
- package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js +28 -28
- package/dist/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.js.map +1 -1
- package/dist/runtime/subsystems/auth/runtime/with-auth-retry.d.ts +1 -1
- package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js +3 -3
- package/dist/runtime/subsystems/auth/runtime/with-auth-retry.js.map +1 -1
- package/dist/runtime/subsystems/bridge/bridge.module.d.ts +0 -1
- package/dist/runtime/subsystems/bridge/bridge.module.js +294 -710
- package/dist/runtime/subsystems/bridge/bridge.module.js.map +1 -1
- package/dist/runtime/subsystems/bridge/index.d.ts +0 -1
- package/dist/runtime/subsystems/bridge/index.js +248 -664
- package/dist/runtime/subsystems/bridge/index.js.map +1 -1
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js +18 -10
- package/dist/runtime/subsystems/events/event-bus.drizzle-backend.js.map +1 -1
- package/dist/runtime/subsystems/events/events.module.js +43 -244
- package/dist/runtime/subsystems/events/events.module.js.map +1 -1
- package/dist/runtime/subsystems/events/index.d.ts +0 -1
- package/dist/runtime/subsystems/events/index.js +39 -241
- package/dist/runtime/subsystems/events/index.js.map +1 -1
- package/dist/runtime/subsystems/index.d.ts +7 -7
- package/dist/runtime/subsystems/index.js +222 -839
- package/dist/runtime/subsystems/index.js.map +1 -1
- package/dist/runtime/subsystems/{sync → integration}/build-change-source.d.ts +3 -3
- package/dist/runtime/subsystems/{sync → integration}/build-change-source.js +3 -3
- package/dist/runtime/subsystems/integration/build-change-source.js.map +1 -0
- package/dist/runtime/subsystems/{sync → integration}/deep-equal.differ.d.ts +2 -2
- package/dist/runtime/subsystems/{sync → integration}/deep-equal.differ.js +1 -1
- package/dist/runtime/subsystems/integration/deep-equal.differ.js.map +1 -0
- package/dist/runtime/subsystems/{sync → integration}/detection-config.schema.d.ts +3 -3
- package/dist/runtime/subsystems/{sync → integration}/detection-config.schema.js +1 -1
- package/dist/runtime/subsystems/integration/detection-config.schema.js.map +1 -0
- package/dist/runtime/subsystems/{sync/execute-sync.use-case.d.ts → integration/execute-integration.use-case.d.ts} +13 -13
- package/dist/runtime/subsystems/{sync/execute-sync.use-case.js → integration/execute-integration.use-case.js} +30 -30
- package/dist/runtime/subsystems/integration/execute-integration.use-case.js.map +1 -0
- package/dist/runtime/subsystems/integration/index.d.ts +28 -0
- package/dist/runtime/subsystems/{sync → integration}/index.js +171 -171
- package/dist/runtime/subsystems/integration/index.js.map +1 -0
- package/dist/runtime/subsystems/{sync/sync-audit.schema.d.ts → integration/integration-audit.schema.d.ts} +64 -64
- package/dist/runtime/subsystems/{sync/sync-audit.schema.js → integration/integration-audit.schema.js} +47 -47
- package/dist/runtime/subsystems/integration/integration-audit.schema.js.map +1 -0
- package/dist/runtime/subsystems/{sync/sync-change-source.protocol.d.ts → integration/integration-change-source.protocol.d.ts} +10 -10
- package/dist/runtime/subsystems/integration/integration-change-source.protocol.js +1 -0
- package/dist/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.d.ts → integration/integration-cursor-store.drizzle-backend.d.ts} +1 -1
- package/dist/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.js → integration/integration-cursor-store.drizzle-backend.js} +65 -65
- package/dist/runtime/subsystems/integration/integration-cursor-store.drizzle-backend.js.map +1 -0
- package/dist/runtime/subsystems/{sync/sync-cursor-store.memory-backend.d.ts → integration/integration-cursor-store.memory-backend.d.ts} +6 -6
- package/dist/runtime/subsystems/{sync/sync-cursor-store.memory-backend.js → integration/integration-cursor-store.memory-backend.js} +5 -5
- package/dist/runtime/subsystems/integration/integration-cursor-store.memory-backend.js.map +1 -0
- package/dist/runtime/subsystems/{sync/sync-cursor-store.protocol.d.ts → integration/integration-cursor-store.protocol.d.ts} +13 -13
- package/dist/runtime/subsystems/integration/integration-cursor-store.protocol.js +1 -0
- package/dist/runtime/subsystems/{sync/sync-errors.d.ts → integration/integration-errors.d.ts} +2 -2
- package/dist/runtime/subsystems/{sync/sync-errors.js → integration/integration-errors.js} +3 -3
- package/dist/runtime/subsystems/integration/integration-errors.js.map +1 -0
- package/dist/runtime/subsystems/{sync/sync-field-diff.protocol.d.ts → integration/integration-field-diff.protocol.d.ts} +2 -2
- package/dist/runtime/subsystems/{sync/sync-field-diff.protocol.js → integration/integration-field-diff.protocol.js} +2 -2
- package/dist/runtime/subsystems/integration/integration-field-diff.protocol.js.map +1 -0
- package/dist/runtime/subsystems/{sync/sync-loopback.protocol.d.ts → integration/integration-loopback.protocol.d.ts} +2 -2
- package/dist/runtime/subsystems/integration/integration-loopback.protocol.js +1 -0
- package/dist/runtime/subsystems/{sync/sync-middleware.protocol.d.ts → integration/integration-middleware.protocol.d.ts} +5 -5
- package/dist/runtime/subsystems/integration/integration-middleware.protocol.js +1 -0
- package/dist/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.d.ts → integration/integration-run-recorder.drizzle-backend.d.ts} +5 -5
- package/dist/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.js → integration/integration-run-recorder.drizzle-backend.js} +73 -73
- package/dist/runtime/subsystems/integration/integration-run-recorder.drizzle-backend.js.map +1 -0
- package/dist/runtime/subsystems/{sync/sync-run-recorder.memory-backend.d.ts → integration/integration-run-recorder.memory-backend.d.ts} +15 -15
- package/dist/runtime/subsystems/{sync/sync-run-recorder.memory-backend.js → integration/integration-run-recorder.memory-backend.js} +11 -11
- package/dist/runtime/subsystems/integration/integration-run-recorder.memory-backend.js.map +1 -0
- package/dist/runtime/subsystems/{sync/sync-run-recorder.protocol.d.ts → integration/integration-run-recorder.protocol.d.ts} +25 -25
- package/dist/runtime/subsystems/integration/integration-run-recorder.protocol.js +1 -0
- package/dist/runtime/subsystems/{sync/sync-sink.protocol.d.ts → integration/integration-sink.protocol.d.ts} +5 -5
- package/dist/runtime/subsystems/integration/integration-sink.protocol.js +1 -0
- package/dist/runtime/subsystems/{sync/sync.module.d.ts → integration/integration.module.d.ts} +24 -24
- package/dist/runtime/subsystems/{sync/sync.module.js → integration/integration.module.js} +132 -132
- package/dist/runtime/subsystems/integration/integration.module.js.map +1 -0
- package/dist/runtime/subsystems/integration/integration.tokens.d.ts +47 -0
- package/dist/runtime/subsystems/integration/integration.tokens.js +18 -0
- package/dist/runtime/subsystems/integration/integration.tokens.js.map +1 -0
- package/dist/runtime/subsystems/{sync → integration}/loopback.middleware.d.ts +5 -5
- package/dist/runtime/subsystems/{sync → integration}/loopback.middleware.js +1 -1
- package/dist/runtime/subsystems/integration/loopback.middleware.js.map +1 -0
- package/dist/runtime/subsystems/{sync → integration}/poll-change-source.d.ts +5 -5
- package/dist/runtime/subsystems/{sync → integration}/poll-change-source.js +1 -1
- package/dist/runtime/subsystems/integration/poll-change-source.js.map +1 -0
- package/dist/runtime/subsystems/{sync → integration}/webhook-change-source.d.ts +5 -5
- package/dist/runtime/subsystems/{sync → integration}/webhook-change-source.js +1 -1
- package/dist/runtime/subsystems/integration/webhook-change-source.js.map +1 -0
- package/dist/runtime/subsystems/jobs/bullmq.config.d.ts +22 -3
- package/dist/runtime/subsystems/jobs/bullmq.config.js.map +1 -1
- package/dist/runtime/subsystems/jobs/index.d.ts +1 -4
- package/dist/runtime/subsystems/jobs/index.js +87 -506
- package/dist/runtime/subsystems/jobs/index.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-orchestrator.bullmq-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js +3 -0
- package/dist/runtime/subsystems/jobs/job-worker.bullmq-backend.js.map +1 -1
- package/dist/runtime/subsystems/jobs/job-worker.module.d.ts +10 -3
- package/dist/runtime/subsystems/jobs/job-worker.module.js +248 -664
- package/dist/runtime/subsystems/jobs/job-worker.module.js.map +1 -1
- package/dist/runtime/subsystems/jobs/jobs-domain.module.d.ts +0 -1
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js +89 -391
- package/dist/runtime/subsystems/jobs/jobs-domain.module.js.map +1 -1
- package/dist/runtime/subsystems/observability/index.d.ts +4 -4
- package/dist/runtime/subsystems/observability/index.js +11 -11
- package/dist/runtime/subsystems/observability/index.js.map +1 -1
- package/dist/runtime/subsystems/observability/observability.module.d.ts +2 -2
- package/dist/runtime/subsystems/observability/observability.module.js +11 -11
- package/dist/runtime/subsystems/observability/observability.module.js.map +1 -1
- package/dist/runtime/subsystems/observability/observability.protocol.d.ts +11 -11
- package/dist/runtime/subsystems/observability/observability.service.d.ts +6 -6
- package/dist/runtime/subsystems/observability/observability.service.js +11 -11
- package/dist/runtime/subsystems/observability/observability.service.js.map +1 -1
- package/dist/runtime/subsystems/observability/observability.tokens.d.ts +1 -1
- package/dist/runtime/subsystems/observability/observability.tokens.js.map +1 -1
- package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.d.ts +3 -3
- package/dist/runtime/subsystems/observability/reporters/bridge-metrics.reporter.js.map +1 -1
- package/dist/runtime/subsystems/observability/reporters/index.d.ts +3 -3
- package/dist/runtime/subsystems/observability/reporters/index.js.map +1 -1
- package/dist/src/cli/index.js +412 -302
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/index.d.ts +22 -22
- package/dist/src/index.js +191 -191
- package/dist/src/index.js.map +1 -1
- package/examples/auth-integrations/README.md +32 -32
- package/examples/auth-integrations/definitions/entities/{integration.yaml → connection.yaml} +10 -10
- package/examples/auth-integrations/runtime/{integrations/adapters/integration-grant-sink.adapter.ts → connections/adapters/connection-grant-sink.adapter.ts} +7 -7
- package/examples/auth-integrations/runtime/{integrations/adapters/integration-reader.adapter.ts → connections/adapters/connection-reader.adapter.ts} +10 -10
- package/examples/auth-integrations/runtime/{integrations/adapters/integration-token-writer.adapter.ts → connections/adapters/connection-token-writer.adapter.ts} +11 -11
- package/examples/auth-integrations/runtime/connections/connections-auth.module.ts +81 -0
- package/examples/auth-integrations/runtime/{integrations/facade/integrations.service.ts → connections/facade/connections.service.ts} +35 -35
- package/examples/auth-integrations/runtime/{integrations → connections}/oauth/use-cases/create-or-update-from-oauth-grant.use-case.ts +11 -11
- package/examples/auth-integrations/runtime/{integrations/oauth/use-cases/disconnect-integration.use-case.ts → connections/oauth/use-cases/disconnect-connection.use-case.ts} +6 -6
- package/examples/auth-integrations/runtime/connections/oauth/use-cases/list-user-connections.use-case.ts +21 -0
- package/examples/auth-integrations/runtime/connections/oauth/use-cases/mark-connection-requires-reauth.use-case.ts +21 -0
- package/package.json +1 -1
- package/runtime/base-classes/index.ts +8 -8
- package/runtime/base-classes/{synced-entity-repository.ts → integrated-entity-repository.ts} +36 -36
- package/runtime/base-classes/{synced-entity-service.ts → integrated-entity-service.ts} +6 -6
- package/runtime/base-classes/{sync-upsert-config.ts → integration-upsert-config.ts} +12 -12
- package/runtime/base-classes/{junction-sync-repository.ts → junction-integration-repository.ts} +28 -28
- package/runtime/subsystems/auth/auth-oauth-state.schema.ts +1 -1
- package/runtime/subsystems/auth/auth.module.ts +4 -4
- package/runtime/subsystems/auth/auth.tokens.ts +7 -7
- package/runtime/subsystems/auth/controllers/auth.controller.ts +7 -7
- package/runtime/subsystems/auth/index.ts +19 -19
- package/runtime/subsystems/auth/protocols/auth-strategy.ts +3 -3
- package/runtime/subsystems/auth/protocols/{integration-store.ts → connection-store.ts} +19 -19
- package/runtime/subsystems/auth/protocols/provider-strategy.ts +2 -2
- package/runtime/subsystems/auth/runtime/{integration-broken.error.ts → connection-broken.error.ts} +5 -5
- package/runtime/subsystems/auth/runtime/oauth2-refresh.strategy.ts +35 -35
- package/runtime/subsystems/auth/runtime/with-auth-retry.ts +3 -3
- package/runtime/subsystems/events/event-bus.drizzle-backend.ts +32 -10
- package/runtime/subsystems/events/events.module.ts +38 -6
- package/runtime/subsystems/events/index.ts +7 -1
- package/runtime/subsystems/index.ts +11 -11
- package/runtime/subsystems/{sync → integration}/build-change-source.ts +3 -3
- package/runtime/subsystems/{sync → integration}/deep-equal.differ.ts +7 -7
- package/runtime/subsystems/{sync → integration}/detection-config.schema.ts +3 -3
- package/runtime/subsystems/{sync/execute-sync.use-case.ts → integration/execute-integration.use-case.ts} +40 -40
- package/runtime/subsystems/{sync → integration}/index.ts +47 -47
- package/runtime/subsystems/{sync/sync-audit.schema.ts → integration/integration-audit.schema.ts} +61 -61
- package/runtime/subsystems/{sync/sync-change-source.protocol.ts → integration/integration-change-source.protocol.ts} +9 -9
- package/runtime/subsystems/{sync/sync-cursor-store.drizzle-backend.ts → integration/integration-cursor-store.drizzle-backend.ts} +30 -30
- package/runtime/subsystems/{sync/sync-cursor-store.memory-backend.ts → integration/integration-cursor-store.memory-backend.ts} +9 -9
- package/runtime/subsystems/{sync/sync-cursor-store.protocol.ts → integration/integration-cursor-store.protocol.ts} +13 -13
- package/runtime/subsystems/{sync/sync-errors.ts → integration/integration-errors.ts} +3 -3
- package/runtime/subsystems/{sync/sync-field-diff.protocol.ts → integration/integration-field-diff.protocol.ts} +2 -2
- package/runtime/subsystems/{sync/sync-loopback.protocol.ts → integration/integration-loopback.protocol.ts} +2 -2
- package/runtime/subsystems/{sync/sync-middleware.protocol.ts → integration/integration-middleware.protocol.ts} +6 -6
- package/runtime/subsystems/{sync/sync-run-recorder.drizzle-backend.ts → integration/integration-run-recorder.drizzle-backend.ts} +39 -39
- package/runtime/subsystems/{sync/sync-run-recorder.memory-backend.ts → integration/integration-run-recorder.memory-backend.ts} +23 -23
- package/runtime/subsystems/{sync/sync-run-recorder.protocol.ts → integration/integration-run-recorder.protocol.ts} +25 -25
- package/runtime/subsystems/{sync/sync-sink.protocol.ts → integration/integration-sink.protocol.ts} +4 -4
- package/runtime/subsystems/{sync/sync.module.ts → integration/integration.module.ts} +48 -48
- package/runtime/subsystems/integration/integration.tokens.ts +49 -0
- package/runtime/subsystems/{sync → integration}/loopback.middleware.ts +5 -5
- package/runtime/subsystems/{sync → integration}/poll-change-source.ts +7 -7
- package/runtime/subsystems/{sync → integration}/webhook-change-source.ts +7 -7
- package/runtime/subsystems/jobs/bullmq.config.ts +23 -3
- package/runtime/subsystems/jobs/index.ts +13 -8
- package/runtime/subsystems/jobs/job-worker.bullmq-backend.ts +5 -2
- package/runtime/subsystems/jobs/job-worker.module.ts +27 -7
- package/runtime/subsystems/jobs/jobs-domain.module.ts +27 -2
- package/runtime/subsystems/observability/index.ts +1 -1
- package/runtime/subsystems/observability/observability.module.ts +2 -2
- package/runtime/subsystems/observability/observability.protocol.ts +11 -11
- package/runtime/subsystems/observability/observability.service.ts +13 -13
- package/runtime/subsystems/observability/observability.tokens.ts +1 -1
- package/src/patterns/library/index.ts +4 -4
- package/src/patterns/library/{synced.pattern.ts → integrated.pattern.ts} +12 -12
- package/src/patterns/library/junction.pattern.ts +1 -1
- package/src/patterns/pattern-definition.ts +3 -3
- package/templates/entity/new/backend/modules/core/{sync-source.ejs.t → integration-source.ejs.t} +6 -6
- package/templates/entity/new/backend/modules/core/{sync-source.providers.ejs.t → integration-source.providers.ejs.t} +2 -2
- package/templates/entity/new/clean-lite-ps/entity.ejs.t +1 -1
- package/templates/entity/new/clean-lite-ps/module.ejs.t +1 -1
- package/templates/entity/new/clean-lite-ps/prompt-extension.js +33 -33
- package/templates/entity/new/clean-lite-ps/repository.ejs.t +27 -27
- package/templates/entity/new/frontend/collections/collection.ejs.t +26 -1
- package/templates/entity/new/frontend/collections/collections-base.ejs.t +11 -0
- package/templates/entity/new/frontend/entity/combined.ejs.t +31 -1
- package/templates/entity/new/prompt.js +27 -15
- package/templates/junction/new/entity.ejs.t +1 -1
- package/templates/junction/new/prompt.js +24 -24
- package/templates/junction/new/repository.ejs.t +19 -19
- package/templates/subsystem/auth/auth-oauth-state.schema.ejs.t +2 -2
- package/templates/subsystem/auth-config/prompt.js +1 -1
- package/templates/subsystem/auth-integrations/app-module-hook.ejs.t +5 -5
- package/templates/subsystem/bridge/prompt.js +1 -1
- package/templates/subsystem/events/domain-events.schema.ejs.t +43 -2
- package/templates/subsystem/integration/integration-audit.schema.ejs.t +192 -0
- package/templates/subsystem/{sync → integration}/prompt.js +12 -12
- package/templates/subsystem/{sync-config/codegen-config-sync-block.ejs.t → integration-config/codegen-config-integration-block.ejs.t} +7 -7
- package/templates/subsystem/integration-config/prompt.js +22 -0
- package/templates/subsystem/jobs/worker.ejs.t +2 -2
- package/templates/subsystem/observability/main-hook.ejs.t +1 -1
- package/templates/subsystem/observability/prompt.js +1 -1
- package/templates/subsystem/openapi-config/prompt.js +1 -1
- package/dist/runtime/base-classes/junction-sync-repository.js.map +0 -1
- package/dist/runtime/base-classes/sync-upsert-config.js +0 -1
- package/dist/runtime/base-classes/synced-entity-repository.js.map +0 -1
- package/dist/runtime/base-classes/synced-entity-service.js.map +0 -1
- package/dist/runtime/subsystems/auth/protocols/integration-store.js +0 -1
- package/dist/runtime/subsystems/auth/runtime/integration-broken.error.js +0 -19
- package/dist/runtime/subsystems/auth/runtime/integration-broken.error.js.map +0 -1
- package/dist/runtime/subsystems/sync/build-change-source.js.map +0 -1
- package/dist/runtime/subsystems/sync/deep-equal.differ.js.map +0 -1
- package/dist/runtime/subsystems/sync/detection-config.schema.js.map +0 -1
- package/dist/runtime/subsystems/sync/execute-sync.use-case.js.map +0 -1
- package/dist/runtime/subsystems/sync/index.d.ts +0 -28
- package/dist/runtime/subsystems/sync/index.js.map +0 -1
- package/dist/runtime/subsystems/sync/loopback.middleware.js.map +0 -1
- package/dist/runtime/subsystems/sync/poll-change-source.js.map +0 -1
- package/dist/runtime/subsystems/sync/sync-audit.schema.js.map +0 -1
- package/dist/runtime/subsystems/sync/sync-change-source.protocol.js +0 -1
- package/dist/runtime/subsystems/sync/sync-cursor-store.drizzle-backend.js.map +0 -1
- package/dist/runtime/subsystems/sync/sync-cursor-store.memory-backend.js.map +0 -1
- package/dist/runtime/subsystems/sync/sync-cursor-store.protocol.js +0 -1
- package/dist/runtime/subsystems/sync/sync-errors.js.map +0 -1
- package/dist/runtime/subsystems/sync/sync-field-diff.protocol.js.map +0 -1
- package/dist/runtime/subsystems/sync/sync-loopback.protocol.js +0 -1
- package/dist/runtime/subsystems/sync/sync-middleware.protocol.js +0 -1
- package/dist/runtime/subsystems/sync/sync-run-recorder.drizzle-backend.js.map +0 -1
- package/dist/runtime/subsystems/sync/sync-run-recorder.memory-backend.js.map +0 -1
- package/dist/runtime/subsystems/sync/sync-run-recorder.protocol.js +0 -1
- package/dist/runtime/subsystems/sync/sync-sink.protocol.js +0 -1
- package/dist/runtime/subsystems/sync/sync.module.js.map +0 -1
- package/dist/runtime/subsystems/sync/sync.tokens.d.ts +0 -47
- package/dist/runtime/subsystems/sync/sync.tokens.js +0 -18
- package/dist/runtime/subsystems/sync/sync.tokens.js.map +0 -1
- package/dist/runtime/subsystems/sync/webhook-change-source.js.map +0 -1
- package/examples/auth-integrations/runtime/integrations/integrations-auth.module.ts +0 -81
- package/examples/auth-integrations/runtime/integrations/oauth/use-cases/list-user-integrations.use-case.ts +0 -21
- package/examples/auth-integrations/runtime/integrations/oauth/use-cases/mark-integration-requires-reauth.use-case.ts +0 -21
- package/runtime/subsystems/sync/sync.tokens.ts +0 -49
- package/templates/subsystem/sync/sync-audit.schema.ejs.t +0 -192
- package/templates/subsystem/sync-config/prompt.js +0 -22
- /package/dist/runtime/base-classes/{sync-upsert-config.js.map → integration-upsert-config.js.map} +0 -0
- /package/dist/runtime/subsystems/auth/protocols/{integration-store.js.map → connection-store.js.map} +0 -0
- /package/dist/runtime/subsystems/{sync/sync-change-source.protocol.js.map → integration/integration-change-source.protocol.js.map} +0 -0
- /package/dist/runtime/subsystems/{sync/sync-cursor-store.protocol.js.map → integration/integration-cursor-store.protocol.js.map} +0 -0
- /package/dist/runtime/subsystems/{sync/sync-loopback.protocol.js.map → integration/integration-loopback.protocol.js.map} +0 -0
- /package/dist/runtime/subsystems/{sync/sync-middleware.protocol.js.map → integration/integration-middleware.protocol.js.map} +0 -0
- /package/dist/runtime/subsystems/{sync/sync-run-recorder.protocol.js.map → integration/integration-run-recorder.protocol.js.map} +0 -0
- /package/dist/runtime/subsystems/{sync/sync-sink.protocol.js.map → integration/integration-sink.protocol.js.map} +0 -0
|
@@ -359,13 +359,12 @@ var BRIDGE_OUTBOX_DRAIN_HOOK = "BRIDGE_OUTBOX_DRAIN_HOOK";
|
|
|
359
359
|
// runtime/subsystems/events/event-bus.drizzle-backend.ts
|
|
360
360
|
var POLL_INTERVAL_MS = 1e3;
|
|
361
361
|
var POLL_BATCH_SIZE = 50;
|
|
362
|
-
function toInsertValues(event) {
|
|
362
|
+
function toInsertValues(event, multiTenant) {
|
|
363
363
|
const metadata = event.metadata ?? void 0;
|
|
364
364
|
const pool = metadata?.["pool"] ?? null;
|
|
365
365
|
const direction = metadata?.["direction"] ?? null;
|
|
366
|
-
const tenantId = metadata?.["tenantId"] ?? null;
|
|
367
366
|
const tier = metadata?.["tier"] ?? "domain";
|
|
368
|
-
|
|
367
|
+
const base = {
|
|
369
368
|
id: event.id,
|
|
370
369
|
type: event.type,
|
|
371
370
|
aggregateId: event.aggregateId,
|
|
@@ -377,9 +376,11 @@ function toInsertValues(event) {
|
|
|
377
376
|
metadata: event.metadata,
|
|
378
377
|
pool,
|
|
379
378
|
direction,
|
|
380
|
-
tier
|
|
381
|
-
tenantId
|
|
379
|
+
tier
|
|
382
380
|
};
|
|
381
|
+
if (!multiTenant) return base;
|
|
382
|
+
const tenantId = metadata?.["tenantId"] ?? null;
|
|
383
|
+
return { ...base, tenantId };
|
|
383
384
|
}
|
|
384
385
|
function toEventSummary(r) {
|
|
385
386
|
const metadata = r.metadata ?? void 0;
|
|
@@ -394,7 +395,11 @@ function toEventSummary(r) {
|
|
|
394
395
|
direction: r.direction,
|
|
395
396
|
tier: r.tier,
|
|
396
397
|
rootRunId: typeof rootRunId === "string" ? rootRunId : null,
|
|
397
|
-
|
|
398
|
+
// EVT-8: `tenant_id` is a scaffold-time conditional column. Read it
|
|
399
|
+
// structurally so this projection typechecks against both the
|
|
400
|
+
// multi-tenant schema (column present) and the single-tenant schema
|
|
401
|
+
// (column absent → undefined → null).
|
|
402
|
+
tenantId: r.tenantId ?? null,
|
|
398
403
|
occurredAt: r.occurredAt instanceof Date ? r.occurredAt : new Date(r.occurredAt),
|
|
399
404
|
processedAt: r.processedAt == null ? null : r.processedAt instanceof Date ? r.processedAt : new Date(r.processedAt)
|
|
400
405
|
};
|
|
@@ -431,12 +436,14 @@ var DrizzleEventBus = class {
|
|
|
431
436
|
// ============================================================================
|
|
432
437
|
async publish(event, tx) {
|
|
433
438
|
const client = tx ?? this.db;
|
|
434
|
-
|
|
439
|
+
const multiTenant = this.opts.multiTenant ?? false;
|
|
440
|
+
await client.insert(domainEvents).values(toInsertValues(event, multiTenant));
|
|
435
441
|
}
|
|
436
442
|
async publishMany(events, tx) {
|
|
437
443
|
if (events.length === 0) return;
|
|
438
444
|
const client = tx ?? this.db;
|
|
439
|
-
|
|
445
|
+
const multiTenant = this.opts.multiTenant ?? false;
|
|
446
|
+
await client.insert(domainEvents).values(events.map((e) => toInsertValues(e, multiTenant)));
|
|
440
447
|
}
|
|
441
448
|
async findById(eventId) {
|
|
442
449
|
const rows = await this.db.select().from(domainEvents).where(eq(domainEvents.id, eventId)).limit(1);
|
|
@@ -478,9 +485,10 @@ var DrizzleEventBus = class {
|
|
|
478
485
|
sql2`${domainEvents.metadata}->>'rootRunId' = ${query.rootRunId}`
|
|
479
486
|
);
|
|
480
487
|
}
|
|
481
|
-
if (query.tenantId !== void 0) {
|
|
488
|
+
if (this.opts.multiTenant && query.tenantId !== void 0) {
|
|
489
|
+
const tenantIdColumn = domainEvents.tenantId;
|
|
482
490
|
conditions.push(
|
|
483
|
-
query.tenantId === null ? sql2`${
|
|
491
|
+
query.tenantId === null ? sql2`${tenantIdColumn} is null` : eq(tenantIdColumn, query.tenantId)
|
|
484
492
|
);
|
|
485
493
|
}
|
|
486
494
|
if (query.cursor) {
|
|
@@ -811,233 +819,12 @@ MemoryEventBus = __decorateClass([
|
|
|
811
819
|
__decorateParam(0, Inject3(EVENTS_MODULE_OPTIONS))
|
|
812
820
|
], MemoryEventBus);
|
|
813
821
|
|
|
814
|
-
// runtime/subsystems/events/event-bus.redis-backend.ts
|
|
815
|
-
import { Injectable as Injectable4, Inject as Inject4, Logger as Logger3 } from "@nestjs/common";
|
|
816
|
-
var CHANNEL_PREFIX = "events:";
|
|
817
|
-
async function createRedisClient(url) {
|
|
818
|
-
let Redis;
|
|
819
|
-
try {
|
|
820
|
-
const mod = await import("ioredis");
|
|
821
|
-
Redis = mod.default ?? mod;
|
|
822
|
-
} catch {
|
|
823
|
-
throw new Error(
|
|
824
|
-
'RedisEventBus requires the "ioredis" package. Install it with: npm install ioredis'
|
|
825
|
-
);
|
|
826
|
-
}
|
|
827
|
-
return new Redis(url);
|
|
828
|
-
}
|
|
829
|
-
var RedisEventBus = class {
|
|
830
|
-
constructor(redisUrl) {
|
|
831
|
-
this.redisUrl = redisUrl;
|
|
832
|
-
}
|
|
833
|
-
redisUrl;
|
|
834
|
-
logger = new Logger3(RedisEventBus.name);
|
|
835
|
-
publisher = null;
|
|
836
|
-
subscriber = null;
|
|
837
|
-
connected = false;
|
|
838
|
-
/**
|
|
839
|
-
* In-process subscriber registry. Handlers registered here are called when
|
|
840
|
-
* a message arrives on the subscriber client — keeping fan-out within the
|
|
841
|
-
* same process without an extra round-trip through Redis.
|
|
842
|
-
*/
|
|
843
|
-
handlers = /* @__PURE__ */ new Map();
|
|
844
|
-
/**
|
|
845
|
-
* Track which event types have active Redis subscriptions.
|
|
846
|
-
* Used to avoid subscribing multiple times to the same type channel.
|
|
847
|
-
*/
|
|
848
|
-
subscribedTypes = /* @__PURE__ */ new Set();
|
|
849
|
-
// ============================================================================
|
|
850
|
-
// Lifecycle
|
|
851
|
-
// ============================================================================
|
|
852
|
-
async onModuleInit() {
|
|
853
|
-
this.publisher = await createRedisClient(this.redisUrl);
|
|
854
|
-
this.subscriber = await createRedisClient(this.redisUrl);
|
|
855
|
-
this.publisher.on(
|
|
856
|
-
"error",
|
|
857
|
-
(err) => this.logger.error(`Redis publisher error: ${err.message}`, err.stack)
|
|
858
|
-
);
|
|
859
|
-
this.subscriber.on(
|
|
860
|
-
"error",
|
|
861
|
-
(err) => this.logger.error(`Redis subscriber error: ${err.message}`, err.stack)
|
|
862
|
-
);
|
|
863
|
-
this.subscriber.on("message", (channel, message) => {
|
|
864
|
-
void this.handleMessage(channel, message);
|
|
865
|
-
});
|
|
866
|
-
this.connected = true;
|
|
867
|
-
this.logger.log(`RedisEventBus connected to ${this.redisUrl}`);
|
|
868
|
-
}
|
|
869
|
-
async onModuleDestroy() {
|
|
870
|
-
this.connected = false;
|
|
871
|
-
if (this.subscriber) {
|
|
872
|
-
await this.subscriber.unsubscribe();
|
|
873
|
-
this.subscriber.disconnect();
|
|
874
|
-
this.subscriber = null;
|
|
875
|
-
}
|
|
876
|
-
if (this.publisher) {
|
|
877
|
-
this.publisher.disconnect();
|
|
878
|
-
this.publisher = null;
|
|
879
|
-
}
|
|
880
|
-
this.subscribedTypes.clear();
|
|
881
|
-
this.logger.log("RedisEventBus disconnected");
|
|
882
|
-
}
|
|
883
|
-
// ============================================================================
|
|
884
|
-
// IEventBus
|
|
885
|
-
// ============================================================================
|
|
886
|
-
/**
|
|
887
|
-
* Publish a single event.
|
|
888
|
-
*
|
|
889
|
-
* `tx` is accepted but ignored — see module-level JSDoc for details.
|
|
890
|
-
*/
|
|
891
|
-
async publish(event, tx) {
|
|
892
|
-
void tx;
|
|
893
|
-
this.assertConnected();
|
|
894
|
-
const payload = this.serialize(event);
|
|
895
|
-
const channel = `${CHANNEL_PREFIX}${event.type}`;
|
|
896
|
-
await this.publisher.publish(channel, payload);
|
|
897
|
-
}
|
|
898
|
-
/**
|
|
899
|
-
* Publish multiple events using a pipeline so all PUBLISH commands are sent
|
|
900
|
-
* in a single round-trip.
|
|
901
|
-
*
|
|
902
|
-
* `tx` is accepted but ignored — see module-level JSDoc for details.
|
|
903
|
-
*/
|
|
904
|
-
async publishMany(events, tx) {
|
|
905
|
-
void tx;
|
|
906
|
-
if (events.length === 0) return;
|
|
907
|
-
this.assertConnected();
|
|
908
|
-
const pipeline = this.publisher.pipeline();
|
|
909
|
-
for (const event of events) {
|
|
910
|
-
const payload = this.serialize(event);
|
|
911
|
-
const channel = `${CHANNEL_PREFIX}${event.type}`;
|
|
912
|
-
pipeline.publish(channel, payload);
|
|
913
|
-
}
|
|
914
|
-
await pipeline.exec();
|
|
915
|
-
}
|
|
916
|
-
/**
|
|
917
|
-
* Register a handler for a specific event type.
|
|
918
|
-
* Returns an unsubscribe function — call it to remove the handler.
|
|
919
|
-
*
|
|
920
|
-
* On first handler for a type, subscribes to the per-type Redis channel.
|
|
921
|
-
* On removal of the last handler for a type, unsubscribes from the channel.
|
|
922
|
-
*/
|
|
923
|
-
/**
|
|
924
|
-
* Lookup by id is unsupported on the Redis Pub/Sub backend — Pub/Sub
|
|
925
|
-
* does not retain history. Always returns `null`. Logs a warning the
|
|
926
|
-
* first time it's called so a misconfiguration surfaces visibly. Using
|
|
927
|
-
* the bridge with the Redis backend is unsupported (the bridge requires
|
|
928
|
-
* a durable event store).
|
|
929
|
-
*/
|
|
930
|
-
warnedFindById = false;
|
|
931
|
-
async findById(_eventId) {
|
|
932
|
-
if (!this.warnedFindById) {
|
|
933
|
-
this.warnedFindById = true;
|
|
934
|
-
this.logger.warn(
|
|
935
|
-
"RedisEventBus.findById is unsupported (Pub/Sub has no history). The bridge subsystem requires a durable event store; switch to DrizzleEventBus if you need bridge fanout."
|
|
936
|
-
);
|
|
937
|
-
}
|
|
938
|
-
return null;
|
|
939
|
-
}
|
|
940
|
-
subscribe(eventType, handler) {
|
|
941
|
-
if (!this.handlers.has(eventType)) {
|
|
942
|
-
this.handlers.set(eventType, /* @__PURE__ */ new Set());
|
|
943
|
-
void this.subscribeToType(eventType);
|
|
944
|
-
}
|
|
945
|
-
const set = this.handlers.get(eventType);
|
|
946
|
-
const h = handler;
|
|
947
|
-
set.add(h);
|
|
948
|
-
return () => {
|
|
949
|
-
set.delete(h);
|
|
950
|
-
if (set.size === 0) {
|
|
951
|
-
this.handlers.delete(eventType);
|
|
952
|
-
void this.unsubscribeFromType(eventType);
|
|
953
|
-
}
|
|
954
|
-
};
|
|
955
|
-
}
|
|
956
|
-
// ============================================================================
|
|
957
|
-
// Internal helpers
|
|
958
|
-
// ============================================================================
|
|
959
|
-
assertConnected() {
|
|
960
|
-
if (!this.connected || !this.publisher) {
|
|
961
|
-
throw new Error(
|
|
962
|
-
"RedisEventBus is not connected. Ensure the module has been initialised before publishing."
|
|
963
|
-
);
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
serialize(event) {
|
|
967
|
-
return JSON.stringify({
|
|
968
|
-
...event,
|
|
969
|
-
occurredAt: event.occurredAt.toISOString()
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
deserialize(raw) {
|
|
973
|
-
const parsed = JSON.parse(raw);
|
|
974
|
-
return {
|
|
975
|
-
...parsed,
|
|
976
|
-
occurredAt: new Date(parsed.occurredAt)
|
|
977
|
-
};
|
|
978
|
-
}
|
|
979
|
-
async handleMessage(channel, message) {
|
|
980
|
-
let event;
|
|
981
|
-
try {
|
|
982
|
-
event = this.deserialize(message);
|
|
983
|
-
} catch (err) {
|
|
984
|
-
this.logger.warn(`Failed to deserialize event on channel "${channel}": ${err}`);
|
|
985
|
-
return;
|
|
986
|
-
}
|
|
987
|
-
await this.dispatch(event);
|
|
988
|
-
}
|
|
989
|
-
async dispatch(event) {
|
|
990
|
-
const set = this.handlers.get(event.type);
|
|
991
|
-
if (!set) return;
|
|
992
|
-
for (const handler of set) {
|
|
993
|
-
try {
|
|
994
|
-
await handler(event);
|
|
995
|
-
} catch (err) {
|
|
996
|
-
this.logger.error(
|
|
997
|
-
`Handler error for event type "${event.type}" (id: ${event.id}): ${err}`
|
|
998
|
-
);
|
|
999
|
-
}
|
|
1000
|
-
}
|
|
1001
|
-
}
|
|
1002
|
-
/**
|
|
1003
|
-
* Subscribe to a per-type Redis channel.
|
|
1004
|
-
* Called lazily when the first handler is registered for a type.
|
|
1005
|
-
*/
|
|
1006
|
-
async subscribeToType(eventType) {
|
|
1007
|
-
if (this.subscribedTypes.has(eventType)) {
|
|
1008
|
-
return;
|
|
1009
|
-
}
|
|
1010
|
-
const channel = `${CHANNEL_PREFIX}${eventType}`;
|
|
1011
|
-
try {
|
|
1012
|
-
await this.subscriber.subscribe(channel);
|
|
1013
|
-
this.subscribedTypes.add(eventType);
|
|
1014
|
-
} catch (err) {
|
|
1015
|
-
this.logger.error(`Failed to subscribe to channel "${channel}": ${err}`);
|
|
1016
|
-
}
|
|
1017
|
-
}
|
|
1018
|
-
/**
|
|
1019
|
-
* Unsubscribe from a per-type Redis channel.
|
|
1020
|
-
* Called when the last handler for a type is removed.
|
|
1021
|
-
*/
|
|
1022
|
-
async unsubscribeFromType(eventType) {
|
|
1023
|
-
if (!this.subscribedTypes.has(eventType)) {
|
|
1024
|
-
return;
|
|
1025
|
-
}
|
|
1026
|
-
const channel = `${CHANNEL_PREFIX}${eventType}`;
|
|
1027
|
-
try {
|
|
1028
|
-
await this.subscriber.unsubscribe(channel);
|
|
1029
|
-
this.subscribedTypes.delete(eventType);
|
|
1030
|
-
} catch (err) {
|
|
1031
|
-
this.logger.error(`Failed to unsubscribe from channel "${channel}": ${err}`);
|
|
1032
|
-
}
|
|
1033
|
-
}
|
|
1034
|
-
};
|
|
1035
|
-
RedisEventBus = __decorateClass([
|
|
1036
|
-
Injectable4(),
|
|
1037
|
-
__decorateParam(0, Inject4(REDIS_URL))
|
|
1038
|
-
], RedisEventBus);
|
|
1039
|
-
|
|
1040
822
|
// runtime/subsystems/events/events.module.ts
|
|
823
|
+
async function loadRedisEventBus() {
|
|
824
|
+
const specifier = "./event-bus.redis-backend";
|
|
825
|
+
const mod = await import(specifier);
|
|
826
|
+
return mod.RedisEventBus;
|
|
827
|
+
}
|
|
1041
828
|
function buildTypedBusProviders(multiTenant) {
|
|
1042
829
|
return [
|
|
1043
830
|
TypedEventBus,
|
|
@@ -1045,7 +832,7 @@ function buildTypedBusProviders(multiTenant) {
|
|
|
1045
832
|
{ provide: EVENTS_MULTI_TENANT, useValue: multiTenant }
|
|
1046
833
|
];
|
|
1047
834
|
}
|
|
1048
|
-
function buildEventBusAsync(options, db, redisUrl) {
|
|
835
|
+
async function buildEventBusAsync(options, db, redisUrl) {
|
|
1049
836
|
if (options.backend === "drizzle") {
|
|
1050
837
|
if (!db) {
|
|
1051
838
|
throw new Error(
|
|
@@ -1055,6 +842,7 @@ function buildEventBusAsync(options, db, redisUrl) {
|
|
|
1055
842
|
return new DrizzleEventBus(db, options);
|
|
1056
843
|
}
|
|
1057
844
|
if (options.backend === "redis") {
|
|
845
|
+
const RedisEventBus = await loadRedisEventBus();
|
|
1058
846
|
return new RedisEventBus(redisUrl);
|
|
1059
847
|
}
|
|
1060
848
|
return new MemoryEventBus(options);
|
|
@@ -1116,9 +904,20 @@ var EventsModule = class {
|
|
|
1116
904
|
providers: [
|
|
1117
905
|
{ provide: EVENTS_MODULE_OPTIONS, useValue: options },
|
|
1118
906
|
{ provide: REDIS_URL, useValue: resolvedUrl },
|
|
1119
|
-
{
|
|
1120
|
-
|
|
1121
|
-
|
|
907
|
+
{
|
|
908
|
+
// #6: useFactory + dynamic import so the consumer's tsc never
|
|
909
|
+
// needs to resolve `event-bus.redis-backend.ts` for drizzle/
|
|
910
|
+
// memory installs (the file is filtered out by
|
|
911
|
+
// `backendFileFilter`). Nest awaits async factories + manages
|
|
912
|
+
// lifecycle on the returned instance, so we drop the old bare
|
|
913
|
+
// `RedisEventBus` provider entry.
|
|
914
|
+
provide: EVENT_BUS,
|
|
915
|
+
useFactory: async (url) => {
|
|
916
|
+
const RedisEventBus = await loadRedisEventBus();
|
|
917
|
+
return new RedisEventBus(url);
|
|
918
|
+
},
|
|
919
|
+
inject: [REDIS_URL]
|
|
920
|
+
},
|
|
1122
921
|
...buildTypedBusProviders(multiTenant)
|
|
1123
922
|
],
|
|
1124
923
|
exports: [EVENT_BUS, TYPED_EVENT_BUS, EVENTS_MULTI_TENANT]
|
|
@@ -1153,7 +952,6 @@ export {
|
|
|
1153
952
|
EventsModule,
|
|
1154
953
|
MemoryEventBus,
|
|
1155
954
|
MissingTenantIdError,
|
|
1156
|
-
RedisEventBus,
|
|
1157
955
|
TYPED_EVENT_BUS,
|
|
1158
956
|
TypedEventBus,
|
|
1159
957
|
domainEvents
|