@contractspec/example.integration-hub 2.5.0 → 2.6.1

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 (48) hide show
  1. package/README.md +40 -0
  2. package/dist/docs/index.js +2 -0
  3. package/dist/docs/integration-hub.docblock.js +2 -0
  4. package/dist/index.d.ts +1 -0
  5. package/dist/index.js +149 -0
  6. package/dist/mcp-example.d.ts +16 -0
  7. package/dist/mcp-example.js +151 -0
  8. package/dist/node/docs/index.js +2 -0
  9. package/dist/node/docs/integration-hub.docblock.js +2 -0
  10. package/dist/node/index.js +149 -0
  11. package/dist/node/mcp-example.js +150 -0
  12. package/dist/node/run-mcp.js +155 -0
  13. package/dist/run-mcp.d.ts +1 -0
  14. package/dist/run-mcp.js +156 -0
  15. package/package.json +34 -94
  16. package/dist/browser/connection/connection.enum.js +0 -12
  17. package/dist/browser/connection/connection.operation.js +0 -101
  18. package/dist/browser/connection/connection.presentation.js +0 -102
  19. package/dist/browser/connection/connection.schema.js +0 -48
  20. package/dist/browser/connection/index.js +0 -104
  21. package/dist/browser/docs/index.js +0 -104
  22. package/dist/browser/docs/integration-hub.docblock.js +0 -104
  23. package/dist/browser/events.js +0 -211
  24. package/dist/browser/example.js +0 -42
  25. package/dist/browser/handlers/index.js +0 -246
  26. package/dist/browser/handlers/integration.handlers.js +0 -246
  27. package/dist/browser/index.js +0 -1595
  28. package/dist/browser/integration/index.js +0 -92
  29. package/dist/browser/integration/integration.enum.js +0 -12
  30. package/dist/browser/integration/integration.operations.js +0 -89
  31. package/dist/browser/integration/integration.presentation.js +0 -120
  32. package/dist/browser/integration/integration.schema.js +0 -42
  33. package/dist/browser/integration-hub.capability.js +0 -43
  34. package/dist/browser/integration-hub.feature.js +0 -114
  35. package/dist/browser/seeders/index.js +0 -60
  36. package/dist/browser/sync/index.js +0 -332
  37. package/dist/browser/sync/sync.enum.js +0 -26
  38. package/dist/browser/sync/sync.operations.js +0 -321
  39. package/dist/browser/sync/sync.presentation.js +0 -301
  40. package/dist/browser/sync/sync.schema.js +0 -154
  41. package/dist/browser/sync-engine/index.js +0 -186
  42. package/dist/browser/tests/operations.test-spec.js +0 -85
  43. package/dist/browser/ui/IntegrationDashboard.js +0 -369
  44. package/dist/browser/ui/hooks/index.js +0 -57
  45. package/dist/browser/ui/hooks/useIntegrationData.js +0 -54
  46. package/dist/browser/ui/index.js +0 -644
  47. package/dist/browser/ui/renderers/index.js +0 -273
  48. package/dist/browser/ui/renderers/integration.markdown.js +0 -273
@@ -1,332 +0,0 @@
1
- // src/sync/sync.enum.ts
2
- import { defineEnum } from "@contractspec/lib.schema";
3
- var SyncDirectionEnum = defineEnum("SyncDirection", [
4
- "INBOUND",
5
- "OUTBOUND",
6
- "BIDIRECTIONAL"
7
- ]);
8
- var SyncStatusEnum = defineEnum("SyncStatus", [
9
- "PENDING",
10
- "RUNNING",
11
- "COMPLETED",
12
- "FAILED",
13
- "CANCELLED"
14
- ]);
15
- var MappingTypeEnum = defineEnum("MappingType", [
16
- "DIRECT",
17
- "TRANSFORM",
18
- "LOOKUP",
19
- "CONSTANT",
20
- "COMPUTED"
21
- ]);
22
-
23
- // src/sync/sync.schema.ts
24
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
25
- var FieldMappingModel = defineSchemaModel({
26
- name: "FieldMappingModel",
27
- fields: {
28
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
29
- sourceField: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
30
- targetField: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
31
- mappingType: { type: MappingTypeEnum, isOptional: false },
32
- transformExpression: {
33
- type: ScalarTypeEnum.String_unsecure(),
34
- isOptional: true
35
- },
36
- isRequired: { type: ScalarTypeEnum.Boolean(), isOptional: false }
37
- }
38
- });
39
- var SyncConfigModel = defineSchemaModel({
40
- name: "SyncConfigModel",
41
- fields: {
42
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
- integrationId: {
44
- type: ScalarTypeEnum.String_unsecure(),
45
- isOptional: false
46
- },
47
- connectionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
48
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
49
- direction: { type: SyncDirectionEnum, isOptional: false },
50
- sourceObject: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
51
- targetObject: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
52
- scheduleEnabled: { type: ScalarTypeEnum.Boolean(), isOptional: false },
53
- scheduleCron: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
54
- isActive: { type: ScalarTypeEnum.Boolean(), isOptional: false },
55
- lastSyncAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
56
- fieldMappings: { type: FieldMappingModel, isArray: true, isOptional: true }
57
- }
58
- });
59
- var SyncRunModel = defineSchemaModel({
60
- name: "SyncRunModel",
61
- fields: {
62
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
63
- syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
64
- status: { type: SyncStatusEnum, isOptional: false },
65
- direction: { type: SyncDirectionEnum, isOptional: false },
66
- trigger: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
67
- recordsProcessed: {
68
- type: ScalarTypeEnum.Int_unsecure(),
69
- isOptional: false
70
- },
71
- recordsCreated: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
72
- recordsUpdated: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
73
- recordsFailed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
74
- errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
75
- startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
76
- completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
77
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
78
- }
79
- });
80
- var CreateSyncConfigInputModel = defineSchemaModel({
81
- name: "CreateSyncConfigInput",
82
- fields: {
83
- integrationId: {
84
- type: ScalarTypeEnum.String_unsecure(),
85
- isOptional: false
86
- },
87
- connectionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
88
- name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
89
- direction: { type: SyncDirectionEnum, isOptional: false },
90
- sourceObject: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
91
- targetObject: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
92
- scheduleEnabled: { type: ScalarTypeEnum.Boolean(), isOptional: true },
93
- scheduleCron: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
94
- }
95
- });
96
- var AddFieldMappingInputModel = defineSchemaModel({
97
- name: "AddFieldMappingInput",
98
- fields: {
99
- syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
100
- sourceField: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
101
- targetField: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
102
- mappingType: { type: MappingTypeEnum, isOptional: false },
103
- transformExpression: {
104
- type: ScalarTypeEnum.String_unsecure(),
105
- isOptional: true
106
- },
107
- lookupConfig: { type: ScalarTypeEnum.JSON(), isOptional: true },
108
- constantValue: { type: ScalarTypeEnum.JSON(), isOptional: true },
109
- isRequired: { type: ScalarTypeEnum.Boolean(), isOptional: true },
110
- defaultValue: { type: ScalarTypeEnum.JSON(), isOptional: true }
111
- }
112
- });
113
- var TriggerSyncInputModel = defineSchemaModel({
114
- name: "TriggerSyncInput",
115
- fields: {
116
- syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
117
- direction: { type: SyncDirectionEnum, isOptional: true },
118
- fullSync: { type: ScalarTypeEnum.Boolean(), isOptional: true }
119
- }
120
- });
121
- var ListSyncRunsInputModel = defineSchemaModel({
122
- name: "ListSyncRunsInput",
123
- fields: {
124
- syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
125
- status: { type: SyncStatusEnum, isOptional: true },
126
- limit: {
127
- type: ScalarTypeEnum.Int_unsecure(),
128
- isOptional: true,
129
- defaultValue: 20
130
- },
131
- offset: {
132
- type: ScalarTypeEnum.Int_unsecure(),
133
- isOptional: true,
134
- defaultValue: 0
135
- }
136
- }
137
- });
138
- var ListSyncRunsOutputModel = defineSchemaModel({
139
- name: "ListSyncRunsOutput",
140
- fields: {
141
- runs: { type: SyncRunModel, isArray: true, isOptional: false },
142
- total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
143
- }
144
- });
145
-
146
- // src/sync/sync.operations.ts
147
- import {
148
- defineCommand,
149
- defineQuery
150
- } from "@contractspec/lib.contracts-spec/operations";
151
- var OWNERS = ["@example.integration-hub"];
152
- var CreateSyncConfigContract = defineCommand({
153
- meta: {
154
- key: "integration.syncConfig.create",
155
- version: "1.0.0",
156
- stability: "stable",
157
- owners: [...OWNERS],
158
- tags: ["integration", "sync", "config", "create"],
159
- description: "Create a sync configuration.",
160
- goal: "Define how data should be synchronized.",
161
- context: "Sync setup."
162
- },
163
- io: { input: CreateSyncConfigInputModel, output: SyncConfigModel },
164
- policy: { auth: "user" },
165
- sideEffects: {
166
- emits: [
167
- {
168
- key: "integration.syncConfig.created",
169
- version: "1.0.0",
170
- when: "Sync config created",
171
- payload: SyncConfigModel
172
- }
173
- ],
174
- audit: ["integration.syncConfig.created"]
175
- },
176
- acceptance: {
177
- scenarios: [
178
- {
179
- key: "create-sync-happy-path",
180
- given: ["User is authenticated"],
181
- when: ["User creates sync config"],
182
- then: ["Sync config is created", "SyncConfigCreated event is emitted"]
183
- }
184
- ],
185
- examples: [
186
- {
187
- key: "create-contact-sync",
188
- input: {
189
- name: "Contacts Sync",
190
- sourceConnectionId: "conn-1",
191
- targetConnectionId: "conn-2"
192
- },
193
- output: { id: "sync-123", status: "active" }
194
- }
195
- ]
196
- }
197
- });
198
- var AddFieldMappingContract = defineCommand({
199
- meta: {
200
- key: "integration.fieldMapping.add",
201
- version: "1.0.0",
202
- stability: "stable",
203
- owners: [...OWNERS],
204
- tags: ["integration", "mapping", "field"],
205
- description: "Add a field mapping to a sync config.",
206
- goal: "Map fields between systems.",
207
- context: "Mapping configuration."
208
- },
209
- io: { input: AddFieldMappingInputModel, output: FieldMappingModel },
210
- policy: { auth: "user" },
211
- sideEffects: {
212
- emits: [
213
- {
214
- key: "integration.fieldMapping.added",
215
- version: "1.0.0",
216
- when: "Mapping added",
217
- payload: FieldMappingModel
218
- }
219
- ]
220
- },
221
- acceptance: {
222
- scenarios: [
223
- {
224
- key: "add-mapping-happy-path",
225
- given: ["Sync config exists"],
226
- when: ["User adds field mapping"],
227
- then: ["Mapping is added", "FieldMappingAdded event is emitted"]
228
- }
229
- ],
230
- examples: [
231
- {
232
- key: "map-email",
233
- input: {
234
- syncConfigId: "sync-123",
235
- sourceField: "email",
236
- targetField: "user_email"
237
- },
238
- output: { id: "map-456", type: "string" }
239
- }
240
- ]
241
- }
242
- });
243
- var TriggerSyncContract = defineCommand({
244
- meta: {
245
- key: "integration.sync.trigger",
246
- version: "1.0.0",
247
- stability: "stable",
248
- owners: [...OWNERS],
249
- tags: ["integration", "sync", "trigger"],
250
- description: "Trigger a manual sync.",
251
- goal: "Start data synchronization.",
252
- context: "Manual sync or webhook trigger."
253
- },
254
- io: { input: TriggerSyncInputModel, output: SyncRunModel },
255
- policy: { auth: "user" },
256
- sideEffects: {
257
- emits: [
258
- {
259
- key: "integration.sync.started",
260
- version: "1.0.0",
261
- when: "Sync starts",
262
- payload: SyncRunModel
263
- }
264
- ],
265
- audit: ["integration.sync.triggered"]
266
- },
267
- acceptance: {
268
- scenarios: [
269
- {
270
- key: "trigger-sync-happy-path",
271
- given: ["Sync config exists"],
272
- when: ["User triggers sync"],
273
- then: ["Sync run starts", "SyncStarted event is emitted"]
274
- }
275
- ],
276
- examples: [
277
- {
278
- key: "manual-trigger",
279
- input: { syncConfigId: "sync-123" },
280
- output: { id: "run-789", status: "pending" }
281
- }
282
- ]
283
- }
284
- });
285
- var ListSyncRunsContract = defineQuery({
286
- meta: {
287
- key: "integration.syncRun.list",
288
- version: "1.0.0",
289
- stability: "stable",
290
- owners: [...OWNERS],
291
- tags: ["integration", "sync", "run", "list"],
292
- description: "List sync run history.",
293
- goal: "View sync history and status.",
294
- context: "Sync monitoring."
295
- },
296
- io: { input: ListSyncRunsInputModel, output: ListSyncRunsOutputModel },
297
- policy: { auth: "user" },
298
- acceptance: {
299
- scenarios: [
300
- {
301
- key: "list-runs-happy-path",
302
- given: ["User has access to syncs"],
303
- when: ["User lists sync runs"],
304
- then: ["List of runs is returned"]
305
- }
306
- ],
307
- examples: [
308
- {
309
- key: "list-recent",
310
- input: { limit: 10 },
311
- output: { items: [], total: 50 }
312
- }
313
- ]
314
- }
315
- });
316
- export {
317
- TriggerSyncInputModel,
318
- TriggerSyncContract,
319
- SyncStatusEnum,
320
- SyncRunModel,
321
- SyncDirectionEnum,
322
- SyncConfigModel,
323
- MappingTypeEnum,
324
- ListSyncRunsOutputModel,
325
- ListSyncRunsInputModel,
326
- ListSyncRunsContract,
327
- FieldMappingModel,
328
- CreateSyncConfigInputModel,
329
- CreateSyncConfigContract,
330
- AddFieldMappingInputModel,
331
- AddFieldMappingContract
332
- };
@@ -1,26 +0,0 @@
1
- // src/sync/sync.enum.ts
2
- import { defineEnum } from "@contractspec/lib.schema";
3
- var SyncDirectionEnum = defineEnum("SyncDirection", [
4
- "INBOUND",
5
- "OUTBOUND",
6
- "BIDIRECTIONAL"
7
- ]);
8
- var SyncStatusEnum = defineEnum("SyncStatus", [
9
- "PENDING",
10
- "RUNNING",
11
- "COMPLETED",
12
- "FAILED",
13
- "CANCELLED"
14
- ]);
15
- var MappingTypeEnum = defineEnum("MappingType", [
16
- "DIRECT",
17
- "TRANSFORM",
18
- "LOOKUP",
19
- "CONSTANT",
20
- "COMPUTED"
21
- ]);
22
- export {
23
- SyncStatusEnum,
24
- SyncDirectionEnum,
25
- MappingTypeEnum
26
- };
@@ -1,321 +0,0 @@
1
- // src/sync/sync.enum.ts
2
- import { defineEnum } from "@contractspec/lib.schema";
3
- var SyncDirectionEnum = defineEnum("SyncDirection", [
4
- "INBOUND",
5
- "OUTBOUND",
6
- "BIDIRECTIONAL"
7
- ]);
8
- var SyncStatusEnum = defineEnum("SyncStatus", [
9
- "PENDING",
10
- "RUNNING",
11
- "COMPLETED",
12
- "FAILED",
13
- "CANCELLED"
14
- ]);
15
- var MappingTypeEnum = defineEnum("MappingType", [
16
- "DIRECT",
17
- "TRANSFORM",
18
- "LOOKUP",
19
- "CONSTANT",
20
- "COMPUTED"
21
- ]);
22
-
23
- // src/sync/sync.schema.ts
24
- import { defineSchemaModel, ScalarTypeEnum } from "@contractspec/lib.schema";
25
- var FieldMappingModel = defineSchemaModel({
26
- name: "FieldMappingModel",
27
- fields: {
28
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
29
- sourceField: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
30
- targetField: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
31
- mappingType: { type: MappingTypeEnum, isOptional: false },
32
- transformExpression: {
33
- type: ScalarTypeEnum.String_unsecure(),
34
- isOptional: true
35
- },
36
- isRequired: { type: ScalarTypeEnum.Boolean(), isOptional: false }
37
- }
38
- });
39
- var SyncConfigModel = defineSchemaModel({
40
- name: "SyncConfigModel",
41
- fields: {
42
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
43
- integrationId: {
44
- type: ScalarTypeEnum.String_unsecure(),
45
- isOptional: false
46
- },
47
- connectionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
48
- name: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
49
- direction: { type: SyncDirectionEnum, isOptional: false },
50
- sourceObject: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
51
- targetObject: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
52
- scheduleEnabled: { type: ScalarTypeEnum.Boolean(), isOptional: false },
53
- scheduleCron: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
54
- isActive: { type: ScalarTypeEnum.Boolean(), isOptional: false },
55
- lastSyncAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
56
- fieldMappings: { type: FieldMappingModel, isArray: true, isOptional: true }
57
- }
58
- });
59
- var SyncRunModel = defineSchemaModel({
60
- name: "SyncRunModel",
61
- fields: {
62
- id: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
63
- syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
64
- status: { type: SyncStatusEnum, isOptional: false },
65
- direction: { type: SyncDirectionEnum, isOptional: false },
66
- trigger: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
67
- recordsProcessed: {
68
- type: ScalarTypeEnum.Int_unsecure(),
69
- isOptional: false
70
- },
71
- recordsCreated: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
72
- recordsUpdated: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
73
- recordsFailed: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false },
74
- errorMessage: { type: ScalarTypeEnum.String_unsecure(), isOptional: true },
75
- startedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
76
- completedAt: { type: ScalarTypeEnum.DateTime(), isOptional: true },
77
- createdAt: { type: ScalarTypeEnum.DateTime(), isOptional: false }
78
- }
79
- });
80
- var CreateSyncConfigInputModel = defineSchemaModel({
81
- name: "CreateSyncConfigInput",
82
- fields: {
83
- integrationId: {
84
- type: ScalarTypeEnum.String_unsecure(),
85
- isOptional: false
86
- },
87
- connectionId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
88
- name: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
89
- direction: { type: SyncDirectionEnum, isOptional: false },
90
- sourceObject: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
91
- targetObject: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
92
- scheduleEnabled: { type: ScalarTypeEnum.Boolean(), isOptional: true },
93
- scheduleCron: { type: ScalarTypeEnum.String_unsecure(), isOptional: true }
94
- }
95
- });
96
- var AddFieldMappingInputModel = defineSchemaModel({
97
- name: "AddFieldMappingInput",
98
- fields: {
99
- syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
100
- sourceField: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
101
- targetField: { type: ScalarTypeEnum.NonEmptyString(), isOptional: false },
102
- mappingType: { type: MappingTypeEnum, isOptional: false },
103
- transformExpression: {
104
- type: ScalarTypeEnum.String_unsecure(),
105
- isOptional: true
106
- },
107
- lookupConfig: { type: ScalarTypeEnum.JSON(), isOptional: true },
108
- constantValue: { type: ScalarTypeEnum.JSON(), isOptional: true },
109
- isRequired: { type: ScalarTypeEnum.Boolean(), isOptional: true },
110
- defaultValue: { type: ScalarTypeEnum.JSON(), isOptional: true }
111
- }
112
- });
113
- var TriggerSyncInputModel = defineSchemaModel({
114
- name: "TriggerSyncInput",
115
- fields: {
116
- syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
117
- direction: { type: SyncDirectionEnum, isOptional: true },
118
- fullSync: { type: ScalarTypeEnum.Boolean(), isOptional: true }
119
- }
120
- });
121
- var ListSyncRunsInputModel = defineSchemaModel({
122
- name: "ListSyncRunsInput",
123
- fields: {
124
- syncConfigId: { type: ScalarTypeEnum.String_unsecure(), isOptional: false },
125
- status: { type: SyncStatusEnum, isOptional: true },
126
- limit: {
127
- type: ScalarTypeEnum.Int_unsecure(),
128
- isOptional: true,
129
- defaultValue: 20
130
- },
131
- offset: {
132
- type: ScalarTypeEnum.Int_unsecure(),
133
- isOptional: true,
134
- defaultValue: 0
135
- }
136
- }
137
- });
138
- var ListSyncRunsOutputModel = defineSchemaModel({
139
- name: "ListSyncRunsOutput",
140
- fields: {
141
- runs: { type: SyncRunModel, isArray: true, isOptional: false },
142
- total: { type: ScalarTypeEnum.Int_unsecure(), isOptional: false }
143
- }
144
- });
145
-
146
- // src/sync/sync.operations.ts
147
- import {
148
- defineCommand,
149
- defineQuery
150
- } from "@contractspec/lib.contracts-spec/operations";
151
- var OWNERS = ["@example.integration-hub"];
152
- var CreateSyncConfigContract = defineCommand({
153
- meta: {
154
- key: "integration.syncConfig.create",
155
- version: "1.0.0",
156
- stability: "stable",
157
- owners: [...OWNERS],
158
- tags: ["integration", "sync", "config", "create"],
159
- description: "Create a sync configuration.",
160
- goal: "Define how data should be synchronized.",
161
- context: "Sync setup."
162
- },
163
- io: { input: CreateSyncConfigInputModel, output: SyncConfigModel },
164
- policy: { auth: "user" },
165
- sideEffects: {
166
- emits: [
167
- {
168
- key: "integration.syncConfig.created",
169
- version: "1.0.0",
170
- when: "Sync config created",
171
- payload: SyncConfigModel
172
- }
173
- ],
174
- audit: ["integration.syncConfig.created"]
175
- },
176
- acceptance: {
177
- scenarios: [
178
- {
179
- key: "create-sync-happy-path",
180
- given: ["User is authenticated"],
181
- when: ["User creates sync config"],
182
- then: ["Sync config is created", "SyncConfigCreated event is emitted"]
183
- }
184
- ],
185
- examples: [
186
- {
187
- key: "create-contact-sync",
188
- input: {
189
- name: "Contacts Sync",
190
- sourceConnectionId: "conn-1",
191
- targetConnectionId: "conn-2"
192
- },
193
- output: { id: "sync-123", status: "active" }
194
- }
195
- ]
196
- }
197
- });
198
- var AddFieldMappingContract = defineCommand({
199
- meta: {
200
- key: "integration.fieldMapping.add",
201
- version: "1.0.0",
202
- stability: "stable",
203
- owners: [...OWNERS],
204
- tags: ["integration", "mapping", "field"],
205
- description: "Add a field mapping to a sync config.",
206
- goal: "Map fields between systems.",
207
- context: "Mapping configuration."
208
- },
209
- io: { input: AddFieldMappingInputModel, output: FieldMappingModel },
210
- policy: { auth: "user" },
211
- sideEffects: {
212
- emits: [
213
- {
214
- key: "integration.fieldMapping.added",
215
- version: "1.0.0",
216
- when: "Mapping added",
217
- payload: FieldMappingModel
218
- }
219
- ]
220
- },
221
- acceptance: {
222
- scenarios: [
223
- {
224
- key: "add-mapping-happy-path",
225
- given: ["Sync config exists"],
226
- when: ["User adds field mapping"],
227
- then: ["Mapping is added", "FieldMappingAdded event is emitted"]
228
- }
229
- ],
230
- examples: [
231
- {
232
- key: "map-email",
233
- input: {
234
- syncConfigId: "sync-123",
235
- sourceField: "email",
236
- targetField: "user_email"
237
- },
238
- output: { id: "map-456", type: "string" }
239
- }
240
- ]
241
- }
242
- });
243
- var TriggerSyncContract = defineCommand({
244
- meta: {
245
- key: "integration.sync.trigger",
246
- version: "1.0.0",
247
- stability: "stable",
248
- owners: [...OWNERS],
249
- tags: ["integration", "sync", "trigger"],
250
- description: "Trigger a manual sync.",
251
- goal: "Start data synchronization.",
252
- context: "Manual sync or webhook trigger."
253
- },
254
- io: { input: TriggerSyncInputModel, output: SyncRunModel },
255
- policy: { auth: "user" },
256
- sideEffects: {
257
- emits: [
258
- {
259
- key: "integration.sync.started",
260
- version: "1.0.0",
261
- when: "Sync starts",
262
- payload: SyncRunModel
263
- }
264
- ],
265
- audit: ["integration.sync.triggered"]
266
- },
267
- acceptance: {
268
- scenarios: [
269
- {
270
- key: "trigger-sync-happy-path",
271
- given: ["Sync config exists"],
272
- when: ["User triggers sync"],
273
- then: ["Sync run starts", "SyncStarted event is emitted"]
274
- }
275
- ],
276
- examples: [
277
- {
278
- key: "manual-trigger",
279
- input: { syncConfigId: "sync-123" },
280
- output: { id: "run-789", status: "pending" }
281
- }
282
- ]
283
- }
284
- });
285
- var ListSyncRunsContract = defineQuery({
286
- meta: {
287
- key: "integration.syncRun.list",
288
- version: "1.0.0",
289
- stability: "stable",
290
- owners: [...OWNERS],
291
- tags: ["integration", "sync", "run", "list"],
292
- description: "List sync run history.",
293
- goal: "View sync history and status.",
294
- context: "Sync monitoring."
295
- },
296
- io: { input: ListSyncRunsInputModel, output: ListSyncRunsOutputModel },
297
- policy: { auth: "user" },
298
- acceptance: {
299
- scenarios: [
300
- {
301
- key: "list-runs-happy-path",
302
- given: ["User has access to syncs"],
303
- when: ["User lists sync runs"],
304
- then: ["List of runs is returned"]
305
- }
306
- ],
307
- examples: [
308
- {
309
- key: "list-recent",
310
- input: { limit: 10 },
311
- output: { items: [], total: 50 }
312
- }
313
- ]
314
- }
315
- });
316
- export {
317
- TriggerSyncContract,
318
- ListSyncRunsContract,
319
- CreateSyncConfigContract,
320
- AddFieldMappingContract
321
- };