@automate.ax/catalog 0.55.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.
- package/LICENSE +21 -0
- package/README.md +3 -0
- package/dist/catalog.d.ts +1106 -0
- package/dist/catalog.js +349 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +3 -0
- package/dist/triggers/airtable.d.ts +62 -0
- package/dist/triggers/airtable.js +36 -0
- package/dist/triggers/asana.d.ts +65 -0
- package/dist/triggers/asana.js +39 -0
- package/dist/triggers/brevo.d.ts +111 -0
- package/dist/triggers/brevo.js +65 -0
- package/dist/triggers/core.d.ts +50 -0
- package/dist/triggers/core.js +74 -0
- package/dist/triggers/github.d.ts +228 -0
- package/dist/triggers/github.js +136 -0
- package/dist/triggers/google.d.ts +126 -0
- package/dist/triggers/google.js +143 -0
- package/dist/triggers/index.d.ts +2598 -0
- package/dist/triggers/index.js +97 -0
- package/dist/triggers/linear.d.ts +110 -0
- package/dist/triggers/linear.js +59 -0
- package/dist/triggers/microsoft.d.ts +40 -0
- package/dist/triggers/microsoft.js +60 -0
- package/dist/triggers/resend.d.ts +110 -0
- package/dist/triggers/resend.js +59 -0
- package/dist/triggers/slack.d.ts +41 -0
- package/dist/triggers/slack.js +53 -0
- package/dist/triggers/trello.d.ts +56 -0
- package/dist/triggers/trello.js +35 -0
- package/dist/triggers/vercel.d.ts +279 -0
- package/dist/triggers/vercel.js +163 -0
- package/dist/triggers/whatsapp.d.ts +65 -0
- package/dist/triggers/whatsapp.js +39 -0
- package/dist/types.d.ts +134 -0
- package/dist/types.js +59 -0
- package/package.json +70 -0
- package/src/catalog.ts +403 -0
- package/src/index.ts +68 -0
- package/src/triggers/airtable.ts +39 -0
- package/src/triggers/asana.ts +42 -0
- package/src/triggers/brevo.ts +68 -0
- package/src/triggers/core.ts +93 -0
- package/src/triggers/github.ts +142 -0
- package/src/triggers/google.ts +149 -0
- package/src/triggers/index.ts +128 -0
- package/src/triggers/linear.ts +62 -0
- package/src/triggers/microsoft.ts +65 -0
- package/src/triggers/resend.ts +62 -0
- package/src/triggers/slack.ts +58 -0
- package/src/triggers/trello.ts +38 -0
- package/src/triggers/vercel.ts +170 -0
- package/src/triggers/whatsapp.ts +42 -0
- package/src/types.ts +219 -0
package/src/types.ts
ADDED
|
@@ -0,0 +1,219 @@
|
|
|
1
|
+
export interface IntegrationFormFieldBase {
|
|
2
|
+
description?: string
|
|
3
|
+
label: string
|
|
4
|
+
name: string
|
|
5
|
+
required: boolean
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
export type IntegrationFormField =
|
|
9
|
+
| (IntegrationFormFieldBase & {
|
|
10
|
+
default?: string
|
|
11
|
+
input: "email" | "text" | "url"
|
|
12
|
+
placeholder?: string
|
|
13
|
+
})
|
|
14
|
+
| (IntegrationFormFieldBase & {
|
|
15
|
+
input: "password"
|
|
16
|
+
placeholder?: string
|
|
17
|
+
})
|
|
18
|
+
| (IntegrationFormFieldBase & {
|
|
19
|
+
default?: number
|
|
20
|
+
input: "number"
|
|
21
|
+
placeholder?: string
|
|
22
|
+
})
|
|
23
|
+
| (IntegrationFormFieldBase & {
|
|
24
|
+
default?: boolean
|
|
25
|
+
input: "boolean"
|
|
26
|
+
})
|
|
27
|
+
|
|
28
|
+
interface IntegrationConnectionDefinitionBase {
|
|
29
|
+
description?: string
|
|
30
|
+
id: string
|
|
31
|
+
name: string
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export type IntegrationConnectionDefinition =
|
|
35
|
+
| (IntegrationConnectionDefinitionBase & {
|
|
36
|
+
type: "redirect"
|
|
37
|
+
})
|
|
38
|
+
| (IntegrationConnectionDefinitionBase & {
|
|
39
|
+
fields: readonly IntegrationFormField[]
|
|
40
|
+
type: "form"
|
|
41
|
+
})
|
|
42
|
+
|
|
43
|
+
export interface IntegrationServiceDefinition {
|
|
44
|
+
connectionMethods: readonly IntegrationConnectionDefinition[]
|
|
45
|
+
description?: string
|
|
46
|
+
id: string
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
* Overrides the icon asset key inferred from `id`.
|
|
50
|
+
*
|
|
51
|
+
* Omit this unless the service intentionally reuses another icon asset.
|
|
52
|
+
*/
|
|
53
|
+
icon?: string
|
|
54
|
+
name: string
|
|
55
|
+
preferredConnectionMethodId?: string
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
export type IntegrationScopeRequirement = ScopeRequirementGroup | string
|
|
59
|
+
|
|
60
|
+
/** A recursive group of integration authorization scope requirements. */
|
|
61
|
+
export interface ScopeRequirementGroup {
|
|
62
|
+
requirements: readonly IntegrationScopeRequirement[]
|
|
63
|
+
type: "and" | "or"
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Combinators for declaring recursive integration scope requirements. */
|
|
67
|
+
export const scope = {
|
|
68
|
+
/**
|
|
69
|
+
* Requires every scope or nested group.
|
|
70
|
+
*
|
|
71
|
+
* @param requirements - Required scopes and nested groups.
|
|
72
|
+
*/
|
|
73
|
+
and(...requirements: IntegrationScopeRequirement[]): ScopeRequirementGroup {
|
|
74
|
+
return { requirements: [...new Set(requirements)], type: "and" }
|
|
75
|
+
},
|
|
76
|
+
|
|
77
|
+
/**
|
|
78
|
+
* Requires any scope or nested group.
|
|
79
|
+
*
|
|
80
|
+
* Alternatives must be ordered from most permissive to least permissive.
|
|
81
|
+
*
|
|
82
|
+
* @param requirements - Alternative scopes and nested groups.
|
|
83
|
+
*/
|
|
84
|
+
any(...requirements: IntegrationScopeRequirement[]): ScopeRequirementGroup {
|
|
85
|
+
return { requirements: [...new Set(requirements)], type: "or" }
|
|
86
|
+
},
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** One connection method accepted by an integration account requirement. */
|
|
90
|
+
export interface IntegrationAccountConnectionOption {
|
|
91
|
+
connectionId?: string
|
|
92
|
+
requiredScopes: readonly IntegrationScopeRequirement[]
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/** One normalized integration account requirement. */
|
|
96
|
+
export interface IntegrationAccountRequirement<
|
|
97
|
+
TServiceId extends string = string,
|
|
98
|
+
> {
|
|
99
|
+
connectionOptions: readonly IntegrationAccountConnectionOption[]
|
|
100
|
+
serviceId: TServiceId
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/** Runtime-neutral metadata for one public trigger type. */
|
|
104
|
+
export interface TriggerDefinition<
|
|
105
|
+
TType extends string = string,
|
|
106
|
+
TServiceId extends string = string,
|
|
107
|
+
> {
|
|
108
|
+
account?: IntegrationAccountRequirement<TServiceId>
|
|
109
|
+
description?: string
|
|
110
|
+
|
|
111
|
+
/** Adds configuration-specific details to this trigger's presentation. */
|
|
112
|
+
getDetails?(context: TriggerPresentationContext): TriggerPresentationDetail[]
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Overrides the connected service icon.
|
|
116
|
+
*
|
|
117
|
+
* Omit this from account-backed triggers to inherit their service icon.
|
|
118
|
+
*/
|
|
119
|
+
icon?: string
|
|
120
|
+
|
|
121
|
+
/**
|
|
122
|
+
* Overrides the display name inferred from `type`.
|
|
123
|
+
*
|
|
124
|
+
* Omit this unless custom copy adds value beyond the inferred name.
|
|
125
|
+
* `triggerCatalog` and `getTriggerDefinition` always expose a resolved name.
|
|
126
|
+
*/
|
|
127
|
+
name?: string
|
|
128
|
+
type: TType
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
/** Runtime-neutral context used to describe one configured trigger. */
|
|
132
|
+
export interface TriggerPresentationContext {
|
|
133
|
+
appOrigin: string
|
|
134
|
+
automationId: string
|
|
135
|
+
config: unknown
|
|
136
|
+
hookSlot: number
|
|
137
|
+
projectId: string
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/** One user-facing property of a configured trigger. */
|
|
141
|
+
export interface TriggerPresentationDetail {
|
|
142
|
+
copyable?: boolean
|
|
143
|
+
label: string
|
|
144
|
+
value: string
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** Client-safe presentation of one configured trigger. */
|
|
148
|
+
export interface TriggerPresentation {
|
|
149
|
+
details: TriggerPresentationDetail[]
|
|
150
|
+
name: string
|
|
151
|
+
type: string
|
|
152
|
+
}
|
|
153
|
+
|
|
154
|
+
/**
|
|
155
|
+
* Preserves the literal IDs and connection shapes in one shared definition.
|
|
156
|
+
*
|
|
157
|
+
* @param service - Complete runtime-neutral service definition.
|
|
158
|
+
* @throws When the service or a form connection is empty or IDs repeat.
|
|
159
|
+
*/
|
|
160
|
+
export function defineIntegrationService<
|
|
161
|
+
const TService extends IntegrationServiceDefinition,
|
|
162
|
+
>(service: TService) {
|
|
163
|
+
if (service.connectionMethods.length === 0) {
|
|
164
|
+
throw new Error(
|
|
165
|
+
`Integration service has no connection methods: ${service.id}`,
|
|
166
|
+
)
|
|
167
|
+
}
|
|
168
|
+
const emptyFormConnection = service.connectionMethods.find(
|
|
169
|
+
(connection) =>
|
|
170
|
+
connection.type === "form" && connection.fields.length === 0,
|
|
171
|
+
)
|
|
172
|
+
if (emptyFormConnection) {
|
|
173
|
+
throw new Error(
|
|
174
|
+
`Integration service ${service.id} has no fields for form connection: ${emptyFormConnection.id}`,
|
|
175
|
+
)
|
|
176
|
+
}
|
|
177
|
+
const duplicateConnectionId = service.connectionMethods.find(
|
|
178
|
+
(connection, index) =>
|
|
179
|
+
service.connectionMethods.findIndex(({ id }) => id === connection.id) !==
|
|
180
|
+
index,
|
|
181
|
+
)?.id
|
|
182
|
+
if (duplicateConnectionId) {
|
|
183
|
+
throw new Error(
|
|
184
|
+
`Integration service ${service.id} has duplicate connection ID: ${duplicateConnectionId}`,
|
|
185
|
+
)
|
|
186
|
+
}
|
|
187
|
+
if (
|
|
188
|
+
service.preferredConnectionMethodId &&
|
|
189
|
+
!service.connectionMethods.some(
|
|
190
|
+
({ id }) => id === service.preferredConnectionMethodId,
|
|
191
|
+
)
|
|
192
|
+
) {
|
|
193
|
+
throw new Error(
|
|
194
|
+
`Integration service ${service.id} has an unknown preferred connection method: ${service.preferredConnectionMethodId}`,
|
|
195
|
+
)
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
return service
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* Validates and preserves one complete compile-time service catalog.
|
|
203
|
+
*
|
|
204
|
+
* @param services - Shared integration service definitions.
|
|
205
|
+
* @throws When multiple services use the same ID.
|
|
206
|
+
*/
|
|
207
|
+
export function defineIntegrationCatalog<
|
|
208
|
+
const TCatalog extends readonly IntegrationServiceDefinition[],
|
|
209
|
+
>(services: TCatalog) {
|
|
210
|
+
const duplicateServiceId = services.find(
|
|
211
|
+
(service, index) =>
|
|
212
|
+
services.findIndex(({ id }) => id === service.id) !== index,
|
|
213
|
+
)?.id
|
|
214
|
+
if (duplicateServiceId) {
|
|
215
|
+
throw new Error(`Duplicate integration service ID: ${duplicateServiceId}`)
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
return services
|
|
219
|
+
}
|