@contractspec/example.integration-hub 1.56.0 → 1.57.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 (52) hide show
  1. package/README.md +9 -19
  2. package/dist/connection/connection.enum.d.ts +2 -2
  3. package/dist/connection/connection.enum.d.ts.map +1 -1
  4. package/dist/connection/connection.operation.d.ts +27 -27
  5. package/dist/connection/connection.operation.d.ts.map +1 -1
  6. package/dist/connection/connection.presentation.d.ts +3 -3
  7. package/dist/connection/connection.presentation.d.ts.map +1 -1
  8. package/dist/connection/connection.schema.d.ts +16 -16
  9. package/dist/connection/connection.schema.d.ts.map +1 -1
  10. package/dist/docs/integration-hub.docblock.js +1 -0
  11. package/dist/docs/integration-hub.docblock.js.map +1 -1
  12. package/dist/events.d.ts.map +1 -1
  13. package/dist/example.d.ts +2 -2
  14. package/dist/example.d.ts.map +1 -1
  15. package/dist/example.js +1 -2
  16. package/dist/example.js.map +1 -1
  17. package/dist/handlers/integration.handlers.d.ts +1 -2
  18. package/dist/handlers/integration.handlers.d.ts.map +1 -1
  19. package/dist/handlers/integration.handlers.js.map +1 -1
  20. package/dist/integration/integration.enum.d.ts +2 -2
  21. package/dist/integration/integration.enum.d.ts.map +1 -1
  22. package/dist/integration/integration.operations.d.ts +25 -25
  23. package/dist/integration/integration.operations.d.ts.map +1 -1
  24. package/dist/integration/integration.presentation.d.ts +4 -4
  25. package/dist/integration/integration.presentation.d.ts.map +1 -1
  26. package/dist/integration/integration.schema.d.ts +16 -16
  27. package/dist/integration/integration.schema.d.ts.map +1 -1
  28. package/dist/integration-hub.capability.d.ts +4 -4
  29. package/dist/integration-hub.capability.d.ts.map +1 -1
  30. package/dist/integration-hub.feature.d.ts +2 -2
  31. package/dist/integration-hub.feature.d.ts.map +1 -1
  32. package/dist/seeders/index.d.ts.map +1 -1
  33. package/dist/seeders/index.js +40 -0
  34. package/dist/seeders/index.js.map +1 -1
  35. package/dist/sync/sync.enum.d.ts +4 -4
  36. package/dist/sync/sync.enum.d.ts.map +1 -1
  37. package/dist/sync/sync.operations.d.ts +126 -126
  38. package/dist/sync/sync.operations.d.ts.map +1 -1
  39. package/dist/sync/sync.presentation.d.ts +7 -7
  40. package/dist/sync/sync.presentation.d.ts.map +1 -1
  41. package/dist/sync/sync.schema.d.ts +85 -85
  42. package/dist/sync/sync.schema.d.ts.map +1 -1
  43. package/dist/sync-engine/index.d.ts.map +1 -1
  44. package/dist/tests/operations.test-spec.d.ts +4 -4
  45. package/dist/tests/operations.test-spec.d.ts.map +1 -1
  46. package/dist/ui/IntegrationDashboard.d.ts.map +1 -1
  47. package/dist/ui/hooks/useIntegrationData.d.ts.map +1 -1
  48. package/dist/ui/renderers/integration.markdown.d.ts +0 -1
  49. package/dist/ui/renderers/integration.markdown.d.ts.map +1 -1
  50. package/dist/ui/renderers/integration.markdown.js +14 -0
  51. package/dist/ui/renderers/integration.markdown.js.map +1 -1
  52. package/package.json +9 -9
package/README.md CHANGED
@@ -2,12 +2,13 @@
2
2
 
3
3
  Website: https://contractspec.io/
4
4
 
5
-
6
5
  A comprehensive integration hub example demonstrating ContractSpec principles for data synchronization.
7
6
 
8
7
  ## Features
9
8
 
10
9
  - **Multi-Provider Support**: Connect to various external systems (Salesforce, HubSpot, etc.)
10
+ - **Voice Provider Coverage**: Includes seeded examples for `ai-voice.gradium` and `ai-voice.fal`
11
+ - **Analytics Coverage**: Includes seeded examples for PostHog analytics
11
12
  - **Bidirectional Sync**: INBOUND, OUTBOUND, or BIDIRECTIONAL data flow
12
13
  - **Field Mapping**: Configurable field mappings with transforms
13
14
  - **Sync Engine**: Change detection, deduplication, and error handling
@@ -18,12 +19,14 @@ A comprehensive integration hub example demonstrating ContractSpec principles fo
18
19
  ## Entities
19
20
 
20
21
  ### Core
22
+
21
23
  - `Integration` - Integration definition
22
24
  - `Connection` - Authenticated connection to external system
23
25
  - `SyncConfig` - Sync configuration for object pairs
24
26
  - `FieldMapping` - Field-level mapping configuration
25
27
 
26
28
  ### Sync Execution
29
+
27
30
  - `SyncRun` - A single sync execution
28
31
  - `SyncLog` - Log entries for a sync run
29
32
  - `SyncRecord` - Tracks synced records for deduplication
@@ -31,14 +34,17 @@ A comprehensive integration hub example demonstrating ContractSpec principles fo
31
34
  ## Contracts
32
35
 
33
36
  ### Integration Management
37
+
34
38
  - `integration.create` - Create a new integration
35
39
  - `integration.connection.create` - Create a connection
36
40
 
37
41
  ### Sync Configuration
42
+
38
43
  - `integration.syncConfig.create` - Create sync config
39
44
  - `integration.fieldMapping.add` - Add field mapping
40
45
 
41
46
  ### Sync Execution
47
+
42
48
  - `integration.sync.trigger` - Trigger manual sync
43
49
  - `integration.syncRun.list` - List sync history
44
50
 
@@ -101,11 +107,11 @@ const result = engine.transformRecord(
101
107
  ## Usage
102
108
 
103
109
  ```typescript
104
- import {
110
+ import {
105
111
  CreateIntegrationContract,
106
112
  CreateSyncConfigContract,
107
113
  TriggerSyncContract,
108
- integrationHubSchemaContribution
114
+ integrationHubSchemaContribution
109
115
  } from '@contractspec/example.integration-hub';
110
116
 
111
117
  // Create integration
@@ -138,19 +144,3 @@ const run = await executeContract(TriggerSyncContract, {
138
144
  - `@contractspec/lib.files` - Import/export file handling
139
145
  - `@contractspec/lib.jobs` - Background sync jobs
140
146
  - `@contractspec/module.audit-trail` - Action auditing
141
-
142
-
143
-
144
-
145
-
146
-
147
-
148
-
149
-
150
-
151
-
152
-
153
-
154
-
155
-
156
-
@@ -1,10 +1,10 @@
1
- import * as _contractspec_lib_schema40 from "@contractspec/lib.schema";
1
+ import * as _contractspec_lib_schema0 from "@contractspec/lib.schema";
2
2
 
3
3
  //#region src/connection/connection.enum.d.ts
4
4
  /**
5
5
  * Connection status enum.
6
6
  */
7
- declare const ConnectionStatusEnum: _contractspec_lib_schema40.EnumType<[string, string, string, string, string]>;
7
+ declare const ConnectionStatusEnum: _contractspec_lib_schema0.EnumType<[string, string, string, string, string]>;
8
8
  //#endregion
9
9
  export { ConnectionStatusEnum };
10
10
  //# sourceMappingURL=connection.enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.enum.d.ts","names":[],"sources":["../../src/connection/connection.enum.ts"],"sourcesContent":[],"mappings":";;;;;;AAKa,cAAA,oBAMX,EAAA,0BAAA,CAN+B,QAAA,CAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"connection.enum.d.ts","names":[],"sources":["../../src/connection/connection.enum.ts"],"mappings":";;;;;;cAKa,oBAAA,EAMX,yBAAA,CAN+B,QAAA"}
@@ -1,103 +1,103 @@
1
- import * as _contractspec_lib_contracts13 from "@contractspec/lib.contracts";
2
- import * as _contractspec_lib_schema41 from "@contractspec/lib.schema";
1
+ import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
2
+ import * as _contractspec_lib_schema0 from "@contractspec/lib.schema";
3
3
 
4
4
  //#region src/connection/connection.operation.d.ts
5
5
  /**
6
6
  * Create a connection to an external system.
7
7
  */
8
- declare const CreateConnectionContract: _contractspec_lib_contracts13.OperationSpec<_contractspec_lib_schema41.SchemaModel<{
8
+ declare const CreateConnectionContract: _contractspec_lib_contracts0.OperationSpec<_contractspec_lib_schema0.SchemaModel<{
9
9
  integrationId: {
10
- type: _contractspec_lib_schema41.FieldType<string, string>;
10
+ type: _contractspec_lib_schema0.FieldType<string, string>;
11
11
  isOptional: false;
12
12
  };
13
13
  name: {
14
- type: _contractspec_lib_schema41.FieldType<string, string>;
14
+ type: _contractspec_lib_schema0.FieldType<string, string>;
15
15
  isOptional: false;
16
16
  };
17
17
  authType: {
18
- type: _contractspec_lib_schema41.FieldType<string, string>;
18
+ type: _contractspec_lib_schema0.FieldType<string, string>;
19
19
  isOptional: false;
20
20
  };
21
21
  credentials: {
22
- type: _contractspec_lib_schema41.FieldType<unknown, unknown>;
22
+ type: _contractspec_lib_schema0.FieldType<unknown, unknown>;
23
23
  isOptional: true;
24
24
  };
25
- }>, _contractspec_lib_schema41.SchemaModel<{
25
+ }>, _contractspec_lib_schema0.SchemaModel<{
26
26
  id: {
27
- type: _contractspec_lib_schema41.FieldType<string, string>;
27
+ type: _contractspec_lib_schema0.FieldType<string, string>;
28
28
  isOptional: false;
29
29
  };
30
30
  integrationId: {
31
- type: _contractspec_lib_schema41.FieldType<string, string>;
31
+ type: _contractspec_lib_schema0.FieldType<string, string>;
32
32
  isOptional: false;
33
33
  };
34
34
  name: {
35
- type: _contractspec_lib_schema41.FieldType<string, string>;
35
+ type: _contractspec_lib_schema0.FieldType<string, string>;
36
36
  isOptional: false;
37
37
  };
38
38
  status: {
39
- type: _contractspec_lib_schema41.EnumType<[string, string, string, string, string]>;
39
+ type: _contractspec_lib_schema0.EnumType<[string, string, string, string, string]>;
40
40
  isOptional: false;
41
41
  };
42
42
  authType: {
43
- type: _contractspec_lib_schema41.FieldType<string, string>;
43
+ type: _contractspec_lib_schema0.FieldType<string, string>;
44
44
  isOptional: false;
45
45
  };
46
46
  externalAccountName: {
47
- type: _contractspec_lib_schema41.FieldType<string, string>;
47
+ type: _contractspec_lib_schema0.FieldType<string, string>;
48
48
  isOptional: true;
49
49
  };
50
50
  connectedAt: {
51
- type: _contractspec_lib_schema41.FieldType<Date, string>;
51
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
52
52
  isOptional: true;
53
53
  };
54
54
  lastHealthCheck: {
55
- type: _contractspec_lib_schema41.FieldType<Date, string>;
55
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
56
56
  isOptional: true;
57
57
  };
58
58
  healthStatus: {
59
- type: _contractspec_lib_schema41.FieldType<string, string>;
59
+ type: _contractspec_lib_schema0.FieldType<string, string>;
60
60
  isOptional: true;
61
61
  };
62
62
  }>, {
63
63
  key: string;
64
64
  version: string;
65
65
  when: string;
66
- payload: _contractspec_lib_schema41.SchemaModel<{
66
+ payload: _contractspec_lib_schema0.SchemaModel<{
67
67
  id: {
68
- type: _contractspec_lib_schema41.FieldType<string, string>;
68
+ type: _contractspec_lib_schema0.FieldType<string, string>;
69
69
  isOptional: false;
70
70
  };
71
71
  integrationId: {
72
- type: _contractspec_lib_schema41.FieldType<string, string>;
72
+ type: _contractspec_lib_schema0.FieldType<string, string>;
73
73
  isOptional: false;
74
74
  };
75
75
  name: {
76
- type: _contractspec_lib_schema41.FieldType<string, string>;
76
+ type: _contractspec_lib_schema0.FieldType<string, string>;
77
77
  isOptional: false;
78
78
  };
79
79
  status: {
80
- type: _contractspec_lib_schema41.EnumType<[string, string, string, string, string]>;
80
+ type: _contractspec_lib_schema0.EnumType<[string, string, string, string, string]>;
81
81
  isOptional: false;
82
82
  };
83
83
  authType: {
84
- type: _contractspec_lib_schema41.FieldType<string, string>;
84
+ type: _contractspec_lib_schema0.FieldType<string, string>;
85
85
  isOptional: false;
86
86
  };
87
87
  externalAccountName: {
88
- type: _contractspec_lib_schema41.FieldType<string, string>;
88
+ type: _contractspec_lib_schema0.FieldType<string, string>;
89
89
  isOptional: true;
90
90
  };
91
91
  connectedAt: {
92
- type: _contractspec_lib_schema41.FieldType<Date, string>;
92
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
93
93
  isOptional: true;
94
94
  };
95
95
  lastHealthCheck: {
96
- type: _contractspec_lib_schema41.FieldType<Date, string>;
96
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
97
97
  isOptional: true;
98
98
  };
99
99
  healthStatus: {
100
- type: _contractspec_lib_schema41.FieldType<string, string>;
100
+ type: _contractspec_lib_schema0.FieldType<string, string>;
101
101
  isOptional: true;
102
102
  };
103
103
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"connection.operation.d.ts","names":[],"sources":["../../src/connection/connection.operation.ts"],"sourcesContent":[],"mappings":";;;;;;;cAWa,wDAAwB,yCAAA;EAAxB,aAAA,EAAA;IAiDX,IAAA,EAAA,0BAAA,CAAA,SAAA,CAAA,MAAA,EAAA,MAAA,CAAA;;;;8CAjDmC,CAAA,MAAA,EAAA,MAAA,CAAA;IAAA,UAAA,EAAA,KAAA;;;;;;;;;;;;UAAA,0BAAA,CAAA;;;;;;;;;;;;6CAAA,CAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA;IAAA,UAAA,EAAA,KAAA"}
1
+ {"version":3,"file":"connection.operation.d.ts","names":[],"sources":["../../src/connection/connection.operation.ts"],"mappings":";;;;;;;cAWa,wBAAA,+BAAwB,aAAA,2BAAA,WAAA;;UAiDnC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;UAjDmC,yBAAA,CAAA,SAAA"}
@@ -1,8 +1,8 @@
1
- import * as _contractspec_lib_contracts14 from "@contractspec/lib.contracts";
1
+ import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
2
2
 
3
3
  //#region src/connection/connection.presentation.d.ts
4
- declare const ConnectionListPresentation: _contractspec_lib_contracts14.PresentationSpec;
5
- declare const ConnectionSetupPresentation: _contractspec_lib_contracts14.PresentationSpec;
4
+ declare const ConnectionListPresentation: _contractspec_lib_contracts0.PresentationSpec;
5
+ declare const ConnectionSetupPresentation: _contractspec_lib_contracts0.PresentationSpec;
6
6
  //#endregion
7
7
  export { ConnectionListPresentation, ConnectionSetupPresentation };
8
8
  //# sourceMappingURL=connection.presentation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"connection.presentation.d.ts","names":[],"sources":["../../src/connection/connection.presentation.ts"],"sourcesContent":[],"mappings":";;;cAGa,4BAuBX,6BAAA,CAvBqC;cAyB1B,6BAuBX,6BAAA,CAvBsC"}
1
+ {"version":3,"file":"connection.presentation.d.ts","names":[],"sources":["../../src/connection/connection.presentation.ts"],"mappings":";;;cAGa,0BAAA,EAuBX,4BAAA,CAvBqC,gBAAA;AAAA,cAyB1B,2BAAA,EAuBX,4BAAA,CAvBsC,gBAAA"}
@@ -1,65 +1,65 @@
1
- import * as _contractspec_lib_schema66 from "@contractspec/lib.schema";
1
+ import * as _contractspec_lib_schema0 from "@contractspec/lib.schema";
2
2
 
3
3
  //#region src/connection/connection.schema.d.ts
4
4
  /**
5
5
  * A connection to an external system.
6
6
  */
7
- declare const ConnectionModel: _contractspec_lib_schema66.SchemaModel<{
7
+ declare const ConnectionModel: _contractspec_lib_schema0.SchemaModel<{
8
8
  id: {
9
- type: _contractspec_lib_schema66.FieldType<string, string>;
9
+ type: _contractspec_lib_schema0.FieldType<string, string>;
10
10
  isOptional: false;
11
11
  };
12
12
  integrationId: {
13
- type: _contractspec_lib_schema66.FieldType<string, string>;
13
+ type: _contractspec_lib_schema0.FieldType<string, string>;
14
14
  isOptional: false;
15
15
  };
16
16
  name: {
17
- type: _contractspec_lib_schema66.FieldType<string, string>;
17
+ type: _contractspec_lib_schema0.FieldType<string, string>;
18
18
  isOptional: false;
19
19
  };
20
20
  status: {
21
- type: _contractspec_lib_schema66.EnumType<[string, string, string, string, string]>;
21
+ type: _contractspec_lib_schema0.EnumType<[string, string, string, string, string]>;
22
22
  isOptional: false;
23
23
  };
24
24
  authType: {
25
- type: _contractspec_lib_schema66.FieldType<string, string>;
25
+ type: _contractspec_lib_schema0.FieldType<string, string>;
26
26
  isOptional: false;
27
27
  };
28
28
  externalAccountName: {
29
- type: _contractspec_lib_schema66.FieldType<string, string>;
29
+ type: _contractspec_lib_schema0.FieldType<string, string>;
30
30
  isOptional: true;
31
31
  };
32
32
  connectedAt: {
33
- type: _contractspec_lib_schema66.FieldType<Date, string>;
33
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
34
34
  isOptional: true;
35
35
  };
36
36
  lastHealthCheck: {
37
- type: _contractspec_lib_schema66.FieldType<Date, string>;
37
+ type: _contractspec_lib_schema0.FieldType<Date, string>;
38
38
  isOptional: true;
39
39
  };
40
40
  healthStatus: {
41
- type: _contractspec_lib_schema66.FieldType<string, string>;
41
+ type: _contractspec_lib_schema0.FieldType<string, string>;
42
42
  isOptional: true;
43
43
  };
44
44
  }>;
45
45
  /**
46
46
  * Input for creating a connection.
47
47
  */
48
- declare const CreateConnectionInputModel: _contractspec_lib_schema66.SchemaModel<{
48
+ declare const CreateConnectionInputModel: _contractspec_lib_schema0.SchemaModel<{
49
49
  integrationId: {
50
- type: _contractspec_lib_schema66.FieldType<string, string>;
50
+ type: _contractspec_lib_schema0.FieldType<string, string>;
51
51
  isOptional: false;
52
52
  };
53
53
  name: {
54
- type: _contractspec_lib_schema66.FieldType<string, string>;
54
+ type: _contractspec_lib_schema0.FieldType<string, string>;
55
55
  isOptional: false;
56
56
  };
57
57
  authType: {
58
- type: _contractspec_lib_schema66.FieldType<string, string>;
58
+ type: _contractspec_lib_schema0.FieldType<string, string>;
59
59
  isOptional: false;
60
60
  };
61
61
  credentials: {
62
- type: _contractspec_lib_schema66.FieldType<unknown, unknown>;
62
+ type: _contractspec_lib_schema0.FieldType<unknown, unknown>;
63
63
  isOptional: true;
64
64
  };
65
65
  }>;
@@ -1 +1 @@
1
- {"version":3,"file":"connection.schema.d.ts","names":[],"sources":["../../src/connection/connection.schema.ts"],"sourcesContent":[],"mappings":";;;;;;AAMa,cAAA,eAmBX,6BAnB0B,WAmB1B,CAAA;EAAA,EAAA,EAAA;UAAA,0BAAA,CAAA;;;;;;;;;;;EAnB0B,MAAA,EAAA;IAwBf,IAAA,qCAWX,CAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA;IAAA,UAAA,EAAA,KAAA;;;;;EAXqC,CAAA;;;;;;;;;;;;;;;;;;;;;cAA1B,uDAA0B;;UAWrC,0BAAA,CAAA"}
1
+ {"version":3,"file":"connection.schema.d.ts","names":[],"sources":["../../src/connection/connection.schema.ts"],"mappings":";;;;;;cAMa,eAAA,4BAAe,WAAA;;UAmB1B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAKW,0BAAA,4BAA0B,WAAA;;UAWrC,yBAAA,CAAA,SAAA"}
@@ -38,6 +38,7 @@ registerDocBlocks([
38
38
  ## Notes
39
39
 
40
40
  - Providers remain agnostic; keep mappings declarative for safe regeneration.
41
+ - Seed data includes voice integrations for \`ai-voice.gradium\` and \`ai-voice.fal\`.
41
42
  - Feature flags can gate specific providers; metering can track sync volume.
42
43
  `
43
44
  },
@@ -1 +1 @@
1
- {"version":3,"file":"integration-hub.docblock.js","names":[],"sources":["../../src/docs/integration-hub.docblock.ts"],"sourcesContent":["import type { DocBlock } from '@contractspec/lib.contracts/docs';\nimport { registerDocBlocks } from '@contractspec/lib.contracts/docs';\n\nconst integrationHubDocBlocks: DocBlock[] = [\n {\n id: 'docs.examples.integration-hub',\n title: 'Integration Hub',\n summary:\n 'Generic integration center with connectors, connections, sync configs, field mappings, and sync logs.',\n kind: 'reference',\n visibility: 'public',\n route: '/docs/examples/integration-hub',\n tags: ['integrations', 'sync', 'etl', 'connectors'],\n body: `## Entities\n\n- Integration, Connection, SyncConfig, FieldMapping, SyncLog.\n- Sync engine config lives in \\`src/sync-engine\\` to map remote <-> local entities.\n\n## Contracts\n\n- \\`integration.create\\`, \\`integration.connect\\`, \\`integration.configureSync\\`, \\`integration.mapFields\\`, \\`integration.runSync\\`.\n- Uses Jobs module for scheduled syncs and retries; Files module for payload archives.\n\n## Events\n\n- sync.started/completed/failed, connection.connected/disconnected, mapping.updated.\n- Forward to Notifications and Audit for observability.\n\n## UI / Presentations\n\n- Dashboard, integration list, connection detail, sync config editor.\n- Templates registered as \\`integration-hub\\` in Template Registry.\n\n## Notes\n\n- Providers remain agnostic; keep mappings declarative for safe regeneration.\n- Feature flags can gate specific providers; metering can track sync volume.\n`,\n },\n {\n id: 'docs.examples.integration-hub.goal',\n title: 'Integration Hub — Goal',\n summary: 'Why this integration hub exists and what success looks like.',\n kind: 'goal',\n visibility: 'public',\n route: '/docs/examples/integration-hub/goal',\n tags: ['integrations', 'goal'],\n body: `## Why it matters\n- Gives a regenerable, provider-agnostic integration hub with explicit mappings.\n- Prevents drift between sync configs, mappings, and event/log outputs.\n\n## Business/Product goal\n- Model connectors, connections, sync jobs, and mappings with governance and retries.\n- Support staged provider rollouts via Feature Flags and observability via Audit/Notifications.\n\n## Success criteria\n- Connections and mappings regenerate safely after spec edits.\n- Sync events and logs provide auditability; payloads are stored and PII-scoped.`,\n },\n {\n id: 'docs.examples.integration-hub.usage',\n title: 'Integration Hub — Usage',\n summary: 'How to configure connectors, mappings, and scheduled syncs.',\n kind: 'usage',\n visibility: 'public',\n route: '/docs/examples/integration-hub/usage',\n tags: ['integrations', 'usage'],\n body: `## Setup\n1) Seed integrations/connections (if available) or create connector definitions.\n2) Configure sync jobs with Jobs module; store payload archives via Files.\n\n## Extend & regenerate\n1) Add mapping fields or provider configs in the spec; include validation and PII paths.\n2) Regenerate to align UI/API/events/logs; verify Notifications/Audit hooks.\n3) Gate risky providers behind Feature Flags; meter sync volume if needed.\n\n## Guardrails\n- Keep mappings declarative; avoid hardcoded transforms.\n- Emit events for sync lifecycle; persist logs for audit.\n- Redact sensitive payload paths in presentations.`,\n },\n {\n id: 'docs.examples.integration-hub.constraints',\n title: 'Integration Hub — Constraints & Safety',\n summary:\n 'Internal guidance for sync lifecycle, mappings, and regeneration safety.',\n kind: 'reference',\n visibility: 'internal',\n route: '/docs/examples/integration-hub/constraints',\n tags: ['integrations', 'constraints', 'internal'],\n body: `## Constraints\n- Mappings and sync states must remain declarative in spec; no hidden code transforms.\n- Events to emit at minimum: sync.started, sync.completed, sync.failed; connection.connected/disconnected.\n- Regeneration should not alter retry/backoff semantics without explicit spec change.\n\n## PII & Payloads\n- Treat payload archives as potentially sensitive; mark policy.pii paths.\n- For MCP/web, avoid exposing raw credentials/tokens; store via provider adapters only.\n\n## Verification\n- Include fixtures for mapping changes and sync retries.\n- Validate that scheduled jobs (cron) are spec-driven; Jobs module wiring intact.\n- Ensure Audit/Notifications receive sync lifecycle events.`,\n },\n];\n\nregisterDocBlocks(integrationHubDocBlocks);\n"],"mappings":";;;AA0GA,kBAvG4C;CAC1C;EACE,IAAI;EACJ,OAAO;EACP,SACE;EACF,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM;GAAC;GAAgB;GAAQ;GAAO;GAAa;EACnD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;EAyBP;CACD;EACE,IAAI;EACJ,OAAO;EACP,SAAS;EACT,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM,CAAC,gBAAgB,OAAO;EAC9B,MAAM;;;;;;;;;;;EAWP;CACD;EACE,IAAI;EACJ,OAAO;EACP,SAAS;EACT,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM,CAAC,gBAAgB,QAAQ;EAC/B,MAAM;;;;;;;;;;;;;EAaP;CACD;EACE,IAAI;EACJ,OAAO;EACP,SACE;EACF,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM;GAAC;GAAgB;GAAe;GAAW;EACjD,MAAM;;;;;;;;;;;;;EAaP;CACF,CAEyC"}
1
+ {"version":3,"file":"integration-hub.docblock.js","names":[],"sources":["../../src/docs/integration-hub.docblock.ts"],"sourcesContent":["import type { DocBlock } from '@contractspec/lib.contracts/docs';\nimport { registerDocBlocks } from '@contractspec/lib.contracts/docs';\n\nconst integrationHubDocBlocks: DocBlock[] = [\n {\n id: 'docs.examples.integration-hub',\n title: 'Integration Hub',\n summary:\n 'Generic integration center with connectors, connections, sync configs, field mappings, and sync logs.',\n kind: 'reference',\n visibility: 'public',\n route: '/docs/examples/integration-hub',\n tags: ['integrations', 'sync', 'etl', 'connectors'],\n body: `## Entities\n\n- Integration, Connection, SyncConfig, FieldMapping, SyncLog.\n- Sync engine config lives in \\`src/sync-engine\\` to map remote <-> local entities.\n\n## Contracts\n\n- \\`integration.create\\`, \\`integration.connect\\`, \\`integration.configureSync\\`, \\`integration.mapFields\\`, \\`integration.runSync\\`.\n- Uses Jobs module for scheduled syncs and retries; Files module for payload archives.\n\n## Events\n\n- sync.started/completed/failed, connection.connected/disconnected, mapping.updated.\n- Forward to Notifications and Audit for observability.\n\n## UI / Presentations\n\n- Dashboard, integration list, connection detail, sync config editor.\n- Templates registered as \\`integration-hub\\` in Template Registry.\n\n## Notes\n\n- Providers remain agnostic; keep mappings declarative for safe regeneration.\n- Seed data includes voice integrations for \\`ai-voice.gradium\\` and \\`ai-voice.fal\\`.\n- Feature flags can gate specific providers; metering can track sync volume.\n`,\n },\n {\n id: 'docs.examples.integration-hub.goal',\n title: 'Integration Hub — Goal',\n summary: 'Why this integration hub exists and what success looks like.',\n kind: 'goal',\n visibility: 'public',\n route: '/docs/examples/integration-hub/goal',\n tags: ['integrations', 'goal'],\n body: `## Why it matters\n- Gives a regenerable, provider-agnostic integration hub with explicit mappings.\n- Prevents drift between sync configs, mappings, and event/log outputs.\n\n## Business/Product goal\n- Model connectors, connections, sync jobs, and mappings with governance and retries.\n- Support staged provider rollouts via Feature Flags and observability via Audit/Notifications.\n\n## Success criteria\n- Connections and mappings regenerate safely after spec edits.\n- Sync events and logs provide auditability; payloads are stored and PII-scoped.`,\n },\n {\n id: 'docs.examples.integration-hub.usage',\n title: 'Integration Hub — Usage',\n summary: 'How to configure connectors, mappings, and scheduled syncs.',\n kind: 'usage',\n visibility: 'public',\n route: '/docs/examples/integration-hub/usage',\n tags: ['integrations', 'usage'],\n body: `## Setup\n1) Seed integrations/connections (if available) or create connector definitions.\n2) Configure sync jobs with Jobs module; store payload archives via Files.\n\n## Extend & regenerate\n1) Add mapping fields or provider configs in the spec; include validation and PII paths.\n2) Regenerate to align UI/API/events/logs; verify Notifications/Audit hooks.\n3) Gate risky providers behind Feature Flags; meter sync volume if needed.\n\n## Guardrails\n- Keep mappings declarative; avoid hardcoded transforms.\n- Emit events for sync lifecycle; persist logs for audit.\n- Redact sensitive payload paths in presentations.`,\n },\n {\n id: 'docs.examples.integration-hub.constraints',\n title: 'Integration Hub — Constraints & Safety',\n summary:\n 'Internal guidance for sync lifecycle, mappings, and regeneration safety.',\n kind: 'reference',\n visibility: 'internal',\n route: '/docs/examples/integration-hub/constraints',\n tags: ['integrations', 'constraints', 'internal'],\n body: `## Constraints\n- Mappings and sync states must remain declarative in spec; no hidden code transforms.\n- Events to emit at minimum: sync.started, sync.completed, sync.failed; connection.connected/disconnected.\n- Regeneration should not alter retry/backoff semantics without explicit spec change.\n\n## PII & Payloads\n- Treat payload archives as potentially sensitive; mark policy.pii paths.\n- For MCP/web, avoid exposing raw credentials/tokens; store via provider adapters only.\n\n## Verification\n- Include fixtures for mapping changes and sync retries.\n- Validate that scheduled jobs (cron) are spec-driven; Jobs module wiring intact.\n- Ensure Audit/Notifications receive sync lifecycle events.`,\n },\n];\n\nregisterDocBlocks(integrationHubDocBlocks);\n"],"mappings":";;;AA2GA,kBAxG4C;CAC1C;EACE,IAAI;EACJ,OAAO;EACP,SACE;EACF,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM;GAAC;GAAgB;GAAQ;GAAO;GAAa;EACnD,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;EA0BP;CACD;EACE,IAAI;EACJ,OAAO;EACP,SAAS;EACT,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM,CAAC,gBAAgB,OAAO;EAC9B,MAAM;;;;;;;;;;;EAWP;CACD;EACE,IAAI;EACJ,OAAO;EACP,SAAS;EACT,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM,CAAC,gBAAgB,QAAQ;EAC/B,MAAM;;;;;;;;;;;;;EAaP;CACD;EACE,IAAI;EACJ,OAAO;EACP,SACE;EACF,MAAM;EACN,YAAY;EACZ,OAAO;EACP,MAAM;GAAC;GAAgB;GAAe;GAAW;EACjD,MAAM;;;;;;;;;;;;;EAaP;CACF,CAEyC"}
@@ -1 +1 @@
1
- {"version":3,"file":"events.d.ts","names":[],"sources":["../src/events.ts"],"sourcesContent":[],"mappings":";;;;cAiBa,yBAAuB,4BAAA,CAAA,oCAAA;;UAUlC,yBAAA,CAAA;;EAVW,CAAA;EAUX,IAAA,EAAA;;;;;IAVkC,IAAA,qCAAA,KAAA,EAAA,MAAA,CAAA;IAAA,UAAA,EAAA,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AA,CAAA;;;;;;;;;;;;;;;;cAaW,mBAAiB,4BAAA,CAAA,oCAAA;;UAU5B,yBAAA,CAAA;;;;;;;;;;;;;;;;cAYW,wBAAsB,4BAAA,CAAA,oCAAA;;UAUjC,yBAAA,CAAA"}
1
+ {"version":3,"file":"events.d.ts","names":[],"sources":["../src/events.ts"],"mappings":";;;;cAiBa,uBAAA,EAAuB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUlC,yBAAA,CAAA,SAAA;;;;;;;;;;;;cAiBW,sBAAA,EAAsB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUjC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;cAgBW,4BAAA,EAA4B,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUvC,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;cAaW,sBAAA,EAAsB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUjC,yBAAA,CAAA,SAAA;;;;;;;;;;;;cAaW,gBAAA,EAAgB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU3B,yBAAA,CAAA,SAAA;;;;;;;;;;;;cAgBW,kBAAA,EAAkB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU7B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;cAaW,eAAA,EAAe,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU1B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;cAaW,iBAAA,EAAiB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAU5B,yBAAA,CAAA,SAAA;;;;;;;;;;;;;;;;cAYW,sBAAA,EAAsB,4BAAA,CAAA,SAAA,2BAAA,WAAA;;UAUjC,yBAAA,CAAA,SAAA"}
package/dist/example.d.ts CHANGED
@@ -1,7 +1,7 @@
1
- import * as _contractspec_lib_contracts8 from "@contractspec/lib.contracts";
1
+ import * as _contractspec_lib_contracts0 from "@contractspec/lib.contracts";
2
2
 
3
3
  //#region src/example.d.ts
4
- declare const example: _contractspec_lib_contracts8.ExampleSpec;
4
+ declare const example: _contractspec_lib_contracts0.ExampleSpec;
5
5
  //#endregion
6
6
  export { example as default };
7
7
  //# sourceMappingURL=example.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"example.d.ts","names":[],"sources":["../src/example.ts"],"sourcesContent":[],"mappings":";;;cAEM,SAoCJ,4BAAA,CApCW"}
1
+ {"version":3,"file":"example.d.ts","names":[],"sources":["../src/example.ts"],"mappings":";;;cAEM,OAAA,EAoCJ,4BAAA,CApCW,WAAA"}
package/dist/example.js CHANGED
@@ -51,8 +51,7 @@ const example = defineExample({
51
51
  mcp: { enabled: true }
52
52
  }
53
53
  });
54
- var example_default = example;
55
54
 
56
55
  //#endregion
57
- export { example_default as default };
56
+ export { example as default };
58
57
  //# sourceMappingURL=example.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"example.js","names":[],"sources":["../src/example.ts"],"sourcesContent":["import { defineExample } from '@contractspec/lib.contracts';\n\nconst example = defineExample({\n meta: {\n key: 'integration-hub',\n version: '1.0.0',\n title: 'Integration Hub',\n description:\n 'Provider-agnostic integration center with connectors, connections, field mappings, and sync logs.',\n kind: 'template',\n visibility: 'public',\n stability: 'experimental',\n owners: ['@platform.core'],\n tags: ['integrations', 'sync', 'etl', 'connectors'],\n },\n docs: {\n rootDocId: 'docs.examples.integration-hub',\n goalDocId: 'docs.examples.integration-hub.goal',\n usageDocId: 'docs.examples.integration-hub.usage',\n constraintsDocId: 'docs.examples.integration-hub.constraints',\n },\n entrypoints: {\n packageName: '@contractspec/example.integration-hub',\n feature: './feature',\n contracts: './contracts',\n presentations: './presentations',\n handlers: './handlers',\n docs: './docs',\n },\n surfaces: {\n templates: true,\n sandbox: {\n enabled: true,\n modes: ['playground', 'specs', 'builder', 'markdown', 'evolution'],\n },\n studio: { enabled: true, installable: true },\n mcp: { enabled: true },\n },\n});\n\nexport default example;\n"],"mappings":";;;AAEA,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,MAAM;EACN,YAAY;EACZ,WAAW;EACX,QAAQ,CAAC,iBAAiB;EAC1B,MAAM;GAAC;GAAgB;GAAQ;GAAO;GAAa;EACpD;CACD,MAAM;EACJ,WAAW;EACX,WAAW;EACX,YAAY;EACZ,kBAAkB;EACnB;CACD,aAAa;EACX,aAAa;EACb,SAAS;EACT,WAAW;EACX,eAAe;EACf,UAAU;EACV,MAAM;EACP;CACD,UAAU;EACR,WAAW;EACX,SAAS;GACP,SAAS;GACT,OAAO;IAAC;IAAc;IAAS;IAAW;IAAY;IAAY;GACnE;EACD,QAAQ;GAAE,SAAS;GAAM,aAAa;GAAM;EAC5C,KAAK,EAAE,SAAS,MAAM;EACvB;CACF,CAAC;AAEF,sBAAe"}
1
+ {"version":3,"file":"example.js","names":[],"sources":["../src/example.ts"],"sourcesContent":["import { defineExample } from '@contractspec/lib.contracts';\n\nconst example = defineExample({\n meta: {\n key: 'integration-hub',\n version: '1.0.0',\n title: 'Integration Hub',\n description:\n 'Provider-agnostic integration center with connectors, connections, field mappings, and sync logs.',\n kind: 'template',\n visibility: 'public',\n stability: 'experimental',\n owners: ['@platform.core'],\n tags: ['integrations', 'sync', 'etl', 'connectors'],\n },\n docs: {\n rootDocId: 'docs.examples.integration-hub',\n goalDocId: 'docs.examples.integration-hub.goal',\n usageDocId: 'docs.examples.integration-hub.usage',\n constraintsDocId: 'docs.examples.integration-hub.constraints',\n },\n entrypoints: {\n packageName: '@contractspec/example.integration-hub',\n feature: './feature',\n contracts: './contracts',\n presentations: './presentations',\n handlers: './handlers',\n docs: './docs',\n },\n surfaces: {\n templates: true,\n sandbox: {\n enabled: true,\n modes: ['playground', 'specs', 'builder', 'markdown', 'evolution'],\n },\n studio: { enabled: true, installable: true },\n mcp: { enabled: true },\n },\n});\n\nexport default example;\n"],"mappings":";;;AAEA,MAAM,UAAU,cAAc;CAC5B,MAAM;EACJ,KAAK;EACL,SAAS;EACT,OAAO;EACP,aACE;EACF,MAAM;EACN,YAAY;EACZ,WAAW;EACX,QAAQ,CAAC,iBAAiB;EAC1B,MAAM;GAAC;GAAgB;GAAQ;GAAO;GAAa;EACpD;CACD,MAAM;EACJ,WAAW;EACX,WAAW;EACX,YAAY;EACZ,kBAAkB;EACnB;CACD,aAAa;EACX,aAAa;EACb,SAAS;EACT,WAAW;EACX,eAAe;EACf,UAAU;EACV,MAAM;EACP;CACD,UAAU;EACR,WAAW;EACX,SAAS;GACP,SAAS;GACT,OAAO;IAAC;IAAc;IAAS;IAAW;IAAY;IAAY;GACnE;EACD,QAAQ;GAAE,SAAS;GAAM,aAAa;GAAM;EAC5C,KAAK,EAAE,SAAS,MAAM;EACvB;CACF,CAAC"}
@@ -1,14 +1,13 @@
1
1
  import { DatabasePort } from "@contractspec/lib.runtime-sandbox";
2
2
 
3
3
  //#region src/handlers/integration.handlers.d.ts
4
-
5
4
  interface Integration {
6
5
  id: string;
7
6
  projectId: string;
8
7
  organizationId: string;
9
8
  name: string;
10
9
  description?: string;
11
- type: 'CRM' | 'MARKETING' | 'PAYMENT' | 'COMMUNICATION' | 'DATA' | 'CUSTOM';
10
+ type: 'CRM' | 'MARKETING' | 'PAYMENT' | 'COMMUNICATION' | 'DATA' | 'ANALYTICS' | 'CUSTOM';
12
11
  status: 'ACTIVE' | 'INACTIVE';
13
12
  iconUrl?: string;
14
13
  createdAt: Date;
@@ -1 +1 @@
1
- {"version":3,"file":"integration.handlers.d.ts","names":[],"sources":["../../src/handlers/integration.handlers.ts"],"sourcesContent":[],"mappings":";;;;AA+BW,UAnBM,WAAA,CAmBN;EACI,EAAA,EAAA,MAAA;EAEF,SAAA,EAAA,MAAA;EACA,cAAA,EAAA,MAAA;EAAI,IAAA,EAAA,MAAA;EAGA,WAAA,CAAA,EAAU,MAAA;EAQb,IAAA,EAAA,KAAA,GAAA,WAAA,GAAA,SAAA,GAAA,eAAA,GAAA,MAAA,GAAA,QAAA;EAGD,MAAA,EAAA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AA;0BAyCF,mBAAA,KACN,OAAA,CAAQ,UAAA;+CAyC6C,OAAA,CAAQ,UAAA;2BAqBvD,oBAAA,KACN,OAAA,CAAQ,qBAAA;yBAwCyB,kBAAA,KAAqB,OAAA,CAAQ,UAAA;qBA+BjC,cAAA,KAAiB,OAAA,CAAQ,YAAA;8CA8CtD,OAAA,CAAQ,YAAA;qCAcmC,OAAA,CAAQ,UAAA;AAAA;AAAA,KAgD5C,mBAAA,GAAsB,UAAA,QAAkB,yBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"integration.handlers.js","names":[],"sources":["../../src/handlers/integration.handlers.ts"],"sourcesContent":["/**\n * Runtime-local Integration Hub handlers\n *\n * Database-backed handlers for the integration-hub template.\n */\nimport type { DatabasePort, DbRow } from '@contractspec/lib.runtime-sandbox';\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { web } from '@contractspec/lib.runtime-sandbox';\nconst { generateId } = web;\n\n// ============ Types ============\n\nexport interface Integration {\n id: string;\n projectId: string;\n organizationId: string;\n name: string;\n description?: string;\n type: 'CRM' | 'MARKETING' | 'PAYMENT' | 'COMMUNICATION' | 'DATA' | 'CUSTOM';\n status: 'ACTIVE' | 'INACTIVE';\n iconUrl?: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface Connection {\n id: string;\n integrationId: string;\n name: string;\n status: 'CONNECTED' | 'DISCONNECTED' | 'ERROR' | 'PENDING';\n credentials?: Record<string, unknown>;\n config?: Record<string, unknown>;\n lastSyncAt?: Date;\n errorMessage?: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface SyncConfig {\n id: string;\n connectionId: string;\n name: string;\n sourceEntity: string;\n targetEntity: string;\n frequency: 'REALTIME' | 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MANUAL';\n status: 'ACTIVE' | 'PAUSED' | 'ERROR';\n lastRunAt?: Date;\n lastRunStatus?: 'SUCCESS' | 'FAILED' | 'PARTIAL';\n recordsSynced: number;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface FieldMapping {\n id: string;\n syncConfigId: string;\n sourceField: string;\n targetField: string;\n transformType?: 'DIRECT' | 'FORMAT' | 'LOOKUP' | 'CUSTOM';\n transformConfig?: Record<string, unknown>;\n createdAt: Date;\n}\n\nexport interface CreateIntegrationInput {\n name: string;\n description?: string;\n type: Integration['type'];\n iconUrl?: string;\n}\n\nexport interface ConnectServiceInput {\n integrationId: string;\n name: string;\n credentials?: Record<string, unknown>;\n config?: Record<string, unknown>;\n}\n\nexport interface ConfigureSyncInput {\n connectionId: string;\n name: string;\n sourceEntity: string;\n targetEntity: string;\n frequency?: SyncConfig['frequency'];\n}\n\nexport interface MapFieldsInput {\n syncConfigId: string;\n mappings: {\n sourceField: string;\n targetField: string;\n transformType?: FieldMapping['transformType'];\n transformConfig?: Record<string, unknown>;\n }[];\n}\n\nexport interface ListIntegrationsInput {\n projectId: string;\n type?: Integration['type'] | 'all';\n status?: 'ACTIVE' | 'INACTIVE' | 'all';\n search?: string;\n limit?: number;\n offset?: number;\n}\n\nexport interface ListIntegrationsOutput {\n integrations: Integration[];\n total: number;\n}\n\nexport interface ListConnectionsInput {\n integrationId?: string;\n status?: Connection['status'] | 'all';\n limit?: number;\n offset?: number;\n}\n\nexport interface ListConnectionsOutput {\n connections: Connection[];\n total: number;\n}\n\nexport interface ListSyncConfigsInput {\n connectionId?: string;\n status?: SyncConfig['status'] | 'all';\n limit?: number;\n offset?: number;\n}\n\nexport interface ListSyncConfigsOutput {\n configs: SyncConfig[];\n total: number;\n}\n\n// ============ Row Types ============\n\ninterface IntegrationRow {\n id: string;\n projectId: string;\n organizationId: string;\n name: string;\n description: string | null;\n type: string;\n status: string;\n iconUrl: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface ConnectionRow {\n id: string;\n integrationId: string;\n name: string;\n status: string;\n credentials: string | null;\n config: string | null;\n lastSyncAt: string | null;\n errorMessage: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface SyncConfigRow {\n id: string;\n connectionId: string;\n name: string;\n sourceEntity: string;\n targetEntity: string;\n frequency: string;\n status: string;\n lastRunAt: string | null;\n lastRunStatus: string | null;\n recordsSynced: number;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface FieldMappingRow {\n id: string;\n syncConfigId: string;\n sourceField: string;\n targetField: string;\n transformType: string | null;\n transformConfig: string | null;\n createdAt: string;\n}\n\nfunction rowToIntegration(row: IntegrationRow): Integration {\n return {\n id: row.id,\n projectId: row.projectId,\n organizationId: row.organizationId,\n name: row.name,\n description: row.description ?? undefined,\n type: row.type as Integration['type'],\n status: row.status as Integration['status'],\n iconUrl: row.iconUrl ?? undefined,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n };\n}\n\nfunction rowToConnection(row: ConnectionRow): Connection {\n return {\n id: row.id,\n integrationId: row.integrationId,\n name: row.name,\n status: row.status as Connection['status'],\n credentials: row.credentials ? JSON.parse(row.credentials) : undefined,\n config: row.config ? JSON.parse(row.config) : undefined,\n lastSyncAt: row.lastSyncAt ? new Date(row.lastSyncAt) : undefined,\n errorMessage: row.errorMessage ?? undefined,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n };\n}\n\nfunction rowToSyncConfig(row: SyncConfigRow): SyncConfig {\n return {\n id: row.id,\n connectionId: row.connectionId,\n name: row.name,\n sourceEntity: row.sourceEntity,\n targetEntity: row.targetEntity,\n frequency: row.frequency as SyncConfig['frequency'],\n status: row.status as SyncConfig['status'],\n lastRunAt: row.lastRunAt ? new Date(row.lastRunAt) : undefined,\n lastRunStatus:\n (row.lastRunStatus as SyncConfig['lastRunStatus']) ?? undefined,\n recordsSynced: row.recordsSynced,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n };\n}\n\nfunction rowToFieldMapping(row: FieldMappingRow): FieldMapping {\n return {\n id: row.id,\n syncConfigId: row.syncConfigId,\n sourceField: row.sourceField,\n targetField: row.targetField,\n transformType:\n (row.transformType as FieldMapping['transformType']) ?? undefined,\n transformConfig: row.transformConfig\n ? JSON.parse(row.transformConfig)\n : undefined,\n createdAt: new Date(row.createdAt),\n };\n}\n\n// ============ Handler Factory ============\n\nexport function createIntegrationHandlers(db: DatabasePort) {\n /**\n * List integrations\n */\n async function listIntegrations(\n input: ListIntegrationsInput\n ): Promise<ListIntegrationsOutput> {\n const { projectId, type, status, search, limit = 20, offset = 0 } = input;\n\n let whereClause = 'WHERE projectId = ?';\n const params: (string | number)[] = [projectId];\n\n if (type && type !== 'all') {\n whereClause += ' AND type = ?';\n params.push(type);\n }\n\n if (status && status !== 'all') {\n whereClause += ' AND status = ?';\n params.push(status);\n }\n\n if (search) {\n whereClause += ' AND name LIKE ?';\n params.push(`%${search}%`);\n }\n\n const countResult = (\n await db.query(\n `SELECT COUNT(*) as count FROM integration ${whereClause}`,\n params\n )\n ).rows as DbRow[];\n const total = (countResult[0]?.count as number) ?? 0;\n\n const rows = (\n await db.query(\n `SELECT * FROM integration ${whereClause} ORDER BY name LIMIT ? OFFSET ?`,\n [...params, limit, offset]\n )\n ).rows as unknown as IntegrationRow[];\n\n return {\n integrations: rows.map(rowToIntegration),\n total,\n };\n }\n\n /**\n * Create an integration\n */\n async function createIntegration(\n input: CreateIntegrationInput,\n context: { projectId: string; organizationId: string }\n ): Promise<Integration> {\n const id = generateId('integ');\n const now = new Date().toISOString();\n\n await db.execute(\n `INSERT INTO integration (id, projectId, organizationId, name, description, type, status, iconUrl, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n context.projectId,\n context.organizationId,\n input.name,\n input.description ?? null,\n input.type,\n 'INACTIVE',\n input.iconUrl ?? null,\n now,\n now,\n ]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration WHERE id = ?`, [id])\n ).rows as unknown as IntegrationRow[];\n\n return rowToIntegration(rows[0]!);\n }\n\n /**\n * List connections\n */\n async function listConnections(\n input: ListConnectionsInput\n ): Promise<ListConnectionsOutput> {\n const { integrationId, status, limit = 20, offset = 0 } = input;\n\n let whereClause = 'WHERE 1=1';\n const params: (string | number)[] = [];\n\n if (integrationId) {\n whereClause += ' AND integrationId = ?';\n params.push(integrationId);\n }\n\n if (status && status !== 'all') {\n whereClause += ' AND status = ?';\n params.push(status);\n }\n\n const countResult = (\n await db.query(\n `SELECT COUNT(*) as count FROM integration_connection ${whereClause}`,\n params\n )\n ).rows as DbRow[];\n const total = (countResult[0]?.count as number) ?? 0;\n\n const rows = (\n await db.query(\n `SELECT * FROM integration_connection ${whereClause} ORDER BY updatedAt DESC LIMIT ? OFFSET ?`,\n [...params, limit, offset]\n )\n ).rows as unknown as ConnectionRow[];\n\n return {\n connections: rows.map(rowToConnection),\n total,\n };\n }\n\n /**\n * Connect a service\n */\n async function connectService(\n input: ConnectServiceInput\n ): Promise<Connection> {\n const id = generateId('conn');\n const now = new Date().toISOString();\n\n await db.execute(\n `INSERT INTO integration_connection (id, integrationId, name, status, credentials, config, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n input.integrationId,\n input.name,\n 'PENDING',\n input.credentials ? JSON.stringify(input.credentials) : null,\n input.config ? JSON.stringify(input.config) : null,\n now,\n now,\n ]\n );\n\n // Simulate connection success\n await db.execute(\n `UPDATE integration_connection SET status = 'CONNECTED', updatedAt = ? WHERE id = ?`,\n [now, id]\n );\n\n // Activate integration\n await db.execute(\n `UPDATE integration SET status = 'ACTIVE', updatedAt = ? WHERE id = ?`,\n [now, input.integrationId]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration_connection WHERE id = ?`, [id])\n ).rows as unknown as ConnectionRow[];\n\n return rowToConnection(rows[0]!);\n }\n\n /**\n * Disconnect a service\n */\n async function disconnectService(connectionId: string): Promise<Connection> {\n const now = new Date().toISOString();\n\n await db.execute(\n `UPDATE integration_connection SET status = 'DISCONNECTED', updatedAt = ? WHERE id = ?`,\n [now, connectionId]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration_connection WHERE id = ?`, [\n connectionId,\n ])\n ).rows as unknown as ConnectionRow[];\n\n return rowToConnection(rows[0]!);\n }\n\n /**\n * List sync configs\n */\n async function listSyncConfigs(\n input: ListSyncConfigsInput\n ): Promise<ListSyncConfigsOutput> {\n const { connectionId, status, limit = 20, offset = 0 } = input;\n\n let whereClause = 'WHERE 1=1';\n const params: (string | number)[] = [];\n\n if (connectionId) {\n whereClause += ' AND connectionId = ?';\n params.push(connectionId);\n }\n\n if (status && status !== 'all') {\n whereClause += ' AND status = ?';\n params.push(status);\n }\n\n const countResult = (\n await db.query(\n `SELECT COUNT(*) as count FROM integration_sync_config ${whereClause}`,\n params\n )\n ).rows as DbRow[];\n const total = (countResult[0]?.count as number) ?? 0;\n\n const rows = (\n await db.query(\n `SELECT * FROM integration_sync_config ${whereClause} ORDER BY updatedAt DESC LIMIT ? OFFSET ?`,\n [...params, limit, offset]\n )\n ).rows as unknown as SyncConfigRow[];\n\n return {\n configs: rows.map(rowToSyncConfig),\n total,\n };\n }\n\n /**\n * Configure a sync\n */\n async function configureSync(input: ConfigureSyncInput): Promise<SyncConfig> {\n const id = generateId('sync');\n const now = new Date().toISOString();\n\n await db.execute(\n `INSERT INTO integration_sync_config (id, connectionId, name, sourceEntity, targetEntity, frequency, status, recordsSynced, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n input.connectionId,\n input.name,\n input.sourceEntity,\n input.targetEntity,\n input.frequency ?? 'DAILY',\n 'ACTIVE',\n 0,\n now,\n now,\n ]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration_sync_config WHERE id = ?`, [id])\n ).rows as unknown as SyncConfigRow[];\n\n return rowToSyncConfig(rows[0]!);\n }\n\n /**\n * Map fields for a sync\n */\n async function mapFields(input: MapFieldsInput): Promise<FieldMapping[]> {\n const now = new Date().toISOString();\n const mappings: FieldMapping[] = [];\n\n // Clear existing mappings\n await db.execute(\n `DELETE FROM integration_field_mapping WHERE syncConfigId = ?`,\n [input.syncConfigId]\n );\n\n for (const mapping of input.mappings) {\n const id = generateId('fmap');\n\n await db.execute(\n `INSERT INTO integration_field_mapping (id, syncConfigId, sourceField, targetField, transformType, transformConfig, createdAt)\n VALUES (?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n input.syncConfigId,\n mapping.sourceField,\n mapping.targetField,\n mapping.transformType ?? null,\n mapping.transformConfig\n ? JSON.stringify(mapping.transformConfig)\n : null,\n now,\n ]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration_field_mapping WHERE id = ?`, [\n id,\n ])\n ).rows as unknown as FieldMappingRow[];\n\n mappings.push(rowToFieldMapping(rows[0]!));\n }\n\n return mappings;\n }\n\n /**\n * Get field mappings for a sync config\n */\n async function getFieldMappings(\n syncConfigId: string\n ): Promise<FieldMapping[]> {\n const rows = (\n await db.query(\n `SELECT * FROM integration_field_mapping WHERE syncConfigId = ?`,\n [syncConfigId]\n )\n ).rows as unknown as FieldMappingRow[];\n\n return rows.map(rowToFieldMapping);\n }\n\n /**\n * Run a sync (simulated)\n */\n async function runSync(syncConfigId: string): Promise<SyncConfig> {\n const now = new Date().toISOString();\n\n // Simulate sync execution\n const recordsSynced = Math.floor(Math.random() * 1000) + 50;\n\n await db.execute(\n `UPDATE integration_sync_config SET lastRunAt = ?, lastRunStatus = 'SUCCESS', recordsSynced = recordsSynced + ?, updatedAt = ? WHERE id = ?`,\n [now, recordsSynced, now, syncConfigId]\n );\n\n // Update connection lastSyncAt\n const config = (\n await db.query(`SELECT * FROM integration_sync_config WHERE id = ?`, [\n syncConfigId,\n ])\n ).rows as unknown as SyncConfigRow[];\n\n if (config[0]) {\n await db.execute(\n `UPDATE integration_connection SET lastSyncAt = ?, updatedAt = ? WHERE id = ?`,\n [now, now, config[0].connectionId]\n );\n }\n\n const rows = (\n await db.query(`SELECT * FROM integration_sync_config WHERE id = ?`, [\n syncConfigId,\n ])\n ).rows as unknown as SyncConfigRow[];\n\n return rowToSyncConfig(rows[0]!);\n }\n\n return {\n listIntegrations,\n createIntegration,\n listConnections,\n connectService,\n disconnectService,\n listSyncConfigs,\n configureSync,\n mapFields,\n getFieldMappings,\n runSync,\n };\n}\n\nexport type IntegrationHandlers = ReturnType<typeof createIntegrationHandlers>;\n"],"mappings":";;;AAQA,MAAM,EAAE,eAAe;AAkLvB,SAAS,iBAAiB,KAAkC;AAC1D,QAAO;EACL,IAAI,IAAI;EACR,WAAW,IAAI;EACf,gBAAgB,IAAI;EACpB,MAAM,IAAI;EACV,aAAa,IAAI,eAAe;EAChC,MAAM,IAAI;EACV,QAAQ,IAAI;EACZ,SAAS,IAAI,WAAW;EACxB,WAAW,IAAI,KAAK,IAAI,UAAU;EAClC,WAAW,IAAI,KAAK,IAAI,UAAU;EACnC;;AAGH,SAAS,gBAAgB,KAAgC;AACvD,QAAO;EACL,IAAI,IAAI;EACR,eAAe,IAAI;EACnB,MAAM,IAAI;EACV,QAAQ,IAAI;EACZ,aAAa,IAAI,cAAc,KAAK,MAAM,IAAI,YAAY,GAAG;EAC7D,QAAQ,IAAI,SAAS,KAAK,MAAM,IAAI,OAAO,GAAG;EAC9C,YAAY,IAAI,aAAa,IAAI,KAAK,IAAI,WAAW,GAAG;EACxD,cAAc,IAAI,gBAAgB;EAClC,WAAW,IAAI,KAAK,IAAI,UAAU;EAClC,WAAW,IAAI,KAAK,IAAI,UAAU;EACnC;;AAGH,SAAS,gBAAgB,KAAgC;AACvD,QAAO;EACL,IAAI,IAAI;EACR,cAAc,IAAI;EAClB,MAAM,IAAI;EACV,cAAc,IAAI;EAClB,cAAc,IAAI;EAClB,WAAW,IAAI;EACf,QAAQ,IAAI;EACZ,WAAW,IAAI,YAAY,IAAI,KAAK,IAAI,UAAU,GAAG;EACrD,eACG,IAAI,iBAAiD;EACxD,eAAe,IAAI;EACnB,WAAW,IAAI,KAAK,IAAI,UAAU;EAClC,WAAW,IAAI,KAAK,IAAI,UAAU;EACnC;;AAGH,SAAS,kBAAkB,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AAe,iBACb,cACyB;AAQzB,UANE,MAAM,GAAG,MACP,kEACA,CAAC,aAAa,CACf,EACD,KAEU,IAAI,kBAAkB;;;;;CAMpC,eAAe,QAAQ,cAA2C;EAChE,MAAM,uBAAM,IAAI,MAAM,EAAC,aAAa;EAGpC,MAAM,gBAAgB,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAK,GAAG;AAEzD,QAAM,GAAG,QACP,8IACA;GAAC;GAAK;GAAe;GAAK;GAAa,CACxC;EAGD,MAAM,UACJ,MAAM,GAAG,MAAM,sDAAsD,CACnE,aACD,CAAC,EACF;AAEF,MAAI,OAAO,GACT,OAAM,GAAG,QACP,gFACA;GAAC;GAAK;GAAK,OAAO,GAAG;GAAa,CACnC;EAGH,MAAM,QACJ,MAAM,GAAG,MAAM,sDAAsD,CACnE,aACD,CAAC,EACF;AAEF,SAAO,gBAAgB,KAAK,GAAI;;AAGlC,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
1
+ {"version":3,"file":"integration.handlers.js","names":[],"sources":["../../src/handlers/integration.handlers.ts"],"sourcesContent":["/**\n * Runtime-local Integration Hub handlers\n *\n * Database-backed handlers for the integration-hub template.\n */\nimport type { DatabasePort, DbRow } from '@contractspec/lib.runtime-sandbox';\n/* eslint-disable @typescript-eslint/no-non-null-assertion */\nimport { web } from '@contractspec/lib.runtime-sandbox';\nconst { generateId } = web;\n\n// ============ Types ============\n\nexport interface Integration {\n id: string;\n projectId: string;\n organizationId: string;\n name: string;\n description?: string;\n type:\n | 'CRM'\n | 'MARKETING'\n | 'PAYMENT'\n | 'COMMUNICATION'\n | 'DATA'\n | 'ANALYTICS'\n | 'CUSTOM';\n status: 'ACTIVE' | 'INACTIVE';\n iconUrl?: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface Connection {\n id: string;\n integrationId: string;\n name: string;\n status: 'CONNECTED' | 'DISCONNECTED' | 'ERROR' | 'PENDING';\n credentials?: Record<string, unknown>;\n config?: Record<string, unknown>;\n lastSyncAt?: Date;\n errorMessage?: string;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface SyncConfig {\n id: string;\n connectionId: string;\n name: string;\n sourceEntity: string;\n targetEntity: string;\n frequency: 'REALTIME' | 'HOURLY' | 'DAILY' | 'WEEKLY' | 'MANUAL';\n status: 'ACTIVE' | 'PAUSED' | 'ERROR';\n lastRunAt?: Date;\n lastRunStatus?: 'SUCCESS' | 'FAILED' | 'PARTIAL';\n recordsSynced: number;\n createdAt: Date;\n updatedAt: Date;\n}\n\nexport interface FieldMapping {\n id: string;\n syncConfigId: string;\n sourceField: string;\n targetField: string;\n transformType?: 'DIRECT' | 'FORMAT' | 'LOOKUP' | 'CUSTOM';\n transformConfig?: Record<string, unknown>;\n createdAt: Date;\n}\n\nexport interface CreateIntegrationInput {\n name: string;\n description?: string;\n type: Integration['type'];\n iconUrl?: string;\n}\n\nexport interface ConnectServiceInput {\n integrationId: string;\n name: string;\n credentials?: Record<string, unknown>;\n config?: Record<string, unknown>;\n}\n\nexport interface ConfigureSyncInput {\n connectionId: string;\n name: string;\n sourceEntity: string;\n targetEntity: string;\n frequency?: SyncConfig['frequency'];\n}\n\nexport interface MapFieldsInput {\n syncConfigId: string;\n mappings: {\n sourceField: string;\n targetField: string;\n transformType?: FieldMapping['transformType'];\n transformConfig?: Record<string, unknown>;\n }[];\n}\n\nexport interface ListIntegrationsInput {\n projectId: string;\n type?: Integration['type'] | 'all';\n status?: 'ACTIVE' | 'INACTIVE' | 'all';\n search?: string;\n limit?: number;\n offset?: number;\n}\n\nexport interface ListIntegrationsOutput {\n integrations: Integration[];\n total: number;\n}\n\nexport interface ListConnectionsInput {\n integrationId?: string;\n status?: Connection['status'] | 'all';\n limit?: number;\n offset?: number;\n}\n\nexport interface ListConnectionsOutput {\n connections: Connection[];\n total: number;\n}\n\nexport interface ListSyncConfigsInput {\n connectionId?: string;\n status?: SyncConfig['status'] | 'all';\n limit?: number;\n offset?: number;\n}\n\nexport interface ListSyncConfigsOutput {\n configs: SyncConfig[];\n total: number;\n}\n\n// ============ Row Types ============\n\ninterface IntegrationRow {\n id: string;\n projectId: string;\n organizationId: string;\n name: string;\n description: string | null;\n type: string;\n status: string;\n iconUrl: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface ConnectionRow {\n id: string;\n integrationId: string;\n name: string;\n status: string;\n credentials: string | null;\n config: string | null;\n lastSyncAt: string | null;\n errorMessage: string | null;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface SyncConfigRow {\n id: string;\n connectionId: string;\n name: string;\n sourceEntity: string;\n targetEntity: string;\n frequency: string;\n status: string;\n lastRunAt: string | null;\n lastRunStatus: string | null;\n recordsSynced: number;\n createdAt: string;\n updatedAt: string;\n}\n\ninterface FieldMappingRow {\n id: string;\n syncConfigId: string;\n sourceField: string;\n targetField: string;\n transformType: string | null;\n transformConfig: string | null;\n createdAt: string;\n}\n\nfunction rowToIntegration(row: IntegrationRow): Integration {\n return {\n id: row.id,\n projectId: row.projectId,\n organizationId: row.organizationId,\n name: row.name,\n description: row.description ?? undefined,\n type: row.type as Integration['type'],\n status: row.status as Integration['status'],\n iconUrl: row.iconUrl ?? undefined,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n };\n}\n\nfunction rowToConnection(row: ConnectionRow): Connection {\n return {\n id: row.id,\n integrationId: row.integrationId,\n name: row.name,\n status: row.status as Connection['status'],\n credentials: row.credentials ? JSON.parse(row.credentials) : undefined,\n config: row.config ? JSON.parse(row.config) : undefined,\n lastSyncAt: row.lastSyncAt ? new Date(row.lastSyncAt) : undefined,\n errorMessage: row.errorMessage ?? undefined,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n };\n}\n\nfunction rowToSyncConfig(row: SyncConfigRow): SyncConfig {\n return {\n id: row.id,\n connectionId: row.connectionId,\n name: row.name,\n sourceEntity: row.sourceEntity,\n targetEntity: row.targetEntity,\n frequency: row.frequency as SyncConfig['frequency'],\n status: row.status as SyncConfig['status'],\n lastRunAt: row.lastRunAt ? new Date(row.lastRunAt) : undefined,\n lastRunStatus:\n (row.lastRunStatus as SyncConfig['lastRunStatus']) ?? undefined,\n recordsSynced: row.recordsSynced,\n createdAt: new Date(row.createdAt),\n updatedAt: new Date(row.updatedAt),\n };\n}\n\nfunction rowToFieldMapping(row: FieldMappingRow): FieldMapping {\n return {\n id: row.id,\n syncConfigId: row.syncConfigId,\n sourceField: row.sourceField,\n targetField: row.targetField,\n transformType:\n (row.transformType as FieldMapping['transformType']) ?? undefined,\n transformConfig: row.transformConfig\n ? JSON.parse(row.transformConfig)\n : undefined,\n createdAt: new Date(row.createdAt),\n };\n}\n\n// ============ Handler Factory ============\n\nexport function createIntegrationHandlers(db: DatabasePort) {\n /**\n * List integrations\n */\n async function listIntegrations(\n input: ListIntegrationsInput\n ): Promise<ListIntegrationsOutput> {\n const { projectId, type, status, search, limit = 20, offset = 0 } = input;\n\n let whereClause = 'WHERE projectId = ?';\n const params: (string | number)[] = [projectId];\n\n if (type && type !== 'all') {\n whereClause += ' AND type = ?';\n params.push(type);\n }\n\n if (status && status !== 'all') {\n whereClause += ' AND status = ?';\n params.push(status);\n }\n\n if (search) {\n whereClause += ' AND name LIKE ?';\n params.push(`%${search}%`);\n }\n\n const countResult = (\n await db.query(\n `SELECT COUNT(*) as count FROM integration ${whereClause}`,\n params\n )\n ).rows as DbRow[];\n const total = (countResult[0]?.count as number) ?? 0;\n\n const rows = (\n await db.query(\n `SELECT * FROM integration ${whereClause} ORDER BY name LIMIT ? OFFSET ?`,\n [...params, limit, offset]\n )\n ).rows as unknown as IntegrationRow[];\n\n return {\n integrations: rows.map(rowToIntegration),\n total,\n };\n }\n\n /**\n * Create an integration\n */\n async function createIntegration(\n input: CreateIntegrationInput,\n context: { projectId: string; organizationId: string }\n ): Promise<Integration> {\n const id = generateId('integ');\n const now = new Date().toISOString();\n\n await db.execute(\n `INSERT INTO integration (id, projectId, organizationId, name, description, type, status, iconUrl, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n context.projectId,\n context.organizationId,\n input.name,\n input.description ?? null,\n input.type,\n 'INACTIVE',\n input.iconUrl ?? null,\n now,\n now,\n ]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration WHERE id = ?`, [id])\n ).rows as unknown as IntegrationRow[];\n\n return rowToIntegration(rows[0]!);\n }\n\n /**\n * List connections\n */\n async function listConnections(\n input: ListConnectionsInput\n ): Promise<ListConnectionsOutput> {\n const { integrationId, status, limit = 20, offset = 0 } = input;\n\n let whereClause = 'WHERE 1=1';\n const params: (string | number)[] = [];\n\n if (integrationId) {\n whereClause += ' AND integrationId = ?';\n params.push(integrationId);\n }\n\n if (status && status !== 'all') {\n whereClause += ' AND status = ?';\n params.push(status);\n }\n\n const countResult = (\n await db.query(\n `SELECT COUNT(*) as count FROM integration_connection ${whereClause}`,\n params\n )\n ).rows as DbRow[];\n const total = (countResult[0]?.count as number) ?? 0;\n\n const rows = (\n await db.query(\n `SELECT * FROM integration_connection ${whereClause} ORDER BY updatedAt DESC LIMIT ? OFFSET ?`,\n [...params, limit, offset]\n )\n ).rows as unknown as ConnectionRow[];\n\n return {\n connections: rows.map(rowToConnection),\n total,\n };\n }\n\n /**\n * Connect a service\n */\n async function connectService(\n input: ConnectServiceInput\n ): Promise<Connection> {\n const id = generateId('conn');\n const now = new Date().toISOString();\n\n await db.execute(\n `INSERT INTO integration_connection (id, integrationId, name, status, credentials, config, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n input.integrationId,\n input.name,\n 'PENDING',\n input.credentials ? JSON.stringify(input.credentials) : null,\n input.config ? JSON.stringify(input.config) : null,\n now,\n now,\n ]\n );\n\n // Simulate connection success\n await db.execute(\n `UPDATE integration_connection SET status = 'CONNECTED', updatedAt = ? WHERE id = ?`,\n [now, id]\n );\n\n // Activate integration\n await db.execute(\n `UPDATE integration SET status = 'ACTIVE', updatedAt = ? WHERE id = ?`,\n [now, input.integrationId]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration_connection WHERE id = ?`, [id])\n ).rows as unknown as ConnectionRow[];\n\n return rowToConnection(rows[0]!);\n }\n\n /**\n * Disconnect a service\n */\n async function disconnectService(connectionId: string): Promise<Connection> {\n const now = new Date().toISOString();\n\n await db.execute(\n `UPDATE integration_connection SET status = 'DISCONNECTED', updatedAt = ? WHERE id = ?`,\n [now, connectionId]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration_connection WHERE id = ?`, [\n connectionId,\n ])\n ).rows as unknown as ConnectionRow[];\n\n return rowToConnection(rows[0]!);\n }\n\n /**\n * List sync configs\n */\n async function listSyncConfigs(\n input: ListSyncConfigsInput\n ): Promise<ListSyncConfigsOutput> {\n const { connectionId, status, limit = 20, offset = 0 } = input;\n\n let whereClause = 'WHERE 1=1';\n const params: (string | number)[] = [];\n\n if (connectionId) {\n whereClause += ' AND connectionId = ?';\n params.push(connectionId);\n }\n\n if (status && status !== 'all') {\n whereClause += ' AND status = ?';\n params.push(status);\n }\n\n const countResult = (\n await db.query(\n `SELECT COUNT(*) as count FROM integration_sync_config ${whereClause}`,\n params\n )\n ).rows as DbRow[];\n const total = (countResult[0]?.count as number) ?? 0;\n\n const rows = (\n await db.query(\n `SELECT * FROM integration_sync_config ${whereClause} ORDER BY updatedAt DESC LIMIT ? OFFSET ?`,\n [...params, limit, offset]\n )\n ).rows as unknown as SyncConfigRow[];\n\n return {\n configs: rows.map(rowToSyncConfig),\n total,\n };\n }\n\n /**\n * Configure a sync\n */\n async function configureSync(input: ConfigureSyncInput): Promise<SyncConfig> {\n const id = generateId('sync');\n const now = new Date().toISOString();\n\n await db.execute(\n `INSERT INTO integration_sync_config (id, connectionId, name, sourceEntity, targetEntity, frequency, status, recordsSynced, createdAt, updatedAt)\n VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n input.connectionId,\n input.name,\n input.sourceEntity,\n input.targetEntity,\n input.frequency ?? 'DAILY',\n 'ACTIVE',\n 0,\n now,\n now,\n ]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration_sync_config WHERE id = ?`, [id])\n ).rows as unknown as SyncConfigRow[];\n\n return rowToSyncConfig(rows[0]!);\n }\n\n /**\n * Map fields for a sync\n */\n async function mapFields(input: MapFieldsInput): Promise<FieldMapping[]> {\n const now = new Date().toISOString();\n const mappings: FieldMapping[] = [];\n\n // Clear existing mappings\n await db.execute(\n `DELETE FROM integration_field_mapping WHERE syncConfigId = ?`,\n [input.syncConfigId]\n );\n\n for (const mapping of input.mappings) {\n const id = generateId('fmap');\n\n await db.execute(\n `INSERT INTO integration_field_mapping (id, syncConfigId, sourceField, targetField, transformType, transformConfig, createdAt)\n VALUES (?, ?, ?, ?, ?, ?, ?)`,\n [\n id,\n input.syncConfigId,\n mapping.sourceField,\n mapping.targetField,\n mapping.transformType ?? null,\n mapping.transformConfig\n ? JSON.stringify(mapping.transformConfig)\n : null,\n now,\n ]\n );\n\n const rows = (\n await db.query(`SELECT * FROM integration_field_mapping WHERE id = ?`, [\n id,\n ])\n ).rows as unknown as FieldMappingRow[];\n\n mappings.push(rowToFieldMapping(rows[0]!));\n }\n\n return mappings;\n }\n\n /**\n * Get field mappings for a sync config\n */\n async function getFieldMappings(\n syncConfigId: string\n ): Promise<FieldMapping[]> {\n const rows = (\n await db.query(\n `SELECT * FROM integration_field_mapping WHERE syncConfigId = ?`,\n [syncConfigId]\n )\n ).rows as unknown as FieldMappingRow[];\n\n return rows.map(rowToFieldMapping);\n }\n\n /**\n * Run a sync (simulated)\n */\n async function runSync(syncConfigId: string): Promise<SyncConfig> {\n const now = new Date().toISOString();\n\n // Simulate sync execution\n const recordsSynced = Math.floor(Math.random() * 1000) + 50;\n\n await db.execute(\n `UPDATE integration_sync_config SET lastRunAt = ?, lastRunStatus = 'SUCCESS', recordsSynced = recordsSynced + ?, updatedAt = ? WHERE id = ?`,\n [now, recordsSynced, now, syncConfigId]\n );\n\n // Update connection lastSyncAt\n const config = (\n await db.query(`SELECT * FROM integration_sync_config WHERE id = ?`, [\n syncConfigId,\n ])\n ).rows as unknown as SyncConfigRow[];\n\n if (config[0]) {\n await db.execute(\n `UPDATE integration_connection SET lastSyncAt = ?, updatedAt = ? WHERE id = ?`,\n [now, now, config[0].connectionId]\n );\n }\n\n const rows = (\n await db.query(`SELECT * FROM integration_sync_config WHERE id = ?`, [\n syncConfigId,\n ])\n ).rows as unknown as SyncConfigRow[];\n\n return rowToSyncConfig(rows[0]!);\n }\n\n return {\n listIntegrations,\n createIntegration,\n listConnections,\n connectService,\n disconnectService,\n listSyncConfigs,\n configureSync,\n mapFields,\n getFieldMappings,\n runSync,\n };\n}\n\nexport type IntegrationHandlers = ReturnType<typeof createIntegrationHandlers>;\n"],"mappings":";;;AAQA,MAAM,EAAE,eAAe;AAyLvB,SAAS,iBAAiB,KAAkC;AAC1D,QAAO;EACL,IAAI,IAAI;EACR,WAAW,IAAI;EACf,gBAAgB,IAAI;EACpB,MAAM,IAAI;EACV,aAAa,IAAI,eAAe;EAChC,MAAM,IAAI;EACV,QAAQ,IAAI;EACZ,SAAS,IAAI,WAAW;EACxB,WAAW,IAAI,KAAK,IAAI,UAAU;EAClC,WAAW,IAAI,KAAK,IAAI,UAAU;EACnC;;AAGH,SAAS,gBAAgB,KAAgC;AACvD,QAAO;EACL,IAAI,IAAI;EACR,eAAe,IAAI;EACnB,MAAM,IAAI;EACV,QAAQ,IAAI;EACZ,aAAa,IAAI,cAAc,KAAK,MAAM,IAAI,YAAY,GAAG;EAC7D,QAAQ,IAAI,SAAS,KAAK,MAAM,IAAI,OAAO,GAAG;EAC9C,YAAY,IAAI,aAAa,IAAI,KAAK,IAAI,WAAW,GAAG;EACxD,cAAc,IAAI,gBAAgB;EAClC,WAAW,IAAI,KAAK,IAAI,UAAU;EAClC,WAAW,IAAI,KAAK,IAAI,UAAU;EACnC;;AAGH,SAAS,gBAAgB,KAAgC;AACvD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GACpC,MAAM,KAAK,WAAW,OAAO;AAE7B,SAAM,GAAG,QACP;wCAEA;IACE;IACA,MAAM;IACN,QAAQ;IACR,QAAQ;IACR,QAAQ,iBAAiB;IACzB,QAAQ,kBACJ,KAAK,UAAU,QAAQ,gBAAgB,GACvC;IACJ;IACD,CACF;GAED,MAAM,QACJ,MAAM,GAAG,MAAM,wDAAwD,CACrE,GACD,CAAC,EACF;AAEF,YAAS,KAAK,kBAAkB,KAAK,GAAI,CAAC;;AAG5C,SAAO;;;;;CAMT,eAAe,iBACb,cACyB;AAQzB,UANE,MAAM,GAAG,MACP,kEACA,CAAC,aAAa,CACf,EACD,KAEU,IAAI,kBAAkB;;;;;CAMpC,eAAe,QAAQ,cAA2C;EAChE,MAAM,uBAAM,IAAI,MAAM,EAAC,aAAa;EAGpC,MAAM,gBAAgB,KAAK,MAAM,KAAK,QAAQ,GAAG,IAAK,GAAG;AAEzD,QAAM,GAAG,QACP,8IACA;GAAC;GAAK;GAAe;GAAK;GAAa,CACxC;EAGD,MAAM,UACJ,MAAM,GAAG,MAAM,sDAAsD,CACnE,aACD,CAAC,EACF;AAEF,MAAI,OAAO,GACT,OAAM,GAAG,QACP,gFACA;GAAC;GAAK;GAAK,OAAO,GAAG;GAAa,CACnC;EAGH,MAAM,QACJ,MAAM,GAAG,MAAM,sDAAsD,CACnE,aACD,CAAC,EACF;AAEF,SAAO,gBAAgB,KAAK,GAAI;;AAGlC,QAAO;EACL;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACA;EACD"}
@@ -1,10 +1,10 @@
1
- import * as _contractspec_lib_schema81 from "@contractspec/lib.schema";
1
+ import * as _contractspec_lib_schema0 from "@contractspec/lib.schema";
2
2
 
3
3
  //#region src/integration/integration.enum.d.ts
4
4
  /**
5
5
  * Integration status enum.
6
6
  */
7
- declare const IntegrationStatusEnum: _contractspec_lib_schema81.EnumType<[string, string, string, string, string]>;
7
+ declare const IntegrationStatusEnum: _contractspec_lib_schema0.EnumType<[string, string, string, string, string]>;
8
8
  //#endregion
9
9
  export { IntegrationStatusEnum };
10
10
  //# sourceMappingURL=integration.enum.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"integration.enum.d.ts","names":[],"sources":["../../src/integration/integration.enum.ts"],"sourcesContent":[],"mappings":";;;;;;AAKa,cAAA,qBAMX,EAAA,0BAAA,CANgC,QAAA,CAAA,CAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,EAAA,MAAA,CAAA,CAAA"}
1
+ {"version":3,"file":"integration.enum.d.ts","names":[],"sources":["../../src/integration/integration.enum.ts"],"mappings":";;;;;;cAKa,qBAAA,EAMX,yBAAA,CANgC,QAAA"}