@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,7 +10,7 @@ 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-field-diff.protocol.ts
|
|
14
14
|
import { z } from "zod";
|
|
15
15
|
var FieldDiffValueSchema = z.object({
|
|
16
16
|
from: z.unknown(),
|
|
@@ -18,7 +18,7 @@ var FieldDiffValueSchema = z.object({
|
|
|
18
18
|
});
|
|
19
19
|
var FieldDiffSchema = z.record(z.string(), FieldDiffValueSchema);
|
|
20
20
|
|
|
21
|
-
// runtime/subsystems/
|
|
21
|
+
// runtime/subsystems/integration/detection-config.schema.ts
|
|
22
22
|
import { z as z2 } from "zod";
|
|
23
23
|
var FieldMappingSchema = z2.object({
|
|
24
24
|
source: z2.string().min(1),
|
|
@@ -76,7 +76,7 @@ var DetectionConfigSchema = z2.discriminatedUnion("mode", [
|
|
|
76
76
|
WebhookModeSchema
|
|
77
77
|
]);
|
|
78
78
|
|
|
79
|
-
// runtime/subsystems/
|
|
79
|
+
// runtime/subsystems/integration/loopback.middleware.ts
|
|
80
80
|
function createLoopbackMiddleware(store) {
|
|
81
81
|
return (next) => {
|
|
82
82
|
return async function* (subscription, cursor) {
|
|
@@ -93,7 +93,7 @@ function createLoopbackMiddleware(store) {
|
|
|
93
93
|
};
|
|
94
94
|
}
|
|
95
95
|
|
|
96
|
-
// runtime/subsystems/
|
|
96
|
+
// runtime/subsystems/integration/poll-change-source.ts
|
|
97
97
|
var PollChangeSource = class {
|
|
98
98
|
label;
|
|
99
99
|
adapter;
|
|
@@ -183,7 +183,7 @@ var PollChangeSource = class {
|
|
|
183
183
|
}
|
|
184
184
|
};
|
|
185
185
|
|
|
186
|
-
// runtime/subsystems/
|
|
186
|
+
// runtime/subsystems/integration/webhook-change-source.ts
|
|
187
187
|
var WebhookChangeSource = class {
|
|
188
188
|
label;
|
|
189
189
|
queue;
|
|
@@ -254,7 +254,7 @@ var WebhookChangeSource = class {
|
|
|
254
254
|
}
|
|
255
255
|
};
|
|
256
256
|
|
|
257
|
-
// runtime/subsystems/
|
|
257
|
+
// runtime/subsystems/integration/build-change-source.ts
|
|
258
258
|
function buildChangeSource(cfg, fetch, middlewares = []) {
|
|
259
259
|
switch (cfg.mode) {
|
|
260
260
|
case "poll":
|
|
@@ -272,21 +272,21 @@ function buildChangeSource(cfg, fetch, middlewares = []) {
|
|
|
272
272
|
}
|
|
273
273
|
}
|
|
274
274
|
|
|
275
|
-
// runtime/subsystems/
|
|
276
|
-
var
|
|
277
|
-
var
|
|
278
|
-
var
|
|
279
|
-
var
|
|
280
|
-
var
|
|
281
|
-
var
|
|
282
|
-
var
|
|
275
|
+
// runtime/subsystems/integration/integration.tokens.ts
|
|
276
|
+
var INTEGRATION_CHANGE_SOURCE = "INTEGRATION_CHANGE_SOURCE";
|
|
277
|
+
var INTEGRATION_CURSOR_STORE = "INTEGRATION_CURSOR_STORE";
|
|
278
|
+
var INTEGRATION_FIELD_DIFFER = "INTEGRATION_FIELD_DIFFER";
|
|
279
|
+
var INTEGRATION_SINK = "INTEGRATION_SINK";
|
|
280
|
+
var INTEGRATION_RUN_RECORDER = "INTEGRATION_RUN_RECORDER";
|
|
281
|
+
var INTEGRATION_MODULE_OPTIONS = "INTEGRATION_MODULE_OPTIONS";
|
|
282
|
+
var INTEGRATION_MULTI_TENANT = "INTEGRATION_MULTI_TENANT";
|
|
283
283
|
|
|
284
|
-
// runtime/subsystems/
|
|
284
|
+
// runtime/subsystems/integration/integration-errors.ts
|
|
285
285
|
var MissingTenantIdError = class extends Error {
|
|
286
286
|
name = "MissingTenantIdError";
|
|
287
287
|
constructor(operation) {
|
|
288
288
|
super(
|
|
289
|
-
`Missing tenantId for
|
|
289
|
+
`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.`
|
|
290
290
|
);
|
|
291
291
|
}
|
|
292
292
|
};
|
|
@@ -297,7 +297,7 @@ function assertTenantId(tenantId, options) {
|
|
|
297
297
|
}
|
|
298
298
|
}
|
|
299
299
|
|
|
300
|
-
// runtime/subsystems/
|
|
300
|
+
// runtime/subsystems/integration/integration-audit.schema.ts
|
|
301
301
|
import {
|
|
302
302
|
pgEnum,
|
|
303
303
|
pgTable,
|
|
@@ -310,39 +310,39 @@ import {
|
|
|
310
310
|
index,
|
|
311
311
|
uniqueIndex
|
|
312
312
|
} from "drizzle-orm/pg-core";
|
|
313
|
-
var
|
|
313
|
+
var integrationRunDirectionEnum = pgEnum("integration_run_direction", [
|
|
314
314
|
"inbound",
|
|
315
315
|
"outbound"
|
|
316
316
|
]);
|
|
317
|
-
var
|
|
317
|
+
var integrationRunActionEnum = pgEnum("integration_run_action", [
|
|
318
318
|
"poll",
|
|
319
319
|
"cdc",
|
|
320
320
|
"webhook",
|
|
321
321
|
"manual",
|
|
322
322
|
"writeback"
|
|
323
323
|
]);
|
|
324
|
-
var
|
|
324
|
+
var integrationRunStatusEnum = pgEnum("integration_run_status", [
|
|
325
325
|
"running",
|
|
326
326
|
"success",
|
|
327
327
|
"no_changes",
|
|
328
328
|
"failed"
|
|
329
329
|
]);
|
|
330
|
-
var
|
|
330
|
+
var integrationRunItemOperationEnum = pgEnum("integration_run_item_operation", [
|
|
331
331
|
"created",
|
|
332
332
|
"updated",
|
|
333
333
|
"deleted",
|
|
334
334
|
"noop"
|
|
335
335
|
]);
|
|
336
|
-
var
|
|
336
|
+
var integrationRunItemStatusEnum = pgEnum("integration_run_item_status", [
|
|
337
337
|
"success",
|
|
338
338
|
"failed",
|
|
339
339
|
"skipped"
|
|
340
340
|
]);
|
|
341
|
-
var
|
|
342
|
-
"
|
|
341
|
+
var integrationSubscriptions = pgTable(
|
|
342
|
+
"integration_subscriptions",
|
|
343
343
|
{
|
|
344
344
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
345
|
-
|
|
345
|
+
connectionId: text("connection_id").notNull(),
|
|
346
346
|
adapter: text("adapter").notNull(),
|
|
347
347
|
domain: text("domain").notNull(),
|
|
348
348
|
externalRef: text("external_ref"),
|
|
@@ -357,8 +357,8 @@ var syncSubscriptions = pgTable(
|
|
|
357
357
|
* successful run advances it.
|
|
358
358
|
*/
|
|
359
359
|
cursor: jsonb("cursor").$type(),
|
|
360
|
-
|
|
361
|
-
/** Runtime-enforced when `
|
|
360
|
+
lastIntegrationAt: timestamp("last_integration_at", { withTimezone: true }),
|
|
361
|
+
/** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
|
|
362
362
|
tenantId: text("tenant_id"),
|
|
363
363
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
364
364
|
updatedAt: timestamp("updated_at", { withTimezone: true }).notNull().defaultNow()
|
|
@@ -367,31 +367,31 @@ var syncSubscriptions = pgTable(
|
|
|
367
367
|
/**
|
|
368
368
|
* Composite uniqueness per the epic shape. `external_ref` is nullable;
|
|
369
369
|
* Postgres treats NULLs as distinct in a UNIQUE constraint, which means
|
|
370
|
-
* two rows with the same `(
|
|
370
|
+
* two rows with the same `(connection_id, adapter, domain)` and NULL
|
|
371
371
|
* external_ref are allowed. That's intentional — a subscription with
|
|
372
372
|
* NULL external_ref covers the full domain, and duplicates there would
|
|
373
373
|
* be a consumer-layer modeling issue, not a schema concern.
|
|
374
374
|
*/
|
|
375
|
-
|
|
376
|
-
t.
|
|
375
|
+
uqIntegrationSubscriptionTuple: uniqueIndex("uq_integration_subscriptions_tuple").on(
|
|
376
|
+
t.connectionId,
|
|
377
377
|
t.adapter,
|
|
378
378
|
t.domain,
|
|
379
379
|
t.externalRef
|
|
380
380
|
),
|
|
381
381
|
/** Scheduling query: list enabled subscriptions ordered by staleness. */
|
|
382
|
-
|
|
383
|
-
"
|
|
384
|
-
).on(t.enabled, t.
|
|
382
|
+
idxIntegrationSubscriptionsEnabledLastIntegration: index(
|
|
383
|
+
"idx_integration_subscriptions_enabled_last_integration"
|
|
384
|
+
).on(t.enabled, t.lastIntegrationAt)
|
|
385
385
|
})
|
|
386
386
|
);
|
|
387
|
-
var
|
|
388
|
-
"
|
|
387
|
+
var integrationRuns = pgTable(
|
|
388
|
+
"integration_runs",
|
|
389
389
|
{
|
|
390
390
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
391
|
-
subscriptionId: uuid("subscription_id").notNull().references(() =>
|
|
392
|
-
direction:
|
|
393
|
-
action:
|
|
394
|
-
status:
|
|
391
|
+
subscriptionId: uuid("subscription_id").notNull().references(() => integrationSubscriptions.id, { onDelete: "cascade" }),
|
|
392
|
+
direction: integrationRunDirectionEnum("direction").notNull(),
|
|
393
|
+
action: integrationRunActionEnum("action").notNull(),
|
|
394
|
+
status: integrationRunStatusEnum("status").notNull().default("running"),
|
|
395
395
|
recordsFound: integer("records_found").notNull().default(0),
|
|
396
396
|
recordsProcessed: integer("records_processed").notNull().default(0),
|
|
397
397
|
cursorBefore: jsonb("cursor_before").$type(),
|
|
@@ -400,31 +400,31 @@ var syncRuns = pgTable(
|
|
|
400
400
|
error: text("error"),
|
|
401
401
|
startedAt: timestamp("started_at", { withTimezone: true }).notNull().defaultNow(),
|
|
402
402
|
completedAt: timestamp("completed_at", { withTimezone: true }),
|
|
403
|
-
/** Runtime-enforced when `
|
|
403
|
+
/** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
|
|
404
404
|
tenantId: text("tenant_id")
|
|
405
405
|
},
|
|
406
406
|
(t) => ({
|
|
407
407
|
/** Timeline read: "most recent runs for this subscription". */
|
|
408
|
-
|
|
409
|
-
"
|
|
408
|
+
idxIntegrationRunsSubscriptionStartedAt: index(
|
|
409
|
+
"idx_integration_runs_subscription_started_at"
|
|
410
410
|
).on(t.subscriptionId, t.startedAt),
|
|
411
411
|
/** Stale-run sweeper: "runs that started > N minutes ago and are still running". */
|
|
412
|
-
|
|
412
|
+
idxIntegrationRunsStatusStartedAt: index("idx_integration_runs_status_started_at").on(
|
|
413
413
|
t.status,
|
|
414
414
|
t.startedAt
|
|
415
415
|
)
|
|
416
416
|
})
|
|
417
417
|
);
|
|
418
|
-
var
|
|
419
|
-
"
|
|
418
|
+
var integrationRunItems = pgTable(
|
|
419
|
+
"integration_run_items",
|
|
420
420
|
{
|
|
421
421
|
id: uuid("id").primaryKey().defaultRandom(),
|
|
422
|
-
|
|
422
|
+
integrationRunId: uuid("integration_run_id").notNull().references(() => integrationRuns.id, { onDelete: "cascade" }),
|
|
423
423
|
entityType: text("entity_type").notNull(),
|
|
424
424
|
externalId: text("external_id").notNull(),
|
|
425
425
|
localId: text("local_id"),
|
|
426
|
-
operation:
|
|
427
|
-
status:
|
|
426
|
+
operation: integrationRunItemOperationEnum("operation").notNull(),
|
|
427
|
+
status: integrationRunItemStatusEnum("status").notNull(),
|
|
428
428
|
/**
|
|
429
429
|
* Structured per-field diff — ADR-0003 shape enforced by
|
|
430
430
|
* `FieldDiffSchema.parse` at the recorder service layer.
|
|
@@ -438,23 +438,23 @@ var syncRunItems = pgTable(
|
|
|
438
438
|
title: text("title"),
|
|
439
439
|
error: text("error"),
|
|
440
440
|
createdAt: timestamp("created_at", { withTimezone: true }).notNull().defaultNow(),
|
|
441
|
-
/** Runtime-enforced when `
|
|
441
|
+
/** Runtime-enforced when `INTEGRATION_MULTI_TENANT` is true; see SYNC-6. */
|
|
442
442
|
tenantId: text("tenant_id")
|
|
443
443
|
},
|
|
444
444
|
(t) => ({
|
|
445
445
|
/** Ordered timeline within a run. */
|
|
446
|
-
|
|
447
|
-
t.
|
|
446
|
+
idxIntegrationRunItemsRunCreatedAt: index("idx_integration_run_items_run_created_at").on(
|
|
447
|
+
t.integrationRunId,
|
|
448
448
|
t.createdAt
|
|
449
449
|
),
|
|
450
|
-
/** Per-record history: "every
|
|
451
|
-
|
|
452
|
-
"
|
|
450
|
+
/** Per-record history: "every integration that touched opportunity/$extId". */
|
|
451
|
+
idxIntegrationRunItemsEntityExternal: index(
|
|
452
|
+
"idx_integration_run_items_entity_external"
|
|
453
453
|
).on(t.entityType, t.externalId)
|
|
454
454
|
})
|
|
455
455
|
);
|
|
456
456
|
|
|
457
|
-
// runtime/subsystems/
|
|
457
|
+
// runtime/subsystems/integration/integration-cursor-store.memory-backend.ts
|
|
458
458
|
import { Injectable } from "@nestjs/common";
|
|
459
459
|
var MemoryCursorStore = class {
|
|
460
460
|
/**
|
|
@@ -465,7 +465,7 @@ var MemoryCursorStore = class {
|
|
|
465
465
|
/**
|
|
466
466
|
* Seedable subscription metadata for `listAll` — the memory backend
|
|
467
467
|
* stores only `subscriptionId → cursor` in its write path, so the
|
|
468
|
-
* snapshot shape (`
|
|
468
|
+
* snapshot shape (`connectionId`, `adapter`, `domain`, `externalRef`,
|
|
469
469
|
* timestamps) has no natural source without test seeding. Tests populate
|
|
470
470
|
* this map; unseeded entries get empty-string metadata and `new Date(0)`
|
|
471
471
|
* timestamps so the shape stays stable. Production paths go through the
|
|
@@ -485,12 +485,12 @@ var MemoryCursorStore = class {
|
|
|
485
485
|
const meta = this.subscriptions.get(subscriptionId);
|
|
486
486
|
snapshots.push({
|
|
487
487
|
subscriptionId,
|
|
488
|
-
|
|
488
|
+
connectionId: meta?.connectionId ?? "",
|
|
489
489
|
adapter: meta?.adapter ?? "",
|
|
490
490
|
domain: meta?.domain ?? "",
|
|
491
491
|
externalRef: meta?.externalRef ?? null,
|
|
492
492
|
cursor: cursor ?? null,
|
|
493
|
-
|
|
493
|
+
lastIntegrationAt: meta?.lastIntegrationAt ?? null,
|
|
494
494
|
updatedAt: meta?.updatedAt ?? /* @__PURE__ */ new Date(0),
|
|
495
495
|
tenantId: null
|
|
496
496
|
});
|
|
@@ -509,7 +509,7 @@ MemoryCursorStore = __decorateClass([
|
|
|
509
509
|
Injectable()
|
|
510
510
|
], MemoryCursorStore);
|
|
511
511
|
|
|
512
|
-
// runtime/subsystems/
|
|
512
|
+
// runtime/subsystems/integration/integration-run-recorder.memory-backend.ts
|
|
513
513
|
import { Injectable as Injectable2 } from "@nestjs/common";
|
|
514
514
|
var MemoryRunRecorder = class {
|
|
515
515
|
/**
|
|
@@ -518,14 +518,14 @@ var MemoryRunRecorder = class {
|
|
|
518
518
|
*/
|
|
519
519
|
runs = /* @__PURE__ */ new Map();
|
|
520
520
|
/**
|
|
521
|
-
* Items keyed by `
|
|
522
|
-
* mirrors the timeline the `(
|
|
521
|
+
* Items keyed by `integration_run_id`, array order matches insertion order —
|
|
522
|
+
* mirrors the timeline the `(integration_run_id, created_at)` index produces
|
|
523
523
|
* in Postgres.
|
|
524
524
|
*/
|
|
525
525
|
items = /* @__PURE__ */ new Map();
|
|
526
526
|
/**
|
|
527
527
|
* Seedable subscription metadata — tests populate this to make
|
|
528
|
-
* `listRecent` return meaningful `
|
|
528
|
+
* `listRecent` return meaningful `connectionId` values. The memory
|
|
529
529
|
* backend doesn't track subscriptions on its own (only runs + items), so
|
|
530
530
|
* this map is the intentional extension point: tests write entries for
|
|
531
531
|
* the subscription ids they use, production code never touches it.
|
|
@@ -554,10 +554,10 @@ var MemoryRunRecorder = class {
|
|
|
554
554
|
}
|
|
555
555
|
async recordItem(input) {
|
|
556
556
|
FieldDiffSchema.parse(input.changedFields);
|
|
557
|
-
const bucket = this.items.get(input.
|
|
557
|
+
const bucket = this.items.get(input.integrationRunId);
|
|
558
558
|
if (!bucket) {
|
|
559
559
|
throw new Error(
|
|
560
|
-
`MemoryRunRecorder.recordItem: no run started for id '${input.
|
|
560
|
+
`MemoryRunRecorder.recordItem: no run started for id '${input.integrationRunId}'. Call startRun(...) first.`
|
|
561
561
|
);
|
|
562
562
|
}
|
|
563
563
|
bucket.push(input);
|
|
@@ -583,10 +583,10 @@ var MemoryRunRecorder = class {
|
|
|
583
583
|
return filtered.sort((a, b) => b.startedAt.getTime() - a.startedAt.getTime()).slice(0, limit).map((r) => ({
|
|
584
584
|
id: r.id,
|
|
585
585
|
subscriptionId: r.subscriptionId,
|
|
586
|
-
//
|
|
586
|
+
// connectionId is only knowable if the test seeded subscriptions
|
|
587
587
|
// metadata; empty string otherwise. The Drizzle backend resolves
|
|
588
588
|
// it via JOIN, which is the production path.
|
|
589
|
-
|
|
589
|
+
connectionId: this.subscriptions.get(r.subscriptionId)?.connectionId ?? "",
|
|
590
590
|
status: r.status,
|
|
591
591
|
startedAt: r.startedAt,
|
|
592
592
|
completedAt: r.completedAt,
|
|
@@ -614,7 +614,7 @@ MemoryRunRecorder = __decorateClass([
|
|
|
614
614
|
Injectable2()
|
|
615
615
|
], MemoryRunRecorder);
|
|
616
616
|
|
|
617
|
-
// runtime/subsystems/
|
|
617
|
+
// runtime/subsystems/integration/deep-equal.differ.ts
|
|
618
618
|
import { Injectable as Injectable3 } from "@nestjs/common";
|
|
619
619
|
var DEFAULT_IGNORE_FIELDS = /* @__PURE__ */ new Set([
|
|
620
620
|
"id",
|
|
@@ -713,9 +713,9 @@ function deepEqualObject(a, b) {
|
|
|
713
713
|
return true;
|
|
714
714
|
}
|
|
715
715
|
|
|
716
|
-
// runtime/subsystems/
|
|
716
|
+
// runtime/subsystems/integration/execute-integration.use-case.ts
|
|
717
717
|
import { Inject, Injectable as Injectable4, Logger, Optional } from "@nestjs/common";
|
|
718
|
-
var
|
|
718
|
+
var ExecuteIntegrationUseCase = class {
|
|
719
719
|
constructor(source, cursors, differ, sink, recorder, multiTenant = false) {
|
|
720
720
|
this.source = source;
|
|
721
721
|
this.cursors = cursors;
|
|
@@ -730,7 +730,7 @@ var ExecuteSyncUseCase = class {
|
|
|
730
730
|
sink;
|
|
731
731
|
recorder;
|
|
732
732
|
multiTenant;
|
|
733
|
-
logger = new Logger(
|
|
733
|
+
logger = new Logger(ExecuteIntegrationUseCase.name);
|
|
734
734
|
async execute(input) {
|
|
735
735
|
assertTenantId(input.tenantId, {
|
|
736
736
|
multiTenant: this.multiTenant,
|
|
@@ -765,10 +765,10 @@ var ExecuteSyncUseCase = class {
|
|
|
765
765
|
recordsFailed++;
|
|
766
766
|
const message = err instanceof Error ? err.message : String(err);
|
|
767
767
|
this.logger.warn(
|
|
768
|
-
`
|
|
768
|
+
`integration item failed: subscription=${input.subscription.id} externalId=${change.externalId}: ${message}`
|
|
769
769
|
);
|
|
770
770
|
await this.recorder.recordItem({
|
|
771
|
-
|
|
771
|
+
integrationRunId: runId,
|
|
772
772
|
entityType: input.subscription.domain,
|
|
773
773
|
externalId: change.externalId,
|
|
774
774
|
operation: change.operation === "deleted" ? "deleted" : "updated",
|
|
@@ -791,7 +791,7 @@ var ExecuteSyncUseCase = class {
|
|
|
791
791
|
status = "failed";
|
|
792
792
|
runError = err instanceof Error ? err.message : String(err);
|
|
793
793
|
this.logger.error(
|
|
794
|
-
`
|
|
794
|
+
`integration source failed: subscription=${input.subscription.id}: ${runError}`
|
|
795
795
|
);
|
|
796
796
|
}
|
|
797
797
|
if (cursorAdvanced && latestCursor !== null && latestCursor !== void 0) {
|
|
@@ -836,7 +836,7 @@ var ExecuteSyncUseCase = class {
|
|
|
836
836
|
change.externalId
|
|
837
837
|
);
|
|
838
838
|
await this.recorder.recordItem({
|
|
839
|
-
|
|
839
|
+
integrationRunId: runId,
|
|
840
840
|
entityType: input.subscription.domain,
|
|
841
841
|
externalId: change.externalId,
|
|
842
842
|
localId: result?.id ?? null,
|
|
@@ -859,7 +859,7 @@ var ExecuteSyncUseCase = class {
|
|
|
859
859
|
if (diff === "noop") {
|
|
860
860
|
if (!this.sink.reprojectsOnNoop) {
|
|
861
861
|
await this.recorder.recordItem({
|
|
862
|
-
|
|
862
|
+
integrationRunId: runId,
|
|
863
863
|
entityType: input.subscription.domain,
|
|
864
864
|
externalId: change.externalId,
|
|
865
865
|
localId: null,
|
|
@@ -876,7 +876,7 @@ var ExecuteSyncUseCase = class {
|
|
|
876
876
|
input.provider
|
|
877
877
|
);
|
|
878
878
|
await this.recorder.recordItem({
|
|
879
|
-
|
|
879
|
+
integrationRunId: runId,
|
|
880
880
|
entityType: input.subscription.domain,
|
|
881
881
|
externalId: change.externalId,
|
|
882
882
|
localId: noopLocalId,
|
|
@@ -893,7 +893,7 @@ var ExecuteSyncUseCase = class {
|
|
|
893
893
|
input.provider
|
|
894
894
|
);
|
|
895
895
|
await this.recorder.recordItem({
|
|
896
|
-
|
|
896
|
+
integrationRunId: runId,
|
|
897
897
|
entityType: input.subscription.domain,
|
|
898
898
|
externalId: change.externalId,
|
|
899
899
|
localId,
|
|
@@ -904,25 +904,25 @@ var ExecuteSyncUseCase = class {
|
|
|
904
904
|
});
|
|
905
905
|
}
|
|
906
906
|
};
|
|
907
|
-
|
|
907
|
+
ExecuteIntegrationUseCase = __decorateClass([
|
|
908
908
|
Injectable4(),
|
|
909
|
-
__decorateParam(0, Inject(
|
|
910
|
-
__decorateParam(1, Inject(
|
|
911
|
-
__decorateParam(2, Inject(
|
|
912
|
-
__decorateParam(3, Inject(
|
|
913
|
-
__decorateParam(4, Inject(
|
|
909
|
+
__decorateParam(0, Inject(INTEGRATION_CHANGE_SOURCE)),
|
|
910
|
+
__decorateParam(1, Inject(INTEGRATION_CURSOR_STORE)),
|
|
911
|
+
__decorateParam(2, Inject(INTEGRATION_FIELD_DIFFER)),
|
|
912
|
+
__decorateParam(3, Inject(INTEGRATION_SINK)),
|
|
913
|
+
__decorateParam(4, Inject(INTEGRATION_RUN_RECORDER)),
|
|
914
914
|
__decorateParam(5, Optional()),
|
|
915
|
-
__decorateParam(5, Inject(
|
|
916
|
-
],
|
|
915
|
+
__decorateParam(5, Inject(INTEGRATION_MULTI_TENANT))
|
|
916
|
+
], ExecuteIntegrationUseCase);
|
|
917
917
|
|
|
918
|
-
// runtime/subsystems/
|
|
918
|
+
// runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
|
|
919
919
|
import { Inject as Inject2, Injectable as Injectable5, Optional as Optional2 } from "@nestjs/common";
|
|
920
920
|
import { and, desc, eq } from "drizzle-orm";
|
|
921
921
|
|
|
922
922
|
// runtime/constants/tokens.ts
|
|
923
923
|
var DRIZZLE = "DRIZZLE";
|
|
924
924
|
|
|
925
|
-
// runtime/subsystems/
|
|
925
|
+
// runtime/subsystems/integration/integration-cursor-store.drizzle-backend.ts
|
|
926
926
|
var PostgresCursorStore = class {
|
|
927
927
|
constructor(db, multiTenant) {
|
|
928
928
|
this.db = db;
|
|
@@ -932,15 +932,15 @@ var PostgresCursorStore = class {
|
|
|
932
932
|
multiTenant;
|
|
933
933
|
async get(subscriptionId, tenantId) {
|
|
934
934
|
const where = this.buildWhere(subscriptionId, tenantId, "cursor.get");
|
|
935
|
-
const rows = await this.db.select({ cursor:
|
|
935
|
+
const rows = await this.db.select({ cursor: integrationSubscriptions.cursor }).from(integrationSubscriptions).where(where).limit(1);
|
|
936
936
|
if (rows.length === 0) return null;
|
|
937
937
|
return rows[0]?.cursor ?? null;
|
|
938
938
|
}
|
|
939
939
|
async put(subscriptionId, cursor, tenantId) {
|
|
940
940
|
const where = this.buildWhere(subscriptionId, tenantId, "cursor.put");
|
|
941
|
-
await this.db.update(
|
|
941
|
+
await this.db.update(integrationSubscriptions).set({
|
|
942
942
|
cursor,
|
|
943
|
-
|
|
943
|
+
lastIntegrationAt: /* @__PURE__ */ new Date(),
|
|
944
944
|
updatedAt: /* @__PURE__ */ new Date()
|
|
945
945
|
}).where(where);
|
|
946
946
|
}
|
|
@@ -949,26 +949,26 @@ var PostgresCursorStore = class {
|
|
|
949
949
|
multiTenant: this.multiTenant,
|
|
950
950
|
operation: "cursor.listAll"
|
|
951
951
|
});
|
|
952
|
-
const where = this.multiTenant ? eq(
|
|
952
|
+
const where = this.multiTenant ? eq(integrationSubscriptions.tenantId, tenantId) : void 0;
|
|
953
953
|
const rows = await this.db.select({
|
|
954
|
-
id:
|
|
955
|
-
|
|
956
|
-
adapter:
|
|
957
|
-
domain:
|
|
958
|
-
externalRef:
|
|
959
|
-
cursor:
|
|
960
|
-
|
|
961
|
-
updatedAt:
|
|
962
|
-
tenantId:
|
|
963
|
-
}).from(
|
|
954
|
+
id: integrationSubscriptions.id,
|
|
955
|
+
connectionId: integrationSubscriptions.connectionId,
|
|
956
|
+
adapter: integrationSubscriptions.adapter,
|
|
957
|
+
domain: integrationSubscriptions.domain,
|
|
958
|
+
externalRef: integrationSubscriptions.externalRef,
|
|
959
|
+
cursor: integrationSubscriptions.cursor,
|
|
960
|
+
lastIntegrationAt: integrationSubscriptions.lastIntegrationAt,
|
|
961
|
+
updatedAt: integrationSubscriptions.updatedAt,
|
|
962
|
+
tenantId: integrationSubscriptions.tenantId
|
|
963
|
+
}).from(integrationSubscriptions).where(where).orderBy(desc(integrationSubscriptions.updatedAt));
|
|
964
964
|
return rows.map((row) => ({
|
|
965
965
|
subscriptionId: row.id,
|
|
966
|
-
|
|
966
|
+
connectionId: row.connectionId,
|
|
967
967
|
adapter: row.adapter,
|
|
968
968
|
domain: row.domain,
|
|
969
969
|
externalRef: row.externalRef,
|
|
970
970
|
cursor: row.cursor ?? null,
|
|
971
|
-
|
|
971
|
+
lastIntegrationAt: row.lastIntegrationAt,
|
|
972
972
|
updatedAt: row.updatedAt,
|
|
973
973
|
tenantId: row.tenantId
|
|
974
974
|
}));
|
|
@@ -985,24 +985,24 @@ var PostgresCursorStore = class {
|
|
|
985
985
|
});
|
|
986
986
|
if (this.multiTenant) {
|
|
987
987
|
return and(
|
|
988
|
-
eq(
|
|
989
|
-
eq(
|
|
988
|
+
eq(integrationSubscriptions.id, subscriptionId),
|
|
989
|
+
eq(integrationSubscriptions.tenantId, tenantId)
|
|
990
990
|
);
|
|
991
991
|
}
|
|
992
|
-
return eq(
|
|
992
|
+
return eq(integrationSubscriptions.id, subscriptionId);
|
|
993
993
|
}
|
|
994
994
|
};
|
|
995
995
|
PostgresCursorStore = __decorateClass([
|
|
996
996
|
Injectable5(),
|
|
997
997
|
__decorateParam(0, Inject2(DRIZZLE)),
|
|
998
998
|
__decorateParam(1, Optional2()),
|
|
999
|
-
__decorateParam(1, Inject2(
|
|
999
|
+
__decorateParam(1, Inject2(INTEGRATION_MULTI_TENANT))
|
|
1000
1000
|
], PostgresCursorStore);
|
|
1001
1001
|
|
|
1002
|
-
// runtime/subsystems/
|
|
1002
|
+
// runtime/subsystems/integration/integration-run-recorder.drizzle-backend.ts
|
|
1003
1003
|
import { Inject as Inject3, Injectable as Injectable6, Optional as Optional3 } from "@nestjs/common";
|
|
1004
1004
|
import { and as and2, desc as desc2, eq as eq2 } from "drizzle-orm";
|
|
1005
|
-
var
|
|
1005
|
+
var DrizzleIntegrationRunRecorder = class {
|
|
1006
1006
|
constructor(db, multiTenant) {
|
|
1007
1007
|
this.db = db;
|
|
1008
1008
|
this.multiTenant = multiTenant ?? false;
|
|
@@ -1014,17 +1014,17 @@ var DrizzleSyncRunRecorder = class {
|
|
|
1014
1014
|
multiTenant: this.multiTenant,
|
|
1015
1015
|
operation: "startRun"
|
|
1016
1016
|
});
|
|
1017
|
-
const rows = await this.db.insert(
|
|
1017
|
+
const rows = await this.db.insert(integrationRuns).values({
|
|
1018
1018
|
subscriptionId: input.subscriptionId,
|
|
1019
1019
|
direction: input.direction,
|
|
1020
1020
|
action: input.action,
|
|
1021
1021
|
status: "running",
|
|
1022
1022
|
cursorBefore: input.cursorBefore ?? null,
|
|
1023
1023
|
tenantId: input.tenantId ?? null
|
|
1024
|
-
}).returning({ id:
|
|
1024
|
+
}).returning({ id: integrationRuns.id });
|
|
1025
1025
|
const id = rows[0]?.id;
|
|
1026
1026
|
if (!id) {
|
|
1027
|
-
throw new Error("
|
|
1027
|
+
throw new Error("DrizzleIntegrationRunRecorder: INSERT RETURNING produced no id");
|
|
1028
1028
|
}
|
|
1029
1029
|
return { id };
|
|
1030
1030
|
}
|
|
@@ -1034,8 +1034,8 @@ var DrizzleSyncRunRecorder = class {
|
|
|
1034
1034
|
operation: "recordItem"
|
|
1035
1035
|
});
|
|
1036
1036
|
FieldDiffSchema.parse(input.changedFields);
|
|
1037
|
-
await this.db.insert(
|
|
1038
|
-
|
|
1037
|
+
await this.db.insert(integrationRunItems).values({
|
|
1038
|
+
integrationRunId: input.integrationRunId,
|
|
1039
1039
|
entityType: input.entityType,
|
|
1040
1040
|
externalId: input.externalId,
|
|
1041
1041
|
localId: input.localId ?? null,
|
|
@@ -1054,29 +1054,29 @@ var DrizzleSyncRunRecorder = class {
|
|
|
1054
1054
|
});
|
|
1055
1055
|
const conditions = [];
|
|
1056
1056
|
if (subscriptionId !== void 0) {
|
|
1057
|
-
conditions.push(eq2(
|
|
1057
|
+
conditions.push(eq2(integrationRuns.subscriptionId, subscriptionId));
|
|
1058
1058
|
}
|
|
1059
1059
|
if (this.multiTenant) {
|
|
1060
|
-
conditions.push(eq2(
|
|
1060
|
+
conditions.push(eq2(integrationRuns.tenantId, tenantId));
|
|
1061
1061
|
}
|
|
1062
1062
|
const where = conditions.length === 0 ? void 0 : conditions.length === 1 ? conditions[0] : and2(...conditions);
|
|
1063
1063
|
const rows = await this.db.select({
|
|
1064
|
-
id:
|
|
1065
|
-
subscriptionId:
|
|
1066
|
-
|
|
1067
|
-
status:
|
|
1068
|
-
startedAt:
|
|
1069
|
-
completedAt:
|
|
1070
|
-
recordsProcessed:
|
|
1071
|
-
tenantId:
|
|
1072
|
-
}).from(
|
|
1073
|
-
|
|
1074
|
-
eq2(
|
|
1075
|
-
).where(where).orderBy(desc2(
|
|
1064
|
+
id: integrationRuns.id,
|
|
1065
|
+
subscriptionId: integrationRuns.subscriptionId,
|
|
1066
|
+
connectionId: integrationSubscriptions.connectionId,
|
|
1067
|
+
status: integrationRuns.status,
|
|
1068
|
+
startedAt: integrationRuns.startedAt,
|
|
1069
|
+
completedAt: integrationRuns.completedAt,
|
|
1070
|
+
recordsProcessed: integrationRuns.recordsProcessed,
|
|
1071
|
+
tenantId: integrationRuns.tenantId
|
|
1072
|
+
}).from(integrationRuns).innerJoin(
|
|
1073
|
+
integrationSubscriptions,
|
|
1074
|
+
eq2(integrationRuns.subscriptionId, integrationSubscriptions.id)
|
|
1075
|
+
).where(where).orderBy(desc2(integrationRuns.startedAt)).limit(limit);
|
|
1076
1076
|
return rows.map((row) => ({
|
|
1077
1077
|
id: row.id,
|
|
1078
1078
|
subscriptionId: row.subscriptionId,
|
|
1079
|
-
|
|
1079
|
+
connectionId: row.connectionId,
|
|
1080
1080
|
status: row.status,
|
|
1081
1081
|
startedAt: row.startedAt,
|
|
1082
1082
|
completedAt: row.completedAt,
|
|
@@ -1085,7 +1085,7 @@ var DrizzleSyncRunRecorder = class {
|
|
|
1085
1085
|
}));
|
|
1086
1086
|
}
|
|
1087
1087
|
async completeRun(runId, input) {
|
|
1088
|
-
await this.db.update(
|
|
1088
|
+
await this.db.update(integrationRuns).set({
|
|
1089
1089
|
status: input.status,
|
|
1090
1090
|
recordsFound: input.recordsFound,
|
|
1091
1091
|
recordsProcessed: input.recordsProcessed,
|
|
@@ -1093,27 +1093,27 @@ var DrizzleSyncRunRecorder = class {
|
|
|
1093
1093
|
durationMs: input.durationMs,
|
|
1094
1094
|
error: input.error ?? null,
|
|
1095
1095
|
completedAt: /* @__PURE__ */ new Date()
|
|
1096
|
-
}).where(eq2(
|
|
1096
|
+
}).where(eq2(integrationRuns.id, runId));
|
|
1097
1097
|
}
|
|
1098
1098
|
};
|
|
1099
|
-
|
|
1099
|
+
DrizzleIntegrationRunRecorder = __decorateClass([
|
|
1100
1100
|
Injectable6(),
|
|
1101
1101
|
__decorateParam(0, Inject3(DRIZZLE)),
|
|
1102
1102
|
__decorateParam(1, Optional3()),
|
|
1103
|
-
__decorateParam(1, Inject3(
|
|
1104
|
-
],
|
|
1103
|
+
__decorateParam(1, Inject3(INTEGRATION_MULTI_TENANT))
|
|
1104
|
+
], DrizzleIntegrationRunRecorder);
|
|
1105
1105
|
|
|
1106
|
-
// runtime/subsystems/
|
|
1106
|
+
// runtime/subsystems/integration/integration.module.ts
|
|
1107
1107
|
import { Module } from "@nestjs/common";
|
|
1108
|
-
var
|
|
1108
|
+
var IntegrationModule = class {
|
|
1109
1109
|
static forRoot(options) {
|
|
1110
1110
|
const multiTenant = options.multiTenant ?? false;
|
|
1111
1111
|
const sharedProviders = [
|
|
1112
|
-
{ provide:
|
|
1113
|
-
{ provide:
|
|
1112
|
+
{ provide: INTEGRATION_MODULE_OPTIONS, useValue: options },
|
|
1113
|
+
{ provide: INTEGRATION_MULTI_TENANT, useValue: multiTenant },
|
|
1114
1114
|
// Default differ — consumers can override by binding a different
|
|
1115
|
-
// `IFieldDiffer<T>` to `
|
|
1116
|
-
{ provide:
|
|
1115
|
+
// `IFieldDiffer<T>` to `INTEGRATION_FIELD_DIFFER` in their feature module.
|
|
1116
|
+
{ provide: INTEGRATION_FIELD_DIFFER, useValue: new DeepEqualDiffer() }
|
|
1117
1117
|
];
|
|
1118
1118
|
const backendProviders = options.backend === "memory" ? [
|
|
1119
1119
|
// Wired as singletons via `useValue` so tests can pull
|
|
@@ -1121,47 +1121,55 @@ var SyncModule = class {
|
|
|
1121
1121
|
// direct assertions. Matches JOB-4 / MemoryJobStore shape.
|
|
1122
1122
|
{ provide: MemoryCursorStore, useValue: new MemoryCursorStore() },
|
|
1123
1123
|
{
|
|
1124
|
-
provide:
|
|
1124
|
+
provide: INTEGRATION_CURSOR_STORE,
|
|
1125
1125
|
useExisting: MemoryCursorStore
|
|
1126
1126
|
},
|
|
1127
1127
|
{ provide: MemoryRunRecorder, useValue: new MemoryRunRecorder() },
|
|
1128
1128
|
{
|
|
1129
|
-
provide:
|
|
1129
|
+
provide: INTEGRATION_RUN_RECORDER,
|
|
1130
1130
|
useExisting: MemoryRunRecorder
|
|
1131
1131
|
}
|
|
1132
1132
|
] : [
|
|
1133
1133
|
// Drizzle backends — injected with DRIZZLE (provided by the
|
|
1134
|
-
// consumer's DrizzleModule) + the
|
|
1134
|
+
// consumer's DrizzleModule) + the INTEGRATION_MULTI_TENANT flag
|
|
1135
1135
|
// we bound above.
|
|
1136
|
-
{ provide:
|
|
1137
|
-
{ provide:
|
|
1136
|
+
{ provide: INTEGRATION_CURSOR_STORE, useClass: PostgresCursorStore },
|
|
1137
|
+
{ provide: INTEGRATION_RUN_RECORDER, useClass: DrizzleIntegrationRunRecorder }
|
|
1138
1138
|
];
|
|
1139
1139
|
return {
|
|
1140
|
-
module:
|
|
1140
|
+
module: IntegrationModule,
|
|
1141
1141
|
global: true,
|
|
1142
1142
|
providers: [...sharedProviders, ...backendProviders],
|
|
1143
1143
|
exports: [
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1144
|
+
INTEGRATION_MODULE_OPTIONS,
|
|
1145
|
+
INTEGRATION_MULTI_TENANT,
|
|
1146
|
+
INTEGRATION_FIELD_DIFFER,
|
|
1147
|
+
INTEGRATION_CURSOR_STORE,
|
|
1148
|
+
INTEGRATION_RUN_RECORDER
|
|
1149
1149
|
]
|
|
1150
1150
|
};
|
|
1151
1151
|
}
|
|
1152
1152
|
};
|
|
1153
|
-
|
|
1153
|
+
IntegrationModule = __decorateClass([
|
|
1154
1154
|
Module({})
|
|
1155
|
-
],
|
|
1155
|
+
], IntegrationModule);
|
|
1156
1156
|
export {
|
|
1157
1157
|
CursorStrategySchema,
|
|
1158
1158
|
DeepEqualDiffer,
|
|
1159
1159
|
DetectionConfigSchema,
|
|
1160
|
-
|
|
1161
|
-
|
|
1160
|
+
DrizzleIntegrationRunRecorder,
|
|
1161
|
+
ExecuteIntegrationUseCase,
|
|
1162
1162
|
FieldDiffSchema,
|
|
1163
1163
|
FieldDiffValueSchema,
|
|
1164
1164
|
FieldMappingSchema,
|
|
1165
|
+
INTEGRATION_CHANGE_SOURCE,
|
|
1166
|
+
INTEGRATION_CURSOR_STORE,
|
|
1167
|
+
INTEGRATION_FIELD_DIFFER,
|
|
1168
|
+
INTEGRATION_MODULE_OPTIONS,
|
|
1169
|
+
INTEGRATION_MULTI_TENANT,
|
|
1170
|
+
INTEGRATION_RUN_RECORDER,
|
|
1171
|
+
INTEGRATION_SINK,
|
|
1172
|
+
IntegrationModule,
|
|
1165
1173
|
MemoryCursorStore,
|
|
1166
1174
|
MemoryRunRecorder,
|
|
1167
1175
|
MissingTenantIdError,
|
|
@@ -1169,26 +1177,18 @@ export {
|
|
|
1169
1177
|
PollDetectionSchema,
|
|
1170
1178
|
PostgresCursorStore,
|
|
1171
1179
|
ResolvedFilterSchema,
|
|
1172
|
-
SYNC_CHANGE_SOURCE,
|
|
1173
|
-
SYNC_CURSOR_STORE,
|
|
1174
|
-
SYNC_FIELD_DIFFER,
|
|
1175
|
-
SYNC_MODULE_OPTIONS,
|
|
1176
|
-
SYNC_MULTI_TENANT,
|
|
1177
|
-
SYNC_RUN_RECORDER,
|
|
1178
|
-
SYNC_SINK,
|
|
1179
|
-
SyncModule,
|
|
1180
1180
|
WebhookChangeSource,
|
|
1181
1181
|
WebhookDetectionSchema,
|
|
1182
1182
|
assertTenantId,
|
|
1183
1183
|
buildChangeSource,
|
|
1184
1184
|
createLoopbackMiddleware,
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1185
|
+
integrationRunActionEnum,
|
|
1186
|
+
integrationRunDirectionEnum,
|
|
1187
|
+
integrationRunItemOperationEnum,
|
|
1188
|
+
integrationRunItemStatusEnum,
|
|
1189
|
+
integrationRunItems,
|
|
1190
|
+
integrationRunStatusEnum,
|
|
1191
|
+
integrationRuns,
|
|
1192
|
+
integrationSubscriptions
|
|
1193
1193
|
};
|
|
1194
1194
|
//# sourceMappingURL=index.js.map
|