@contractspec/example.integration-hub 1.57.0 → 1.58.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.
Files changed (190) hide show
  1. package/dist/browser/connection/connection.enum.js +12 -0
  2. package/dist/browser/connection/connection.operation.js +101 -0
  3. package/dist/browser/connection/connection.presentation.js +99 -0
  4. package/dist/browser/connection/connection.schema.js +48 -0
  5. package/dist/browser/connection/index.js +104 -0
  6. package/dist/browser/docs/index.js +104 -0
  7. package/dist/browser/docs/integration-hub.docblock.js +104 -0
  8. package/dist/browser/events.js +211 -0
  9. package/dist/browser/example.js +42 -0
  10. package/dist/browser/handlers/index.js +246 -0
  11. package/dist/browser/handlers/integration.handlers.js +246 -0
  12. package/dist/browser/index.js +1595 -0
  13. package/dist/browser/integration/index.js +92 -0
  14. package/dist/browser/integration/integration.enum.js +12 -0
  15. package/dist/browser/integration/integration.operations.js +89 -0
  16. package/dist/browser/integration/integration.presentation.js +117 -0
  17. package/dist/browser/integration/integration.schema.js +42 -0
  18. package/dist/browser/integration-hub.capability.js +40 -0
  19. package/dist/browser/integration-hub.feature.js +114 -0
  20. package/dist/browser/seeders/index.js +60 -0
  21. package/dist/browser/sync/index.js +332 -0
  22. package/dist/browser/sync/sync.enum.js +26 -0
  23. package/dist/browser/sync/sync.operations.js +321 -0
  24. package/dist/browser/sync/sync.presentation.js +298 -0
  25. package/dist/browser/sync/sync.schema.js +154 -0
  26. package/dist/browser/sync-engine/index.js +186 -0
  27. package/dist/browser/tests/operations.test-spec.js +85 -0
  28. package/dist/browser/ui/IntegrationDashboard.js +369 -0
  29. package/dist/browser/ui/hooks/index.js +57 -0
  30. package/dist/browser/ui/hooks/useIntegrationData.js +54 -0
  31. package/dist/browser/ui/index.js +644 -0
  32. package/dist/browser/ui/renderers/index.js +273 -0
  33. package/dist/browser/ui/renderers/integration.markdown.js +273 -0
  34. package/dist/connection/connection.enum.d.ts +1 -6
  35. package/dist/connection/connection.enum.d.ts.map +1 -1
  36. package/dist/connection/connection.enum.js +11 -15
  37. package/dist/connection/connection.operation.d.ts +78 -84
  38. package/dist/connection/connection.operation.d.ts.map +1 -1
  39. package/dist/connection/connection.operation.js +99 -60
  40. package/dist/connection/connection.presentation.d.ts +2 -7
  41. package/dist/connection/connection.presentation.d.ts.map +1 -1
  42. package/dist/connection/connection.presentation.js +96 -56
  43. package/dist/connection/connection.schema.d.ts +54 -59
  44. package/dist/connection/connection.schema.d.ts.map +1 -1
  45. package/dist/connection/connection.schema.js +46 -73
  46. package/dist/connection/index.d.ts +7 -4
  47. package/dist/connection/index.d.ts.map +1 -0
  48. package/dist/connection/index.js +104 -4
  49. package/dist/docs/index.d.ts +2 -1
  50. package/dist/docs/index.d.ts.map +1 -0
  51. package/dist/docs/index.js +105 -1
  52. package/dist/docs/integration-hub.docblock.d.ts +2 -1
  53. package/dist/docs/integration-hub.docblock.d.ts.map +1 -0
  54. package/dist/docs/integration-hub.docblock.js +45 -56
  55. package/dist/events.d.ts +137 -143
  56. package/dist/events.d.ts.map +1 -1
  57. package/dist/events.js +210 -287
  58. package/dist/example.d.ts +2 -6
  59. package/dist/example.d.ts.map +1 -1
  60. package/dist/example.js +41 -55
  61. package/dist/handlers/index.d.ts +2 -2
  62. package/dist/handlers/index.d.ts.map +1 -0
  63. package/dist/handlers/index.js +247 -3
  64. package/dist/handlers/integration.handlers.d.ts +114 -113
  65. package/dist/handlers/integration.handlers.d.ts.map +1 -1
  66. package/dist/handlers/integration.handlers.js +232 -267
  67. package/dist/index.d.ts +12 -19
  68. package/dist/index.d.ts.map +1 -0
  69. package/dist/index.js +1596 -20
  70. package/dist/integration/index.d.ts +7 -4
  71. package/dist/integration/index.d.ts.map +1 -0
  72. package/dist/integration/index.js +92 -4
  73. package/dist/integration/integration.enum.d.ts +1 -6
  74. package/dist/integration/integration.enum.d.ts.map +1 -1
  75. package/dist/integration/integration.enum.js +11 -15
  76. package/dist/integration/integration.operations.d.ts +74 -80
  77. package/dist/integration/integration.operations.d.ts.map +1 -1
  78. package/dist/integration/integration.operations.js +87 -54
  79. package/dist/integration/integration.presentation.d.ts +3 -8
  80. package/dist/integration/integration.presentation.d.ts.map +1 -1
  81. package/dist/integration/integration.presentation.js +114 -73
  82. package/dist/integration/integration.schema.d.ts +54 -59
  83. package/dist/integration/integration.schema.d.ts.map +1 -1
  84. package/dist/integration/integration.schema.js +40 -73
  85. package/dist/integration-hub.capability.d.ts +3 -8
  86. package/dist/integration-hub.capability.d.ts.map +1 -1
  87. package/dist/integration-hub.capability.js +41 -38
  88. package/dist/integration-hub.feature.d.ts +1 -6
  89. package/dist/integration-hub.feature.d.ts.map +1 -1
  90. package/dist/integration-hub.feature.js +113 -242
  91. package/dist/node/connection/connection.enum.js +12 -0
  92. package/dist/node/connection/connection.operation.js +101 -0
  93. package/dist/node/connection/connection.presentation.js +99 -0
  94. package/dist/node/connection/connection.schema.js +48 -0
  95. package/dist/node/connection/index.js +104 -0
  96. package/dist/node/docs/index.js +104 -0
  97. package/dist/node/docs/integration-hub.docblock.js +104 -0
  98. package/dist/node/events.js +211 -0
  99. package/dist/node/example.js +42 -0
  100. package/dist/node/handlers/index.js +246 -0
  101. package/dist/node/handlers/integration.handlers.js +246 -0
  102. package/dist/node/index.js +1595 -0
  103. package/dist/node/integration/index.js +92 -0
  104. package/dist/node/integration/integration.enum.js +12 -0
  105. package/dist/node/integration/integration.operations.js +89 -0
  106. package/dist/node/integration/integration.presentation.js +117 -0
  107. package/dist/node/integration/integration.schema.js +42 -0
  108. package/dist/node/integration-hub.capability.js +40 -0
  109. package/dist/node/integration-hub.feature.js +114 -0
  110. package/dist/node/seeders/index.js +60 -0
  111. package/dist/node/sync/index.js +332 -0
  112. package/dist/node/sync/sync.enum.js +26 -0
  113. package/dist/node/sync/sync.operations.js +321 -0
  114. package/dist/node/sync/sync.presentation.js +298 -0
  115. package/dist/node/sync/sync.schema.js +154 -0
  116. package/dist/node/sync-engine/index.js +186 -0
  117. package/dist/node/tests/operations.test-spec.js +85 -0
  118. package/dist/node/ui/IntegrationDashboard.js +369 -0
  119. package/dist/node/ui/hooks/index.js +57 -0
  120. package/dist/node/ui/hooks/useIntegrationData.js +54 -0
  121. package/dist/node/ui/index.js +644 -0
  122. package/dist/node/ui/renderers/index.js +273 -0
  123. package/dist/node/ui/renderers/integration.markdown.js +273 -0
  124. package/dist/seeders/index.d.ts +4 -8
  125. package/dist/seeders/index.d.ts.map +1 -1
  126. package/dist/seeders/index.js +54 -52
  127. package/dist/sync/index.d.ts +7 -4
  128. package/dist/sync/index.d.ts.map +1 -0
  129. package/dist/sync/index.js +332 -4
  130. package/dist/sync/sync.enum.d.ts +3 -8
  131. package/dist/sync/sync.enum.d.ts.map +1 -1
  132. package/dist/sync/sync.enum.js +23 -31
  133. package/dist/sync/sync.operations.d.ts +413 -419
  134. package/dist/sync/sync.operations.d.ts.map +1 -1
  135. package/dist/sync/sync.operations.js +316 -197
  136. package/dist/sync/sync.presentation.d.ts +6 -11
  137. package/dist/sync/sync.presentation.d.ts.map +1 -1
  138. package/dist/sync/sync.presentation.js +291 -160
  139. package/dist/sync/sync.schema.d.ts +317 -322
  140. package/dist/sync/sync.schema.d.ts.map +1 -1
  141. package/dist/sync/sync.schema.js +146 -295
  142. package/dist/sync-engine/index.d.ts +88 -91
  143. package/dist/sync-engine/index.d.ts.map +1 -1
  144. package/dist/sync-engine/index.js +181 -142
  145. package/dist/tests/operations.test-spec.d.ts +3 -8
  146. package/dist/tests/operations.test-spec.d.ts.map +1 -1
  147. package/dist/tests/operations.test-spec.js +82 -90
  148. package/dist/ui/IntegrationDashboard.d.ts +1 -6
  149. package/dist/ui/IntegrationDashboard.d.ts.map +1 -1
  150. package/dist/ui/IntegrationDashboard.js +365 -261
  151. package/dist/ui/hooks/index.d.ts +2 -2
  152. package/dist/ui/hooks/index.d.ts.map +1 -0
  153. package/dist/ui/hooks/index.js +57 -4
  154. package/dist/ui/hooks/useIntegrationData.d.ts +16 -20
  155. package/dist/ui/hooks/useIntegrationData.d.ts.map +1 -1
  156. package/dist/ui/hooks/useIntegrationData.js +51 -55
  157. package/dist/ui/index.d.ts +7 -6
  158. package/dist/ui/index.d.ts.map +1 -0
  159. package/dist/ui/index.js +644 -5
  160. package/dist/ui/renderers/index.d.ts +2 -2
  161. package/dist/ui/renderers/index.d.ts.map +1 -0
  162. package/dist/ui/renderers/index.js +274 -3
  163. package/dist/ui/renderers/integration.markdown.d.ts +13 -14
  164. package/dist/ui/renderers/integration.markdown.d.ts.map +1 -1
  165. package/dist/ui/renderers/integration.markdown.js +268 -264
  166. package/package.json +360 -71
  167. package/dist/connection/connection.enum.js.map +0 -1
  168. package/dist/connection/connection.operation.js.map +0 -1
  169. package/dist/connection/connection.presentation.js.map +0 -1
  170. package/dist/connection/connection.schema.js.map +0 -1
  171. package/dist/docs/integration-hub.docblock.js.map +0 -1
  172. package/dist/events.js.map +0 -1
  173. package/dist/example.js.map +0 -1
  174. package/dist/handlers/integration.handlers.js.map +0 -1
  175. package/dist/integration/integration.enum.js.map +0 -1
  176. package/dist/integration/integration.operations.js.map +0 -1
  177. package/dist/integration/integration.presentation.js.map +0 -1
  178. package/dist/integration/integration.schema.js.map +0 -1
  179. package/dist/integration-hub.capability.js.map +0 -1
  180. package/dist/integration-hub.feature.js.map +0 -1
  181. package/dist/seeders/index.js.map +0 -1
  182. package/dist/sync/sync.enum.js.map +0 -1
  183. package/dist/sync/sync.operations.js.map +0 -1
  184. package/dist/sync/sync.presentation.js.map +0 -1
  185. package/dist/sync/sync.schema.js.map +0 -1
  186. package/dist/sync-engine/index.js.map +0 -1
  187. package/dist/tests/operations.test-spec.js.map +0 -1
  188. package/dist/ui/IntegrationDashboard.js.map +0 -1
  189. package/dist/ui/hooks/useIntegrationData.js.map +0 -1
  190. package/dist/ui/renderers/integration.markdown.js.map +0 -1
@@ -0,0 +1,104 @@
1
+ // src/connection/connection.enum.ts
2
+ import { defineEnum } from "@contractspec/lib.schema";
3
+ var ConnectionStatusEnum = defineEnum("ConnectionStatus", [
4
+ "PENDING",
5
+ "CONNECTED",
6
+ "DISCONNECTED",
7
+ "ERROR",
8
+ "EXPIRED"
9
+ ]);
10
+
11
+ // src/connection/connection.schema.ts
12
+ import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
13
+ var ConnectionModel = defineSchemaModel({
14
+ name: "ConnectionModel",
15
+ fields: {
16
+ id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
17
+ integrationId: {
18
+ type: ScalarTypeEnum.String_unsecure(),
19
+ isOptional: false
20
+ },
21
+ name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
22
+ status: { type: ConnectionStatusEnum, isOptional: false },
23
+ authType: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
24
+ externalAccountName: {
25
+ type: ScalarTypeEnum.String_unsecure(),
26
+ isOptional: true
27
+ },
28
+ connectedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
29
+ lastHealthCheck: { type: ScalarTypeEnum.DateTime(), isOptional: true },
30
+ healthStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
31
+ }
32
+ });
33
+ var CreateConnectionInputModel = defineSchemaModel({
34
+ name: "CreateConnectionInput",
35
+ fields: {
36
+ integrationId: {
37
+ type: ScalarTypeEnum.String_unsecure(),
38
+ isOptional: false
39
+ },
40
+ name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
41
+ authType: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
42
+ credentials: { type: ScalarTypeEnum.JSON(), isOptional: true }
43
+ }
44
+ });
45
+
46
+ // src/connection/connection.operation.ts
47
+ import { defineCommand } from "@contractspec/lib.contracts/operations";
48
+ var OWNERS = ["@example.integration-hub"];
49
+ var CreateConnectionContract = defineCommand({
50
+ meta: {
51
+ key: "integration.connection.create",
52
+ version: "1.0.0",
53
+ stability: "stable",
54
+ owners: [...OWNERS],
55
+ tags: ["integration", "connection", "create"],
56
+ description: "Create a connection to an external system.",
57
+ goal: "Authenticate with external systems.",
58
+ context: "Connection setup."
59
+ },
60
+ io: { input: CreateConnectionInputModel, output: ConnectionModel },
61
+ policy: { auth: "user" },
62
+ sideEffects: {
63
+ emits: [
64
+ {
65
+ key: "integration.connection.created",
66
+ version: "1.0.0",
67
+ when: "Connection created",
68
+ payload: ConnectionModel
69
+ }
70
+ ],
71
+ audit: ["integration.connection.created"]
72
+ },
73
+ acceptance: {
74
+ scenarios: [
75
+ {
76
+ key: "create-connection-happy-path",
77
+ given: ["User is authenticated"],
78
+ when: ["User creates connection with valid credentials"],
79
+ then: ["Connection is created", "ConnectionCreated event is emitted"]
80
+ }
81
+ ],
82
+ examples: [
83
+ {
84
+ key: "connect-crm",
85
+ input: {
86
+ name: "Salesforce Prod",
87
+ integrationId: "salesforce",
88
+ credentials: { clientId: "xxx" }
89
+ },
90
+ output: {
91
+ id: "conn-123",
92
+ status: "connected",
93
+ connectedAt: "2025-01-01T12:00:00Z"
94
+ }
95
+ }
96
+ ]
97
+ }
98
+ });
99
+ export {
100
+ CreateConnectionInputModel,
101
+ CreateConnectionContract,
102
+ ConnectionStatusEnum,
103
+ ConnectionModel
104
+ };
@@ -0,0 +1,104 @@
1
+ // src/docs/integration-hub.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var integrationHubDocBlocks = [
4
+ {
5
+ id: "docs.examples.integration-hub",
6
+ title: "Integration Hub",
7
+ summary: "Generic integration center with connectors, connections, sync configs, field mappings, and sync logs.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/integration-hub",
11
+ tags: ["integrations", "sync", "etl", "connectors"],
12
+ body: `## Entities
13
+
14
+ - Integration, Connection, SyncConfig, FieldMapping, SyncLog.
15
+ - Sync engine config lives in \`src/sync-engine\` to map remote <-> local entities.
16
+
17
+ ## Contracts
18
+
19
+ - \`integration.create\`, \`integration.connect\`, \`integration.configureSync\`, \`integration.mapFields\`, \`integration.runSync\`.
20
+ - Uses Jobs module for scheduled syncs and retries; Files module for payload archives.
21
+
22
+ ## Events
23
+
24
+ - sync.started/completed/failed, connection.connected/disconnected, mapping.updated.
25
+ - Forward to Notifications and Audit for observability.
26
+
27
+ ## UI / Presentations
28
+
29
+ - Dashboard, integration list, connection detail, sync config editor.
30
+ - Templates registered as \`integration-hub\` in Template Registry.
31
+
32
+ ## Notes
33
+
34
+ - Providers remain agnostic; keep mappings declarative for safe regeneration.
35
+ - Seed data includes voice integrations for \`ai-voice.gradium\` and \`ai-voice.fal\`.
36
+ - Feature flags can gate specific providers; metering can track sync volume.
37
+ `
38
+ },
39
+ {
40
+ id: "docs.examples.integration-hub.goal",
41
+ title: "Integration Hub — Goal",
42
+ summary: "Why this integration hub exists and what success looks like.",
43
+ kind: "goal",
44
+ visibility: "public",
45
+ route: "/docs/examples/integration-hub/goal",
46
+ tags: ["integrations", "goal"],
47
+ body: `## Why it matters
48
+ - Gives a regenerable, provider-agnostic integration hub with explicit mappings.
49
+ - Prevents drift between sync configs, mappings, and event/log outputs.
50
+
51
+ ## Business/Product goal
52
+ - Model connectors, connections, sync jobs, and mappings with governance and retries.
53
+ - Support staged provider rollouts via Feature Flags and observability via Audit/Notifications.
54
+
55
+ ## Success criteria
56
+ - Connections and mappings regenerate safely after spec edits.
57
+ - Sync events and logs provide auditability; payloads are stored and PII-scoped.`
58
+ },
59
+ {
60
+ id: "docs.examples.integration-hub.usage",
61
+ title: "Integration Hub — Usage",
62
+ summary: "How to configure connectors, mappings, and scheduled syncs.",
63
+ kind: "usage",
64
+ visibility: "public",
65
+ route: "/docs/examples/integration-hub/usage",
66
+ tags: ["integrations", "usage"],
67
+ body: `## Setup
68
+ 1) Seed integrations/connections (if available) or create connector definitions.
69
+ 2) Configure sync jobs with Jobs module; store payload archives via Files.
70
+
71
+ ## Extend & regenerate
72
+ 1) Add mapping fields or provider configs in the spec; include validation and PII paths.
73
+ 2) Regenerate to align UI/API/events/logs; verify Notifications/Audit hooks.
74
+ 3) Gate risky providers behind Feature Flags; meter sync volume if needed.
75
+
76
+ ## Guardrails
77
+ - Keep mappings declarative; avoid hardcoded transforms.
78
+ - Emit events for sync lifecycle; persist logs for audit.
79
+ - Redact sensitive payload paths in presentations.`
80
+ },
81
+ {
82
+ id: "docs.examples.integration-hub.constraints",
83
+ title: "Integration Hub — Constraints & Safety",
84
+ summary: "Internal guidance for sync lifecycle, mappings, and regeneration safety.",
85
+ kind: "reference",
86
+ visibility: "internal",
87
+ route: "/docs/examples/integration-hub/constraints",
88
+ tags: ["integrations", "constraints", "internal"],
89
+ body: `## Constraints
90
+ - Mappings and sync states must remain declarative in spec; no hidden code transforms.
91
+ - Events to emit at minimum: sync.started, sync.completed, sync.failed; connection.connected/disconnected.
92
+ - Regeneration should not alter retry/backoff semantics without explicit spec change.
93
+
94
+ ## PII & Payloads
95
+ - Treat payload archives as potentially sensitive; mark policy.pii paths.
96
+ - For MCP/web, avoid exposing raw credentials/tokens; store via provider adapters only.
97
+
98
+ ## Verification
99
+ - Include fixtures for mapping changes and sync retries.
100
+ - Validate that scheduled jobs (cron) are spec-driven; Jobs module wiring intact.
101
+ - Ensure Audit/Notifications receive sync lifecycle events.`
102
+ }
103
+ ];
104
+ registerDocBlocks(integrationHubDocBlocks);
@@ -0,0 +1,104 @@
1
+ // src/docs/integration-hub.docblock.ts
2
+ import { registerDocBlocks } from "@contractspec/lib.contracts/docs";
3
+ var integrationHubDocBlocks = [
4
+ {
5
+ id: "docs.examples.integration-hub",
6
+ title: "Integration Hub",
7
+ summary: "Generic integration center with connectors, connections, sync configs, field mappings, and sync logs.",
8
+ kind: "reference",
9
+ visibility: "public",
10
+ route: "/docs/examples/integration-hub",
11
+ tags: ["integrations", "sync", "etl", "connectors"],
12
+ body: `## Entities
13
+
14
+ - Integration, Connection, SyncConfig, FieldMapping, SyncLog.
15
+ - Sync engine config lives in \`src/sync-engine\` to map remote <-> local entities.
16
+
17
+ ## Contracts
18
+
19
+ - \`integration.create\`, \`integration.connect\`, \`integration.configureSync\`, \`integration.mapFields\`, \`integration.runSync\`.
20
+ - Uses Jobs module for scheduled syncs and retries; Files module for payload archives.
21
+
22
+ ## Events
23
+
24
+ - sync.started/completed/failed, connection.connected/disconnected, mapping.updated.
25
+ - Forward to Notifications and Audit for observability.
26
+
27
+ ## UI / Presentations
28
+
29
+ - Dashboard, integration list, connection detail, sync config editor.
30
+ - Templates registered as \`integration-hub\` in Template Registry.
31
+
32
+ ## Notes
33
+
34
+ - Providers remain agnostic; keep mappings declarative for safe regeneration.
35
+ - Seed data includes voice integrations for \`ai-voice.gradium\` and \`ai-voice.fal\`.
36
+ - Feature flags can gate specific providers; metering can track sync volume.
37
+ `
38
+ },
39
+ {
40
+ id: "docs.examples.integration-hub.goal",
41
+ title: "Integration Hub — Goal",
42
+ summary: "Why this integration hub exists and what success looks like.",
43
+ kind: "goal",
44
+ visibility: "public",
45
+ route: "/docs/examples/integration-hub/goal",
46
+ tags: ["integrations", "goal"],
47
+ body: `## Why it matters
48
+ - Gives a regenerable, provider-agnostic integration hub with explicit mappings.
49
+ - Prevents drift between sync configs, mappings, and event/log outputs.
50
+
51
+ ## Business/Product goal
52
+ - Model connectors, connections, sync jobs, and mappings with governance and retries.
53
+ - Support staged provider rollouts via Feature Flags and observability via Audit/Notifications.
54
+
55
+ ## Success criteria
56
+ - Connections and mappings regenerate safely after spec edits.
57
+ - Sync events and logs provide auditability; payloads are stored and PII-scoped.`
58
+ },
59
+ {
60
+ id: "docs.examples.integration-hub.usage",
61
+ title: "Integration Hub — Usage",
62
+ summary: "How to configure connectors, mappings, and scheduled syncs.",
63
+ kind: "usage",
64
+ visibility: "public",
65
+ route: "/docs/examples/integration-hub/usage",
66
+ tags: ["integrations", "usage"],
67
+ body: `## Setup
68
+ 1) Seed integrations/connections (if available) or create connector definitions.
69
+ 2) Configure sync jobs with Jobs module; store payload archives via Files.
70
+
71
+ ## Extend & regenerate
72
+ 1) Add mapping fields or provider configs in the spec; include validation and PII paths.
73
+ 2) Regenerate to align UI/API/events/logs; verify Notifications/Audit hooks.
74
+ 3) Gate risky providers behind Feature Flags; meter sync volume if needed.
75
+
76
+ ## Guardrails
77
+ - Keep mappings declarative; avoid hardcoded transforms.
78
+ - Emit events for sync lifecycle; persist logs for audit.
79
+ - Redact sensitive payload paths in presentations.`
80
+ },
81
+ {
82
+ id: "docs.examples.integration-hub.constraints",
83
+ title: "Integration Hub — Constraints & Safety",
84
+ summary: "Internal guidance for sync lifecycle, mappings, and regeneration safety.",
85
+ kind: "reference",
86
+ visibility: "internal",
87
+ route: "/docs/examples/integration-hub/constraints",
88
+ tags: ["integrations", "constraints", "internal"],
89
+ body: `## Constraints
90
+ - Mappings and sync states must remain declarative in spec; no hidden code transforms.
91
+ - Events to emit at minimum: sync.started, sync.completed, sync.failed; connection.connected/disconnected.
92
+ - Regeneration should not alter retry/backoff semantics without explicit spec change.
93
+
94
+ ## PII & Payloads
95
+ - Treat payload archives as potentially sensitive; mark policy.pii paths.
96
+ - For MCP/web, avoid exposing raw credentials/tokens; store via provider adapters only.
97
+
98
+ ## Verification
99
+ - Include fixtures for mapping changes and sync retries.
100
+ - Validate that scheduled jobs (cron) are spec-driven; Jobs module wiring intact.
101
+ - Ensure Audit/Notifications receive sync lifecycle events.`
102
+ }
103
+ ];
104
+ registerDocBlocks(integrationHubDocBlocks);
@@ -0,0 +1,211 @@
1
+ // src/events.ts
2
+ import { defineEvent } from "@contractspec/lib.contracts";
3
+ import { ScalarTypeEnum, defineSchemaModel } from "@contractspec/lib.schema";
4
+ var IntegrationCreatedPayload = defineSchemaModel({
5
+ name: "IntegrationCreatedPayload",
6
+ description: "Payload when an integration is created",
7
+ fields: {
8
+ integrationId: {
9
+ type: ScalarTypeEnum.String_unsecure(),
10
+ isOptional: false
11
+ },
12
+ type: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
13
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
14
+ }
15
+ });
16
+ var IntegrationCreatedEvent = defineEvent({
17
+ meta: {
18
+ key: "integration.created",
19
+ version: "1.0.0",
20
+ description: "Fired when a new integration is created",
21
+ stability: "experimental",
22
+ owners: ["@integration-team"],
23
+ tags: ["integration"]
24
+ },
25
+ payload: IntegrationCreatedPayload
26
+ });
27
+ var ConnectionCreatedPayload = defineSchemaModel({
28
+ name: "ConnectionCreatedPayload",
29
+ description: "Payload when a connection is established",
30
+ fields: {
31
+ connectionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
32
+ integrationId: {
33
+ type: ScalarTypeEnum.String_unsecure(),
34
+ isOptional: false
35
+ },
36
+ status: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
37
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
38
+ }
39
+ });
40
+ var ConnectionCreatedEvent = defineEvent({
41
+ meta: {
42
+ key: "integration.connection.created",
43
+ version: "1.0.0",
44
+ description: "Fired when a new connection is established",
45
+ stability: "experimental",
46
+ owners: ["@integration-team"],
47
+ tags: ["integration", "connection"]
48
+ },
49
+ payload: ConnectionCreatedPayload
50
+ });
51
+ var ConnectionStatusChangedPayload = defineSchemaModel({
52
+ name: "ConnectionStatusChangedPayload",
53
+ description: "Payload when a connection status changes",
54
+ fields: {
55
+ connectionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
56
+ previousStatus: {
57
+ type: ScalarTypeEnum.String_unsecure(),
58
+ isOptional: false
59
+ },
60
+ newStatus: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
61
+ changedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
62
+ }
63
+ });
64
+ var ConnectionStatusChangedEvent = defineEvent({
65
+ meta: {
66
+ key: "integration.connection.statusChanged",
67
+ version: "1.0.0",
68
+ description: "Fired when a connection status changes",
69
+ stability: "experimental",
70
+ owners: ["@integration-team"],
71
+ tags: ["integration", "connection"]
72
+ },
73
+ payload: ConnectionStatusChangedPayload
74
+ });
75
+ var SyncConfigCreatedPayload = defineSchemaModel({
76
+ name: "SyncConfigCreatedPayload",
77
+ description: "Payload when a sync configuration is created",
78
+ fields: {
79
+ syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
80
+ connectionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
81
+ createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
82
+ }
83
+ });
84
+ var SyncConfigCreatedEvent = defineEvent({
85
+ meta: {
86
+ key: "integration.syncConfig.created",
87
+ version: "1.0.0",
88
+ description: "Fired when a sync configuration is created",
89
+ stability: "experimental",
90
+ owners: ["@integration-team"],
91
+ tags: ["integration", "sync"]
92
+ },
93
+ payload: SyncConfigCreatedPayload
94
+ });
95
+ var SyncStartedPayload = defineSchemaModel({
96
+ name: "SyncStartedPayload",
97
+ description: "Payload when a sync run starts",
98
+ fields: {
99
+ syncRunId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
100
+ syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
101
+ startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
102
+ }
103
+ });
104
+ var SyncStartedEvent = defineEvent({
105
+ meta: {
106
+ key: "integration.sync.started",
107
+ version: "1.0.0",
108
+ description: "Fired when a sync run starts",
109
+ stability: "experimental",
110
+ owners: ["@integration-team"],
111
+ tags: ["integration", "sync"]
112
+ },
113
+ payload: SyncStartedPayload
114
+ });
115
+ var SyncCompletedPayload = defineSchemaModel({
116
+ name: "SyncCompletedPayload",
117
+ description: "Payload when a sync run completes successfully",
118
+ fields: {
119
+ syncRunId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
120
+ syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
121
+ recordsProcessed: {
122
+ type: ScalarTypeEnum.Int_unsecure(),
123
+ isOptional: false
124
+ },
125
+ completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
126
+ }
127
+ });
128
+ var SyncCompletedEvent = defineEvent({
129
+ meta: {
130
+ key: "integration.sync.completed",
131
+ version: "1.0.0",
132
+ description: "Fired when a sync run completes successfully",
133
+ stability: "experimental",
134
+ owners: ["@integration-team"],
135
+ tags: ["integration", "sync"]
136
+ },
137
+ payload: SyncCompletedPayload
138
+ });
139
+ var SyncFailedPayload = defineSchemaModel({
140
+ name: "SyncFailedPayload",
141
+ description: "Payload when a sync run fails",
142
+ fields: {
143
+ syncRunId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
144
+ syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
145
+ error: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
146
+ failedAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
147
+ }
148
+ });
149
+ var SyncFailedEvent = defineEvent({
150
+ meta: {
151
+ key: "integration.sync.failed",
152
+ version: "1.0.0",
153
+ description: "Fired when a sync run fails",
154
+ stability: "experimental",
155
+ owners: ["@integration-team"],
156
+ tags: ["integration", "sync"]
157
+ },
158
+ payload: SyncFailedPayload
159
+ });
160
+ var RecordSyncedPayload = defineSchemaModel({
161
+ name: "RecordSyncedPayload",
162
+ description: "Payload when a single record is synced",
163
+ fields: {
164
+ syncRunId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
165
+ recordId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
166
+ sourceId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
167
+ targetId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
168
+ }
169
+ });
170
+ var RecordSyncedEvent = defineEvent({
171
+ meta: {
172
+ key: "integration.record.synced",
173
+ version: "1.0.0",
174
+ description: "Fired when a single record is synced",
175
+ stability: "experimental",
176
+ owners: ["@integration-team"],
177
+ tags: ["integration", "sync"]
178
+ },
179
+ payload: RecordSyncedPayload
180
+ });
181
+ var FieldMappingAddedPayload = defineSchemaModel({
182
+ name: "FieldMappingAddedPayload",
183
+ description: "Payload when a field mapping is added to a sync config",
184
+ fields: {
185
+ syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
186
+ sourceField: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
187
+ targetField: { type: ScalarTypeEnum.String_unsecure(), isOptional: false }
188
+ }
189
+ });
190
+ var FieldMappingAddedEvent = defineEvent({
191
+ meta: {
192
+ key: "integration.fieldMapping.added",
193
+ version: "1.0.0",
194
+ description: "Fired when a field mapping is added to a sync config",
195
+ stability: "experimental",
196
+ owners: ["@integration-team"],
197
+ tags: ["integration", "sync"]
198
+ },
199
+ payload: FieldMappingAddedPayload
200
+ });
201
+ export {
202
+ SyncStartedEvent,
203
+ SyncFailedEvent,
204
+ SyncConfigCreatedEvent,
205
+ SyncCompletedEvent,
206
+ RecordSyncedEvent,
207
+ IntegrationCreatedEvent,
208
+ FieldMappingAddedEvent,
209
+ ConnectionStatusChangedEvent,
210
+ ConnectionCreatedEvent
211
+ };
@@ -0,0 +1,42 @@
1
+ // src/example.ts
2
+ import { defineExample } from "@contractspec/lib.contracts";
3
+ var example = defineExample({
4
+ meta: {
5
+ key: "integration-hub",
6
+ version: "1.0.0",
7
+ title: "Integration Hub",
8
+ description: "Provider-agnostic integration center with connectors, connections, field mappings, and sync logs.",
9
+ kind: "template",
10
+ visibility: "public",
11
+ stability: "experimental",
12
+ owners: ["@platform.core"],
13
+ tags: ["integrations", "sync", "etl", "connectors"]
14
+ },
15
+ docs: {
16
+ rootDocId: "docs.examples.integration-hub",
17
+ goalDocId: "docs.examples.integration-hub.goal",
18
+ usageDocId: "docs.examples.integration-hub.usage",
19
+ constraintsDocId: "docs.examples.integration-hub.constraints"
20
+ },
21
+ entrypoints: {
22
+ packageName: "@contractspec/example.integration-hub",
23
+ feature: "./feature",
24
+ contracts: "./contracts",
25
+ presentations: "./presentations",
26
+ handlers: "./handlers",
27
+ docs: "./docs"
28
+ },
29
+ surfaces: {
30
+ templates: true,
31
+ sandbox: {
32
+ enabled: true,
33
+ modes: ["playground", "specs", "builder", "markdown", "evolution"]
34
+ },
35
+ studio: { enabled: true, installable: true },
36
+ mcp: { enabled: true }
37
+ }
38
+ });
39
+ var example_default = example;
40
+ export {
41
+ example_default as default
42
+ };