@friggframework/core 2.0.0--canary.690.08cd07e.0 → 2.0.0--canary.694.f66a64a.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 (267) hide show
  1. package/CLAUDE.md +0 -28
  2. package/README.md +0 -105
  3. package/application/commands/integration-commands.js +10 -20
  4. package/application/commands/scheduler-commands.js +7 -11
  5. package/application/commands/user-commands.js +5 -17
  6. package/application/index.js +2 -6
  7. package/core/Worker.js +7 -31
  8. package/core/create-handler.js +0 -9
  9. package/credential/repositories/credential-repository-documentdb.js +0 -34
  10. package/credential/repositories/credential-repository-interface.js +0 -15
  11. package/credential/repositories/credential-repository-mongo.js +0 -23
  12. package/credential/repositories/credential-repository-postgres.js +0 -28
  13. package/database/config.js +24 -48
  14. package/database/documentdb-utils.js +2 -2
  15. package/database/encryption/encryption-schema-registry.js +12 -93
  16. package/database/prisma.js +2 -4
  17. package/errors/index.js +4 -0
  18. package/errors/mapping-already-exists-error.js +14 -0
  19. package/generated/prisma-mongodb/edge.js +38 -33
  20. package/generated/prisma-mongodb/index-browser.js +35 -30
  21. package/generated/prisma-mongodb/index.d.ts +1880 -3191
  22. package/generated/prisma-mongodb/index.js +38 -33
  23. package/generated/prisma-mongodb/package.json +1 -1
  24. package/generated/prisma-mongodb/schema.prisma +50 -86
  25. package/generated/prisma-mongodb/wasm.js +38 -33
  26. package/generated/prisma-postgresql/edge.js +38 -33
  27. package/generated/prisma-postgresql/index-browser.js +35 -30
  28. package/generated/prisma-postgresql/index.d.ts +2050 -3390
  29. package/generated/prisma-postgresql/index.js +38 -33
  30. package/generated/prisma-postgresql/package.json +1 -1
  31. package/generated/prisma-postgresql/schema.prisma +48 -81
  32. package/generated/prisma-postgresql/wasm.js +38 -33
  33. package/handlers/WEBHOOKS.md +29 -0
  34. package/handlers/app-definition-loader.js +19 -128
  35. package/handlers/app-handler-helpers.js +3 -25
  36. package/handlers/backend-utils.js +25 -31
  37. package/handlers/middleware/admin-auth.js +1 -14
  38. package/handlers/routers/auth.js +10 -46
  39. package/handlers/routers/health.js +4 -13
  40. package/handlers/routers/integration-defined-routers.js +92 -144
  41. package/handlers/routers/integration-webhook-routers.js +64 -102
  42. package/handlers/workers/integration-defined-workers.js +2 -5
  43. package/handlers/workers/integration-triggers.js +25 -0
  44. package/index.js +3 -65
  45. package/infrastructure/scheduler/index.js +6 -19
  46. package/infrastructure/scheduler/recurrence.js +204 -0
  47. package/infrastructure/scheduler/scheduler-service-factory.js +7 -55
  48. package/integrations/data-defined/README.md +185 -0
  49. package/integrations/data-defined/canonical.js +11 -0
  50. package/integrations/data-defined/capabilities/acmeerp.capabilities.json +608 -0
  51. package/integrations/data-defined/capabilities/asana.capabilities.json +265 -0
  52. package/integrations/data-defined/capabilities/calendly.capabilities.json +385 -0
  53. package/integrations/data-defined/capabilities/docusign.capabilities.json +314 -0
  54. package/integrations/data-defined/capabilities/fathom.capabilities.json +228 -0
  55. package/integrations/data-defined/capabilities/github.capabilities.json +563 -0
  56. package/integrations/data-defined/capabilities/hubspot.capabilities.json +715 -0
  57. package/integrations/data-defined/capabilities/jira.capabilities.json +376 -0
  58. package/integrations/data-defined/capabilities/klaviyo.capabilities.json +475 -0
  59. package/integrations/data-defined/capabilities/linear.capabilities.json +324 -0
  60. package/integrations/data-defined/capabilities/netsuite.capabilities.json +491 -0
  61. package/integrations/data-defined/capabilities/notion.capabilities.json +208 -0
  62. package/integrations/data-defined/capabilities/phone.capabilities.json +470 -0
  63. package/integrations/data-defined/capabilities/pipedrive.capabilities.json +388 -0
  64. package/integrations/data-defined/capabilities/quickbooks.capabilities.json +615 -0
  65. package/integrations/data-defined/capabilities/salesforce.capabilities.json +507 -0
  66. package/integrations/data-defined/capabilities/shopify.capabilities.json +1082 -0
  67. package/integrations/data-defined/capabilities/slack.capabilities.json +363 -0
  68. package/integrations/data-defined/capabilities/stripe.capabilities.json +580 -0
  69. package/integrations/data-defined/capabilities/webflow.capabilities.json +196 -0
  70. package/integrations/data-defined/capabilities/zendesk.capabilities.json +409 -0
  71. package/integrations/data-defined/compile.js +80 -0
  72. package/integrations/data-defined/config-form.js +137 -0
  73. package/integrations/data-defined/data-defined-integration.js +417 -0
  74. package/integrations/data-defined/examples/acme-erp-quickbooks.definition.json +467 -0
  75. package/integrations/data-defined/examples/asana-slack.definition.json +220 -0
  76. package/integrations/data-defined/examples/calendly-salesforce.definition.json +459 -0
  77. package/integrations/data-defined/examples/docusign-salesforce.definition.json +305 -0
  78. package/integrations/data-defined/examples/fathom-hubspot-notion.definition.json +575 -0
  79. package/integrations/data-defined/examples/github-linear.definition.json +316 -0
  80. package/integrations/data-defined/examples/hubspot-slack.definition.json +409 -0
  81. package/integrations/data-defined/examples/klaviyo-hubspot.definition.json +339 -0
  82. package/integrations/data-defined/examples/phone-hubspot.definition.json +637 -0
  83. package/integrations/data-defined/examples/pipedrive-hubspot.definition.json +136 -0
  84. package/integrations/data-defined/examples/pipedrive-phone.definition.json +340 -0
  85. package/integrations/data-defined/examples/records/phone-hubspot.definition-version.json +652 -0
  86. package/integrations/data-defined/examples/records/phone-hubspot.integration.json +86 -0
  87. package/integrations/data-defined/examples/records/phone-hubspot.mappings.json +39 -0
  88. package/integrations/data-defined/examples/records/phone-hubspot.workflow-run.json +62 -0
  89. package/integrations/data-defined/examples/shopify-klaviyo.definition.json +488 -0
  90. package/integrations/data-defined/examples/shopify-netsuite.definition.json +622 -0
  91. package/integrations/data-defined/examples/stripe-quickbooks.definition.json +476 -0
  92. package/integrations/data-defined/examples/webflow-hubspot-slack.definition.json +262 -0
  93. package/integrations/data-defined/examples/zendesk-jira.definition.json +604 -0
  94. package/integrations/data-defined/expressions.js +225 -0
  95. package/integrations/data-defined/index.js +39 -0
  96. package/integrations/data-defined/interpreter.js +89 -0
  97. package/integrations/data-defined/manifests.js +125 -0
  98. package/integrations/data-defined/repositories/definition-version-repository.js +67 -0
  99. package/integrations/data-defined/repositories/workflow-run-repository.js +59 -0
  100. package/integrations/data-defined/router.js +97 -0
  101. package/integrations/data-defined/runtime.js +208 -0
  102. package/integrations/data-defined/schema/capability-manifest.v0.1.schema.json +377 -0
  103. package/integrations/data-defined/schema/installation.v0.1.schema.json +130 -0
  104. package/integrations/data-defined/schema/integration-definition.v0.1.schema.json +902 -0
  105. package/integrations/data-defined/schema/records.md +98 -0
  106. package/integrations/data-defined/schema-check.js +58 -0
  107. package/integrations/data-defined/scripts/validate.js +66 -0
  108. package/integrations/data-defined/steps.js +89 -0
  109. package/integrations/data-defined/transforms.js +91 -0
  110. package/integrations/data-defined/use-cases/definition-use-cases.js +187 -0
  111. package/integrations/data-defined/validate.js +384 -0
  112. package/integrations/data-defined/versioning.js +176 -0
  113. package/integrations/data-defined/webhooks.js +119 -0
  114. package/integrations/index.js +0 -1
  115. package/integrations/integration-base.js +117 -0
  116. package/integrations/integration-router.js +101 -131
  117. package/integrations/repositories/integration-mapping-repository-documentdb.js +50 -0
  118. package/integrations/repositories/integration-mapping-repository-interface.js +15 -0
  119. package/integrations/repositories/integration-mapping-repository-mongo.js +29 -0
  120. package/integrations/repositories/integration-mapping-repository-postgres.js +30 -0
  121. package/integrations/repositories/integration-mapping-repository.js +29 -0
  122. package/integrations/repositories/integration-repository-documentdb.js +9 -37
  123. package/integrations/repositories/integration-repository-interface.js +4 -17
  124. package/integrations/repositories/integration-repository-mongo.js +96 -64
  125. package/integrations/repositories/integration-repository-postgres.js +81 -63
  126. package/integrations/repositories/process-repository-mongo.js +1 -1
  127. package/integrations/tests/doubles/test-integration-repository.js +1 -12
  128. package/integrations/triggers.js +244 -0
  129. package/integrations/use-cases/create-integration.js +20 -55
  130. package/integrations/use-cases/get-integrations-for-user.js +40 -80
  131. package/integrations/use-cases/index.js +1 -7
  132. package/integrations/use-cases/run-trigger-tick.js +132 -0
  133. package/integrations/use-cases/run-trigger.js +77 -0
  134. package/integrations/utils/map-integration-dto.js +14 -43
  135. package/modules/index.js +0 -14
  136. package/modules/module-factory.js +0 -12
  137. package/modules/module.js +2 -53
  138. package/modules/repositories/module-repository-documentdb.js +6 -51
  139. package/modules/repositories/module-repository-interface.js +2 -19
  140. package/modules/repositories/module-repository-mongo.js +74 -67
  141. package/modules/repositories/module-repository-postgres.js +74 -66
  142. package/modules/repositories/module-repository.js +1 -2
  143. package/modules/requester/requester.js +5 -35
  144. package/modules/use-cases/get-entities-for-user.js +13 -26
  145. package/modules/use-cases/get-entity-options-by-id.js +4 -10
  146. package/modules/use-cases/get-entity-options-by-type.js +1 -1
  147. package/modules/use-cases/get-module-instance-from-type.js +1 -1
  148. package/modules/use-cases/get-module.js +4 -10
  149. package/modules/use-cases/process-authorization-callback.js +19 -53
  150. package/modules/use-cases/refresh-entity-options.js +4 -10
  151. package/modules/use-cases/test-module-auth.js +4 -10
  152. package/package.json +6 -6
  153. package/prisma-mongodb/schema.prisma +50 -86
  154. package/prisma-postgresql/migrations/20261018000000_add_data_defined_integrations/migration.sql +66 -0
  155. package/prisma-postgresql/schema.prisma +48 -81
  156. package/queues/index.js +0 -25
  157. package/queues/queuer-util.js +9 -2
  158. package/types/index.d.ts +0 -2
  159. package/user/repositories/user-repository-documentdb.js +2 -27
  160. package/user/repositories/user-repository-interface.js +0 -18
  161. package/user/repositories/user-repository-mongo.js +0 -24
  162. package/user/repositories/user-repository-postgres.js +0 -18
  163. package/user/use-cases/authenticate-user.js +1 -7
  164. package/user/use-cases/get-user-from-adopter-jwt.js +124 -95
  165. package/user/use-cases/get-user-from-x-frigg-headers.js +80 -83
  166. package/user/user.js +1 -64
  167. package/credential/use-cases/credential-operations-for-user.js +0 -202
  168. package/credential/use-cases/reauthorize-credential-for-user.js +0 -73
  169. package/database/organization-where.js +0 -18
  170. package/database/unique-violation.js +0 -25
  171. package/extensions/bootstrap-runner.js +0 -43
  172. package/extensions/extension-loader.js +0 -187
  173. package/extensions/index.js +0 -41
  174. package/extensions/initialize-app.js +0 -123
  175. package/extensions/route-mounter.js +0 -103
  176. package/extensions/schema-composer.js +0 -188
  177. package/infrastructure/scheduler/netlify-scheduler-adapter.js +0 -216
  178. package/infrastructure/scheduler/scheduled-job-repository.js +0 -118
  179. package/integrations/repositories/integration-not-found.js +0 -14
  180. package/integrations/schedule-config.js +0 -80
  181. package/integrations/use-cases/dispatch-ongoing-syncs.js +0 -100
  182. package/integrations/use-cases/integration-operations-for-user.js +0 -256
  183. package/integrations/use-cases/resolve-integration-ownership.js +0 -177
  184. package/management-api/create-management-api-router.js +0 -49
  185. package/management-api/error-response.js +0 -116
  186. package/management-api/management-api-config.js +0 -151
  187. package/management-api/meta-router.js +0 -76
  188. package/management-api/openapi/build-openapi.js +0 -144
  189. package/management-api/openapi/components.js +0 -415
  190. package/management-api/openapi/v1-operations.js +0 -83
  191. package/management-api/openapi/v2-operations.js +0 -264
  192. package/management-api/route-registry.js +0 -411
  193. package/management-api/test-support/http-client.js +0 -39
  194. package/management-api/use-cases/get-management-api-meta.js +0 -57
  195. package/management-api/v1-deprecation.js +0 -120
  196. package/management-api/v2/create-v2-router.js +0 -85
  197. package/management-api/v2/dependencies.js +0 -281
  198. package/management-api/v2/dto.js +0 -143
  199. package/management-api/v2/handlers/authorization.js +0 -94
  200. package/management-api/v2/handlers/credentials.js +0 -33
  201. package/management-api/v2/handlers/entities.js +0 -77
  202. package/management-api/v2/handlers/integrations.js +0 -128
  203. package/management-api/v2/handlers/proxy.js +0 -34
  204. package/management-api/v2/request.js +0 -85
  205. package/management-api/v2/test-support/fake-dependencies.js +0 -103
  206. package/modules/domain/authorization-session.js +0 -144
  207. package/modules/entity-scope.js +0 -15
  208. package/modules/entity-type-registry.js +0 -311
  209. package/modules/proxy/proxy-bases.js +0 -169
  210. package/modules/proxy/proxy-errors.js +0 -31
  211. package/modules/proxy/proxy-path.js +0 -183
  212. package/modules/proxy/proxy-policy.js +0 -277
  213. package/modules/repositories/authorization-session-repository-documentdb.js +0 -112
  214. package/modules/repositories/authorization-session-repository-factory.js +0 -31
  215. package/modules/repositories/authorization-session-repository-interface.js +0 -47
  216. package/modules/repositories/authorization-session-repository-prisma.js +0 -87
  217. package/modules/repositories/entity-not-found.js +0 -18
  218. package/modules/requester/proxy-request.js +0 -245
  219. package/modules/scope-config.js +0 -192
  220. package/modules/scope-policy.js +0 -112
  221. package/modules/scope-resolution.js +0 -288
  222. package/modules/scope-visibility.js +0 -247
  223. package/modules/tests/doubles/in-memory-authorization-session-repository.js +0 -45
  224. package/modules/tests/doubles/ownership-matching.js +0 -18
  225. package/modules/use-cases/authorize-entity-for-user.js +0 -61
  226. package/modules/use-cases/create-entity-from-credential.js +0 -113
  227. package/modules/use-cases/entity-operations-for-user.js +0 -162
  228. package/modules/use-cases/entity-types.js +0 -139
  229. package/modules/use-cases/execute-entity-proxy-request.js +0 -331
  230. package/modules/use-cases/get-authorization-requirements.js +0 -100
  231. package/modules/use-cases/get-entity-module-for-user.js +0 -113
  232. package/modules/use-cases/manage-access.js +0 -21
  233. package/modules/use-cases/multi-step-authorization.js +0 -329
  234. package/prisma-postgresql/migrations/20261003000000_add_authorization_session/migration.sql +0 -28
  235. package/prisma-postgresql/migrations/20261015000000_add_organization_membership/migration.sql +0 -26
  236. package/prisma-postgresql/migrations/20261016000000_add_entity_integration_organization/migration.sql +0 -25
  237. package/prisma-postgresql/migrations/20261017000000_add_scheduled_job/migration.sql +0 -28
  238. package/providers/index.js +0 -23
  239. package/providers/resolve-provider.js +0 -93
  240. package/providers/runtime-detection.js +0 -124
  241. package/queues/providers/index.js +0 -11
  242. package/queues/providers/netlify-background-provider.js +0 -150
  243. package/queues/providers/qstash-queue-provider.js +0 -219
  244. package/queues/providers/sqs-queue-provider.js +0 -70
  245. package/queues/queue-client-interface.js +0 -55
  246. package/queues/queue-message-auth.js +0 -193
  247. package/queues/queue-provider-factory.js +0 -101
  248. package/queues/queue-provider.js +0 -65
  249. package/queues/sqs-queue-client.js +0 -81
  250. package/types/modules/index.d.ts +0 -214
  251. package/types/user/index.d.ts +0 -134
  252. package/user/adopter-jwt-config.js +0 -177
  253. package/user/adopter-jwt-errors.js +0 -59
  254. package/user/adopter-token-verifier.js +0 -122
  255. package/user/app-user-helpers.js +0 -97
  256. package/user/create-user-authentication.js +0 -64
  257. package/user/membership.js +0 -51
  258. package/user/repositories/organization-membership-record.js +0 -19
  259. package/user/repositories/organization-membership-repository-documentdb.js +0 -106
  260. package/user/repositories/organization-membership-repository-factory.js +0 -42
  261. package/user/repositories/organization-membership-repository-interface.js +0 -57
  262. package/user/repositories/organization-membership-repository-mongo.js +0 -13
  263. package/user/repositories/organization-membership-repository-postgres.js +0 -29
  264. package/user/repositories/organization-membership-repository-prisma.js +0 -81
  265. package/user/tests/doubles/adopter-jwt-fixtures.js +0 -220
  266. package/user/use-cases/ensure-organization-membership.js +0 -92
  267. package/user/use-cases/find-individual-users-by-organization.js +0 -54
@@ -0,0 +1,902 @@
1
+ {
2
+ "$schema": "https://json-schema.org/draft/2020-12/schema",
3
+ "$id": "https://friggframework.org/schemas/integration-definition/v0.1.json",
4
+ "title": "Frigg integration definition v0.1",
5
+ "description": "An integration as data: what it connects, what it keeps in sync, which workflows it runs and which UI it shows. One document per published version; immutable once published (ADR-063).",
6
+ "type": "object",
7
+ "required": [
8
+ "schemaVersion",
9
+ "id",
10
+ "version",
11
+ "display",
12
+ "modules"
13
+ ],
14
+ "additionalProperties": false,
15
+ "properties": {
16
+ "$schema": {
17
+ "type": "string"
18
+ },
19
+ "schemaVersion": {
20
+ "const": "0.1"
21
+ },
22
+ "id": {
23
+ "type": "string",
24
+ "pattern": "^[a-z][a-z0-9-]*$"
25
+ },
26
+ "version": {
27
+ "type": "string",
28
+ "pattern": "^\\d+\\.\\d+\\.\\d+(-[\\w.]+)?$"
29
+ },
30
+ "display": {
31
+ "type": "object",
32
+ "required": [
33
+ "label"
34
+ ],
35
+ "properties": {
36
+ "label": {
37
+ "type": "string"
38
+ },
39
+ "description": {
40
+ "type": "string"
41
+ },
42
+ "category": {
43
+ "type": "string"
44
+ },
45
+ "tags": {
46
+ "type": "array",
47
+ "items": {
48
+ "type": "string"
49
+ }
50
+ }
51
+ }
52
+ },
53
+ "modules": {
54
+ "type": "object",
55
+ "minProperties": 1,
56
+ "additionalProperties": {
57
+ "type": "object",
58
+ "required": [
59
+ "module"
60
+ ],
61
+ "properties": {
62
+ "module": {
63
+ "type": "string",
64
+ "description": "Capability manifest name."
65
+ },
66
+ "version": {
67
+ "type": "string"
68
+ }
69
+ }
70
+ }
71
+ },
72
+ "settings": {
73
+ "type": "object",
74
+ "additionalProperties": {
75
+ "$ref": "#/$defs/setting"
76
+ }
77
+ },
78
+ "syncs": {
79
+ "type": "array",
80
+ "items": {
81
+ "type": "object",
82
+ "required": [
83
+ "id",
84
+ "label",
85
+ "source",
86
+ "target",
87
+ "direction",
88
+ "identity",
89
+ "mapping"
90
+ ],
91
+ "additionalProperties": false,
92
+ "properties": {
93
+ "id": {
94
+ "type": "string",
95
+ "pattern": "^[a-z][a-z0-9-]*$"
96
+ },
97
+ "label": {
98
+ "type": "string"
99
+ },
100
+ "description": {
101
+ "type": "string"
102
+ },
103
+ "source": {
104
+ "type": "string",
105
+ "pattern": "^[a-zA-Z]\\w*\\.[a-zA-Z]\\w*$",
106
+ "description": "<moduleKey>.<object>"
107
+ },
108
+ "target": {
109
+ "type": "string",
110
+ "pattern": "^[a-zA-Z]\\w*\\.[a-zA-Z]\\w*$"
111
+ },
112
+ "direction": {
113
+ "enum": [
114
+ "one_way",
115
+ "two_way"
116
+ ]
117
+ },
118
+ "identity": {
119
+ "type": "object",
120
+ "required": [
121
+ "match"
122
+ ],
123
+ "properties": {
124
+ "match": {
125
+ "type": "array",
126
+ "minItems": 1,
127
+ "items": {
128
+ "type": "object",
129
+ "required": [
130
+ "key",
131
+ "source",
132
+ "target"
133
+ ],
134
+ "properties": {
135
+ "source": {
136
+ "type": "string"
137
+ },
138
+ "target": {
139
+ "type": "string"
140
+ },
141
+ "transform": {
142
+ "enum": [
143
+ "none",
144
+ "trim",
145
+ "lowercase",
146
+ "uppercase",
147
+ "number",
148
+ "boolean",
149
+ "to_iso_date",
150
+ "to_e164_phone",
151
+ "split_full_name",
152
+ "join",
153
+ "map_values",
154
+ "default",
155
+ "units_to_cents",
156
+ "cents_to_units",
157
+ "from_unix_seconds",
158
+ "to_unix_seconds"
159
+ ]
160
+ },
161
+ "key": {
162
+ "type": "string",
163
+ "pattern": "^[a-z][a-zA-Z0-9]*$",
164
+ "description": "Name of the identity key (email, phone). links.find { key: { phone } } looks records up by it."
165
+ }
166
+ }
167
+ }
168
+ },
169
+ "onAmbiguous": {
170
+ "enum": [
171
+ "skip",
172
+ "first",
173
+ "create"
174
+ ],
175
+ "default": "skip"
176
+ }
177
+ }
178
+ },
179
+ "mapping": {
180
+ "type": "array",
181
+ "items": {
182
+ "$ref": "#/$defs/mappingRow"
183
+ }
184
+ },
185
+ "filter": {
186
+ "type": "string",
187
+ "description": "Only records matching this condition are synced ($.record)."
188
+ },
189
+ "backfill": {
190
+ "type": "object",
191
+ "properties": {
192
+ "trigger": {
193
+ "enum": [
194
+ "userAction",
195
+ "onInstall",
196
+ "none"
197
+ ]
198
+ },
199
+ "pageSize": {
200
+ "type": "integer",
201
+ "minimum": 1,
202
+ "maximum": 500
203
+ }
204
+ }
205
+ },
206
+ "ongoing": {
207
+ "type": "object",
208
+ "required": [
209
+ "mode"
210
+ ],
211
+ "properties": {
212
+ "mode": {
213
+ "enum": [
214
+ "webhook",
215
+ "poll",
216
+ "none"
217
+ ]
218
+ },
219
+ "every": {
220
+ "type": "string",
221
+ "pattern": "^\\d+\\s*(m|h|d)$",
222
+ "description": "Poll interval (default 15m)."
223
+ },
224
+ "configurable": {
225
+ "$ref": "#/$defs/scheduleConfigurable"
226
+ }
227
+ }
228
+ },
229
+ "default": {
230
+ "enum": [
231
+ "on",
232
+ "off"
233
+ ],
234
+ "default": "on"
235
+ }
236
+ }
237
+ }
238
+ },
239
+ "links": {
240
+ "type": "array",
241
+ "description": "Link sets: records on two modules known to be the same thing, with no sync behind them. links.find / links.upsert take { link: <id> }.",
242
+ "items": {
243
+ "type": "object",
244
+ "required": [
245
+ "id",
246
+ "between"
247
+ ],
248
+ "additionalProperties": false,
249
+ "properties": {
250
+ "id": {
251
+ "type": "string",
252
+ "pattern": "^[a-z][a-z0-9-]*$"
253
+ },
254
+ "label": {
255
+ "type": "string"
256
+ },
257
+ "description": {
258
+ "type": "string"
259
+ },
260
+ "between": {
261
+ "type": "array",
262
+ "minItems": 2,
263
+ "maxItems": 2,
264
+ "items": {
265
+ "type": "string",
266
+ "pattern": "^[a-zA-Z]\\w*\\.[a-zA-Z]\\w*$"
267
+ },
268
+ "description": "Two <moduleKey>.<object> on different modules."
269
+ },
270
+ "identity": {
271
+ "type": "object",
272
+ "required": [
273
+ "match"
274
+ ],
275
+ "additionalProperties": false,
276
+ "properties": {
277
+ "match": {
278
+ "type": "array",
279
+ "items": {
280
+ "type": "object",
281
+ "required": [
282
+ "key"
283
+ ],
284
+ "additionalProperties": false,
285
+ "properties": {
286
+ "key": {
287
+ "type": "string",
288
+ "pattern": "^[a-z][a-zA-Z0-9]*$"
289
+ },
290
+ "transform": {
291
+ "enum": [
292
+ "none",
293
+ "trim",
294
+ "lowercase",
295
+ "uppercase",
296
+ "number",
297
+ "boolean",
298
+ "to_iso_date",
299
+ "to_e164_phone",
300
+ "split_full_name",
301
+ "join",
302
+ "map_values",
303
+ "default",
304
+ "units_to_cents",
305
+ "cents_to_units",
306
+ "from_unix_seconds",
307
+ "to_unix_seconds"
308
+ ]
309
+ }
310
+ }
311
+ }
312
+ }
313
+ }
314
+ }
315
+ }
316
+ }
317
+ },
318
+ "workflows": {
319
+ "type": "array",
320
+ "items": {
321
+ "type": "object",
322
+ "required": [
323
+ "id",
324
+ "label",
325
+ "trigger",
326
+ "steps"
327
+ ],
328
+ "additionalProperties": false,
329
+ "properties": {
330
+ "id": {
331
+ "type": "string",
332
+ "pattern": "^[a-z][a-z0-9-]*$"
333
+ },
334
+ "label": {
335
+ "type": "string"
336
+ },
337
+ "description": {
338
+ "type": "string"
339
+ },
340
+ "purpose": {
341
+ "enum": [
342
+ "notify",
343
+ "write",
344
+ "enrich",
345
+ "maintain",
346
+ "respond"
347
+ ],
348
+ "description": "What the workflow is for. Shown in the UI; not executed."
349
+ },
350
+ "default": {
351
+ "enum": [
352
+ "on",
353
+ "off"
354
+ ],
355
+ "default": "on"
356
+ },
357
+ "settings": {
358
+ "type": "object",
359
+ "additionalProperties": {
360
+ "$ref": "#/$defs/setting"
361
+ }
362
+ },
363
+ "trigger": {
364
+ "$ref": "#/$defs/trigger"
365
+ },
366
+ "steps": {
367
+ "type": "array",
368
+ "minItems": 1,
369
+ "items": {
370
+ "$ref": "#/$defs/step"
371
+ }
372
+ },
373
+ "retry": {
374
+ "type": "object",
375
+ "properties": {
376
+ "max": {
377
+ "type": "integer",
378
+ "minimum": 0,
379
+ "maximum": 10
380
+ },
381
+ "backoff": {
382
+ "enum": [
383
+ "fixed",
384
+ "exponential"
385
+ ]
386
+ }
387
+ }
388
+ }
389
+ }
390
+ }
391
+ },
392
+ "queries": {
393
+ "type": "array",
394
+ "items": {
395
+ "type": "object",
396
+ "required": [
397
+ "id",
398
+ "steps",
399
+ "returns"
400
+ ],
401
+ "additionalProperties": false,
402
+ "properties": {
403
+ "id": {
404
+ "type": "string",
405
+ "pattern": "^[a-z][a-z0-9-]*$"
406
+ },
407
+ "description": {
408
+ "type": "string"
409
+ },
410
+ "steps": {
411
+ "type": "array",
412
+ "items": {
413
+ "$ref": "#/$defs/step"
414
+ }
415
+ },
416
+ "returns": {
417
+ "description": "Expression for the query result."
418
+ }
419
+ }
420
+ }
421
+ },
422
+ "ui": {
423
+ "type": "array",
424
+ "items": {
425
+ "type": "object",
426
+ "required": [
427
+ "id",
428
+ "label",
429
+ "host",
430
+ "placement",
431
+ "data",
432
+ "view"
433
+ ],
434
+ "additionalProperties": false,
435
+ "properties": {
436
+ "id": {
437
+ "type": "string",
438
+ "pattern": "^[a-z][a-z0-9-]*$"
439
+ },
440
+ "label": {
441
+ "type": "string"
442
+ },
443
+ "host": {
444
+ "type": "string",
445
+ "description": "Module key of the app that shows it."
446
+ },
447
+ "placement": {
448
+ "type": "string",
449
+ "description": "One of the host manifest's ui.placements."
450
+ },
451
+ "objects": {
452
+ "type": "array",
453
+ "items": {
454
+ "type": "string"
455
+ }
456
+ },
457
+ "data": {
458
+ "type": "object",
459
+ "required": [
460
+ "query"
461
+ ],
462
+ "properties": {
463
+ "query": {
464
+ "type": "string"
465
+ },
466
+ "with": {
467
+ "type": "object"
468
+ }
469
+ }
470
+ },
471
+ "view": {
472
+ "$ref": "#/$defs/view"
473
+ },
474
+ "default": {
475
+ "enum": [
476
+ "on",
477
+ "off"
478
+ ],
479
+ "default": "on"
480
+ }
481
+ }
482
+ }
483
+ },
484
+ "templates": {
485
+ "type": "object",
486
+ "additionalProperties": {
487
+ "type": "string"
488
+ }
489
+ },
490
+ "lifecycle": {
491
+ "type": "object",
492
+ "additionalProperties": false,
493
+ "properties": {
494
+ "onInstall": {
495
+ "type": "array",
496
+ "items": {
497
+ "$ref": "#/$defs/step"
498
+ }
499
+ },
500
+ "onUninstall": {
501
+ "type": "array",
502
+ "items": {
503
+ "$ref": "#/$defs/step"
504
+ }
505
+ }
506
+ }
507
+ }
508
+ },
509
+ "$defs": {
510
+ "step": {
511
+ "type": "object",
512
+ "required": [
513
+ "use"
514
+ ],
515
+ "additionalProperties": false,
516
+ "properties": {
517
+ "id": {
518
+ "type": "string",
519
+ "pattern": "^[a-zA-Z][\\w-]*$"
520
+ },
521
+ "use": {
522
+ "type": "string",
523
+ "description": "A built-in (links.find, links.upsert, map, merge, template, set, stop, foreach, branch, code) or <moduleKey>.<object>.<verb> declared by that module's capability manifest."
524
+ },
525
+ "with": {
526
+ "type": "object",
527
+ "description": "Arguments. Values may be expressions."
528
+ },
529
+ "when": {
530
+ "type": "string",
531
+ "description": "Condition; the step is skipped when false."
532
+ },
533
+ "onError": {
534
+ "enum": [
535
+ "fail",
536
+ "continue",
537
+ "stop"
538
+ ],
539
+ "default": "fail"
540
+ },
541
+ "do": {
542
+ "type": "array",
543
+ "items": {
544
+ "$ref": "#/$defs/step"
545
+ },
546
+ "description": "foreach: steps run per item."
547
+ },
548
+ "cases": {
549
+ "type": "array",
550
+ "items": {
551
+ "type": "object",
552
+ "required": [
553
+ "when",
554
+ "do"
555
+ ],
556
+ "properties": {
557
+ "when": {
558
+ "type": "string"
559
+ },
560
+ "do": {
561
+ "type": "array",
562
+ "items": {
563
+ "$ref": "#/$defs/step"
564
+ }
565
+ }
566
+ }
567
+ }
568
+ },
569
+ "else": {
570
+ "type": "array",
571
+ "items": {
572
+ "$ref": "#/$defs/step"
573
+ }
574
+ }
575
+ }
576
+ },
577
+ "setting": {
578
+ "type": "object",
579
+ "required": [
580
+ "type",
581
+ "label"
582
+ ],
583
+ "additionalProperties": false,
584
+ "properties": {
585
+ "type": {
586
+ "enum": [
587
+ "string",
588
+ "text",
589
+ "number",
590
+ "boolean",
591
+ "enum",
592
+ "option",
593
+ "duration"
594
+ ]
595
+ },
596
+ "label": {
597
+ "type": "string"
598
+ },
599
+ "help": {
600
+ "type": "string"
601
+ },
602
+ "required": {
603
+ "type": "boolean"
604
+ },
605
+ "default": {},
606
+ "enum": {
607
+ "type": "array",
608
+ "items": {
609
+ "type": "string"
610
+ }
611
+ },
612
+ "options": {
613
+ "description": "option settings: \"<moduleKey>.<list>\" from the module manifest, or { source, with } when the list takes inputs read from other settings ($.settings.workspace; a workflow setting may also read $.install.<integration setting>).",
614
+ "oneOf": [
615
+ {
616
+ "type": "string",
617
+ "pattern": "^[a-zA-Z]\\w*\\.[a-zA-Z]\\w*$"
618
+ },
619
+ {
620
+ "type": "object",
621
+ "required": [
622
+ "source"
623
+ ],
624
+ "additionalProperties": false,
625
+ "properties": {
626
+ "source": {
627
+ "type": "string",
628
+ "pattern": "^[a-zA-Z]\\w*\\.[a-zA-Z]\\w*$"
629
+ },
630
+ "with": {
631
+ "type": "object",
632
+ "additionalProperties": {
633
+ "type": "string"
634
+ }
635
+ }
636
+ }
637
+ }
638
+ ]
639
+ }
640
+ }
641
+ },
642
+ "trigger": {
643
+ "oneOf": [
644
+ {
645
+ "type": "object",
646
+ "required": [
647
+ "type",
648
+ "module",
649
+ "topic"
650
+ ],
651
+ "additionalProperties": false,
652
+ "properties": {
653
+ "type": {
654
+ "const": "webhook"
655
+ },
656
+ "module": {
657
+ "type": "string"
658
+ },
659
+ "topic": {
660
+ "type": "string"
661
+ },
662
+ "filter": {
663
+ "type": "string"
664
+ }
665
+ }
666
+ },
667
+ {
668
+ "type": "object",
669
+ "required": [
670
+ "type"
671
+ ],
672
+ "additionalProperties": false,
673
+ "properties": {
674
+ "type": {
675
+ "const": "schedule"
676
+ },
677
+ "cron": {
678
+ "type": "string",
679
+ "description": "Five-field cron (minute hour day-of-month month day-of-week). Restrict day of month or day of week, not both."
680
+ },
681
+ "timezone": {
682
+ "type": "string",
683
+ "description": "IANA time zone for cron (default UTC)."
684
+ },
685
+ "every": {
686
+ "type": "string",
687
+ "pattern": "^\\d+\\s*(m|h|d)$",
688
+ "description": "Fixed interval (15m, 2h, 1d). Give cron or every."
689
+ },
690
+ "configurable": {
691
+ "$ref": "#/$defs/scheduleConfigurable"
692
+ }
693
+ },
694
+ "oneOf": [
695
+ {
696
+ "required": [
697
+ "cron"
698
+ ],
699
+ "not": {
700
+ "required": [
701
+ "every"
702
+ ]
703
+ }
704
+ },
705
+ {
706
+ "required": [
707
+ "every"
708
+ ],
709
+ "not": {
710
+ "required": [
711
+ "cron"
712
+ ]
713
+ }
714
+ }
715
+ ]
716
+ },
717
+ {
718
+ "type": "object",
719
+ "required": [
720
+ "type",
721
+ "label"
722
+ ],
723
+ "additionalProperties": false,
724
+ "properties": {
725
+ "type": {
726
+ "const": "userAction"
727
+ },
728
+ "label": {
729
+ "type": "string"
730
+ },
731
+ "from": {
732
+ "type": "string",
733
+ "description": "A UI surface id when the action is a button on that surface."
734
+ }
735
+ }
736
+ },
737
+ {
738
+ "type": "object",
739
+ "required": [
740
+ "type",
741
+ "sync",
742
+ "on"
743
+ ],
744
+ "additionalProperties": false,
745
+ "properties": {
746
+ "type": {
747
+ "const": "syncRecord"
748
+ },
749
+ "sync": {
750
+ "type": "string"
751
+ },
752
+ "on": {
753
+ "type": "array",
754
+ "items": {
755
+ "enum": [
756
+ "created",
757
+ "updated",
758
+ "linked"
759
+ ]
760
+ }
761
+ },
762
+ "filter": {
763
+ "type": "string"
764
+ }
765
+ }
766
+ }
767
+ ]
768
+ },
769
+ "view": {
770
+ "type": "object",
771
+ "required": [
772
+ "component"
773
+ ],
774
+ "additionalProperties": false,
775
+ "properties": {
776
+ "component": {
777
+ "enum": [
778
+ "Stack",
779
+ "Heading",
780
+ "Text",
781
+ "KeyValue",
782
+ "List",
783
+ "Table",
784
+ "Badge",
785
+ "Button",
786
+ "Empty",
787
+ "Divider"
788
+ ]
789
+ },
790
+ "props": {
791
+ "type": "object"
792
+ },
793
+ "children": {
794
+ "type": "array",
795
+ "items": {
796
+ "$ref": "#/$defs/view"
797
+ }
798
+ },
799
+ "when": {
800
+ "type": "string"
801
+ }
802
+ }
803
+ },
804
+ "mappingRow": {
805
+ "type": "object",
806
+ "required": [
807
+ "target"
808
+ ],
809
+ "additionalProperties": false,
810
+ "properties": {
811
+ "source": {
812
+ "type": "string"
813
+ },
814
+ "target": {
815
+ "type": "string"
816
+ },
817
+ "transform": {
818
+ "enum": [
819
+ "none",
820
+ "trim",
821
+ "lowercase",
822
+ "uppercase",
823
+ "number",
824
+ "boolean",
825
+ "to_iso_date",
826
+ "to_e164_phone",
827
+ "split_full_name",
828
+ "join",
829
+ "map_values",
830
+ "default",
831
+ "units_to_cents",
832
+ "cents_to_units",
833
+ "from_unix_seconds",
834
+ "to_unix_seconds"
835
+ ]
836
+ },
837
+ "options": {
838
+ "type": "object"
839
+ },
840
+ "master": {
841
+ "enum": [
842
+ "source",
843
+ "target",
844
+ "newest"
845
+ ],
846
+ "default": "source"
847
+ },
848
+ "direction": {
849
+ "enum": [
850
+ "both",
851
+ "to_target",
852
+ "to_source"
853
+ ],
854
+ "default": "both"
855
+ },
856
+ "value": {
857
+ "description": "A fixed value written to target instead of reading source (QuickBooks Line[0].DetailType)."
858
+ }
859
+ },
860
+ "oneOf": [
861
+ {
862
+ "required": [
863
+ "source"
864
+ ],
865
+ "not": {
866
+ "required": [
867
+ "value"
868
+ ]
869
+ }
870
+ },
871
+ {
872
+ "required": [
873
+ "value"
874
+ ],
875
+ "not": {
876
+ "required": [
877
+ "source"
878
+ ]
879
+ }
880
+ }
881
+ ]
882
+ },
883
+ "scheduleConfigurable": {
884
+ "description": "Lets each installation choose its own timing. true: any valid timing. { min }: never more often than this (15m, 2h, 1d).",
885
+ "oneOf": [
886
+ {
887
+ "type": "boolean"
888
+ },
889
+ {
890
+ "type": "object",
891
+ "additionalProperties": false,
892
+ "properties": {
893
+ "min": {
894
+ "type": "string",
895
+ "pattern": "^\\d+\\s*(m|h|d)$"
896
+ }
897
+ }
898
+ }
899
+ ]
900
+ }
901
+ }
902
+ }