@pattern-stack/codegen 0.10.1 → 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 +62 -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 +7 -7
- package/dist/runtime/subsystems/index.js +51 -51
- 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/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 +262 -269
- 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/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/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/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
|
@@ -10,17 +10,17 @@ var __decorateClass = (decorators, target, key, kind) => {
|
|
|
10
10
|
};
|
|
11
11
|
var __decorateParam = (index2, decorator) => (target, key) => decorator(target, key, index2);
|
|
12
12
|
|
|
13
|
-
// runtime/subsystems/
|
|
13
|
+
// runtime/subsystems/integration/integration.module.ts
|
|
14
14
|
import { Module } from "@nestjs/common";
|
|
15
15
|
|
|
16
|
-
// runtime/subsystems/
|
|
17
|
-
var
|
|
18
|
-
var
|
|
19
|
-
var
|
|
20
|
-
var
|
|
21
|
-
var
|
|
16
|
+
// runtime/subsystems/integration/integration.tokens.ts
|
|
17
|
+
var INTEGRATION_CURSOR_STORE = "INTEGRATION_CURSOR_STORE";
|
|
18
|
+
var INTEGRATION_FIELD_DIFFER = "INTEGRATION_FIELD_DIFFER";
|
|
19
|
+
var INTEGRATION_RUN_RECORDER = "INTEGRATION_RUN_RECORDER";
|
|
20
|
+
var INTEGRATION_MODULE_OPTIONS = "INTEGRATION_MODULE_OPTIONS";
|
|
21
|
+
var INTEGRATION_MULTI_TENANT = "INTEGRATION_MULTI_TENANT";
|
|
22
22
|
|
|
23
|
-
// runtime/subsystems/
|
|
23
|
+
// runtime/subsystems/integration/integration-cursor-store.memory-backend.ts
|
|
24
24
|
import { Injectable } from "@nestjs/common";
|
|
25
25
|
var MemoryCursorStore = class {
|
|
26
26
|
/**
|
|
@@ -31,7 +31,7 @@ var MemoryCursorStore = class {
|
|
|
31
31
|
/**
|
|
32
32
|
* Seedable subscription metadata for `listAll` — the memory backend
|
|
33
33
|
* stores only `subscriptionId → cursor` in its write path, so the
|
|
34
|
-
* snapshot shape (`
|
|
34
|
+
* snapshot shape (`connectionId`, `adapter`, `domain`, `externalRef`,
|
|
35
35
|
* timestamps) has no natural source without test seeding. Tests populate
|
|
36
36
|
* this map; unseeded entries get empty-string metadata and `new Date(0)`
|
|
37
37
|
* timestamps so the shape stays stable. Production paths go through the
|
|
@@ -51,12 +51,12 @@ var MemoryCursorStore = class {
|
|
|
51
51
|
const meta = this.subscriptions.get(subscriptionId);
|
|
52
52
|
snapshots.push({
|
|
53
53
|
subscriptionId,
|
|
54
|
-
|
|
54
|
+
connectionId: meta?.connectionId ?? "",
|
|
55
55
|
adapter: meta?.adapter ?? "",
|
|
56
56
|
domain: meta?.domain ?? "",
|
|
57
57
|
externalRef: meta?.externalRef ?? null,
|
|
58
58
|
cursor: cursor ?? null,
|
|
59
|
-
|
|
59
|
+
lastIntegrationAt: meta?.lastIntegrationAt ?? null,
|
|
60
60
|
updatedAt: meta?.updatedAt ?? /* @__PURE__ */ new Date(0),
|
|
61
61
|
tenantId: null
|
|
62
62
|
});
|
|
@@ -75,10 +75,10 @@ MemoryCursorStore = __decorateClass([
|
|
|
75
75
|
Injectable()
|
|
76
76
|
], MemoryCursorStore);
|
|
77
77
|
|
|
78
|
-
// runtime/subsystems/
|
|
78
|
+
// runtime/subsystems/integration/integration-run-recorder.memory-backend.ts
|
|
79
79
|
import { Injectable as Injectable2 } from "@nestjs/common";
|
|
80
80
|
|
|
81
|
-
// runtime/subsystems/
|
|
81
|
+
// runtime/subsystems/integration/integration-field-diff.protocol.ts
|
|
82
82
|
import { z } from "zod";
|
|
83
83
|
var FieldDiffValueSchema = z.object({
|
|
84
84
|
from: z.unknown(),
|
|
@@ -86,7 +86,7 @@ var FieldDiffValueSchema = z.object({
|
|
|
86
86
|
});
|
|
87
87
|
var FieldDiffSchema = z.record(z.string(), FieldDiffValueSchema);
|
|
88
88
|
|
|
89
|
-
// runtime/subsystems/
|
|
89
|
+
// runtime/subsystems/integration/integration-run-recorder.memory-backend.ts
|
|
90
90
|
var MemoryRunRecorder = class {
|
|
91
91
|
/**
|
|
92
92
|
* All started runs keyed by id. Public so tests can inspect lifecycle
|
|
@@ -94,14 +94,14 @@ var MemoryRunRecorder = class {
|
|
|
94
94
|
*/
|
|
95
95
|
runs = /* @__PURE__ */ new Map();
|
|
96
96
|
/**
|
|
97
|
-
* Items keyed by `
|
|
98
|
-
* mirrors the timeline the `(
|
|
97
|
+
* Items keyed by `integration_run_id`, array order matches insertion order —
|
|
98
|
+
* mirrors the timeline the `(integration_run_id, created_at)` index produces
|
|
99
99
|
* in Postgres.
|
|
100
100
|
*/
|
|
101
101
|
items = /* @__PURE__ */ new Map();
|
|
102
102
|
/**
|
|
103
103
|
* Seedable subscription metadata — tests populate this to make
|
|
104
|
-
* `listRecent` return meaningful `
|
|
104
|
+
* `listRecent` return meaningful `connectionId` values. The memory
|
|
105
105
|
* backend doesn't track subscriptions on its own (only runs + items), so
|
|
106
106
|
* this map is the intentional extension point: tests write entries for
|
|
107
107
|
* the subscription ids they use, production code never touches it.
|
|
@@ -130,10 +130,10 @@ var MemoryRunRecorder = class {
|
|
|
130
130
|
}
|
|
131
131
|
async recordItem(input) {
|
|
132
132
|
FieldDiffSchema.parse(input.changedFields);
|
|
133
|
-
const bucket = this.items.get(input.
|
|
133
|
+
const bucket = this.items.get(input.integrationRunId);
|
|
134
134
|
if (!bucket) {
|
|
135
135
|
throw new Error(
|
|
136
|
-
`MemoryRunRecorder.recordItem: no run started for id '${input.
|
|
136
|
+
`MemoryRunRecorder.recordItem: no run started for id '${input.integrationRunId}'. Call startRun(...) first.`
|
|
137
137
|
);
|
|
138
138
|
}
|
|
139
139
|
bucket.push(input);
|
|
@@ -159,10 +159,10 @@ var MemoryRunRecorder = class {
|
|
|
159
159
|
return filtered.sort((a, b) => b.startedAt.getTime() - a.startedAt.getTime()).slice(0, limit).map((r) => ({
|
|
160
160
|
id: r.id,
|
|
161
161
|
subscriptionId: r.subscriptionId,
|
|
162
|
-
//
|
|
162
|
+
// connectionId is only knowable if the test seeded subscriptions
|
|
163
163
|
// metadata; empty string otherwise. The Drizzle backend resolves
|
|
164
164
|
// it via JOIN, which is the production path.
|
|
165
|
-
|
|
165
|
+
connectionId: this.subscriptions.get(r.subscriptionId)?.connectionId ?? "",
|
|
166
166
|
status: r.status,
|
|
167
167
|
startedAt: r.startedAt,
|
|
168
168
|
completedAt: r.completedAt,
|
|
@@ -190,14 +190,14 @@ MemoryRunRecorder = __decorateClass([
|
|
|
190
190
|
Injectable2()
|
|
191
191
|
], MemoryRunRecorder);
|
|
192
192
|
|
|
193
|
-
// runtime/subsystems/
|
|
193
|
+
// runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
|
|
194
194
|
import { Inject, Injectable as Injectable3, Optional } from "@nestjs/common";
|
|
195
195
|
import { and, desc, eq } from "drizzle-orm";
|
|
196
196
|
|
|
197
197
|
// runtime/constants/tokens.ts
|
|
198
198
|
var DRIZZLE = "DRIZZLE";
|
|
199
199
|
|
|
200
|
-
// runtime/subsystems/
|
|
200
|
+
// runtime/subsystems/integration/integration-audit.schema.ts
|
|
201
201
|
import {
|
|
202
202
|
pgEnum,
|
|
203
203
|
pgTable,
|
|
@@ -210,39 +210,39 @@ import {
|
|
|
210
210
|
index,
|
|
211
211
|
uniqueIndex
|
|
212
212
|
} from "drizzle-orm/pg-core";
|
|
213
|
-
var
|
|
213
|
+
var integrationRunDirectionEnum = pgEnum("integration_run_direction", [
|
|
214
214
|
"inbound",
|
|
215
215
|
"outbound"
|
|
216
216
|
]);
|
|
217
|
-
var
|
|
217
|
+
var integrationRunActionEnum = pgEnum("integration_run_action", [
|
|
218
218
|
"poll",
|
|
219
219
|
"cdc",
|
|
220
220
|
"webhook",
|
|
221
221
|
"manual",
|
|
222
222
|
"writeback"
|
|
223
223
|
]);
|
|
224
|
-
var
|
|
224
|
+
var integrationRunStatusEnum = pgEnum("integration_run_status", [
|
|
225
225
|
"running",
|
|
226
226
|
"success",
|
|
227
227
|
"no_changes",
|
|
228
228
|
"failed"
|
|
229
229
|
]);
|
|
230
|
-
var
|
|
230
|
+
var integrationRunItemOperationEnum = pgEnum("integration_run_item_operation", [
|
|
231
231
|
"created",
|
|
232
232
|
"updated",
|
|
233
233
|
"deleted",
|
|
234
234
|
"noop"
|
|
235
235
|
]);
|
|
236
|
-
var
|
|
236
|
+
var integrationRunItemStatusEnum = pgEnum("integration_run_item_status", [
|
|
237
237
|
"success",
|
|
238
238
|
"failed",
|
|
239
239
|
"skipped"
|
|
240
240
|
]);
|
|
241
|
-
var
|
|
242
|
-
"
|
|
241
|
+
var integrationSubscriptions = pgTable(
|
|
242
|
+
"integration_subscriptions",
|
|
243
243
|
{
|
|
244
244
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
245
|
-
|
|
245
|
+
connectionId: text("connection_id").notNull(),
|
|
246
246
|
adapter: text("adapter").notNull(),
|
|
247
247
|
domain: text("domain").notNull(),
|
|
248
248
|
externalRef: text("external_ref"),
|
|
@@ -257,8 +257,8 @@ var syncSubscriptions = pgTable(
|
|
|
257
257
|
* successful run advances it.
|
|
258
258
|
*/
|
|
259
259
|
cursor: jsonb("cursor").$type(),
|
|
260
|
-
|
|
261
|
-
/** Runtime-enforced when `
|
|
260
|
+
lastIntegrationAt: timestamp("last_integration_at", { withTimezone: true }),
|
|
261
|
+
/** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
|
|
262
262
|
tenantId: text("tenant_id"),
|
|
263
263
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
264
264
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
@@ -267,31 +267,31 @@ var syncSubscriptions = pgTable(
|
|
|
267
267
|
/**
|
|
268
268
|
* Composite uniqueness per the epic shape. `external_ref` is nullable;
|
|
269
269
|
* Postgres treats NULLs as distinct in a UNIQUE constraint, which means
|
|
270
|
-
* two rows with the same `(
|
|
270
|
+
* two rows with the same `(connection_id, adapter, domain)` and NULL
|
|
271
271
|
* external_ref are allowed. That's intentional — a subscription with
|
|
272
272
|
* NULL external_ref covers the full domain, and duplicates there would
|
|
273
273
|
* be a consumer-layer modeling issue, not a schema concern.
|
|
274
274
|
*/
|
|
275
|
-
|
|
276
|
-
t.
|
|
275
|
+
uqIntegrationSubscriptionTuple: uniqueIndex("uq_integration_subscriptions_tuple").on(
|
|
276
|
+
t.connectionId,
|
|
277
277
|
t.adapter,
|
|
278
278
|
t.domain,
|
|
279
279
|
t.externalRef
|
|
280
280
|
),
|
|
281
281
|
/** Scheduling query: list enabled subscriptions ordered by staleness. */
|
|
282
|
-
|
|
283
|
-
"
|
|
284
|
-
).on(t.enabled, t.
|
|
282
|
+
idxIntegrationSubscriptionsEnabledLastIntegration: index(
|
|
283
|
+
"idx_integration_subscriptions_enabled_last_integration"
|
|
284
|
+
).on(t.enabled, t.lastIntegrationAt)
|
|
285
285
|
})
|
|
286
286
|
);
|
|
287
|
-
var
|
|
288
|
-
"
|
|
287
|
+
var integrationRuns = pgTable(
|
|
288
|
+
"integration_runs",
|
|
289
289
|
{
|
|
290
290
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
291
|
-
subscriptionId: uuid("subscription_id").notNull().references(() =>
|
|
292
|
-
direction:
|
|
293
|
-
action:
|
|
294
|
-
status:
|
|
291
|
+
subscriptionId: uuid("subscription_id").notNull().references(() => integrationSubscriptions.id, { onDelete: "cascade" }),
|
|
292
|
+
direction: integrationRunDirectionEnum("direction").notNull(),
|
|
293
|
+
action: integrationRunActionEnum("action").notNull(),
|
|
294
|
+
status: integrationRunStatusEnum("status").notNull().default("running"),
|
|
295
295
|
recordsFound: integer("records_found").notNull().default(0),
|
|
296
296
|
recordsProcessed: integer("records_processed").notNull().default(0),
|
|
297
297
|
cursorBefore: jsonb("cursor_before").$type(),
|
|
@@ -300,31 +300,31 @@ var syncRuns = pgTable(
|
|
|
300
300
|
error: text("error"),
|
|
301
301
|
startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
|
|
302
302
|
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
303
|
-
/** Runtime-enforced when `
|
|
303
|
+
/** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
|
|
304
304
|
tenantId: text("tenant_id")
|
|
305
305
|
},
|
|
306
306
|
(t) => ({
|
|
307
307
|
/** Timeline read: "most recent runs for this subscription". */
|
|
308
|
-
|
|
309
|
-
"
|
|
308
|
+
idxIntegrationRunsSubscriptionStartedAt: index(
|
|
309
|
+
"idx_integration_runs_subscription_started_at"
|
|
310
310
|
).on(t.subscriptionId, t.startedAt),
|
|
311
311
|
/** Stale-run sweeper: "runs that started > N minutes ago and are still running". */
|
|
312
|
-
|
|
312
|
+
idxIntegrationRunsStatusStartedAt: index("idx_integration_runs_status_started_at").on(
|
|
313
313
|
t.status,
|
|
314
314
|
t.startedAt
|
|
315
315
|
)
|
|
316
316
|
})
|
|
317
317
|
);
|
|
318
|
-
var
|
|
319
|
-
"
|
|
318
|
+
var integrationRunItems = pgTable(
|
|
319
|
+
"integration_run_items",
|
|
320
320
|
{
|
|
321
321
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
322
|
-
|
|
322
|
+
integrationRunId: uuid("integration_run_id").notNull().references(() => integrationRuns.id, { onDelete: "cascade" }),
|
|
323
323
|
entityType: text("entity_type").notNull(),
|
|
324
324
|
externalId: text("external_id").notNull(),
|
|
325
325
|
localId: text("local_id"),
|
|
326
|
-
operation:
|
|
327
|
-
status:
|
|
326
|
+
operation: integrationRunItemOperationEnum("operation").notNull(),
|
|
327
|
+
status: integrationRunItemStatusEnum("status").notNull(),
|
|
328
328
|
/**
|
|
329
329
|
* Structured per-field diff — ADR-0003 shape enforced by
|
|
330
330
|
* `FieldDiffSchema.parse` at the recorder service layer.
|
|
@@ -338,28 +338,28 @@ var syncRunItems = pgTable(
|
|
|
338
338
|
title: text("title"),
|
|
339
339
|
error: text("error"),
|
|
340
340
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
341
|
-
/** Runtime-enforced when `
|
|
341
|
+
/** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
|
|
342
342
|
tenantId: text("tenant_id")
|
|
343
343
|
},
|
|
344
344
|
(t) => ({
|
|
345
345
|
/** Ordered timeline within a run. */
|
|
346
|
-
|
|
347
|
-
t.
|
|
346
|
+
idxIntegrationRunItemsRunCreatedAt: index("idx_integration_run_items_run_created_at").on(
|
|
347
|
+
t.integrationRunId,
|
|
348
348
|
t.createdAt
|
|
349
349
|
),
|
|
350
|
-
/** Per-record history: "every
|
|
351
|
-
|
|
352
|
-
"
|
|
350
|
+
/** Per-record history: "every integration that touched opportunity/$extId". */
|
|
351
|
+
idxIntegrationRunItemsEntityExternal: index(
|
|
352
|
+
"idx_integration_run_items_entity_external"
|
|
353
353
|
).on(t.entityType, t.externalId)
|
|
354
354
|
})
|
|
355
355
|
);
|
|
356
356
|
|
|
357
|
-
// runtime/subsystems/
|
|
357
|
+
// runtime/subsystems/integration/integration-errors.ts
|
|
358
358
|
var MissingTenantIdError = class extends Error {
|
|
359
359
|
name = "MissingTenantIdError";
|
|
360
360
|
constructor(operation) {
|
|
361
361
|
super(
|
|
362
|
-
`Missing tenantId for
|
|
362
|
+
`Missing tenantId for integration operation '${operation}'. IntegrationModule is configured with multiTenant: true \u2014 every call must include a non-null tenantId. Either pass the tenantId or disable multi-tenancy on the module.`
|
|
363
363
|
);
|
|
364
364
|
}
|
|
365
365
|
};
|
|
@@ -370,7 +370,7 @@ function assertTenantId(tenantId, options) {
|
|
|
370
370
|
}
|
|
371
371
|
}
|
|
372
372
|
|
|
373
|
-
// runtime/subsystems/
|
|
373
|
+
// runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
|
|
374
374
|
var PostgresCursorStore = class {
|
|
375
375
|
constructor(db, multiTenant) {
|
|
376
376
|
this.db = db;
|
|
@@ -380,15 +380,15 @@ var PostgresCursorStore = class {
|
|
|
380
380
|
multiTenant;
|
|
381
381
|
async get(subscriptionId, tenantId) {
|
|
382
382
|
const where = this.buildWhere(subscriptionId, tenantId, "cursor.get");
|
|
383
|
-
const rows = await this.db.select({ cursor:
|
|
383
|
+
const rows = await this.db.select({ cursor: integrationSubscriptions.cursor }).from(integrationSubscriptions).where(where).limit(1);
|
|
384
384
|
if (rows.length === 0) return null;
|
|
385
385
|
return rows[0]?.cursor ?? null;
|
|
386
386
|
}
|
|
387
387
|
async put(subscriptionId, cursor, tenantId) {
|
|
388
388
|
const where = this.buildWhere(subscriptionId, tenantId, "cursor.put");
|
|
389
|
-
await this.db.update(
|
|
389
|
+
await this.db.update(integrationSubscriptions).set({
|
|
390
390
|
cursor,
|
|
391
|
-
|
|
391
|
+
lastIntegrationAt: /* @__PURE__ */ new Date(),
|
|
392
392
|
updatedAt: /* @__PURE__ */ new Date()
|
|
393
393
|
}).where(where);
|
|
394
394
|
}
|
|
@@ -397,26 +397,26 @@ var PostgresCursorStore = class {
|
|
|
397
397
|
multiTenant: this.multiTenant,
|
|
398
398
|
operation: "cursor.listAll"
|
|
399
399
|
});
|
|
400
|
-
const where = this.multiTenant ? eq(
|
|
400
|
+
const where = this.multiTenant ? eq(integrationSubscriptions.tenantId, tenantId) : void 0;
|
|
401
401
|
const rows = await this.db.select({
|
|
402
|
-
id:
|
|
403
|
-
|
|
404
|
-
adapter:
|
|
405
|
-
domain:
|
|
406
|
-
externalRef:
|
|
407
|
-
cursor:
|
|
408
|
-
|
|
409
|
-
updatedAt:
|
|
410
|
-
tenantId:
|
|
411
|
-
}).from(
|
|
402
|
+
id: integrationSubscriptions.id,
|
|
403
|
+
connectionId: integrationSubscriptions.connectionId,
|
|
404
|
+
adapter: integrationSubscriptions.adapter,
|
|
405
|
+
domain: integrationSubscriptions.domain,
|
|
406
|
+
externalRef: integrationSubscriptions.externalRef,
|
|
407
|
+
cursor: integrationSubscriptions.cursor,
|
|
408
|
+
lastIntegrationAt: integrationSubscriptions.lastIntegrationAt,
|
|
409
|
+
updatedAt: integrationSubscriptions.updatedAt,
|
|
410
|
+
tenantId: integrationSubscriptions.tenantId
|
|
411
|
+
}).from(integrationSubscriptions).where(where).orderBy(desc(integrationSubscriptions.updatedAt));
|
|
412
412
|
return rows.map((row) => ({
|
|
413
413
|
subscriptionId: row.id,
|
|
414
|
-
|
|
414
|
+
connectionId: row.connectionId,
|
|
415
415
|
adapter: row.adapter,
|
|
416
416
|
domain: row.domain,
|
|
417
417
|
externalRef: row.externalRef,
|
|
418
418
|
cursor: row.cursor ?? null,
|
|
419
|
-
|
|
419
|
+
lastIntegrationAt: row.lastIntegrationAt,
|
|
420
420
|
updatedAt: row.updatedAt,
|
|
421
421
|
tenantId: row.tenantId
|
|
422
422
|
}));
|
|
@@ -433,24 +433,24 @@ var PostgresCursorStore = class {
|
|
|
433
433
|
});
|
|
434
434
|
if (this.multiTenant) {
|
|
435
435
|
return and(
|
|
436
|
-
eq(
|
|
437
|
-
eq(
|
|
436
|
+
eq(integrationSubscriptions.id, subscriptionId),
|
|
437
|
+
eq(integrationSubscriptions.tenantId, tenantId)
|
|
438
438
|
);
|
|
439
439
|
}
|
|
440
|
-
return eq(
|
|
440
|
+
return eq(integrationSubscriptions.id, subscriptionId);
|
|
441
441
|
}
|
|
442
442
|
};
|
|
443
443
|
PostgresCursorStore = __decorateClass([
|
|
444
444
|
Injectable3(),
|
|
445
445
|
__decorateParam(0, Inject(DRIZZLE)),
|
|
446
446
|
__decorateParam(1, Optional()),
|
|
447
|
-
__decorateParam(1, Inject(
|
|
447
|
+
__decorateParam(1, Inject(INTEGRATION_MULTI_TENANT))
|
|
448
448
|
], PostgresCursorStore);
|
|
449
449
|
|
|
450
|
-
// runtime/subsystems/
|
|
450
|
+
// runtime/subsystems/integration/integration-run-recorder.drizzle-backend.ts
|
|
451
451
|
import { Inject as Inject2, Injectable as Injectable4, Optional as Optional2 } from "@nestjs/common";
|
|
452
452
|
import { and as and2, desc as desc2, eq as eq2 } from "drizzle-orm";
|
|
453
|
-
var
|
|
453
|
+
var DrizzleIntegrationRunRecorder = class {
|
|
454
454
|
constructor(db, multiTenant) {
|
|
455
455
|
this.db = db;
|
|
456
456
|
this.multiTenant = multiTenant ?? false;
|
|
@@ -462,17 +462,17 @@ var DrizzleSyncRunRecorder = class {
|
|
|
462
462
|
multiTenant: this.multiTenant,
|
|
463
463
|
operation: "startRun"
|
|
464
464
|
});
|
|
465
|
-
const rows = await this.db.insert(
|
|
465
|
+
const rows = await this.db.insert(integrationRuns).values({
|
|
466
466
|
subscriptionId: input.subscriptionId,
|
|
467
467
|
direction: input.direction,
|
|
468
468
|
action: input.action,
|
|
469
469
|
status: "running",
|
|
470
470
|
cursorBefore: input.cursorBefore ?? null,
|
|
471
471
|
tenantId: input.tenantId ?? null
|
|
472
|
-
}).returning({ id:
|
|
472
|
+
}).returning({ id: integrationRuns.id });
|
|
473
473
|
const id = rows[0]?.id;
|
|
474
474
|
if (!id) {
|
|
475
|
-
throw new Error("
|
|
475
|
+
throw new Error("DrizzleIntegrationRunRecorder: INSERT RETURNING produced no id");
|
|
476
476
|
}
|
|
477
477
|
return { id };
|
|
478
478
|
}
|
|
@@ -482,8 +482,8 @@ var DrizzleSyncRunRecorder = class {
|
|
|
482
482
|
operation: "recordItem"
|
|
483
483
|
});
|
|
484
484
|
FieldDiffSchema.parse(input.changedFields);
|
|
485
|
-
await this.db.insert(
|
|
486
|
-
|
|
485
|
+
await this.db.insert(integrationRunItems).values({
|
|
486
|
+
integrationRunId: input.integrationRunId,
|
|
487
487
|
entityType: input.entityType,
|
|
488
488
|
externalId: input.externalId,
|
|
489
489
|
localId: input.localId ?? null,
|
|
@@ -502,29 +502,29 @@ var DrizzleSyncRunRecorder = class {
|
|
|
502
502
|
});
|
|
503
503
|
const conditions = [];
|
|
504
504
|
if (subscriptionId !== void 0) {
|
|
505
|
-
conditions.push(eq2(
|
|
505
|
+
conditions.push(eq2(integrationRuns.subscriptionId, subscriptionId));
|
|
506
506
|
}
|
|
507
507
|
if (this.multiTenant) {
|
|
508
|
-
conditions.push(eq2(
|
|
508
|
+
conditions.push(eq2(integrationRuns.tenantId, tenantId));
|
|
509
509
|
}
|
|
510
510
|
const where = conditions.length === 0 ? void 0 : conditions.length === 1 ? conditions[0] : and2(...conditions);
|
|
511
511
|
const rows = await this.db.select({
|
|
512
|
-
id:
|
|
513
|
-
subscriptionId:
|
|
514
|
-
|
|
515
|
-
status:
|
|
516
|
-
startedAt:
|
|
517
|
-
completedAt:
|
|
518
|
-
recordsProcessed:
|
|
519
|
-
tenantId:
|
|
520
|
-
}).from(
|
|
521
|
-
|
|
522
|
-
eq2(
|
|
523
|
-
).where(where).orderBy(desc2(
|
|
512
|
+
id: integrationRuns.id,
|
|
513
|
+
subscriptionId: integrationRuns.subscriptionId,
|
|
514
|
+
connectionId: integrationSubscriptions.connectionId,
|
|
515
|
+
status: integrationRuns.status,
|
|
516
|
+
startedAt: integrationRuns.startedAt,
|
|
517
|
+
completedAt: integrationRuns.completedAt,
|
|
518
|
+
recordsProcessed: integrationRuns.recordsProcessed,
|
|
519
|
+
tenantId: integrationRuns.tenantId
|
|
520
|
+
}).from(integrationRuns).innerJoin(
|
|
521
|
+
integrationSubscriptions,
|
|
522
|
+
eq2(integrationRuns.subscriptionId, integrationSubscriptions.id)
|
|
523
|
+
).where(where).orderBy(desc2(integrationRuns.startedAt)).limit(limit);
|
|
524
524
|
return rows.map((row) => ({
|
|
525
525
|
id: row.id,
|
|
526
526
|
subscriptionId: row.subscriptionId,
|
|
527
|
-
|
|
527
|
+
connectionId: row.connectionId,
|
|
528
528
|
status: row.status,
|
|
529
529
|
startedAt: row.startedAt,
|
|
530
530
|
completedAt: row.completedAt,
|
|
@@ -533,7 +533,7 @@ var DrizzleSyncRunRecorder = class {
|
|
|
533
533
|
}));
|
|
534
534
|
}
|
|
535
535
|
async completeRun(runId, input) {
|
|
536
|
-
await this.db.update(
|
|
536
|
+
await this.db.update(integrationRuns).set({
|
|
537
537
|
status: input.status,
|
|
538
538
|
recordsFound: input.recordsFound,
|
|
539
539
|
recordsProcessed: input.recordsProcessed,
|
|
@@ -541,17 +541,17 @@ var DrizzleSyncRunRecorder = class {
|
|
|
541
541
|
durationMs: input.durationMs,
|
|
542
542
|
error: input.error ?? null,
|
|
543
543
|
completedAt: /* @__PURE__ */ new Date()
|
|
544
|
-
}).where(eq2(
|
|
544
|
+
}).where(eq2(integrationRuns.id, runId));
|
|
545
545
|
}
|
|
546
546
|
};
|
|
547
|
-
|
|
547
|
+
DrizzleIntegrationRunRecorder = __decorateClass([
|
|
548
548
|
Injectable4(),
|
|
549
549
|
__decorateParam(0, Inject2(DRIZZLE)),
|
|
550
550
|
__decorateParam(1, Optional2()),
|
|
551
|
-
__decorateParam(1, Inject2(
|
|
552
|
-
],
|
|
551
|
+
__decorateParam(1, Inject2(INTEGRATION_MULTI_TENANT))
|
|
552
|
+
], DrizzleIntegrationRunRecorder);
|
|
553
553
|
|
|
554
|
-
// runtime/subsystems/
|
|
554
|
+
// runtime/subsystems/integration/deep-equal.differ.ts
|
|
555
555
|
import { Injectable as Injectable5 } from "@nestjs/common";
|
|
556
556
|
var DEFAULT_IGNORE_FIELDS = /* @__PURE__ */ new Set([
|
|
557
557
|
"id",
|
|
@@ -650,16 +650,16 @@ function deepEqualObject(a, b) {
|
|
|
650
650
|
return true;
|
|
651
651
|
}
|
|
652
652
|
|
|
653
|
-
// runtime/subsystems/
|
|
654
|
-
var
|
|
653
|
+
// runtime/subsystems/integration/integration.module.ts
|
|
654
|
+
var IntegrationModule = class {
|
|
655
655
|
static forRoot(options) {
|
|
656
656
|
const multiTenant = options.multiTenant ?? false;
|
|
657
657
|
const sharedProviders = [
|
|
658
|
-
{ provide:
|
|
659
|
-
{ provide:
|
|
658
|
+
{ provide: INTEGRATION_MODULE_OPTIONS, useValue: options },
|
|
659
|
+
{ provide: INTEGRATION_MULTI_TENANT, useValue: multiTenant },
|
|
660
660
|
// Default differ — consumers can override by binding a different
|
|
661
|
-
// `IFieldDiffer<T>` to `
|
|
662
|
-
{ provide:
|
|
661
|
+
// `IFieldDiffer<T>` to `INTEGRATION_FIELD_DIFFER` in their feature module.
|
|
662
|
+
{ provide: INTEGRATION_FIELD_DIFFER, useValue: new DeepEqualDiffer() }
|
|
663
663
|
];
|
|
664
664
|
const backendProviders = options.backend === "memory" ? [
|
|
665
665
|
// Wired as singletons via `useValue` so tests can pull
|
|
@@ -667,39 +667,39 @@ var SyncModule = class {
|
|
|
667
667
|
// direct assertions. Matches JOB-4 / MemoryJobStore shape.
|
|
668
668
|
{ provide: MemoryCursorStore, useValue: new MemoryCursorStore() },
|
|
669
669
|
{
|
|
670
|
-
provide:
|
|
670
|
+
provide: INTEGRATION_CURSOR_STORE,
|
|
671
671
|
useExisting: MemoryCursorStore
|
|
672
672
|
},
|
|
673
673
|
{ provide: MemoryRunRecorder, useValue: new MemoryRunRecorder() },
|
|
674
674
|
{
|
|
675
|
-
provide:
|
|
675
|
+
provide: INTEGRATION_RUN_RECORDER,
|
|
676
676
|
useExisting: MemoryRunRecorder
|
|
677
677
|
}
|
|
678
678
|
] : [
|
|
679
679
|
// Drizzle backends — injected with DRIZZLE (provided by the
|
|
680
|
-
// consumer's DrizzleModule) + the
|
|
680
|
+
// consumer's DrizzleModule) + the INTEGRATION_MULTI_TENANT flag
|
|
681
681
|
// we bound above.
|
|
682
|
-
{ provide:
|
|
683
|
-
{ provide:
|
|
682
|
+
{ provide: INTEGRATION_CURSOR_STORE, useClass: PostgresCursorStore },
|
|
683
|
+
{ provide: INTEGRATION_RUN_RECORDER, useClass: DrizzleIntegrationRunRecorder }
|
|
684
684
|
];
|
|
685
685
|
return {
|
|
686
|
-
module:
|
|
686
|
+
module: IntegrationModule,
|
|
687
687
|
global: true,
|
|
688
688
|
providers: [...sharedProviders, ...backendProviders],
|
|
689
689
|
exports: [
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
690
|
+
INTEGRATION_MODULE_OPTIONS,
|
|
691
|
+
INTEGRATION_MULTI_TENANT,
|
|
692
|
+
INTEGRATION_FIELD_DIFFER,
|
|
693
|
+
INTEGRATION_CURSOR_STORE,
|
|
694
|
+
INTEGRATION_RUN_RECORDER
|
|
695
695
|
]
|
|
696
696
|
};
|
|
697
697
|
}
|
|
698
698
|
};
|
|
699
|
-
|
|
699
|
+
IntegrationModule = __decorateClass([
|
|
700
700
|
Module({})
|
|
701
|
-
],
|
|
701
|
+
], IntegrationModule);
|
|
702
702
|
export {
|
|
703
|
-
|
|
703
|
+
IntegrationModule
|
|
704
704
|
};
|
|
705
|
-
//# sourceMappingURL=
|
|
705
|
+
//# sourceMappingURL=integration.module.js.map
|