@pattern-stack/codegen 0.10.1 → 0.12.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 +122 -0
- package/README.md +5 -5
- package/consumer-skills/codegen/SKILL.md +2 -2
- 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 +8 -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/index.d.ts +11 -7
- package/dist/runtime/subsystems/index.js +1041 -67
- 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/integration/entity-change-source-registry.memory.d.ts +25 -0
- package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js +34 -0
- package/dist/runtime/subsystems/integration/entity-change-source-registry.memory.js.map +1 -0
- package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.d.ts +53 -0
- package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.js +13 -0
- package/dist/runtime/subsystems/integration/entity-change-source-registry.protocol.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 +30 -0
- package/dist/runtime/subsystems/{sync → integration}/index.js +206 -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 +60 -0
- package/dist/runtime/subsystems/integration/integration.tokens.js +20 -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/job-worker.module.d.ts +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 +1336 -376
- package/dist/src/cli/index.js.map +1 -1
- package/dist/src/index.d.ts +70 -22
- package/dist/src/index.js +290 -194
- 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 +9 -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/index.ts +26 -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/integration/entity-change-source-registry.memory.ts +40 -0
- package/runtime/subsystems/integration/entity-change-source-registry.protocol.ts +59 -0
- package/runtime/subsystems/{sync/execute-sync.use-case.ts → integration/execute-integration.use-case.ts} +40 -40
- package/runtime/subsystems/{sync → integration}/index.ts +56 -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 +63 -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/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/clean-lite-ps/entity.ejs.t +12 -3
- package/templates/entity/new/clean-lite-ps/module.ejs.t +1 -1
- package/templates/entity/new/clean-lite-ps/prompt-extension.js +243 -60
- 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/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/entity/new/backend/modules/core/sync-source.providers.ejs.t +0 -18
- 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
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../runtime/subsystems/observability/observability.service.ts","../../../../runtime/subsystems/jobs/jobs-domain.tokens.ts","../../../../runtime/subsystems/events/events.tokens.ts","../../../../runtime/subsystems/bridge/bridge.tokens.ts","../../../../runtime/subsystems/sync/sync.tokens.ts"],"sourcesContent":["/**\n * ObservabilityService — `IObservability` combiner implementation\n * (ADR-025, OBS-5).\n *\n * Composes read methods across the jobs, bridge, and sync subsystems via\n * DI. Owns no state, no schema, no SQL. Every method is a one-line\n * delegation to the sibling port that already encodes the semantics.\n *\n * # Missing-port degradation\n *\n * Every sibling is injected with `@Optional()`. When the consumer's app\n * has not wired a given subsystem, the corresponding field is `undefined`\n * and the delegating method returns an empty shape:\n * - array methods return `[]`\n * - `getBridgeDeliveryHistogram` returns `{ pending: 0, delivered: 0,\n * skipped: 0, failed: 0 }` (matches the bridge protocol's fixed-keys\n * contract so consumers can render a 4-row chart unconditionally).\n *\n * Graceful absence is the whole point of the combiner pattern (ADR-025\n * §Shape, constraint 3) — a consumer that only installed the jobs\n * subsystem can still inject `OBSERVABILITY` and get useful job reads\n * without wiring the rest.\n *\n * # Multi-tenancy\n *\n * `tenantId` passes VERBATIM from the public method to the owning port.\n * `ObservabilityService` never re-implements tenant filtering. See\n * `.claude/skills/observability/SKILL.md` §3 and ADR-025.\n */\nimport { Inject, Injectable, Optional } from '@nestjs/common';\n\nimport { JOB_RUN_SERVICE } from '../jobs/jobs-domain.tokens';\nimport type {\n IJobRunService,\n JobRunFailure,\n JobRunPage,\n JobRunSummary,\n ListJobRunsQuery,\n PoolStatusCount,\n} from '../jobs/job-run-service.protocol';\n\nimport { EVENT_READ_PORT } from '../events/events.tokens';\nimport type {\n EventPage,\n EventSummary,\n IEventReadPort,\n ListEventsQuery,\n} from '../events/event-read.protocol';\n\nimport { BRIDGE_DELIVERY_REPO } from '../bridge/bridge.tokens';\nimport type { IJobBridge, StatusHistogram } from '../bridge/bridge.protocol';\n\nimport { SYNC_CURSOR_STORE, SYNC_RUN_RECORDER } from '../sync/sync.tokens';\nimport type {\n ISyncRunRecorder,\n SyncRunSummary,\n} from '../sync/sync-run-recorder.protocol';\nimport type {\n CursorSnapshot,\n ICursorStore,\n} from '../sync/sync-cursor-store.protocol';\n\nimport type {\n CorrelationTimeline,\n CorrelationTimelineEntry,\n IObservability,\n} from './observability.protocol';\n\n/**\n * Safety bound on how many pages the correlation timeline will walk when\n * draining a sibling port. A single run tree producing more than\n * 50 pages × default page size of correlated rows is pathological; cap to\n * keep the stitch bounded rather than unbounded-loop on bad data.\n */\nconst MAX_TIMELINE_PAGES = 50;\n\n@Injectable()\nexport class ObservabilityService implements IObservability {\n /**\n * All-zero histogram used when the bridge subsystem is absent. Matches\n * the bridge protocol's \"fixed keys, zero-filled\" contract so consumers\n * never branch on presence.\n */\n private static readonly EMPTY_HISTOGRAM: StatusHistogram = {\n pending: 0,\n delivered: 0,\n skipped: 0,\n failed: 0,\n };\n\n /** Empty page used when a sibling read port is absent. */\n private static readonly EMPTY_JOB_RUN_PAGE: JobRunPage = {\n items: [],\n nextCursor: null,\n };\n private static readonly EMPTY_EVENT_PAGE: EventPage = {\n items: [],\n nextCursor: null,\n };\n\n constructor(\n @Optional()\n @Inject(JOB_RUN_SERVICE)\n private readonly jobRuns?: IJobRunService,\n @Optional()\n @Inject(BRIDGE_DELIVERY_REPO)\n private readonly bridge?: IJobBridge,\n @Optional()\n @Inject(SYNC_RUN_RECORDER)\n private readonly syncRuns?: ISyncRunRecorder,\n @Optional()\n @Inject(SYNC_CURSOR_STORE)\n private readonly cursors?: ICursorStore,\n @Optional()\n @Inject(EVENT_READ_PORT)\n private readonly events?: IEventReadPort | null,\n ) {}\n\n async getPoolDepths(tenantId?: string | null): Promise<PoolStatusCount[]> {\n if (!this.jobRuns) return [];\n return this.jobRuns.countByPoolAndStatus(tenantId);\n }\n\n async getRecentFailedJobs(\n limit: number,\n tenantId?: string | null,\n ): Promise<JobRunFailure[]> {\n if (!this.jobRuns) return [];\n return this.jobRuns.listRecentFailed(limit, tenantId);\n }\n\n async getBridgeDeliveryHistogram(\n windowHours: number,\n tenantId?: string | null,\n ): Promise<StatusHistogram> {\n if (!this.bridge) return { ...ObservabilityService.EMPTY_HISTOGRAM };\n return this.bridge.getStatusHistogram(windowHours, tenantId);\n }\n\n async getRecentSyncRuns(\n limit: number,\n subscriptionId?: string,\n tenantId?: string | null,\n ): Promise<SyncRunSummary[]> {\n if (!this.syncRuns) return [];\n return this.syncRuns.listRecent(limit, subscriptionId, tenantId);\n }\n\n async getCursors(tenantId?: string | null): Promise<CursorSnapshot[]> {\n if (!this.cursors) return [];\n return this.cursors.listAll(tenantId);\n }\n\n async listJobRuns(query?: ListJobRunsQuery): Promise<JobRunPage> {\n if (!this.jobRuns) {\n return { ...ObservabilityService.EMPTY_JOB_RUN_PAGE };\n }\n return this.jobRuns.listJobRuns(query);\n }\n\n async listEvents(query?: ListEventsQuery): Promise<EventPage> {\n if (!this.events) {\n return { ...ObservabilityService.EMPTY_EVENT_PAGE };\n }\n return this.events.listEvents(query);\n }\n\n async getCorrelationTimeline(\n rootRunId: string,\n tenantId?: string | null,\n ): Promise<CorrelationTimeline> {\n const runs = await this.collectRuns(rootRunId, tenantId);\n const events = await this.collectEvents(rootRunId, tenantId);\n\n const entries: CorrelationTimelineEntry[] = [\n ...runs.map(\n (run): CorrelationTimelineEntry => ({\n kind: 'job_run',\n at: run.createdAt,\n run,\n }),\n ),\n ...events.map(\n (event): CorrelationTimelineEntry => ({\n kind: 'event',\n at: event.occurredAt,\n event,\n }),\n ),\n ];\n\n // Ascending chronological order. Stable tie-break: job runs before\n // events at the same instant (the run that emits an event precedes it).\n entries.sort((a, b) => {\n const dt = a.at.getTime() - b.at.getTime();\n if (dt !== 0) return dt;\n if (a.kind === b.kind) return 0;\n return a.kind === 'job_run' ? -1 : 1;\n });\n\n const startedAt = entries.length > 0 ? entries[0]!.at : null;\n const lastActivityAt =\n entries.length > 0 ? entries[entries.length - 1]!.at : null;\n\n return {\n rootRunId,\n entries,\n summary: {\n runCount: runs.length,\n eventCount: events.length,\n startedAt,\n lastActivityAt,\n },\n };\n }\n\n /**\n * Drain every `job_run` sharing `rootRunId` by walking the keyset cursor.\n * Empty when the jobs subsystem is absent.\n */\n private async collectRuns(\n rootRunId: string,\n tenantId?: string | null,\n ): Promise<JobRunSummary[]> {\n if (!this.jobRuns) return [];\n const out: JobRunSummary[] = [];\n let cursor: string | undefined;\n for (let page = 0; page < MAX_TIMELINE_PAGES; page += 1) {\n const result = await this.jobRuns.listJobRuns({\n rootRunId,\n tenantId,\n cursor,\n });\n out.push(...result.items);\n if (!result.nextCursor) break;\n cursor = result.nextCursor;\n }\n return out;\n }\n\n /**\n * Drain every `domain_event` whose `metadata.rootRunId` matches by walking\n * the keyset cursor. Empty when the events read port is absent.\n */\n private async collectEvents(\n rootRunId: string,\n tenantId?: string | null,\n ): Promise<EventSummary[]> {\n if (!this.events) return [];\n const out: EventSummary[] = [];\n let cursor: string | undefined;\n for (let page = 0; page < MAX_TIMELINE_PAGES; page += 1) {\n const result = await this.events.listEvents({\n rootRunId,\n tenantId,\n cursor,\n });\n out.push(...result.items);\n if (!result.nextCursor) break;\n cursor = result.nextCursor;\n }\n return out;\n }\n}\n","/**\n * Injection tokens for the job orchestration domain layer (ADR-022, JOB-2).\n *\n * Consumer code injects these symbols via `@Inject(JOB_ORCHESTRATOR)` etc.;\n * concrete backends (JOB-3 Drizzle, JOB-4 Memory) provide the implementations\n * through `JobsDomainModule.forRoot({ backend })` in JOB-5.\n *\n * Each token is a unique `Symbol` — guaranteed distinct from every other\n * Symbol at runtime, which is exactly the uniqueness guarantee Nest's DI\n * container relies on for token-based lookup.\n */\nexport const JOB_ORCHESTRATOR = Symbol('JOB_ORCHESTRATOR');\nexport const JOB_RUN_SERVICE = Symbol('JOB_RUN_SERVICE');\nexport const JOB_STEP_SERVICE = Symbol('JOB_STEP_SERVICE');\n\n/**\n * Multi-tenancy opt-in flag (JOB-8). Bound to the boolean passed in via\n * `JobsDomainModule.forRoot({ multiTenant })`, defaulting to `false`.\n *\n * When `true`, the four service-layer backends (Drizzle + Memory orchestrator\n * and run-service) enforce `tenantId` on every mutating / targeted-read call:\n * `start`, `cancel`, `listForScope`, `cancelForScope`, `rescheduleForScope`.\n * Missing (`undefined`) `tenantId` throws `MissingTenantIdError`; explicit\n * `null` opts into cross-tenant background work and passes through.\n *\n * The JobWorker claim loop is **cross-tenant by design** — the worker has no\n * tenant context; `tenantId` is populated at write time and enforced on\n * targeted reads. See docs/specs/JOB-8.md.\n */\nexport const JOBS_MULTI_TENANT = Symbol('JOBS_MULTI_TENANT');\n","/**\n * Injection token for the event bus.\n *\n * String constant (not Symbol) so it matches by value across import boundaries.\n * Matches the token in runtime/constants/tokens.ts — both are 'EVENT_BUS'.\n *\n * Usage in use cases:\n * ```typescript\n * constructor(@Inject(EVENT_BUS) private readonly eventBus: IEventBus) {}\n * ```\n */\nexport const EVENT_BUS = 'EVENT_BUS' as const;\n\n/**\n * Injection token for the read-side `IEventReadPort` over `domain_events`\n * (OBS-LIST-1).\n *\n * Bound by `EventsModule.forRoot` to the same backend instance as\n * `EVENT_BUS` for the `drizzle` and `memory` backends (both implement\n * `IEventReadPort`). The `redis` backend retains no history and therefore\n * does NOT provide this token — consumers composing it (e.g. the\n * observability combiner) inject it `@Optional()` and degrade to empty\n * results.\n *\n * String constant (not Symbol) so it matches by value across import\n * boundaries — same convention as `EVENT_BUS`.\n */\nexport const EVENT_READ_PORT = 'EVENT_READ_PORT' as const;\n\n/**\n * Injection token for the generated `TypedEventBus` facade.\n *\n * `TypedEventBus` lives in `runtime/subsystems/events/generated/bus.ts` and\n * wraps `IEventBus` with project-specific `AppDomainEvent`-typed `publish<T>()`\n * and `subscribe<T>()`. Use cases inject this token in preference to\n * `EVENT_BUS` when they want compile-time type safety on event shapes.\n *\n * String constant (not Symbol) so it matches by value across import\n * boundaries — same convention as `EVENT_BUS`.\n *\n * Provider registration lands in EVT-6 (EventsModule wiring); the token is\n * declared here so generated code can import it without depending on the\n * still-being-formalised module.\n */\nexport const TYPED_EVENT_BUS = 'TYPED_EVENT_BUS' as const;\n\n/**\n * Injection token for the resolved multi-tenancy flag.\n *\n * Provided by `EventsModule.forRoot(...)` as `options.multiTenant ?? false`.\n * Consumed by `TypedEventBus` to enforce the tenantId-is-required rule at\n * publish time.\n *\n * String constant (not Symbol) so it matches by value across import\n * boundaries — same convention as the other events tokens. (The jobs\n * subsystem uses Symbols for the analogous token; events chose strings\n * from the start and we keep the file internally consistent.)\n */\nexport const EVENTS_MULTI_TENANT = 'EVENTS_MULTI_TENANT' as const;\n\n/**\n * Injection token for the Redis connection URL used by RedisEventBus.\n * Provided automatically by EventsModule.forRoot({ backend: 'redis' }).\n */\nexport const REDIS_URL = Symbol('REDIS_URL');\n\n/**\n * Injection token for the resolved `EventsModuleOptions` object.\n *\n * Provided automatically by `EventsModule.forRoot(...)` /\n * `EventsModule.forRootAsync(...)`. Backends that need to observe module\n * configuration (e.g. `DrizzleEventBus` reading `opts.pools` for\n * pool-filtered drain) inject via this token.\n *\n * String-valued (not `Symbol`) so it matches by value across import\n * boundaries — same convention as `EVENT_BUS`.\n */\nexport const EVENTS_MODULE_OPTIONS = 'EVENTS_MODULE_OPTIONS' as const;\n","/**\n * Injection tokens for the bridge subsystem (ADR-023 Phase 2, BRIDGE-2).\n *\n * String constants (not Symbols) so they match by value across import\n * boundaries — same convention as `EVENT_BUS` / `EVENTS_MULTI_TENANT` in the\n * events subsystem (per EVT-6 §Implementation Notes). The jobs subsystem\n * uses Symbols for its analogous tokens; we keep the bridge file internally\n * consistent with the events convention because the bridge is conceptually\n * downstream of (and imports from) the events module.\n */\n\n/**\n * Token for the `IJobBridge` repo backend (memory in BRIDGE-3, Drizzle in\n * BRIDGE-4). Consumed by `BridgeDeliveryHandler` (BRIDGE-5), the outbox\n * drain (BRIDGE-4 modification), and `EventFlowService` (BRIDGE-7).\n */\nexport const BRIDGE_DELIVERY_REPO = 'BRIDGE_DELIVERY_REPO' as const;\n\n/**\n * Token for the `IEventFlow` facade implementation (BRIDGE-7). Use cases\n * inject this in preference to `EVENT_BUS` / `TYPED_EVENT_BUS` — calling\n * `eventFlow.publish(...)` / `eventFlow.publishAndStart(...)` is the\n * sanctioned authoring surface (ADR-023 §Decision 7).\n */\nexport const EVENT_FLOW = 'EVENT_FLOW' as const;\n\n/**\n * Token for the resolved multi-tenancy flag, provided by\n * `BridgeModule.forRoot({ multiTenant })` in BRIDGE-8. Consumed by\n * `EventFlowService.publishAndStart` (entry), `BridgeDeliveryHandler.handle`\n * (entry), and `DrizzleBridgeDeliveryRepo.insertDelivery` (pre-write) — the\n * three enforcement sites called out in ADR-023 §Multi-tenancy.\n */\nexport const BRIDGE_MULTI_TENANT = 'BRIDGE_MULTI_TENANT' as const;\n\n/**\n * Token for the resolved `BridgeModuleOptions` object. Provided by\n * `BridgeModule.forRoot(...)` / `forRootAsync(...)` in BRIDGE-8.\n * Mirrors `EVENTS_MODULE_OPTIONS` and `JOBS_DOMAIN_OPTIONS` shape — backends\n * inject this when they need to observe additional module configuration\n * (e.g. pool overrides) without each adding a dedicated token.\n */\nexport const BRIDGE_MODULE_OPTIONS = 'BRIDGE_MODULE_OPTIONS' as const;\n\n/**\n * Token for the codegen-emitted `bridgeRegistry` — the\n * `Record<EventTypeName, BridgeTriggerEntry[]>` map that drives\n * outbox-drain trigger lookup (BRIDGE-4) and `EventFlowService` Case B\n * dedup (BRIDGE-7). Provider registration lands in BRIDGE-8; the token is\n * declared here so generated code (BRIDGE-6) can import it without\n * depending on the still-being-formalised module.\n */\nexport const BRIDGE_REGISTRY = 'BRIDGE_REGISTRY' as const;\n\n\n/**\n * Token for the `IBridgeOutboxDrainHook` implementation (BRIDGE-4).\n * Injected `@Optional()` into `DrizzleEventBus` — when the bridge\n * subsystem is not installed the token is undefined and the events\n * outbox drain skips the bridge block entirely (preserves EVT-4\n * baseline behaviour).\n *\n * Resolution order: `BridgeModule.forRoot()` provides this token in\n * BRIDGE-8 alongside the rest of the bridge subsystem. `EventsModule`\n * itself never provides it; the events subsystem stays unaware of the\n * bridge unless the consumer wires it.\n */\nexport const BRIDGE_OUTBOX_DRAIN_HOOK = 'BRIDGE_OUTBOX_DRAIN_HOOK' as const;\n","/**\n * Sync subsystem — DI tokens\n *\n * String constants (not Symbols) so they match by value across import\n * boundaries — same convention as the events subsystem (`EVENT_BUS`). The\n * jobs subsystem uses Symbols for its analogous tokens; events and sync\n * stay internally consistent with strings.\n *\n * Usage in use cases:\n * ```ts\n * constructor(\n * @Inject(SYNC_CHANGE_SOURCE) private readonly source: IChangeSource<CanonicalOpportunity>,\n * @Inject(SYNC_CURSOR_STORE) private readonly cursors: ICursorStore,\n * @Inject(SYNC_FIELD_DIFFER) private readonly differ: IFieldDiffer<CanonicalOpportunity>,\n * @Inject(SYNC_SINK) private readonly sink: ISyncSink<CanonicalOpportunity>,\n * @Inject(SYNC_RUN_RECORDER) private readonly recorder: ISyncRunRecorder,\n * ) {}\n * ```\n *\n * Concrete bindings are registered by `SyncModule.forRoot(...)` (SYNC-6).\n */\n\nexport const SYNC_CHANGE_SOURCE = 'SYNC_CHANGE_SOURCE' as const;\nexport const SYNC_CURSOR_STORE = 'SYNC_CURSOR_STORE' as const;\nexport const SYNC_FIELD_DIFFER = 'SYNC_FIELD_DIFFER' as const;\nexport const SYNC_SINK = 'SYNC_SINK' as const;\n\n/**\n * Run-recorder token (SYNC-5). Backed by `ISyncRunRecorder`. Drizzle impl\n * lands in SYNC-4; tests provide inline fakes.\n */\nexport const SYNC_RUN_RECORDER = 'SYNC_RUN_RECORDER' as const;\n\n/**\n * Injection token for the resolved `SyncModuleOptions` object (SYNC-6).\n *\n * Backends that need to observe module configuration (e.g. `multiTenant`\n * flag, pool filters) inject via this token. Provided automatically by\n * `SyncModule.forRoot(...)` / `SyncModule.forRootAsync(...)`.\n */\nexport const SYNC_MODULE_OPTIONS = 'SYNC_MODULE_OPTIONS' as const;\n\n/**\n * Injection token for the resolved multi-tenancy flag (SYNC-6).\n *\n * Provided by `SyncModule.forRoot(...)` as `options.multiTenant ?? false`.\n * Consumed by `ExecuteSyncUseCase` to enforce the tenantId-is-required rule.\n */\nexport const SYNC_MULTI_TENANT = 'SYNC_MULTI_TENANT' as const;\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,SAAS,QAAQ,YAAY,gBAAgB;;;ACjBtC,IAAM,kBAAkB,u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time/subsystems/observability/observability.service.ts","../../../../runtime/subsystems/jobs/jobs-domain.tokens.ts","../../../../runtime/subsystems/events/events.tokens.ts","../../../../runtime/subsystems/bridge/bridge.tokens.ts","../../../../runtime/subsystems/integration/integration.tokens.ts"],"sourcesContent":["/**\n * ObservabilityService — `IObservability` combiner implementation\n * (ADR-025, OBS-5).\n *\n * Composes read methods across the jobs, bridge, and integration subsystems via\n * DI. Owns no state, no schema, no SQL. Every method is a one-line\n * delegation to the sibling port that already encodes the semantics.\n *\n * # Missing-port degradation\n *\n * Every sibling is injected with `@Optional()`. When the consumer's app\n * has not wired a given subsystem, the corresponding field is `undefined`\n * and the delegating method returns an empty shape:\n * - array methods return `[]`\n * - `getBridgeDeliveryHistogram` returns `{ pending: 0, delivered: 0,\n * skipped: 0, failed: 0 }` (matches the bridge protocol's fixed-keys\n * contract so consumers can render a 4-row chart unconditionally).\n *\n * Graceful absence is the whole point of the combiner pattern (ADR-025\n * §Shape, constraint 3) — a consumer that only installed the jobs\n * subsystem can still inject `OBSERVABILITY` and get useful job reads\n * without wiring the rest.\n *\n * # Multi-tenancy\n *\n * `tenantId` passes VERBATIM from the public method to the owning port.\n * `ObservabilityService` never re-implements tenant filtering. See\n * `.claude/skills/observability/SKILL.md` §3 and ADR-025.\n */\nimport { Inject, Injectable, Optional } from '@nestjs/common';\n\nimport { JOB_RUN_SERVICE } from '../jobs/jobs-domain.tokens';\nimport type {\n IJobRunService,\n JobRunFailure,\n JobRunPage,\n JobRunSummary,\n ListJobRunsQuery,\n PoolStatusCount,\n} from '../jobs/job-run-service.protocol';\n\nimport { EVENT_READ_PORT } from '../events/events.tokens';\nimport type {\n EventPage,\n EventSummary,\n IEventReadPort,\n ListEventsQuery,\n} from '../events/event-read.protocol';\n\nimport { BRIDGE_DELIVERY_REPO } from '../bridge/bridge.tokens';\nimport type { IJobBridge, StatusHistogram } from '../bridge/bridge.protocol';\n\nimport { INTEGRATION_CURSOR_STORE, INTEGRATION_RUN_RECORDER } from '../integration/integration.tokens';\nimport type {\n IIntegrationRunRecorder,\n IntegrationRunSummary,\n} from '../integration/integration-run-recorder.protocol';\nimport type {\n CursorSnapshot,\n ICursorStore,\n} from '../integration/integration-cursor-store.protocol';\n\nimport type {\n CorrelationTimeline,\n CorrelationTimelineEntry,\n IObservability,\n} from './observability.protocol';\n\n/**\n * Safety bound on how many pages the correlation timeline will walk when\n * draining a sibling port. A single run tree producing more than\n * 50 pages × default page size of correlated rows is pathological; cap to\n * keep the stitch bounded rather than unbounded-loop on bad data.\n */\nconst MAX_TIMELINE_PAGES = 50;\n\n@Injectable()\nexport class ObservabilityService implements IObservability {\n /**\n * All-zero histogram used when the bridge subsystem is absent. Matches\n * the bridge protocol's \"fixed keys, zero-filled\" contract so consumers\n * never branch on presence.\n */\n private static readonly EMPTY_HISTOGRAM: StatusHistogram = {\n pending: 0,\n delivered: 0,\n skipped: 0,\n failed: 0,\n };\n\n /** Empty page used when a sibling read port is absent. */\n private static readonly EMPTY_JOB_RUN_PAGE: JobRunPage = {\n items: [],\n nextCursor: null,\n };\n private static readonly EMPTY_EVENT_PAGE: EventPage = {\n items: [],\n nextCursor: null,\n };\n\n constructor(\n @Optional()\n @Inject(JOB_RUN_SERVICE)\n private readonly jobRuns?: IJobRunService,\n @Optional()\n @Inject(BRIDGE_DELIVERY_REPO)\n private readonly bridge?: IJobBridge,\n @Optional()\n @Inject(INTEGRATION_RUN_RECORDER)\n private readonly integrationRuns?: IIntegrationRunRecorder,\n @Optional()\n @Inject(INTEGRATION_CURSOR_STORE)\n private readonly cursors?: ICursorStore,\n @Optional()\n @Inject(EVENT_READ_PORT)\n private readonly events?: IEventReadPort | null,\n ) {}\n\n async getPoolDepths(tenantId?: string | null): Promise<PoolStatusCount[]> {\n if (!this.jobRuns) return [];\n return this.jobRuns.countByPoolAndStatus(tenantId);\n }\n\n async getRecentFailedJobs(\n limit: number,\n tenantId?: string | null,\n ): Promise<JobRunFailure[]> {\n if (!this.jobRuns) return [];\n return this.jobRuns.listRecentFailed(limit, tenantId);\n }\n\n async getBridgeDeliveryHistogram(\n windowHours: number,\n tenantId?: string | null,\n ): Promise<StatusHistogram> {\n if (!this.bridge) return { ...ObservabilityService.EMPTY_HISTOGRAM };\n return this.bridge.getStatusHistogram(windowHours, tenantId);\n }\n\n async getRecentIntegrationRuns(\n limit: number,\n subscriptionId?: string,\n tenantId?: string | null,\n ): Promise<IntegrationRunSummary[]> {\n if (!this.integrationRuns) return [];\n return this.integrationRuns.listRecent(limit, subscriptionId, tenantId);\n }\n\n async getCursors(tenantId?: string | null): Promise<CursorSnapshot[]> {\n if (!this.cursors) return [];\n return this.cursors.listAll(tenantId);\n }\n\n async listJobRuns(query?: ListJobRunsQuery): Promise<JobRunPage> {\n if (!this.jobRuns) {\n return { ...ObservabilityService.EMPTY_JOB_RUN_PAGE };\n }\n return this.jobRuns.listJobRuns(query);\n }\n\n async listEvents(query?: ListEventsQuery): Promise<EventPage> {\n if (!this.events) {\n return { ...ObservabilityService.EMPTY_EVENT_PAGE };\n }\n return this.events.listEvents(query);\n }\n\n async getCorrelationTimeline(\n rootRunId: string,\n tenantId?: string | null,\n ): Promise<CorrelationTimeline> {\n const runs = await this.collectRuns(rootRunId, tenantId);\n const events = await this.collectEvents(rootRunId, tenantId);\n\n const entries: CorrelationTimelineEntry[] = [\n ...runs.map(\n (run): CorrelationTimelineEntry => ({\n kind: 'job_run',\n at: run.createdAt,\n run,\n }),\n ),\n ...events.map(\n (event): CorrelationTimelineEntry => ({\n kind: 'event',\n at: event.occurredAt,\n event,\n }),\n ),\n ];\n\n // Ascending chronological order. Stable tie-break: job runs before\n // events at the same instant (the run that emits an event precedes it).\n entries.sort((a, b) => {\n const dt = a.at.getTime() - b.at.getTime();\n if (dt !== 0) return dt;\n if (a.kind === b.kind) return 0;\n return a.kind === 'job_run' ? -1 : 1;\n });\n\n const startedAt = entries.length > 0 ? entries[0]!.at : null;\n const lastActivityAt =\n entries.length > 0 ? entries[entries.length - 1]!.at : null;\n\n return {\n rootRunId,\n entries,\n summary: {\n runCount: runs.length,\n eventCount: events.length,\n startedAt,\n lastActivityAt,\n },\n };\n }\n\n /**\n * Drain every `job_run` sharing `rootRunId` by walking the keyset cursor.\n * Empty when the jobs subsystem is absent.\n */\n private async collectRuns(\n rootRunId: string,\n tenantId?: string | null,\n ): Promise<JobRunSummary[]> {\n if (!this.jobRuns) return [];\n const out: JobRunSummary[] = [];\n let cursor: string | undefined;\n for (let page = 0; page < MAX_TIMELINE_PAGES; page += 1) {\n const result = await this.jobRuns.listJobRuns({\n rootRunId,\n tenantId,\n cursor,\n });\n out.push(...result.items);\n if (!result.nextCursor) break;\n cursor = result.nextCursor;\n }\n return out;\n }\n\n /**\n * Drain every `domain_event` whose `metadata.rootRunId` matches by walking\n * the keyset cursor. Empty when the events read port is absent.\n */\n private async collectEvents(\n rootRunId: string,\n tenantId?: string | null,\n ): Promise<EventSummary[]> {\n if (!this.events) return [];\n const out: EventSummary[] = [];\n let cursor: string | undefined;\n for (let page = 0; page < MAX_TIMELINE_PAGES; page += 1) {\n const result = await this.events.listEvents({\n rootRunId,\n tenantId,\n cursor,\n });\n out.push(...result.items);\n if (!result.nextCursor) break;\n cursor = result.nextCursor;\n }\n return out;\n }\n}\n","/**\n * Injection tokens for the job orchestration domain layer (ADR-022, JOB-2).\n *\n * Consumer code injects these symbols via `@Inject(JOB_ORCHESTRATOR)` etc.;\n * concrete backends (JOB-3 Drizzle, JOB-4 Memory) provide the implementations\n * through `JobsDomainModule.forRoot({ backend })` in JOB-5.\n *\n * Each token is a unique `Symbol` — guaranteed distinct from every other\n * Symbol at runtime, which is exactly the uniqueness guarantee Nest's DI\n * container relies on for token-based lookup.\n */\nexport const JOB_ORCHESTRATOR = Symbol('JOB_ORCHESTRATOR');\nexport const JOB_RUN_SERVICE = Symbol('JOB_RUN_SERVICE');\nexport const JOB_STEP_SERVICE = Symbol('JOB_STEP_SERVICE');\n\n/**\n * Multi-tenancy opt-in flag (JOB-8). Bound to the boolean passed in via\n * `JobsDomainModule.forRoot({ multiTenant })`, defaulting to `false`.\n *\n * When `true`, the four service-layer backends (Drizzle + Memory orchestrator\n * and run-service) enforce `tenantId` on every mutating / targeted-read call:\n * `start`, `cancel`, `listForScope`, `cancelForScope`, `rescheduleForScope`.\n * Missing (`undefined`) `tenantId` throws `MissingTenantIdError`; explicit\n * `null` opts into cross-tenant background work and passes through.\n *\n * The JobWorker claim loop is **cross-tenant by design** — the worker has no\n * tenant context; `tenantId` is populated at write time and enforced on\n * targeted reads. See docs/specs/JOB-8.md.\n */\nexport const JOBS_MULTI_TENANT = Symbol('JOBS_MULTI_TENANT');\n","/**\n * Injection token for the event bus.\n *\n * String constant (not Symbol) so it matches by value across import boundaries.\n * Matches the token in runtime/constants/tokens.ts — both are 'EVENT_BUS'.\n *\n * Usage in use cases:\n * ```typescript\n * constructor(@Inject(EVENT_BUS) private readonly eventBus: IEventBus) {}\n * ```\n */\nexport const EVENT_BUS = 'EVENT_BUS' as const;\n\n/**\n * Injection token for the read-side `IEventReadPort` over `domain_events`\n * (OBS-LIST-1).\n *\n * Bound by `EventsModule.forRoot` to the same backend instance as\n * `EVENT_BUS` for the `drizzle` and `memory` backends (both implement\n * `IEventReadPort`). The `redis` backend retains no history and therefore\n * does NOT provide this token — consumers composing it (e.g. the\n * observability combiner) inject it `@Optional()` and degrade to empty\n * results.\n *\n * String constant (not Symbol) so it matches by value across import\n * boundaries — same convention as `EVENT_BUS`.\n */\nexport const EVENT_READ_PORT = 'EVENT_READ_PORT' as const;\n\n/**\n * Injection token for the generated `TypedEventBus` facade.\n *\n * `TypedEventBus` lives in `runtime/subsystems/events/generated/bus.ts` and\n * wraps `IEventBus` with project-specific `AppDomainEvent`-typed `publish<T>()`\n * and `subscribe<T>()`. Use cases inject this token in preference to\n * `EVENT_BUS` when they want compile-time type safety on event shapes.\n *\n * String constant (not Symbol) so it matches by value across import\n * boundaries — same convention as `EVENT_BUS`.\n *\n * Provider registration lands in EVT-6 (EventsModule wiring); the token is\n * declared here so generated code can import it without depending on the\n * still-being-formalised module.\n */\nexport const TYPED_EVENT_BUS = 'TYPED_EVENT_BUS' as const;\n\n/**\n * Injection token for the resolved multi-tenancy flag.\n *\n * Provided by `EventsModule.forRoot(...)` as `options.multiTenant ?? false`.\n * Consumed by `TypedEventBus` to enforce the tenantId-is-required rule at\n * publish time.\n *\n * String constant (not Symbol) so it matches by value across import\n * boundaries — same convention as the other events tokens. (The jobs\n * subsystem uses Symbols for the analogous token; events chose strings\n * from the start and we keep the file internally consistent.)\n */\nexport const EVENTS_MULTI_TENANT = 'EVENTS_MULTI_TENANT' as const;\n\n/**\n * Injection token for the Redis connection URL used by RedisEventBus.\n * Provided automatically by EventsModule.forRoot({ backend: 'redis' }).\n */\nexport const REDIS_URL = Symbol('REDIS_URL');\n\n/**\n * Injection token for the resolved `EventsModuleOptions` object.\n *\n * Provided automatically by `EventsModule.forRoot(...)` /\n * `EventsModule.forRootAsync(...)`. Backends that need to observe module\n * configuration (e.g. `DrizzleEventBus` reading `opts.pools` for\n * pool-filtered drain) inject via this token.\n *\n * String-valued (not `Symbol`) so it matches by value across import\n * boundaries — same convention as `EVENT_BUS`.\n */\nexport const EVENTS_MODULE_OPTIONS = 'EVENTS_MODULE_OPTIONS' as const;\n","/**\n * Injection tokens for the bridge subsystem (ADR-023 Phase 2, BRIDGE-2).\n *\n * String constants (not Symbols) so they match by value across import\n * boundaries — same convention as `EVENT_BUS` / `EVENTS_MULTI_TENANT` in the\n * events subsystem (per EVT-6 §Implementation Notes). The jobs subsystem\n * uses Symbols for its analogous tokens; we keep the bridge file internally\n * consistent with the events convention because the bridge is conceptually\n * downstream of (and imports from) the events module.\n */\n\n/**\n * Token for the `IJobBridge` repo backend (memory in BRIDGE-3, Drizzle in\n * BRIDGE-4). Consumed by `BridgeDeliveryHandler` (BRIDGE-5), the outbox\n * drain (BRIDGE-4 modification), and `EventFlowService` (BRIDGE-7).\n */\nexport const BRIDGE_DELIVERY_REPO = 'BRIDGE_DELIVERY_REPO' as const;\n\n/**\n * Token for the `IEventFlow` facade implementation (BRIDGE-7). Use cases\n * inject this in preference to `EVENT_BUS` / `TYPED_EVENT_BUS` — calling\n * `eventFlow.publish(...)` / `eventFlow.publishAndStart(...)` is the\n * sanctioned authoring surface (ADR-023 §Decision 7).\n */\nexport const EVENT_FLOW = 'EVENT_FLOW' as const;\n\n/**\n * Token for the resolved multi-tenancy flag, provided by\n * `BridgeModule.forRoot({ multiTenant })` in BRIDGE-8. Consumed by\n * `EventFlowService.publishAndStart` (entry), `BridgeDeliveryHandler.handle`\n * (entry), and `DrizzleBridgeDeliveryRepo.insertDelivery` (pre-write) — the\n * three enforcement sites called out in ADR-023 §Multi-tenancy.\n */\nexport const BRIDGE_MULTI_TENANT = 'BRIDGE_MULTI_TENANT' as const;\n\n/**\n * Token for the resolved `BridgeModuleOptions` object. Provided by\n * `BridgeModule.forRoot(...)` / `forRootAsync(...)` in BRIDGE-8.\n * Mirrors `EVENTS_MODULE_OPTIONS` and `JOBS_DOMAIN_OPTIONS` shape — backends\n * inject this when they need to observe additional module configuration\n * (e.g. pool overrides) without each adding a dedicated token.\n */\nexport const BRIDGE_MODULE_OPTIONS = 'BRIDGE_MODULE_OPTIONS' as const;\n\n/**\n * Token for the codegen-emitted `bridgeRegistry` — the\n * `Record<EventTypeName, BridgeTriggerEntry[]>` map that drives\n * outbox-drain trigger lookup (BRIDGE-4) and `EventFlowService` Case B\n * dedup (BRIDGE-7). Provider registration lands in BRIDGE-8; the token is\n * declared here so generated code (BRIDGE-6) can import it without\n * depending on the still-being-formalised module.\n */\nexport const BRIDGE_REGISTRY = 'BRIDGE_REGISTRY' as const;\n\n\n/**\n * Token for the `IBridgeOutboxDrainHook` implementation (BRIDGE-4).\n * Injected `@Optional()` into `DrizzleEventBus` — when the bridge\n * subsystem is not installed the token is undefined and the events\n * outbox drain skips the bridge block entirely (preserves EVT-4\n * baseline behaviour).\n *\n * Resolution order: `BridgeModule.forRoot()` provides this token in\n * BRIDGE-8 alongside the rest of the bridge subsystem. `EventsModule`\n * itself never provides it; the events subsystem stays unaware of the\n * bridge unless the consumer wires it.\n */\nexport const BRIDGE_OUTBOX_DRAIN_HOOK = 'BRIDGE_OUTBOX_DRAIN_HOOK' as const;\n","/**\n * Integration subsystem — DI tokens\n *\n * String constants (not Symbols) so they match by value across import\n * boundaries — same convention as the events subsystem (`EVENT_BUS`). The\n * jobs subsystem uses Symbols for its analogous tokens; events and integration\n * stay internally consistent with strings.\n *\n * Usage in use cases:\n * ```ts\n * constructor(\n * @Inject(INTEGRATION_CHANGE_SOURCE) private readonly source: IChangeSource<CanonicalOpportunity>,\n * @Inject(INTEGRATION_CURSOR_STORE) private readonly cursors: ICursorStore,\n * @Inject(INTEGRATION_FIELD_DIFFER) private readonly differ: IFieldDiffer<CanonicalOpportunity>,\n * @Inject(INTEGRATION_SINK) private readonly sink: IIntegrationSink<CanonicalOpportunity>,\n * @Inject(INTEGRATION_RUN_RECORDER) private readonly recorder: IIntegrationRunRecorder,\n * ) {}\n * ```\n *\n * Concrete bindings are registered by `IntegrationModule.forRoot(...)` (SYNC-6).\n */\n\nexport const INTEGRATION_CHANGE_SOURCE = 'INTEGRATION_CHANGE_SOURCE' as const;\nexport const INTEGRATION_CURSOR_STORE = 'INTEGRATION_CURSOR_STORE' as const;\nexport const INTEGRATION_FIELD_DIFFER = 'INTEGRATION_FIELD_DIFFER' as const;\nexport const INTEGRATION_SINK = 'INTEGRATION_SINK' as const;\n\n/**\n * Run-recorder token (SYNC-5). Backed by `IIntegrationRunRecorder`. Drizzle impl\n * lands in SYNC-4; tests provide inline fakes.\n */\nexport const INTEGRATION_RUN_RECORDER = 'INTEGRATION_RUN_RECORDER' as const;\n\n/**\n * Injection token for the resolved `IntegrationModuleOptions` object (SYNC-6).\n *\n * Backends that need to observe module configuration (e.g. `multiTenant`\n * flag, pool filters) inject via this token. Provided automatically by\n * `IntegrationModule.forRoot(...)` / `IntegrationModule.forRootAsync(...)`.\n */\nexport const INTEGRATION_MODULE_OPTIONS = 'INTEGRATION_MODULE_OPTIONS' as const;\n\n/**\n * Injection token for the resolved multi-tenancy flag (SYNC-6).\n *\n * Provided by `IntegrationModule.forRoot(...)` as `options.multiTenant ?? false`.\n * Consumed by `ExecuteIntegrationUseCase` to enforce the tenantId-is-required rule.\n */\nexport const INTEGRATION_MULTI_TENANT = 'INTEGRATION_MULTI_TENANT' as const;\n\n/**\n * Injection token for the entity-keyed `IEntityChangeSourceRegistry` (C7,\n * #336). Bound to the codegen-emitted aggregator that folds per-provider\n * adapter contributions into one registry (RFC-0001 §3, emitted by Track D\n * D3/D4).\n *\n * A string constant, not `Symbol.for(...)`, to match this subsystem's token\n * convention (see file header). The originating issue's code block proposed a\n * `Symbol.for('@pattern-stack/codegen.entity-change-source-registry')` key,\n * predating the sync→integration consolidation onto string tokens; kept as a\n * string here for internal consistency with the other INTEGRATION_* tokens.\n */\nexport const ENTITY_CHANGE_SOURCE_REGISTRY = 'ENTITY_CHANGE_SOURCE_REGISTRY' as const;\n"],"mappings":";;;;;;;;;;;;;;;AA6BA,SAAS,QAAQ,YAAY,gBAAgB;;;ACjBtC,IAAM,kBAAkB,uBAAO,iBAAiB;;;ACehD,IAAM,kBAAkB;;;ACXxB,IAAM,uBAAuB;;;ACO7B,IAAM,2BAA2B;AAQjC,IAAM,2BAA2B;;;AJ2CxC,IAAM,qBAAqB;AAGpB,IAAM,uBAAN,MAAqD;AAAA,EAuB1D,YAGmB,SAGA,QAGA,iBAGA,SAGA,QACjB;AAbiB;AAGA;AAGA;AAGA;AAGA;AAAA,EAChB;AAAA,EAbgB;AAAA,EAGA;AAAA,EAGA;AAAA,EAGA;AAAA,EAGA;AAAA,EAGnB,MAAM,cAAc,UAAsD;AACxE,QAAI,CAAC,KAAK,QAAS,QAAO,CAAC;AAC3B,WAAO,KAAK,QAAQ,qBAAqB,QAAQ;AAAA,EACnD;AAAA,EAEA,MAAM,oBACJ,OACA,UAC0B;AAC1B,QAAI,CAAC,KAA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MACF,CAAC;AACD,UAAI,KAAK,GAAG,OAAO,KAAK;AACxB,UAAI,CAAC,OAAO,WAAY;AACxB,eAAS,OAAO;AAAA,IAClB;AACA,WAAO;AAAA,EACT;AACF;AAAA;AAAA;AAAA;AAAA;AAAA;AApLE,cANW,sBAMa,mBAAmC;AAAA,EACzD,SAAS;AAAA,EACT,WAAW;AAAA,EACX,SAAS;AAAA,EACT,QAAQ;AACV;AAAA;AAGA,cAdW,sBAca,sBAAiC;AAAA,EACvD,OAAO,CAAC;AAAA,EACR,YAAY;AACd;AACA,cAlBW,sBAkBa,oBAA8B;AAAA,EACpD,OAAO,CAAC;AAAA,EACR,YAAY;AACd;AArBW,uBAAN;AAAA,EADN,WAAW;AAAA,EAyBP,4BAAS;AAAA,EACT,0BAAO,eAAe;AAAA,EAEtB,4BAAS;AAAA,EACT,0BAAO,oBAAoB;AAAA,EAE3B,4BAAS;AAAA,EACT,0BAAO,wBAAwB;AAAA,EAE/B,4BAAS;AAAA,EACT,0BAAO,wBAAwB;AAAA,EAE/B,4BAAS;AAAA,EACT,0BAAO,eAAe;AAAA,GArCd;","names":[]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Observability combiner subsystem — DI tokens (ADR-025, OBS-5).
|
|
3
3
|
*
|
|
4
|
-
* String constants (not Symbols), matching the events / bridge /
|
|
4
|
+
* String constants (not Symbols), matching the events / bridge / integration
|
|
5
5
|
* convention. The jobs subsystem uses Symbols for its analogous tokens;
|
|
6
6
|
* observability stays internally consistent with its sibling combiner
|
|
7
7
|
* (bridge) because the two are structurally paired (ADR-025).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../runtime/subsystems/observability/observability.tokens.ts"],"sourcesContent":["/**\n * Observability combiner subsystem — DI tokens (ADR-025, OBS-5).\n *\n * String constants (not Symbols), matching the events / bridge /
|
|
1
|
+
{"version":3,"sources":["../../../../runtime/subsystems/observability/observability.tokens.ts"],"sourcesContent":["/**\n * Observability combiner subsystem — DI tokens (ADR-025, OBS-5).\n *\n * String constants (not Symbols), matching the events / bridge / integration\n * convention. The jobs subsystem uses Symbols for its analogous tokens;\n * observability stays internally consistent with its sibling combiner\n * (bridge) because the two are structurally paired (ADR-025).\n *\n * Usage in consumers:\n * ```ts\n * constructor(@Inject(OBSERVABILITY) private readonly obs: IObservability) {}\n * ```\n */\n\n/**\n * Token for the `IObservability` composer facade (OBS-5). Resolves to the\n * single `ObservabilityService` instance registered by\n * `ObservabilityModule.forRoot(...)`.\n */\nexport const OBSERVABILITY = 'OBSERVABILITY' as const;\n\n/**\n * Token for the resolved `ObservabilityModuleOptions` object. Provided by\n * `ObservabilityModule.forRoot(...)`. Reserved for phase 2 — the current\n * options shape is empty; OBS-6 will extend it with a `reporters` field.\n */\nexport const OBSERVABILITY_MODULE_OPTIONS = 'OBSERVABILITY_MODULE_OPTIONS' as const;\n"],"mappings":";AAmBO,IAAM,gBAAgB;AAOtB,IAAM,+BAA+B;","names":[]}
|
|
@@ -13,10 +13,10 @@ import '../../events/generated/types.js';
|
|
|
13
13
|
import '../../events/event-read.protocol.js';
|
|
14
14
|
import '../../bridge/bridge.protocol.js';
|
|
15
15
|
import '../../bridge/bridge-delivery.schema.js';
|
|
16
|
-
import '../../
|
|
17
|
-
import '../../
|
|
16
|
+
import '../../integration/integration-run-recorder.protocol.js';
|
|
17
|
+
import '../../integration/integration-field-diff.protocol.js';
|
|
18
18
|
import 'zod';
|
|
19
|
-
import '../../
|
|
19
|
+
import '../../integration/integration-cursor-store.protocol.js';
|
|
20
20
|
|
|
21
21
|
/**
|
|
22
22
|
* BridgeMetricsReporter — internal consumer of `IObservability`
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../runtime/subsystems/observability/reporters/bridge-metrics.reporter.ts","../../../../../runtime/subsystems/observability/observability.tokens.ts"],"sourcesContent":["/**\n * BridgeMetricsReporter — internal consumer of `IObservability`\n * (ADR-025, OBS-6).\n *\n * Periodically samples `getBridgeDeliveryHistogram` from the observability\n * facade and emits one log line per tick. Auto-registered by\n * `ObservabilityModule.forRoot()` when\n * `options.reporters.bridgeMetrics.enabled === true`. Consumers configure\n * via options; they never import this class. Not exported from the\n * module's `exports` array — internal.\n *\n * # Invariants (enforced by skill + ADR-025)\n *\n * - Injects ONLY `OBSERVABILITY` + `OBSERVABILITY_MODULE_OPTIONS`. Never\n * `BRIDGE_DELIVERY_REPO` or any other sibling token. Reporters are\n * consumers of the composed facade, not parallel composers.\n * - Never reaches into sibling tables or extends `IObservability`.\n * - Errors isolated per-tick (logged, never rethrown) so a transient\n * sibling failure does not kill the interval.\n * - `tenantId` passes VERBATIM to the facade — observability owns tenant\n * semantics, reporters don't re-implement them.\n *\n * # Lifecycle\n *\n * - `onModuleInit` — eager first-tick, then `setInterval`. Handle is\n * `.unref()`-ed when supported so the loop never blocks node shutdown.\n * - `onModuleDestroy` — `clearInterval` + null the handle. Idempotent.\n *\n * No `@nestjs/schedule` dependency — raw `setInterval` keeps the runtime\n * footprint minimal and avoids pulling a decorator framework in for a\n * single loop.\n */\nimport {\n Inject,\n Injectable,\n Logger,\n type OnModuleDestroy,\n type OnModuleInit,\n} from '@nestjs/common';\n\nimport type { IObservability } from '../observability.protocol';\nimport {\n OBSERVABILITY,\n OBSERVABILITY_MODULE_OPTIONS,\n} from '../observability.tokens';\n// Type-only imports — the module imports this file as a value for DI\n// registration, and this file imports config types back. Keeping the\n// back-edge type-only prevents a runtime circular-import.\nimport type {\n BridgeMetricsReporterConfig,\n ObservabilityModuleOptions,\n} from '../observability.module';\n\n@Injectable()\nexport class BridgeMetricsReporter implements OnModuleInit, OnModuleDestroy {\n private readonly logger = new Logger(BridgeMetricsReporter.name);\n private handle: ReturnType<typeof setInterval> | null = null;\n private readonly config: BridgeMetricsReporterConfig | undefined;\n\n constructor(\n @Inject(OBSERVABILITY) private readonly observability: IObservability,\n @Inject(OBSERVABILITY_MODULE_OPTIONS) options: ObservabilityModuleOptions,\n ) {\n this.config = options.reporters?.bridgeMetrics;\n }\n\n onModuleInit(): void {\n if (!this.config || !this.config.enabled) {\n this.logger.log('BridgeMetricsReporter disabled');\n return;\n }\n if (this.config.intervalMs <= 0 || this.config.windowHours <= 0) {\n this.logger.warn(\n `invalid config; not starting: intervalMs=${this.config.intervalMs} windowHours=${this.config.windowHours}`,\n );\n return;\n }\n // Eager first-tick so consumers see data immediately on boot, without\n // waiting `intervalMs` for the first sample.\n void this.runOnce();\n this.handle = setInterval(() => {\n void this.runOnce();\n }, this.config.intervalMs);\n // `.unref()` lets the node process exit even if the interval is still\n // scheduled — important in short-lived CLI/test contexts. Guarded\n // because browser-shimmed timers may not expose it.\n if (typeof this.handle.unref === 'function') this.handle.unref();\n }\n\n onModuleDestroy(): void {\n if (this.handle !== null) {\n clearInterval(this.handle);\n this.handle = null;\n }\n }\n\n /**\n * Single sample. Public so tests and future ops tooling can trigger a\n * sample on demand without waiting for the interval. Errors are caught\n * and logged here — never rethrown — so a transient sibling failure\n * does not kill subsequent ticks.\n */\n async runOnce(): Promise<void> {\n if (!this.config || !this.config.enabled) return;\n try {\n const h = await this.observability.getBridgeDeliveryHistogram(\n this.config.windowHours,\n this.config.tenantId,\n );\n this.logger.log(\n `bridge-delivery window=${this.config.windowHours}h tenant=${this.config.tenantId ?? 'default'} pending=${h.pending} delivered=${h.delivered} skipped=${h.skipped} failed=${h.failed}`,\n );\n } catch (err) {\n this.logger.error(\n 'BridgeMetricsReporter runOnce failed',\n err instanceof Error ? err.stack : String(err),\n );\n }\n }\n}\n","/**\n * Observability combiner subsystem — DI tokens (ADR-025, OBS-5).\n *\n * String constants (not Symbols), matching the events / bridge /
|
|
1
|
+
{"version":3,"sources":["../../../../../runtime/subsystems/observability/reporters/bridge-metrics.reporter.ts","../../../../../runtime/subsystems/observability/observability.tokens.ts"],"sourcesContent":["/**\n * BridgeMetricsReporter — internal consumer of `IObservability`\n * (ADR-025, OBS-6).\n *\n * Periodically samples `getBridgeDeliveryHistogram` from the observability\n * facade and emits one log line per tick. Auto-registered by\n * `ObservabilityModule.forRoot()` when\n * `options.reporters.bridgeMetrics.enabled === true`. Consumers configure\n * via options; they never import this class. Not exported from the\n * module's `exports` array — internal.\n *\n * # Invariants (enforced by skill + ADR-025)\n *\n * - Injects ONLY `OBSERVABILITY` + `OBSERVABILITY_MODULE_OPTIONS`. Never\n * `BRIDGE_DELIVERY_REPO` or any other sibling token. Reporters are\n * consumers of the composed facade, not parallel composers.\n * - Never reaches into sibling tables or extends `IObservability`.\n * - Errors isolated per-tick (logged, never rethrown) so a transient\n * sibling failure does not kill the interval.\n * - `tenantId` passes VERBATIM to the facade — observability owns tenant\n * semantics, reporters don't re-implement them.\n *\n * # Lifecycle\n *\n * - `onModuleInit` — eager first-tick, then `setInterval`. Handle is\n * `.unref()`-ed when supported so the loop never blocks node shutdown.\n * - `onModuleDestroy` — `clearInterval` + null the handle. Idempotent.\n *\n * No `@nestjs/schedule` dependency — raw `setInterval` keeps the runtime\n * footprint minimal and avoids pulling a decorator framework in for a\n * single loop.\n */\nimport {\n Inject,\n Injectable,\n Logger,\n type OnModuleDestroy,\n type OnModuleInit,\n} from '@nestjs/common';\n\nimport type { IObservability } from '../observability.protocol';\nimport {\n OBSERVABILITY,\n OBSERVABILITY_MODULE_OPTIONS,\n} from '../observability.tokens';\n// Type-only imports — the module imports this file as a value for DI\n// registration, and this file imports config types back. Keeping the\n// back-edge type-only prevents a runtime circular-import.\nimport type {\n BridgeMetricsReporterConfig,\n ObservabilityModuleOptions,\n} from '../observability.module';\n\n@Injectable()\nexport class BridgeMetricsReporter implements OnModuleInit, OnModuleDestroy {\n private readonly logger = new Logger(BridgeMetricsReporter.name);\n private handle: ReturnType<typeof setInterval> | null = null;\n private readonly config: BridgeMetricsReporterConfig | undefined;\n\n constructor(\n @Inject(OBSERVABILITY) private readonly observability: IObservability,\n @Inject(OBSERVABILITY_MODULE_OPTIONS) options: ObservabilityModuleOptions,\n ) {\n this.config = options.reporters?.bridgeMetrics;\n }\n\n onModuleInit(): void {\n if (!this.config || !this.config.enabled) {\n this.logger.log('BridgeMetricsReporter disabled');\n return;\n }\n if (this.config.intervalMs <= 0 || this.config.windowHours <= 0) {\n this.logger.warn(\n `invalid config; not starting: intervalMs=${this.config.intervalMs} windowHours=${this.config.windowHours}`,\n );\n return;\n }\n // Eager first-tick so consumers see data immediately on boot, without\n // waiting `intervalMs` for the first sample.\n void this.runOnce();\n this.handle = setInterval(() => {\n void this.runOnce();\n }, this.config.intervalMs);\n // `.unref()` lets the node process exit even if the interval is still\n // scheduled — important in short-lived CLI/test contexts. Guarded\n // because browser-shimmed timers may not expose it.\n if (typeof this.handle.unref === 'function') this.handle.unref();\n }\n\n onModuleDestroy(): void {\n if (this.handle !== null) {\n clearInterval(this.handle);\n this.handle = null;\n }\n }\n\n /**\n * Single sample. Public so tests and future ops tooling can trigger a\n * sample on demand without waiting for the interval. Errors are caught\n * and logged here — never rethrown — so a transient sibling failure\n * does not kill subsequent ticks.\n */\n async runOnce(): Promise<void> {\n if (!this.config || !this.config.enabled) return;\n try {\n const h = await this.observability.getBridgeDeliveryHistogram(\n this.config.windowHours,\n this.config.tenantId,\n );\n this.logger.log(\n `bridge-delivery window=${this.config.windowHours}h tenant=${this.config.tenantId ?? 'default'} pending=${h.pending} delivered=${h.delivered} skipped=${h.skipped} failed=${h.failed}`,\n );\n } catch (err) {\n this.logger.error(\n 'BridgeMetricsReporter runOnce failed',\n err instanceof Error ? err.stack : String(err),\n );\n }\n }\n}\n","/**\n * Observability combiner subsystem — DI tokens (ADR-025, OBS-5).\n *\n * String constants (not Symbols), matching the events / bridge / integration\n * convention. The jobs subsystem uses Symbols for its analogous tokens;\n * observability stays internally consistent with its sibling combiner\n * (bridge) because the two are structurally paired (ADR-025).\n *\n * Usage in consumers:\n * ```ts\n * constructor(@Inject(OBSERVABILITY) private readonly obs: IObservability) {}\n * ```\n */\n\n/**\n * Token for the `IObservability` composer facade (OBS-5). Resolves to the\n * single `ObservabilityService` instance registered by\n * `ObservabilityModule.forRoot(...)`.\n */\nexport const OBSERVABILITY = 'OBSERVABILITY' as const;\n\n/**\n * Token for the resolved `ObservabilityModuleOptions` object. Provided by\n * `ObservabilityModule.forRoot(...)`. Reserved for phase 2 — the current\n * options shape is empty; OBS-6 will extend it with a `reporters` field.\n */\nexport const OBSERVABILITY_MODULE_OPTIONS = 'OBSERVABILITY_MODULE_OPTIONS' as const;\n"],"mappings":";;;;;;;;;;;;;AAgCA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;;;ACnBA,IAAM,gBAAgB;AAOtB,IAAM,+BAA+B;;;AD4BrC,IAAM,wBAAN,MAAqE;AAAA,EAK1E,YAC0C,eACF,SACtC;AAFwC;AAGxC,SAAK,SAAS,QAAQ,WAAW;AAAA,EACnC;AAAA,EAJ0C;AAAA,EALzB,SAAS,IAAI,OAAO,sBAAsB,IAAI;AAAA,EACvD,SAAgD;AAAA,EACvC;AAAA,EASjB,eAAqB;AACnB,QAAI,CAAC,KAAK,UAAU,CAAC,KAAK,OAAO,SAAS;AACxC,WAAK,OAAO,IAAI,gCAAgC;AAChD;AAAA,IACF;AACA,QAAI,KAAK,OAAO,cAAc,KAAK,KAAK,OAAO,eAAe,GAAG;AAC/D,WAAK,OAAO;AAAA,QACV,4CAA4C,KAAK,OAAO,UAAU,gBAAgB,KAAK,OAAO,WAAW;AAAA,MAC3G;AACA;AAAA,IACF;AAGA,SAAK,KAAK,QAAQ;AAClB,SAAK,SAAS,YAAY,MAAM;AAC9B,WAAK,KAAK,QAAQ;AAAA,IACpB,GAAG,KAAK,OAAO,UAAU;AAIzB,QAAI,OAAO,KAAK,OAAO,UAAU,WAAY,MAAK,OAAO,MAAM;AAAA,EACjE;AAAA,EAEA,kBAAwB;AACtB,QAAI,KAAK,WAAW,MAAM;AACxB,oBAAc,KAAK,MAAM;AACzB,WAAK,SAAS;AAAA,IAChB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UAAyB;AAC7B,QAAI,CAAC,KAAK,UAAU,CAAC,KAAK,OAAO,QAAS;AAC1C,QAAI;AACF,YAAM,IAAI,MAAM,KAAK,cAAc;AAAA,QACjC,KAAK,OAAO;AAAA,QACZ,KAAK,OAAO;AAAA,MACd;AACA,WAAK,OAAO;AAAA,QACV,0BAA0B,KAAK,OAAO,WAAW,YAAY,KAAK,OAAO,YAAY,SAAS,YAAY,EAAE,OAAO,cAAc,EAAE,SAAS,YAAY,EAAE,OAAO,WAAW,EAAE,MAAM;AAAA,MACtL;AAAA,IACF,SAAS,KAAK;AACZ,WAAK,OAAO;AAAA,QACV;AAAA,QACA,eAAe,QAAQ,IAAI,QAAQ,OAAO,GAAG;AAAA,MAC/C;AAAA,IACF;AAAA,EACF;AACF;AAjEa,wBAAN;AAAA,EADN,WAAW;AAAA,EAOP,0BAAO,aAAa;AAAA,EACpB,0BAAO,4BAA4B;AAAA,GAP3B;","names":[]}
|
|
@@ -13,8 +13,8 @@ import '../../events/generated/types.js';
|
|
|
13
13
|
import '../../events/event-read.protocol.js';
|
|
14
14
|
import '../../bridge/bridge.protocol.js';
|
|
15
15
|
import '../../bridge/bridge-delivery.schema.js';
|
|
16
|
-
import '../../
|
|
17
|
-
import '../../
|
|
16
|
+
import '../../integration/integration-run-recorder.protocol.js';
|
|
17
|
+
import '../../integration/integration-field-diff.protocol.js';
|
|
18
18
|
import 'zod';
|
|
19
|
-
import '../../
|
|
19
|
+
import '../../integration/integration-cursor-store.protocol.js';
|
|
20
20
|
import '../observability.module.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../../../runtime/subsystems/observability/reporters/bridge-metrics.reporter.ts","../../../../../runtime/subsystems/observability/observability.tokens.ts"],"sourcesContent":["/**\n * BridgeMetricsReporter — internal consumer of `IObservability`\n * (ADR-025, OBS-6).\n *\n * Periodically samples `getBridgeDeliveryHistogram` from the observability\n * facade and emits one log line per tick. Auto-registered by\n * `ObservabilityModule.forRoot()` when\n * `options.reporters.bridgeMetrics.enabled === true`. Consumers configure\n * via options; they never import this class. Not exported from the\n * module's `exports` array — internal.\n *\n * # Invariants (enforced by skill + ADR-025)\n *\n * - Injects ONLY `OBSERVABILITY` + `OBSERVABILITY_MODULE_OPTIONS`. Never\n * `BRIDGE_DELIVERY_REPO` or any other sibling token. Reporters are\n * consumers of the composed facade, not parallel composers.\n * - Never reaches into sibling tables or extends `IObservability`.\n * - Errors isolated per-tick (logged, never rethrown) so a transient\n * sibling failure does not kill the interval.\n * - `tenantId` passes VERBATIM to the facade — observability owns tenant\n * semantics, reporters don't re-implement them.\n *\n * # Lifecycle\n *\n * - `onModuleInit` — eager first-tick, then `setInterval`. Handle is\n * `.unref()`-ed when supported so the loop never blocks node shutdown.\n * - `onModuleDestroy` — `clearInterval` + null the handle. Idempotent.\n *\n * No `@nestjs/schedule` dependency — raw `setInterval` keeps the runtime\n * footprint minimal and avoids pulling a decorator framework in for a\n * single loop.\n */\nimport {\n Inject,\n Injectable,\n Logger,\n type OnModuleDestroy,\n type OnModuleInit,\n} from '@nestjs/common';\n\nimport type { IObservability } from '../observability.protocol';\nimport {\n OBSERVABILITY,\n OBSERVABILITY_MODULE_OPTIONS,\n} from '../observability.tokens';\n// Type-only imports — the module imports this file as a value for DI\n// registration, and this file imports config types back. Keeping the\n// back-edge type-only prevents a runtime circular-import.\nimport type {\n BridgeMetricsReporterConfig,\n ObservabilityModuleOptions,\n} from '../observability.module';\n\n@Injectable()\nexport class BridgeMetricsReporter implements OnModuleInit, OnModuleDestroy {\n private readonly logger = new Logger(BridgeMetricsReporter.name);\n private handle: ReturnType<typeof setInterval> | null = null;\n private readonly config: BridgeMetricsReporterConfig | undefined;\n\n constructor(\n @Inject(OBSERVABILITY) private readonly observability: IObservability,\n @Inject(OBSERVABILITY_MODULE_OPTIONS) options: ObservabilityModuleOptions,\n ) {\n this.config = options.reporters?.bridgeMetrics;\n }\n\n onModuleInit(): void {\n if (!this.config || !this.config.enabled) {\n this.logger.log('BridgeMetricsReporter disabled');\n return;\n }\n if (this.config.intervalMs <= 0 || this.config.windowHours <= 0) {\n this.logger.warn(\n `invalid config; not starting: intervalMs=${this.config.intervalMs} windowHours=${this.config.windowHours}`,\n );\n return;\n }\n // Eager first-tick so consumers see data immediately on boot, without\n // waiting `intervalMs` for the first sample.\n void this.runOnce();\n this.handle = setInterval(() => {\n void this.runOnce();\n }, this.config.intervalMs);\n // `.unref()` lets the node process exit even if the interval is still\n // scheduled — important in short-lived CLI/test contexts. Guarded\n // because browser-shimmed timers may not expose it.\n if (typeof this.handle.unref === 'function') this.handle.unref();\n }\n\n onModuleDestroy(): void {\n if (this.handle !== null) {\n clearInterval(this.handle);\n this.handle = null;\n }\n }\n\n /**\n * Single sample. Public so tests and future ops tooling can trigger a\n * sample on demand without waiting for the interval. Errors are caught\n * and logged here — never rethrown — so a transient sibling failure\n * does not kill subsequent ticks.\n */\n async runOnce(): Promise<void> {\n if (!this.config || !this.config.enabled) return;\n try {\n const h = await this.observability.getBridgeDeliveryHistogram(\n this.config.windowHours,\n this.config.tenantId,\n );\n this.logger.log(\n `bridge-delivery window=${this.config.windowHours}h tenant=${this.config.tenantId ?? 'default'} pending=${h.pending} delivered=${h.delivered} skipped=${h.skipped} failed=${h.failed}`,\n );\n } catch (err) {\n this.logger.error(\n 'BridgeMetricsReporter runOnce failed',\n err instanceof Error ? err.stack : String(err),\n );\n }\n }\n}\n","/**\n * Observability combiner subsystem — DI tokens (ADR-025, OBS-5).\n *\n * String constants (not Symbols), matching the events / bridge /
|
|
1
|
+
{"version":3,"sources":["../../../../../runtime/subsystems/observability/reporters/bridge-metrics.reporter.ts","../../../../../runtime/subsystems/observability/observability.tokens.ts"],"sourcesContent":["/**\n * BridgeMetricsReporter — internal consumer of `IObservability`\n * (ADR-025, OBS-6).\n *\n * Periodically samples `getBridgeDeliveryHistogram` from the observability\n * facade and emits one log line per tick. Auto-registered by\n * `ObservabilityModule.forRoot()` when\n * `options.reporters.bridgeMetrics.enabled === true`. Consumers configure\n * via options; they never import this class. Not exported from the\n * module's `exports` array — internal.\n *\n * # Invariants (enforced by skill + ADR-025)\n *\n * - Injects ONLY `OBSERVABILITY` + `OBSERVABILITY_MODULE_OPTIONS`. Never\n * `BRIDGE_DELIVERY_REPO` or any other sibling token. Reporters are\n * consumers of the composed facade, not parallel composers.\n * - Never reaches into sibling tables or extends `IObservability`.\n * - Errors isolated per-tick (logged, never rethrown) so a transient\n * sibling failure does not kill the interval.\n * - `tenantId` passes VERBATIM to the facade — observability owns tenant\n * semantics, reporters don't re-implement them.\n *\n * # Lifecycle\n *\n * - `onModuleInit` — eager first-tick, then `setInterval`. Handle is\n * `.unref()`-ed when supported so the loop never blocks node shutdown.\n * - `onModuleDestroy` — `clearInterval` + null the handle. Idempotent.\n *\n * No `@nestjs/schedule` dependency — raw `setInterval` keeps the runtime\n * footprint minimal and avoids pulling a decorator framework in for a\n * single loop.\n */\nimport {\n Inject,\n Injectable,\n Logger,\n type OnModuleDestroy,\n type OnModuleInit,\n} from '@nestjs/common';\n\nimport type { IObservability } from '../observability.protocol';\nimport {\n OBSERVABILITY,\n OBSERVABILITY_MODULE_OPTIONS,\n} from '../observability.tokens';\n// Type-only imports — the module imports this file as a value for DI\n// registration, and this file imports config types back. Keeping the\n// back-edge type-only prevents a runtime circular-import.\nimport type {\n BridgeMetricsReporterConfig,\n ObservabilityModuleOptions,\n} from '../observability.module';\n\n@Injectable()\nexport class BridgeMetricsReporter implements OnModuleInit, OnModuleDestroy {\n private readonly logger = new Logger(BridgeMetricsReporter.name);\n private handle: ReturnType<typeof setInterval> | null = null;\n private readonly config: BridgeMetricsReporterConfig | undefined;\n\n constructor(\n @Inject(OBSERVABILITY) private readonly observability: IObservability,\n @Inject(OBSERVABILITY_MODULE_OPTIONS) options: ObservabilityModuleOptions,\n ) {\n this.config = options.reporters?.bridgeMetrics;\n }\n\n onModuleInit(): void {\n if (!this.config || !this.config.enabled) {\n this.logger.log('BridgeMetricsReporter disabled');\n return;\n }\n if (this.config.intervalMs <= 0 || this.config.windowHours <= 0) {\n this.logger.warn(\n `invalid config; not starting: intervalMs=${this.config.intervalMs} windowHours=${this.config.windowHours}`,\n );\n return;\n }\n // Eager first-tick so consumers see data immediately on boot, without\n // waiting `intervalMs` for the first sample.\n void this.runOnce();\n this.handle = setInterval(() => {\n void this.runOnce();\n }, this.config.intervalMs);\n // `.unref()` lets the node process exit even if the interval is still\n // scheduled — important in short-lived CLI/test contexts. Guarded\n // because browser-shimmed timers may not expose it.\n if (typeof this.handle.unref === 'function') this.handle.unref();\n }\n\n onModuleDestroy(): void {\n if (this.handle !== null) {\n clearInterval(this.handle);\n this.handle = null;\n }\n }\n\n /**\n * Single sample. Public so tests and future ops tooling can trigger a\n * sample on demand without waiting for the interval. Errors are caught\n * and logged here — never rethrown — so a transient sibling failure\n * does not kill subsequent ticks.\n */\n async runOnce(): Promise<void> {\n if (!this.config || !this.config.enabled) return;\n try {\n const h = await this.observability.getBridgeDeliveryHistogram(\n this.config.windowHours,\n this.config.tenantId,\n );\n this.logger.log(\n `bridge-delivery window=${this.config.windowHours}h tenant=${this.config.tenantId ?? 'default'} pending=${h.pending} delivered=${h.delivered} skipped=${h.skipped} failed=${h.failed}`,\n );\n } catch (err) {\n this.logger.error(\n 'BridgeMetricsReporter runOnce failed',\n err instanceof Error ? err.stack : String(err),\n );\n }\n }\n}\n","/**\n * Observability combiner subsystem — DI tokens (ADR-025, OBS-5).\n *\n * String constants (not Symbols), matching the events / bridge / integration\n * convention. The jobs subsystem uses Symbols for its analogous tokens;\n * observability stays internally consistent with its sibling combiner\n * (bridge) because the two are structurally paired (ADR-025).\n *\n * Usage in consumers:\n * ```ts\n * constructor(@Inject(OBSERVABILITY) private readonly obs: IObservability) {}\n * ```\n */\n\n/**\n * Token for the `IObservability` composer facade (OBS-5). Resolves to the\n * single `ObservabilityService` instance registered by\n * `ObservabilityModule.forRoot(...)`.\n */\nexport const OBSERVABILITY = 'OBSERVABILITY' as const;\n\n/**\n * Token for the resolved `ObservabilityModuleOptions` object. Provided by\n * `ObservabilityModule.forRoot(...)`. Reserved for phase 2 — the current\n * options shape is empty; OBS-6 will extend it with a `reporters` field.\n */\nexport const OBSERVABILITY_MODULE_OPTIONS = 'OBSERVABILITY_MODULE_OPTIONS' as const;\n"],"mappings":";;;;;;;;;;;;;AAgCA;AAAA,EACE;AAAA,EACA;AAAA,EACA;AAAA,OAGK;;;ACnBA,IAAM,gBAAgB;AAOtB,IAAM,+BAA+B;;;AD4BrC,IAAM,wBAAN,MAAqE;AAAA,EAK1E,YAC0C,eACF,SACtC;AAFwC;AAGxC,SAAK,SAAS,QAAQ,WAAW;AAAA,EACnC;AAAA,EAJ0C;AAAA,EALzB,SAAS,IAAI,OAAO,sBAAsB,IAAI;AAAA,EACvD,SAAgD;AAAA,EACvC;AAAA,EASjB,eAAqB;AACnB,QAAI,CAAC,KAAK,UAAU,CAAC,KAAK,OAAO,SAAS;AACxC,WAAK,OAAO,IAAI,gCAAgC;AAChD;AAAA,IACF;AACA,QAAI,KAAK,OAAO,cAAc,KAAK,KAAK,OAAO,eAAe,GAAG;AAC/D,WAAK,OAAO;AAAA,QACV,4CAA4C,KAAK,OAAO,UAAU,gBAAgB,KAAK,OAAO,WAAW;AAAA,MAC3G;AACA;AAAA,IACF;AAGA,SAAK,KAAK,QAAQ;AAClB,SAAK,SAAS,YAAY,MAAM;AAC9B,WAAK,KAAK,QAAQ;AAAA,IACpB,GAAG,KAAK,OAAO,UAAU;AAIzB,QAAI,OAAO,KAAK,OAAO,UAAU,WAAY,MAAK,OAAO,MAAM;AAAA,EACjE;AAAA,EAEA,kBAAwB;AACtB,QAAI,KAAK,WAAW,MAAM;AACxB,oBAAc,KAAK,MAAM;AACzB,WAAK,SAAS;AAAA,IAChB;AAAA,EACF;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAQA,MAAM,UAAyB;AAC7B,QAAI,CAAC,KAAK,UAAU,CAAC,KAAK,OAAO,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