@friggframework/core 2.0.0--canary.700.80ec1cc.0 → 2.0.0--canary.702.047d3c4.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 (130) hide show
  1. package/database/documentdb-utils.js +1 -6
  2. package/errors/index.js +0 -4
  3. package/generated/prisma-mongodb/edge.js +4 -52
  4. package/generated/prisma-mongodb/index-browser.js +1 -49
  5. package/generated/prisma-mongodb/index.d.ts +60 -3506
  6. package/generated/prisma-mongodb/index.js +4 -52
  7. package/generated/prisma-mongodb/package.json +1 -1
  8. package/generated/prisma-mongodb/schema.prisma +0 -65
  9. package/generated/prisma-mongodb/wasm.js +4 -52
  10. package/generated/prisma-postgresql/edge.js +4 -52
  11. package/generated/prisma-postgresql/index-browser.js +1 -49
  12. package/generated/prisma-postgresql/index.d.ts +94 -3824
  13. package/generated/prisma-postgresql/index.js +4 -52
  14. package/generated/prisma-postgresql/package.json +1 -1
  15. package/generated/prisma-postgresql/schema.prisma +0 -63
  16. package/generated/prisma-postgresql/wasm.js +4 -52
  17. package/handlers/WEBHOOKS.md +0 -29
  18. package/handlers/app-definition-loader.js +9 -2
  19. package/handlers/app-handler-helpers.js +2 -5
  20. package/handlers/integration-event-dispatcher.js +3 -7
  21. package/handlers/routers/integration-webhook-routers.js +38 -26
  22. package/index.js +0 -2
  23. package/integrations/integration-base.js +1 -162
  24. package/integrations/integration-router.js +1 -6
  25. package/integrations/repositories/integration-mapping-repository-documentdb.js +0 -50
  26. package/integrations/repositories/integration-mapping-repository-interface.js +0 -15
  27. package/integrations/repositories/integration-mapping-repository-mongo.js +0 -29
  28. package/integrations/repositories/integration-mapping-repository-postgres.js +0 -30
  29. package/integrations/repositories/integration-mapping-repository.js +0 -29
  30. package/integrations/repositories/integration-repository-documentdb.js +2 -6
  31. package/integrations/repositories/integration-repository-interface.js +0 -3
  32. package/integrations/repositories/integration-repository-mongo.js +5 -20
  33. package/integrations/repositories/integration-repository-postgres.js +1 -5
  34. package/integrations/repositories/process-repository-mongo.js +1 -1
  35. package/integrations/use-cases/create-integration.js +4 -14
  36. package/integrations/use-cases/delete-integration-for-user.js +4 -4
  37. package/integrations/use-cases/get-integration-for-user.js +2 -4
  38. package/integrations/use-cases/get-integration-instance.js +4 -4
  39. package/integrations/use-cases/get-integrations-for-user.js +4 -4
  40. package/integrations/use-cases/get-possible-integrations.js +2 -7
  41. package/integrations/use-cases/update-integration.js +4 -4
  42. package/package.json +6 -6
  43. package/prisma-mongodb/schema.prisma +0 -65
  44. package/prisma-postgresql/schema.prisma +0 -63
  45. package/queues/queuer-util.js +2 -9
  46. package/errors/mapping-already-exists-error.js +0 -14
  47. package/handlers/workers/integration-triggers.js +0 -25
  48. package/infrastructure/scheduler/recurrence.js +0 -204
  49. package/integrations/definitions/README.md +0 -278
  50. package/integrations/definitions/canonical.js +0 -11
  51. package/integrations/definitions/capabilities/AUDIT.md +0 -480
  52. package/integrations/definitions/capabilities/acmeerp.capabilities.json +0 -633
  53. package/integrations/definitions/capabilities/asana.capabilities.json +0 -279
  54. package/integrations/definitions/capabilities/calendly.capabilities.json +0 -385
  55. package/integrations/definitions/capabilities/docusign.capabilities.json +0 -314
  56. package/integrations/definitions/capabilities/fathom.capabilities.json +0 -238
  57. package/integrations/definitions/capabilities/github.capabilities.json +0 -585
  58. package/integrations/definitions/capabilities/hubspot.capabilities.json +0 -822
  59. package/integrations/definitions/capabilities/jira.capabilities.json +0 -391
  60. package/integrations/definitions/capabilities/klaviyo.capabilities.json +0 -503
  61. package/integrations/definitions/capabilities/linear.capabilities.json +0 -378
  62. package/integrations/definitions/capabilities/netsuite.capabilities.json +0 -535
  63. package/integrations/definitions/capabilities/notion.capabilities.json +0 -208
  64. package/integrations/definitions/capabilities/phone.capabilities.json +0 -511
  65. package/integrations/definitions/capabilities/pipedrive.capabilities.json +0 -430
  66. package/integrations/definitions/capabilities/quickbooks.capabilities.json +0 -635
  67. package/integrations/definitions/capabilities/salesforce.capabilities.json +0 -568
  68. package/integrations/definitions/capabilities/shopify.capabilities.json +0 -1128
  69. package/integrations/definitions/capabilities/slack.capabilities.json +0 -373
  70. package/integrations/definitions/capabilities/stripe.capabilities.json +0 -630
  71. package/integrations/definitions/capabilities/webflow.capabilities.json +0 -196
  72. package/integrations/definitions/capabilities/zendesk.capabilities.json +0 -422
  73. package/integrations/definitions/compile.js +0 -80
  74. package/integrations/definitions/config-form.js +0 -137
  75. package/integrations/definitions/examples/acme-erp-quickbooks.definition.json +0 -467
  76. package/integrations/definitions/examples/asana-slack.definition.json +0 -219
  77. package/integrations/definitions/examples/calendly-salesforce.definition.json +0 -459
  78. package/integrations/definitions/examples/docusign-salesforce.definition.json +0 -305
  79. package/integrations/definitions/examples/fathom-hubspot-notion.definition.json +0 -575
  80. package/integrations/definitions/examples/github-linear.definition.json +0 -322
  81. package/integrations/definitions/examples/hubspot-slack.definition.json +0 -427
  82. package/integrations/definitions/examples/klaviyo-hubspot.definition.json +0 -336
  83. package/integrations/definitions/examples/phone-hubspot.definition.json +0 -633
  84. package/integrations/definitions/examples/pipedrive-hubspot.definition.json +0 -136
  85. package/integrations/definitions/examples/pipedrive-phone.definition.json +0 -340
  86. package/integrations/definitions/examples/records/phone-hubspot.definition-version.json +0 -652
  87. package/integrations/definitions/examples/records/phone-hubspot.integration.json +0 -86
  88. package/integrations/definitions/examples/records/phone-hubspot.mappings.json +0 -39
  89. package/integrations/definitions/examples/records/phone-hubspot.workflow-run.json +0 -62
  90. package/integrations/definitions/examples/shopify-klaviyo.definition.json +0 -488
  91. package/integrations/definitions/examples/shopify-netsuite.definition.json +0 -622
  92. package/integrations/definitions/examples/stripe-quickbooks.definition.json +0 -476
  93. package/integrations/definitions/examples/webflow-hubspot-slack.definition.json +0 -262
  94. package/integrations/definitions/examples/zendesk-jira.definition.json +0 -604
  95. package/integrations/definitions/expressions.js +0 -229
  96. package/integrations/definitions/index.js +0 -45
  97. package/integrations/definitions/integration-runtime.js +0 -763
  98. package/integrations/definitions/interpreter.js +0 -104
  99. package/integrations/definitions/manifests.js +0 -177
  100. package/integrations/definitions/renderers/common.js +0 -67
  101. package/integrations/definitions/renderers/html.js +0 -129
  102. package/integrations/definitions/renderers/hubspot.js +0 -59
  103. package/integrations/definitions/renderers/preview.js +0 -154
  104. package/integrations/definitions/renderers/slack.js +0 -146
  105. package/integrations/definitions/repositories/definition-version-repository.js +0 -67
  106. package/integrations/definitions/repositories/workflow-run-repository.js +0 -80
  107. package/integrations/definitions/router.js +0 -170
  108. package/integrations/definitions/runtime.js +0 -268
  109. package/integrations/definitions/schema/capability-manifest.v0.1.schema.json +0 -549
  110. package/integrations/definitions/schema/installation.v0.1.schema.json +0 -130
  111. package/integrations/definitions/schema/integration-definition.v0.1.schema.json +0 -909
  112. package/integrations/definitions/schema/records.md +0 -105
  113. package/integrations/definitions/schema-check.js +0 -58
  114. package/integrations/definitions/scripts/check-manifests.js +0 -220
  115. package/integrations/definitions/scripts/validate.js +0 -66
  116. package/integrations/definitions/steps.js +0 -123
  117. package/integrations/definitions/sync-engine.js +0 -297
  118. package/integrations/definitions/tests/helpers-fake-crm.js +0 -49
  119. package/integrations/definitions/transforms.js +0 -91
  120. package/integrations/definitions/use-cases/definition-use-cases.js +0 -245
  121. package/integrations/definitions/validate.js +0 -436
  122. package/integrations/definitions/versioning.js +0 -176
  123. package/integrations/definitions/webhooks.js +0 -119
  124. package/integrations/integration-types.js +0 -64
  125. package/integrations/triggers.js +0 -244
  126. package/integrations/use-cases/run-trigger-tick.js +0 -155
  127. package/integrations/use-cases/run-trigger.js +0 -77
  128. package/prisma-postgresql/migrations/20261018000000_add_data_defined_integrations/migration.sql +0 -66
  129. package/prisma-postgresql/migrations/20261019000000_workflow_run_waits/migration.sql +0 -7
  130. package/prisma-postgresql/migrations/20261019120000_definition_workspace/migration.sql +0 -5
@@ -1,196 +0,0 @@
1
- {
2
- "$schema": "https://friggframework.org/schemas/capability-manifest/v0.1.json",
3
- "module": "webflow",
4
- "label": "Webflow",
5
- "package": "@friggframework/api-module-webflow",
6
- "version": "2.0.0",
7
- "auth": "oauth2",
8
- "objects": {
9
- "formSubmission": {
10
- "label": "Form submission",
11
- "fields": [
12
- {
13
- "name": "id",
14
- "type": "id",
15
- "readOnly": true
16
- },
17
- {
18
- "name": "name",
19
- "type": "string",
20
- "tag": "form.name"
21
- },
22
- {
23
- "name": "formId",
24
- "type": "string"
25
- },
26
- {
27
- "name": "siteId",
28
- "type": "string"
29
- },
30
- {
31
- "name": "publishedPath",
32
- "type": "string",
33
- "tag": "web.pagePath"
34
- },
35
- {
36
- "name": "submittedAt",
37
- "type": "datetime",
38
- "tag": "record.createdAt"
39
- },
40
- {
41
- "name": "data.Name",
42
- "type": "string",
43
- "tag": "person.fullName"
44
- },
45
- {
46
- "name": "data.Email",
47
- "type": "email",
48
- "tag": "contact.email"
49
- },
50
- {
51
- "name": "data.Phone",
52
- "type": "phone",
53
- "tag": "contact.phone"
54
- },
55
- {
56
- "name": "data.Company",
57
- "type": "string",
58
- "tag": "organization.name"
59
- },
60
- {
61
- "name": "data.Interest",
62
- "type": "enum",
63
- "values": [
64
- "Sales",
65
- "Support",
66
- "Partnerships"
67
- ]
68
- },
69
- {
70
- "name": "data.Message",
71
- "type": "text"
72
- },
73
- {
74
- "name": "data.Website",
75
- "type": "string",
76
- "help": "Hidden honeypot field; humans leave it empty."
77
- }
78
- ]
79
- }
80
- },
81
- "events": {
82
- "form.submitted": {
83
- "delivery": "webhook",
84
- "object": "formSubmission",
85
- "subscribe": "webhook.create",
86
- "description": "triggerType form_submission, registered per site.",
87
- "payload": {
88
- "triggerType": "form_submission",
89
- "payload": {
90
- "name": "Contact Us",
91
- "siteId": "65427cf400e02b306eaa049c",
92
- "formId": "65429eadebe8a9f3a30f62d0",
93
- "formElementId": "4e038d2c-6a1e-4953-7be9-a59a2b453177",
94
- "pageId": "65427cf400e02b306eaa04a0",
95
- "publishedPath": "/contact",
96
- "id": "6321ca84df3949bfc6752327",
97
- "submittedAt": "2026-10-20T17:12:00.000Z",
98
- "data": {
99
- "Name": "Priya Natarajan",
100
- "Email": "priya@acme.example",
101
- "Phone": "512 555 0177",
102
- "Company": "Acme Corp",
103
- "Interest": "Sales",
104
- "Message": "We need a Salesforce \u2194 NetSuite integration by Q1.",
105
- "Website": ""
106
- }
107
- }
108
- },
109
- "record": "payload",
110
- "idPath": "payload.id",
111
- "match": "form_submission"
112
- }
113
- },
114
- "webhook": {
115
- "scope": "installation",
116
- "topic": "{{body.triggerType}}",
117
- "eventId": "{{body.payload.id}}",
118
- "verify": "verifyWebhookSignature"
119
- },
120
- "capabilities": {
121
- "site.list": {
122
- "kind": "read",
123
- "method": "listSites",
124
- "input": {},
125
- "output": "site[]"
126
- },
127
- "form.list": {
128
- "kind": "read",
129
- "method": "listForms",
130
- "input": {
131
- "siteId": {
132
- "type": "string",
133
- "required": true
134
- }
135
- },
136
- "output": "form[]"
137
- },
138
- "form.submissions": {
139
- "kind": "read",
140
- "method": "listFormSubmissions",
141
- "input": {
142
- "formId": {
143
- "type": "string",
144
- "required": true
145
- },
146
- "offset": {
147
- "type": "number"
148
- },
149
- "limit": {
150
- "type": "number"
151
- }
152
- },
153
- "output": "formSubmission[]"
154
- },
155
- "webhook.create": {
156
- "kind": "subscribe",
157
- "method": "createWebhook",
158
- "input": {
159
- "siteId": {
160
- "type": "string",
161
- "required": true
162
- },
163
- "triggerType": {
164
- "type": "string",
165
- "required": true
166
- },
167
- "url": {
168
- "type": "string",
169
- "required": true
170
- },
171
- "filter": {
172
- "type": "object"
173
- }
174
- },
175
- "output": "webhook"
176
- },
177
- "webhook.delete": {
178
- "kind": "delete",
179
- "method": "deleteWebhook",
180
- "input": {
181
- "webhookId": {
182
- "type": "string",
183
- "required": true
184
- }
185
- },
186
- "output": "void"
187
- }
188
- },
189
- "options": {
190
- "site": {
191
- "capability": "site.list",
192
- "label": "{{item.displayName}}",
193
- "value": "$.item.id"
194
- }
195
- }
196
- }
@@ -1,422 +0,0 @@
1
- {
2
- "$schema": "https://friggframework.org/schemas/capability-manifest/v0.1.json",
3
- "module": "zendesk",
4
- "label": "Zendesk Support",
5
- "package": "@friggframework/api-module-zendesk",
6
- "version": "1.6.0",
7
- "auth": "oauth2",
8
- "account": {
9
- "description": "Values about the connected account, persisted by the module (apiPropertiesToPersist). Definitions read them as $.install.accounts.<module key>.<name>.",
10
- "fields": [
11
- {
12
- "name": "subdomain",
13
- "type": "string",
14
- "description": "Zendesk subdomain (acme in acme.zendesk.com)"
15
- }
16
- ]
17
- },
18
- "objects": {
19
- "ticket": {
20
- "label": "Ticket",
21
- "fields": [
22
- {
23
- "name": "id",
24
- "type": "id",
25
- "tag": "record.displayId",
26
- "readOnly": true
27
- },
28
- {
29
- "name": "subject",
30
- "type": "string",
31
- "tag": "ticket.subject"
32
- },
33
- {
34
- "name": "description",
35
- "type": "text",
36
- "tag": "ticket.description",
37
- "readOnly": true
38
- },
39
- {
40
- "name": "status",
41
- "type": "enum",
42
- "tag": "ticket.status",
43
- "values": [
44
- "new",
45
- "open",
46
- "pending",
47
- "hold",
48
- "solved",
49
- "closed"
50
- ]
51
- },
52
- {
53
- "name": "priority",
54
- "type": "enum",
55
- "tag": "ticket.priority",
56
- "values": [
57
- "low",
58
- "normal",
59
- "high",
60
- "urgent"
61
- ]
62
- },
63
- {
64
- "name": "type",
65
- "type": "enum",
66
- "values": [
67
- "problem",
68
- "incident",
69
- "question",
70
- "task"
71
- ]
72
- },
73
- {
74
- "name": "requester_id",
75
- "type": "string"
76
- },
77
- {
78
- "name": "assignee_id",
79
- "type": "string",
80
- "tag": "record.owner"
81
- },
82
- {
83
- "name": "group_id",
84
- "type": "string"
85
- },
86
- {
87
- "name": "organization_id",
88
- "type": "string"
89
- },
90
- {
91
- "name": "tags",
92
- "type": "string[]",
93
- "tag": "record.tags"
94
- },
95
- {
96
- "name": "external_id",
97
- "type": "string",
98
- "tag": "record.externalId"
99
- },
100
- {
101
- "name": "url",
102
- "type": "string",
103
- "readOnly": true
104
- },
105
- {
106
- "name": "created_at",
107
- "type": "datetime",
108
- "tag": "record.createdAt",
109
- "readOnly": true
110
- },
111
- {
112
- "name": "updated_at",
113
- "type": "datetime",
114
- "tag": "record.updatedAt",
115
- "readOnly": true
116
- }
117
- ],
118
- "sync": {
119
- "id": "id",
120
- "updatedAt": "updated_at",
121
- "get": {
122
- "capability": "ticket.get",
123
- "id": "id"
124
- },
125
- "update": {
126
- "capability": "ticket.update",
127
- "id": "id",
128
- "body": "ticket"
129
- }
130
- }
131
- },
132
- "user": {
133
- "label": "User",
134
- "fields": [
135
- {
136
- "name": "id",
137
- "type": "id",
138
- "readOnly": true
139
- },
140
- {
141
- "name": "name",
142
- "type": "string",
143
- "tag": "person.fullName"
144
- },
145
- {
146
- "name": "email",
147
- "type": "email",
148
- "tag": "contact.email"
149
- },
150
- {
151
- "name": "phone",
152
- "type": "phone",
153
- "tag": "contact.phone"
154
- },
155
- {
156
- "name": "role",
157
- "type": "enum",
158
- "values": [
159
- "end-user",
160
- "agent",
161
- "admin"
162
- ]
163
- },
164
- {
165
- "name": "organization_id",
166
- "type": "string"
167
- }
168
- ]
169
- }
170
- },
171
- "events": {
172
- "ticket.tagsChanged": {
173
- "delivery": "webhook",
174
- "object": "ticket",
175
- "subscribe": "webhook.create",
176
- "description": "Event-subscription webhook zen:event-type:ticket.tags_changed. $.record is the ticket (detail); added/removed tags are in event.",
177
- "payload": {
178
- "account_id": 22129848,
179
- "detail": {
180
- "id": 35436,
181
- "url": "https://acmehelp.zendesk.com/api/v2/tickets/35436.json",
182
- "subject": "Checkout fails with 500 for EU customers",
183
- "description": "Since this morning every EU checkout returns a 500 at the payment step.",
184
- "status": "open",
185
- "priority": "urgent",
186
- "type": "incident",
187
- "requester_id": 20978392,
188
- "assignee_id": 235323,
189
- "group_id": 98738,
190
- "organization_id": 509974,
191
- "tags": [
192
- "checkout",
193
- "eu",
194
- "escalate_jira"
195
- ],
196
- "external_id": null,
197
- "created_at": "2026-10-20T08:12:44Z",
198
- "updated_at": "2026-10-20T09:01:02Z"
199
- },
200
- "event": {
201
- "tags_added": [
202
- "escalate_jira"
203
- ],
204
- "tags_removed": []
205
- },
206
- "id": "cbe4028c-7239-495d-b020-f22348516046",
207
- "subject": "zen:ticket:35436",
208
- "time": "2026-10-20T09:01:02.882Z",
209
- "type": "zen:event-type:ticket.tags_changed",
210
- "zendesk_event_version": "2022-11-06"
211
- },
212
- "record": "detail",
213
- "match": "zen:event-type:ticket.tags_changed"
214
- },
215
- "ticket.priorityChanged": {
216
- "delivery": "webhook",
217
- "object": "ticket",
218
- "subscribe": "webhook.create",
219
- "payload": {
220
- "account_id": 22129848,
221
- "detail": {
222
- "id": 35436,
223
- "url": "https://acmehelp.zendesk.com/api/v2/tickets/35436.json",
224
- "subject": "Checkout fails with 500 for EU customers",
225
- "description": "Since this morning every EU checkout returns a 500 at the payment step.",
226
- "status": "open",
227
- "priority": "urgent",
228
- "type": "incident",
229
- "requester_id": 20978392,
230
- "assignee_id": 235323,
231
- "group_id": 98738,
232
- "organization_id": 509974,
233
- "tags": [
234
- "checkout",
235
- "eu",
236
- "escalate_jira"
237
- ],
238
- "external_id": null,
239
- "created_at": "2026-10-20T08:12:44Z",
240
- "updated_at": "2026-10-20T09:01:02Z"
241
- },
242
- "event": {
243
- "current": "urgent",
244
- "previous": "high"
245
- },
246
- "id": "cbe4028c-7239-495d-b020-f22348516046",
247
- "subject": "zen:ticket:35436",
248
- "time": "2026-10-20T09:01:02.882Z",
249
- "type": "zen:event-type:ticket.priority_changed",
250
- "zendesk_event_version": "2022-11-06"
251
- },
252
- "record": "detail",
253
- "match": "zen:event-type:ticket.priority_changed"
254
- },
255
- "ticket.statusChanged": {
256
- "delivery": "webhook",
257
- "object": "ticket",
258
- "subscribe": "webhook.create",
259
- "payload": {
260
- "account_id": 22129848,
261
- "detail": {
262
- "id": 35436,
263
- "url": "https://acmehelp.zendesk.com/api/v2/tickets/35436.json",
264
- "subject": "Checkout fails with 500 for EU customers",
265
- "description": "Since this morning every EU checkout returns a 500 at the payment step.",
266
- "status": "solved",
267
- "priority": "urgent",
268
- "type": "incident",
269
- "requester_id": 20978392,
270
- "assignee_id": 235323,
271
- "group_id": 98738,
272
- "organization_id": 509974,
273
- "tags": [
274
- "checkout",
275
- "eu",
276
- "escalate_jira"
277
- ],
278
- "external_id": null,
279
- "created_at": "2026-10-20T08:12:44Z",
280
- "updated_at": "2026-10-20T09:01:02Z"
281
- },
282
- "event": {
283
- "current": "SOLVED",
284
- "previous": "OPEN"
285
- },
286
- "id": "cbe4028c-7239-495d-b020-f22348516046",
287
- "subject": "zen:ticket:35436",
288
- "time": "2026-10-20T09:01:02.882Z",
289
- "type": "zen:event-type:ticket.status_changed",
290
- "zendesk_event_version": "2022-11-06"
291
- },
292
- "record": "detail",
293
- "match": "zen:event-type:ticket.status_changed"
294
- }
295
- },
296
- "webhook": {
297
- "scope": "installation",
298
- "topic": "{{body.type}}",
299
- "eventId": "{{body.id}}",
300
- "verify": "verifyWebhookSignature"
301
- },
302
- "capabilities": {
303
- "ticket.get": {
304
- "kind": "read",
305
- "method": "showTicket",
306
- "input": {
307
- "id": {
308
- "type": "string",
309
- "required": true
310
- }
311
- },
312
- "output": "ticket"
313
- },
314
- "ticket.update": {
315
- "kind": "write",
316
- "method": "updateTicket",
317
- "input": {
318
- "id": {
319
- "type": "string",
320
- "required": true
321
- },
322
- "ticket": {
323
- "type": "object",
324
- "required": true
325
- }
326
- },
327
- "output": "ticket"
328
- },
329
- "ticket.addComment": {
330
- "kind": "write",
331
- "method": "addTicketComment",
332
- "input": {
333
- "id": {
334
- "type": "string",
335
- "required": true
336
- },
337
- "body": {
338
- "type": "string",
339
- "required": true
340
- },
341
- "public": {
342
- "type": "boolean"
343
- }
344
- },
345
- "output": "ticket"
346
- },
347
- "ticket.search": {
348
- "kind": "search",
349
- "method": "searchTickets",
350
- "input": {
351
- "query": {
352
- "type": "string",
353
- "required": true
354
- }
355
- },
356
- "output": "ticket[]"
357
- },
358
- "user.get": {
359
- "kind": "read",
360
- "method": "showUser",
361
- "input": {
362
- "id": {
363
- "type": "string",
364
- "required": true
365
- }
366
- },
367
- "output": "user"
368
- },
369
- "group.list": {
370
- "kind": "read",
371
- "method": "listGroups",
372
- "input": {},
373
- "output": "group[]"
374
- },
375
- "webhook.create": {
376
- "kind": "subscribe",
377
- "method": "createWebhook",
378
- "input": {
379
- "name": {
380
- "type": "string",
381
- "required": true
382
- },
383
- "endpoint": {
384
- "type": "string",
385
- "required": true
386
- },
387
- "subscriptions": {
388
- "type": "array",
389
- "required": true
390
- }
391
- },
392
- "output": "webhook"
393
- },
394
- "webhook.delete": {
395
- "kind": "delete",
396
- "method": "deleteWebhook",
397
- "input": {
398
- "id": {
399
- "type": "string",
400
- "required": true
401
- }
402
- },
403
- "output": "void"
404
- }
405
- },
406
- "options": {
407
- "group": {
408
- "capability": "group.list",
409
- "label": "{{item.name}}",
410
- "value": "$.item.id"
411
- }
412
- },
413
- "ui": {
414
- "placements": [
415
- "ticket_sidebar",
416
- "new_ticket_sidebar",
417
- "user_sidebar",
418
- "organization_sidebar"
419
- ],
420
- "renderer": "frigg-zaf-app"
421
- }
422
- }
@@ -1,80 +0,0 @@
1
- /**
2
- * Compile a definition + one installation into what Frigg runs: an events map shaped exactly like a hand-written
3
- * integration's `this.events`, plus the routing tables the runtime needs. Pure; no I/O.
4
- *
5
- * Only what the installation has enabled is compiled, so a disabled workflow has no event, no route and no trigger.
6
- *
7
- * Event names: SYNC_<ID>_BACKFILL (USER_ACTION) · SYNC_<ID>_PAGE (QUEUE) · SYNC_<ID>_ONGOING (WEBHOOK|CRON)
8
- * WF_<ID> (WEBHOOK|CRON|USER_ACTION|QUEUE) · Q_<ID> (ROUTE) · UI_<ID> (ROUTE)
9
- */
10
- const eventName = (prefix, id, suffix) => [prefix, id.toUpperCase().replace(/-/g, '_'), suffix].filter(Boolean).join('_');
11
-
12
- function isOn(item, chosen) {
13
- if (chosen && typeof chosen.enabled === 'boolean') return chosen.enabled;
14
- return (item.default || 'on') === 'on';
15
- }
16
-
17
- function compile(def, installation = {}) {
18
- const events = {};
19
- const webhooks = {}; // moduleKey -> topic -> [eventName]
20
- const triggers = []; // recurring triggers (integrations/triggers.js): { name, every | cron, timezone?, configurable, choice }
21
- const userActions = []; // { event, label, from }
22
- const routes = []; // { method, path, event }
23
- const add = (name, e) => { events[name] = e; return name; };
24
- const route = (mod, topic, name) => { ((webhooks[mod] ||= {})[topic] ||= []).push(name); };
25
-
26
- for (const s of def.syncs || []) {
27
- if (!isOn(s, installation.syncs?.[s.id])) continue;
28
- if (s.backfill?.trigger === 'userAction') {
29
- const n = add(eventName('SYNC', s.id, 'BACKFILL'), { type: 'USER_ACTION', userActionType: 'SYNC_ACTION', title: `Sync existing ${s.label.toLowerCase()}`, ref: { kind: 'sync', id: s.id, phase: 'backfill' } });
30
- userActions.push({ event: n, label: events[n].title });
31
- }
32
- add(eventName('SYNC', s.id, 'PAGE'), { type: 'QUEUE', ref: { kind: 'sync', id: s.id, phase: 'page' } });
33
- const mode = s.ongoing?.mode || 'none';
34
- if (mode === 'webhook') {
35
- const n = add(eventName('SYNC', s.id, 'ONGOING'), { type: 'WEBHOOK', ref: { kind: 'sync', id: s.id, phase: 'ongoing' } });
36
- for (const side of [s.source, ...(s.direction === 'two_way' ? [s.target] : [])]) {
37
- const [mod, obj] = side.split('.');
38
- route(mod, `${obj}.*`, n);
39
- }
40
- } else if (mode === 'poll') {
41
- const n = add(eventName('SYNC', s.id, 'ONGOING'), { type: 'CRON', ref: { kind: 'sync', id: s.id, phase: 'ongoing' } });
42
- triggers.push({ name: n, every: s.ongoing.every || '15m', configurable: s.ongoing.configurable || false, choice: installation.syncs?.[s.id]?.schedule });
43
- }
44
- }
45
-
46
- for (const w of def.workflows || []) {
47
- if (!isOn(w, installation.workflows?.[w.id])) continue;
48
- const t = w.trigger;
49
- const type = { webhook: 'WEBHOOK', schedule: 'CRON', userAction: 'USER_ACTION', syncRecord: 'QUEUE' }[t.type];
50
- const n = add(eventName('WF', w.id), { type, ...(type === 'USER_ACTION' ? { userActionType: 'DATA_ACTION', title: t.label } : {}), ref: { kind: 'workflow', id: w.id } });
51
- if (t.type === 'webhook') route(t.module, t.topic, n);
52
- if (t.type === 'schedule') {
53
- const timing = t.every !== undefined ? { every: t.every } : { cron: t.cron, ...(t.timezone ? { timezone: t.timezone } : {}) };
54
- triggers.push({ name: n, ...timing, configurable: t.configurable || false, choice: installation.workflows?.[w.id]?.schedule });
55
- }
56
- if (t.type === 'userAction') userActions.push({ event: n, label: t.label, from: t.from || null });
57
- if (t.type === 'syncRecord') route('$sync', `${t.sync}:${(t.on || []).join('|')}`, n);
58
- }
59
-
60
- for (const q of def.queries || []) add(eventName('Q', q.id), { type: 'ROUTE', ref: { kind: 'query', id: q.id } });
61
- for (const u of def.ui || []) {
62
- if (!isOn(u, installation.ui?.[u.id])) continue;
63
- const n = add(eventName('UI', u.id), { type: 'ROUTE', ref: { kind: 'ui', id: u.id } });
64
- routes.push({ method: 'GET', path: `/ui/${u.id}`, event: n });
65
- }
66
-
67
- return { events, webhooks, triggers, userActions, routes };
68
- }
69
-
70
- /** Which compiled events a delivered webhook goes to. Topic patterns may end in ".*". */
71
- function routeWebhook(compiled, moduleKey, topic) {
72
- const table = compiled.webhooks[moduleKey] || {};
73
- const out = new Set(table[topic] || []);
74
- for (const [pattern, names] of Object.entries(table)) {
75
- if (pattern.endsWith('.*') && topic.startsWith(pattern.slice(0, -1))) names.forEach((n) => out.add(n));
76
- }
77
- return [...out];
78
- }
79
-
80
- module.exports = { compile, routeWebhook, eventName };