@prismatic-io/spectral 10.17.2 → 10.18.2

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 (53) hide show
  1. package/dist/clients/http/index.d.ts +84 -16
  2. package/dist/clients/http/index.js +85 -17
  3. package/dist/component.d.ts +3 -3
  4. package/dist/component.js +8 -8
  5. package/dist/conditionalLogic/index.js +3 -3
  6. package/dist/errors.d.ts +67 -0
  7. package/dist/errors.js +67 -0
  8. package/dist/generators/cniComponentManifest/cli.js +5 -5
  9. package/dist/generators/cniComponentManifest/index.d.ts +1 -1
  10. package/dist/generators/componentManifest/cli.js +6 -6
  11. package/dist/generators/componentManifest/createActions.d.ts +1 -1
  12. package/dist/generators/componentManifest/createActions.js +4 -4
  13. package/dist/generators/componentManifest/createConnections.d.ts +1 -1
  14. package/dist/generators/componentManifest/createConnections.js +4 -4
  15. package/dist/generators/componentManifest/createDataSources.d.ts +1 -1
  16. package/dist/generators/componentManifest/createDataSources.js +4 -4
  17. package/dist/generators/componentManifest/createStaticFiles.d.ts +1 -1
  18. package/dist/generators/componentManifest/createStaticFiles.js +1 -1
  19. package/dist/generators/componentManifest/createTriggers.d.ts +1 -1
  20. package/dist/generators/componentManifest/createTriggers.js +4 -4
  21. package/dist/generators/componentManifest/helpers.js +1 -1
  22. package/dist/generators/componentManifest/index.d.ts +2 -2
  23. package/dist/generators/componentManifest/index.js +1 -1
  24. package/dist/generators/utils/escapeSpecialCharacters.js +1 -1
  25. package/dist/index.d.ts +543 -53
  26. package/dist/index.js +545 -55
  27. package/dist/integration.d.ts +2 -2
  28. package/dist/integration.js +9 -9
  29. package/dist/serverTypes/asyncContext.d.ts +1 -1
  30. package/dist/serverTypes/context.d.ts +1 -1
  31. package/dist/serverTypes/context.js +2 -2
  32. package/dist/serverTypes/convertComponent.d.ts +2 -2
  33. package/dist/serverTypes/convertComponent.js +2 -2
  34. package/dist/serverTypes/convertIntegration.d.ts +3 -3
  35. package/dist/serverTypes/convertIntegration.js +13 -13
  36. package/dist/serverTypes/index.d.ts +2 -7
  37. package/dist/serverTypes/perform.d.ts +1 -1
  38. package/dist/serverTypes/perform.js +1 -1
  39. package/dist/testing.d.ts +195 -31
  40. package/dist/testing.js +199 -33
  41. package/dist/types/ActionPerformFunction.d.ts +6 -6
  42. package/dist/types/ConfigVars.d.ts +6 -6
  43. package/dist/types/ConnectionDefinition.d.ts +1 -1
  44. package/dist/types/FlowAttributes.d.ts +1 -1
  45. package/dist/types/index.d.ts +20 -20
  46. package/dist/types/index.js +20 -20
  47. package/dist/types/typeExportComponent.d.ts +15 -15
  48. package/dist/types/typeExportComponent.js +18 -18
  49. package/dist/types/typeExportIntegration.d.ts +17 -17
  50. package/dist/types/typeExportIntegration.js +17 -17
  51. package/dist/util.d.ts +29 -14
  52. package/dist/util.js +366 -108
  53. package/package.json +26 -28
package/dist/index.d.ts CHANGED
@@ -3,189 +3,679 @@
3
3
  * integration authors create inputs, actions, components, and integrations
4
4
  * that can run on the Prismatic platform.
5
5
  */
6
- import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, DataSourceType, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar, OnPremConnectionDefinition, ComponentManifest, OrganizationActivatedConnectionConfigVar, CustomerActivatedConnectionConfigVar } from "./types";
7
6
  import { convertComponent } from "./serverTypes/convertComponent";
8
7
  import { convertIntegration } from "./serverTypes/convertIntegration";
8
+ import { ActionDefinition, ActionPerformReturn, ComponentDefinition, ComponentManifest, ConfigPage, ConfigVarResultCollection, ConnectionConfigVar, CustomerActivatedConnectionConfigVar, DataSourceConfigVar, DataSourceDefinition, DataSourceType, DefaultConnectionDefinition, Flow, InputFieldDefinition, Inputs, IntegrationDefinition, OAuth2ConnectionDefinition, OnPremConnectionDefinition, OrganizationActivatedConnectionConfigVar, StandardConfigVar, TriggerDefinition, TriggerPayload, TriggerResult } from "./types";
9
9
  import type { PollingTriggerDefinition } from "./types/PollingTriggerDefinition";
10
10
  /**
11
11
  * This function creates a code-native integration object that can be
12
- * imported into Prismatic. For information on using this function to
13
- * write code-native integrations, see
14
- * https://prismatic.io/docs/integrations/code-native/.
12
+ * imported into Prismatic.
15
13
  *
16
14
  * @param definition An IntegrationDefinition type object.
17
15
  * @returns This function returns an integration object that has the shape the Prismatic API expects.
16
+ * @see {@link https://prismatic.io/docs/integrations/code-native/ | Code-Native Integrations}
17
+ * @example
18
+ * import { integration } from "@prismatic-io/spectral";
19
+ * import flows from "./flows";
20
+ * import { configPages } from "./configPages";
21
+ * import { componentRegistry } from "./componentRegistry";
22
+ *
23
+ * export default integration({
24
+ * name: "Acme Integration",
25
+ * description: "Syncs data between Acme and your system",
26
+ * category: "Communication",
27
+ * labels: ["chat", "beta"],
28
+ * iconPath: "icon.png",
29
+ * version: "1.0.0",
30
+ * flows,
31
+ * configPages,
32
+ * componentRegistry,
33
+ * });
18
34
  */
19
35
  export declare const integration: <TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, T extends IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult> = IntegrationDefinition<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>>(definition: T) => ReturnType<typeof convertIntegration<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult>>;
20
36
  /**
21
37
  * This function creates a flow object for use in code-native integrations.
22
- * For information on writing code-native flows, see
23
- * https://prismatic.io/docs/integrations/code-native/flows/.
24
38
  *
25
39
  * @param definition A Flow type object.
26
40
  * @returns This function returns a flow object that has the shape the Prismatic API expects.
41
+ * @see {@link https://prismatic.io/docs/integrations/code-native/flows/ | Code-Native Flows}
42
+ * @example
43
+ * // A webhook-triggered flow
44
+ * import { flow } from "@prismatic-io/spectral";
45
+ *
46
+ * export const myFlow = flow({
47
+ * name: "Process Webhook",
48
+ * stableKey: "process-webhook",
49
+ * description: "Receives and processes incoming webhooks",
50
+ * onTrigger: async (context, payload, params) => {
51
+ * return Promise.resolve({ payload });
52
+ * },
53
+ * onExecution: async (context, params) => {
54
+ * const { logger, configVars } = context;
55
+ * const triggerData = params.onTrigger.results;
56
+ * logger.info("Processing webhook payload");
57
+ * return Promise.resolve({ data: triggerData });
58
+ * },
59
+ * });
60
+ *
61
+ * @example
62
+ * // A scheduled flow with cron expression
63
+ * import { flow } from "@prismatic-io/spectral";
64
+ *
65
+ * export const scheduledSync = flow({
66
+ * name: "Nightly Sync",
67
+ * stableKey: "nightly-sync",
68
+ * description: "Syncs data every night at midnight",
69
+ * schedule: { value: "0 0 * * *", timezone: "America/Chicago" },
70
+ * onExecution: async (context, params) => {
71
+ * context.logger.info(`Sync started at ${new Date().toISOString()}`);
72
+ * return Promise.resolve({ data: null });
73
+ * },
74
+ * });
27
75
  */
28
76
  export declare const flow: <TInputs extends Inputs, TActionInputs extends Inputs, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TTriggerPayload extends TriggerPayload = TriggerPayload, T extends Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload> = Flow<TInputs, TActionInputs, TPayload, TAllowsBranching, TResult, TTriggerPayload>>(definition: T) => T;
29
77
  /**
30
78
  * This function creates a config wizard page object for use in code-native
31
- * integrations. For information on code-native config wizards, see
32
- * https://prismatic.io/docs/integrations/code-native/config-wizard/.
79
+ * integrations.
33
80
  *
34
81
  * @param definition A Config Page type object.
35
82
  * @returns This function returns a config page object that has the shape the Prismatic API expects.
83
+ * @see {@link https://prismatic.io/docs/integrations/code-native/config-wizard/ | Code-Native Config Wizard}
84
+ * @example
85
+ * import { configPage, connectionConfigVar, configVar } from "@prismatic-io/spectral";
86
+ *
87
+ * export const configPages = {
88
+ * Connections: configPage({
89
+ * tagline: "Set up your API connections",
90
+ * elements: {
91
+ * "Acme Connection": connectionConfigVar({
92
+ * stableKey: "acme-connection",
93
+ * dataType: "connection",
94
+ * inputs: {
95
+ * apiKey: { label: "API Key", type: "password", required: true },
96
+ * baseUrl: { label: "Base URL", type: "string", required: true },
97
+ * },
98
+ * }),
99
+ * },
100
+ * }),
101
+ * Configuration: configPage({
102
+ * tagline: "Configure sync settings",
103
+ * elements: {
104
+ * "Sync Interval": configVar({
105
+ * stableKey: "sync-interval",
106
+ * dataType: "picklist",
107
+ * pickList: ["hourly", "daily", "weekly"],
108
+ * defaultValue: "daily",
109
+ * }),
110
+ * },
111
+ * }),
112
+ * };
36
113
  */
37
114
  export declare const configPage: <T extends ConfigPage = ConfigPage>(definition: T) => T;
38
115
  /**
39
116
  * This function creates a config variable object for code-native integrations.
40
- * For information on writing code-native integrations, see
41
- * https://prismatic.io/docs/integrations/code-native/config-wizard/#other-config-variable-types-in-code-native-integrations.
42
117
  *
43
118
  * @param definition A Config Var type object.
44
119
  * @returns This function returns a standard config var object that has the shape the Prismatic API expects.
120
+ * @see {@link https://prismatic.io/docs/integrations/code-native/config-wizard/#other-config-variable-types-in-code-native-integrations | Config Variable Types}
121
+ * @example
122
+ * import { configVar } from "@prismatic-io/spectral";
123
+ *
124
+ * // String config variable
125
+ * const endpoint = configVar({
126
+ * stableKey: "api-endpoint",
127
+ * dataType: "string",
128
+ * defaultValue: "https://api.example.com",
129
+ * description: "The base URL of the API",
130
+ * });
131
+ *
132
+ * @example
133
+ * import { configVar } from "@prismatic-io/spectral";
134
+ *
135
+ * // Picklist config variable
136
+ * const region = configVar({
137
+ * stableKey: "region",
138
+ * dataType: "picklist",
139
+ * pickList: ["us-east-1", "us-west-2", "eu-west-1"],
140
+ * defaultValue: "us-east-1",
141
+ * description: "AWS region to use",
142
+ * });
143
+ *
144
+ * @example
145
+ * import { configVar } from "@prismatic-io/spectral";
146
+ *
147
+ * // Boolean config variable
148
+ * const enableDebug = configVar({
149
+ * stableKey: "enable-debug",
150
+ * dataType: "boolean",
151
+ * defaultValue: false,
152
+ * description: "Enable debug logging",
153
+ * });
154
+ *
155
+ * @example
156
+ * import { configVar } from "@prismatic-io/spectral";
157
+ *
158
+ * // Schedule config variable
159
+ * const syncSchedule = configVar({
160
+ * stableKey: "sync-schedule",
161
+ * dataType: "schedule",
162
+ * description: "When to run the sync",
163
+ * timeZone: "America/Chicago",
164
+ * });
45
165
  */
46
166
  export declare const configVar: <T extends StandardConfigVar>(definition: T) => T;
47
167
  /**
48
168
  * This function creates a data source-backed config variable for code-native
49
- * integrations. For information on code-native data sources, see
50
- * https://prismatic.io/docs/integrations/code-native/config-wizard/#data-sources-is-code-native-integrations.
169
+ * integrations.
51
170
  *
52
171
  * @param definition A Data Source Config Var type object.
53
172
  * @returns This function returns a data source config var object that has the shape the Prismatic API expects.
173
+ * @see {@link https://prismatic.io/docs/integrations/code-native/config-wizard/#data-sources-is-code-native-integrations | Data Sources in Code-Native}
174
+ * @example
175
+ * import { dataSourceConfigVar } from "@prismatic-io/spectral";
176
+ *
177
+ * const selectRepository = dataSourceConfigVar({
178
+ * stableKey: "select-repo",
179
+ * dataSourceType: "picklist",
180
+ * description: "Choose a repository from GitHub",
181
+ * perform: async (context, params) => {
182
+ * // Fetch repos from an API and return them as picklist options
183
+ * return { result: ["repo-1", "repo-2", "repo-3"] };
184
+ * },
185
+ * });
54
186
  */
55
187
  export declare const dataSourceConfigVar: <TDataSourceConfigVar extends DataSourceConfigVar>(definition: TDataSourceConfigVar) => TDataSourceConfigVar;
56
188
  /**
57
189
  * This function creates a connection config variable for code-native
58
- * integrations. For information on writing code-native integrations, see
59
- * https://prismatic.io/docs/integrations/code-native/config-wizard/#connections-in-code-native-integrations.
190
+ * integrations.
60
191
  *
61
192
  * @param definition A Connection Config Var type object.
62
193
  * @returns This function returns a connection config var object that has the shape the Prismatic API expects.
194
+ * @see {@link https://prismatic.io/docs/integrations/code-native/config-wizard/#connections-in-code-native-integrations | Connections in Code-Native}
195
+ * @example
196
+ * import { connectionConfigVar } from "@prismatic-io/spectral";
197
+ * import { acmeConnection } from "./connections";
198
+ *
199
+ * const myConnection = connectionConfigVar({
200
+ * stableKey: "acme-connection",
201
+ * ...acmeConnection,
202
+ * });
203
+ *
204
+ * @example
205
+ * import { connectionConfigVar } from "@prismatic-io/spectral";
206
+ *
207
+ * // Inline connection definition
208
+ * const myApiConnection = connectionConfigVar({
209
+ * stableKey: "my-api-connection",
210
+ * dataType: "connection",
211
+ * inputs: {
212
+ * apiKey: { label: "API Key", type: "password", required: true },
213
+ * baseUrl: {
214
+ * label: "Base URL",
215
+ * type: "string",
216
+ * required: true,
217
+ * default: "https://api.example.com",
218
+ * },
219
+ * },
220
+ * });
63
221
  */
64
222
  export declare const connectionConfigVar: <T extends ConnectionConfigVar = ConnectionConfigVar>(definition: T) => T;
65
223
  /**
66
224
  * This function creates a customer-activated connection for code-native
67
- * integrations. For information on writing code-native integrations, see
68
- * https://prismatic.io/docs/integrations/code-native/.
69
- * For information on customer-activated connections, see
70
- * https://prismatic.io/docs/integrations/connections/integration-agnostic-connections/customer-activated/.
225
+ * integrations. Customer-activated connections are configured by end-users
226
+ * and can be shared across multiple integrations.
71
227
  *
72
228
  * @param definition A Customer-Activated Connection Config Var type object.
73
229
  * @returns This function returns a connection config var object that has the shape the Prismatic API expects.
230
+ * @see {@link https://prismatic.io/docs/integrations/connections/integration-agnostic-connections/customer-activated/ | Customer-Activated Connections}
231
+ * @example
232
+ * import { customerActivatedConnection } from "@prismatic-io/spectral";
233
+ *
234
+ * const sharedSlackConnection = customerActivatedConnection({
235
+ * stableKey: "shared-slack-connection",
236
+ * });
74
237
  */
75
238
  export declare const customerActivatedConnection: <T extends {
76
239
  stableKey: string;
77
240
  }>(definition: T) => CustomerActivatedConnectionConfigVar;
78
241
  /**
79
242
  * This function creates an org-activated connection for code-native
80
- * integrations. For information on writing code-native integrations, see
81
- * https://prismatic.io/docs/integrations/code-native/.
82
- * For information on customer-activated connections, see
83
- * https://prismatic.io/docs/integrations/connections/integration-agnostic-connections/org-activated-customer/.
243
+ * integrations. Org-activated connections are configured once by the
244
+ * organization and shared across all customer instances.
84
245
  *
85
246
  * @param definition An Organization-Activated Connection Config Var type object.
86
247
  * @returns This function returns a connection config var object that has the shape the Prismatic API expects.
248
+ * @see {@link https://prismatic.io/docs/integrations/connections/integration-agnostic-connections/org-activated-customer/ | Org-Activated Connections}
249
+ * @example
250
+ * import { organizationActivatedConnection } from "@prismatic-io/spectral";
251
+ *
252
+ * const orgSlackConnection = organizationActivatedConnection({
253
+ * stableKey: "org-slack-connection",
254
+ * });
87
255
  */
88
256
  export declare const organizationActivatedConnection: <T extends {
89
257
  stableKey: string;
90
258
  }>(definition: T) => OrganizationActivatedConnectionConfigVar;
91
259
  /**
92
- * Generate a manifest of components that this code-native integration relies on. See
93
- * https://prismatic.io/docs/integrations/code-native/existing-components/
260
+ * Generate a manifest of components that this code-native integration relies on.
261
+ * Component manifests allow your code-native integration to reference actions,
262
+ * triggers, connections, and data sources from published Prismatic components.
94
263
  *
95
264
  * @param definition A Component Manifest type object.
96
265
  * @returns This function returns a component manifest object that has the shape the Prismatic API expects.
266
+ * @see {@link https://prismatic.io/docs/integrations/code-native/existing-components/ | Using Existing Components}
267
+ * @example
268
+ * import { componentManifest } from "@prismatic-io/spectral";
269
+ *
270
+ * const slack = componentManifest({
271
+ * key: "slack",
272
+ * public: true,
273
+ * actions: {
274
+ * postMessage: {
275
+ * inputs: {
276
+ * message: { label: "Message" },
277
+ * channelName: { label: "Channel Name" },
278
+ * },
279
+ * },
280
+ * },
281
+ * });
97
282
  */
98
283
  export declare const componentManifest: <T extends ComponentManifest>(definition: T) => T;
99
284
  /**
100
285
  * This function creates a component object that can be
101
- * imported into the Prismatic API. For information on using
102
- * this function to write custom components, see
103
- * https://prismatic.io/docs/custom-connectors/.
286
+ * imported into the Prismatic API.
104
287
  *
105
288
  * @param definition A ComponentDefinition type object, including display information, unique key, and a set of actions the component implements.
106
289
  * @returns This function returns a component object that has the shape the Prismatic API expects.
290
+ * @see {@link https://prismatic.io/docs/custom-connectors/ | Custom Connectors}
291
+ * @example
292
+ * import { component } from "@prismatic-io/spectral";
293
+ * import actions from "./actions";
294
+ * import triggers from "./triggers";
295
+ * import connections from "./connections";
296
+ *
297
+ * export default component({
298
+ * key: "acme-connector",
299
+ * display: {
300
+ * label: "Acme",
301
+ * description: "Interact with Acme's API",
302
+ * iconPath: "icon.png",
303
+ * },
304
+ * actions,
305
+ * triggers,
306
+ * connections,
307
+ * });
107
308
  */
108
309
  export declare const component: <TPublic extends boolean, TKey extends string>(definition: ComponentDefinition<TPublic, TKey>) => ReturnType<typeof convertComponent>;
109
310
  /**
110
311
  * This function creates an action object that can be referenced
111
312
  * by a custom component. It helps ensure that the shape of the
112
313
  * action object conforms to what the Prismatic API expects.
113
- * For information on writing custom component actions, see
114
- * https://prismatic.io/docs/custom-connectors/actions/.
115
314
  *
116
- * @param definition An ActionDefinition type object that includes UI display information, a function to perform when the action is invoked, and a an object containing inputs for the perform function.
315
+ * @param definition An ActionDefinition type object that includes UI display information, a function to perform when the action is invoked, and an object containing inputs for the perform function.
117
316
  * @returns This function validates the shape of the `definition` object provided, and returns the same action object.
317
+ * @see {@link https://prismatic.io/docs/custom-connectors/actions/ | Writing Custom Actions}
318
+ * @example
319
+ * import { action, input, util } from "@prismatic-io/spectral";
320
+ *
321
+ * const listItems = action({
322
+ * display: {
323
+ * label: "List Items",
324
+ * description: "Retrieve a list of items from Acme",
325
+ * },
326
+ * inputs: {
327
+ * connection: input({ label: "Connection", type: "connection", required: true }),
328
+ * limit: input({
329
+ * label: "Limit",
330
+ * type: "string",
331
+ * required: false,
332
+ * default: "100",
333
+ * comments: "Maximum number of items to return",
334
+ * }),
335
+ * },
336
+ * perform: async (context, { connection, limit }) => {
337
+ * const maxItems = util.types.toInt(limit, 100);
338
+ * context.logger.info(`Fetching up to ${maxItems} items`);
339
+ * // Make API call using connection...
340
+ * return { data: { items: [] } };
341
+ * },
342
+ * });
118
343
  */
119
344
  export declare const action: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TReturn extends ActionPerformReturn<TAllowsBranching, unknown>>(definition: ActionDefinition<TInputs, TConfigVars, TAllowsBranching, TReturn>) => ActionDefinition<TInputs, TConfigVars, TAllowsBranching, TReturn>;
120
345
  /**
121
346
  * This function creates a trigger object that can be referenced
122
347
  * by a custom component. It helps ensure that the shape of the
123
348
  * trigger object conforms to what the Prismatic API expects.
124
- * For information on writing custom component triggers, see
125
- * https://prismatic.io/docs/custom-connectors/triggers/.
126
349
  *
127
- * @param definition A TriggerDefinition type object that includes UI display information, a function to perform when the trigger is invoked, and a an object containing inputs for the perform function.
350
+ * @param definition A TriggerDefinition type object that includes UI display information, a function to perform when the trigger is invoked, and an object containing inputs for the perform function.
128
351
  * @returns This function validates the shape of the `definition` object provided, and returns the same trigger object.
352
+ * @see {@link https://prismatic.io/docs/custom-connectors/triggers/ | Writing Custom Triggers}
353
+ * @example
354
+ * import { trigger, input } from "@prismatic-io/spectral";
355
+ * import { HttpResponse } from "@prismatic-io/spectral";
356
+ *
357
+ * const webhookTrigger = trigger({
358
+ * display: {
359
+ * label: "Acme Webhook",
360
+ * description: "Receives webhooks from Acme",
361
+ * },
362
+ * inputs: {
363
+ * secret: input({
364
+ * label: "Signing Secret",
365
+ * type: "password",
366
+ * required: true,
367
+ * comments: "Used to verify webhook signatures",
368
+ * }),
369
+ * },
370
+ * scheduleSupport: "invalid",
371
+ * synchronousResponseSupport: "valid",
372
+ * perform: async (context, payload, { secret }) => {
373
+ * // Validate and process the incoming webhook
374
+ * const response: HttpResponse = {
375
+ * statusCode: 200,
376
+ * contentType: "application/json",
377
+ * body: JSON.stringify({ received: true }),
378
+ * };
379
+ * return Promise.resolve({
380
+ * payload,
381
+ * response,
382
+ * });
383
+ * },
384
+ * });
129
385
  */
130
386
  export declare const trigger: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload>>(definition: TriggerDefinition<TInputs, TConfigVars, TAllowsBranching, TResult>) => TriggerDefinition<TInputs, TConfigVars, TAllowsBranching, TResult>;
131
387
  /**
132
388
  * This function creates a polling trigger object that can be referenced
133
- * by a custom component. See
134
- * https://prismatic.io/docs/custom-connectors/triggers/#app-event-polling-triggers
389
+ * by a custom component. A polling trigger runs on a schedule and uses
390
+ * `context.polling` to track state between invocations, enabling detection
391
+ * of new or changed records.
135
392
  *
136
- * @param definition A PollingTriggerDefinition is similar to a TriggerDefinition, except it requires a pollAction instead of a perform. The pollAction, which can be any action defined in the component, will be polled on the defined schedule.
393
+ * @param definition A PollingTriggerDefinition, similar to a TriggerDefinition, except it requires a pollAction instead of a perform. The pollAction, which can be any action defined in the component, will be polled on the defined schedule.
394
+ * @see {@link https://prismatic.io/docs/custom-connectors/triggers/#app-event-polling-triggers | Polling Triggers}
137
395
  * @returns This function validates the shape of the `definition` object provided, and returns the same polling trigger object.
396
+ * @example
397
+ * import { pollingTrigger, input } from "@prismatic-io/spectral";
398
+ *
399
+ * const newRecordsTrigger = pollingTrigger({
400
+ * display: {
401
+ * label: "New Records",
402
+ * description: "Triggers when new records are detected",
403
+ * },
404
+ * inputs: {
405
+ * connection: input({ label: "Connection", type: "connection", required: true }),
406
+ * },
407
+ * perform: async (context, payload, params) => {
408
+ * const lastCursor = context.polling.getState()["cursor"] ?? "";
409
+ * // Fetch records since lastCursor...
410
+ * const newRecords = []; // results from API
411
+ * context.polling.setState({ cursor: "new-cursor-value" });
412
+ * return Promise.resolve({
413
+ * payload: {
414
+ * ...payload,
415
+ * body: { data: newRecords },
416
+ * },
417
+ * });
418
+ * },
419
+ * });
138
420
  */
139
421
  export declare const pollingTrigger: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TPayload extends TriggerPayload, TAllowsBranching extends boolean, TResult extends TriggerResult<TAllowsBranching, TPayload>, TActionInputs extends Inputs>(definition: PollingTriggerDefinition<TInputs, TConfigVars, TPayload, TAllowsBranching, TResult, TActionInputs>) => PollingTriggerDefinition<TInputs, TConfigVars, TPayload, TAllowsBranching, TResult, TActionInputs>;
140
422
  /**
141
423
  * This function creates a data source object that can be referenced
142
424
  * by a custom component. It helps ensure that the shape of the
143
425
  * data source object conforms to what the Prismatic API expects.
144
- * For information on writing custom component data sources, see
145
- * https://prismatic.io/docs/custom-connectors/data-sources/.
146
426
  *
147
- * @param definition A DataSourceDefinition type object that includes UI display information, a function to perform when the data source is invoked, and a an object containing inputs for the perform function.
427
+ * @param definition A DataSourceDefinition type object that includes UI display information, a function to perform when the data source is invoked, and an object containing inputs for the perform function.
148
428
  * @returns This function validates the shape of the `definition` object provided, and returns the same data source object.
429
+ * @see {@link https://prismatic.io/docs/custom-connectors/data-sources/ | Writing Custom Data Sources}
430
+ * @example
431
+ * import { dataSource, input } from "@prismatic-io/spectral";
432
+ *
433
+ * const selectChannel = dataSource({
434
+ * display: {
435
+ * label: "Select Channel",
436
+ * description: "Fetches a list of channels from the API",
437
+ * },
438
+ * dataSourceType: "picklist",
439
+ * inputs: {
440
+ * connection: input({ label: "Connection", type: "connection", required: true }),
441
+ * },
442
+ * perform: async (context, { connection }) => {
443
+ * // Fetch channels from API using the connection...
444
+ * return {
445
+ * result: [
446
+ * { label: "General", value: "C123" },
447
+ * { label: "Engineering", value: "C456" },
448
+ * ],
449
+ * };
450
+ * },
451
+ * });
149
452
  */
150
453
  export declare const dataSource: <TInputs extends Inputs, TConfigVars extends ConfigVarResultCollection, TDataSourceType extends DataSourceType>(definition: DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>) => DataSourceDefinition<TInputs, TConfigVars, TDataSourceType>;
151
454
  /**
152
- * For information and examples on how to write inputs
153
- * for custom component actions and triggers, see
154
- * https://prismatic.io/docs/custom-connectors/actions/#action-inputs.
455
+ * This function creates an input definition for a custom component action,
456
+ * trigger, or data source. Inputs define what information is collected from
457
+ * the user when configuring an integration step.
155
458
  *
156
459
  * @param definition An InputFieldDefinition object that describes the type of an input for a custom component action or trigger, and information on how it should be displayed in the Prismatic WebApp.
460
+ * @see {@link https://prismatic.io/docs/custom-connectors/actions/#action-inputs | Action Inputs}
157
461
  * @returns This function validates the shape of the `definition` object provided, and returns the same input object.
462
+ * @example
463
+ * import { input } from "@prismatic-io/spectral";
464
+ *
465
+ * // A basic string input
466
+ * const itemName = input({
467
+ * label: "Item Name",
468
+ * type: "string",
469
+ * required: true,
470
+ * comments: "The name of the item to create",
471
+ * example: "My New Item",
472
+ * });
473
+ *
474
+ * @example
475
+ * import { input } from "@prismatic-io/spectral";
476
+ *
477
+ * // A string input with a dropdown of preset choices
478
+ * const priority = input({
479
+ * label: "Priority",
480
+ * type: "string",
481
+ * required: true,
482
+ * model: [
483
+ * { label: "Low", value: "low" },
484
+ * { label: "Medium", value: "medium" },
485
+ * { label: "High", value: "high" },
486
+ * ],
487
+ * default: "medium",
488
+ * });
489
+ *
490
+ * @example
491
+ * import { input } from "@prismatic-io/spectral";
492
+ *
493
+ * // A code input for JSON
494
+ * const requestBody = input({
495
+ * label: "Request Body",
496
+ * type: "code",
497
+ * language: "json",
498
+ * required: false,
499
+ * comments: "JSON body to send with the request",
500
+ * });
501
+ *
502
+ * @example
503
+ * import { input } from "@prismatic-io/spectral";
504
+ *
505
+ * // A key-value list collection input
506
+ * const headers = input({
507
+ * label: "HTTP Headers",
508
+ * type: "string",
509
+ * collection: "keyvaluelist",
510
+ * required: false,
511
+ * comments: "Additional headers to include in the request",
512
+ * });
158
513
  */
159
514
  export declare const input: <T extends InputFieldDefinition>(definition: T) => T;
160
515
  /**
161
516
  * This function creates a connection that can be used by a code-native integration
162
- * or custom component. For information on writing connections, see
163
- * https://prismatic.io/docs/custom-connectors/connections/.
517
+ * or custom component. Connections define the fields (API keys, tokens, etc.) needed
518
+ * to authenticate with a third-party service.
164
519
  *
165
520
  * @param definition A DefaultConnectionDefinition object that describes the type of a connection for a custom component action or trigger, and information on how it should be displayed in the Prismatic WebApp.
166
- * @returns This functions validates the shape of the `definition` object provided and returns the same connection object.
521
+ * @see {@link https://prismatic.io/docs/custom-connectors/connections/ | Writing Custom Connections}
522
+ * @returns This function validates the shape of the `definition` object provided and returns the same connection object.
523
+ * @example
524
+ * import { connection } from "@prismatic-io/spectral";
525
+ *
526
+ * const apiKeyConnection = connection({
527
+ * key: "apiKey",
528
+ * display: {
529
+ * label: "Acme API Key",
530
+ * description: "Authenticate with Acme using an API key",
531
+ * },
532
+ * inputs: {
533
+ * apiKey: {
534
+ * label: "API Key",
535
+ * type: "password",
536
+ * required: true,
537
+ * comments: "Generate an API key from your Acme dashboard",
538
+ * },
539
+ * baseUrl: {
540
+ * label: "Base URL",
541
+ * type: "string",
542
+ * required: true,
543
+ * default: "https://api.acme.com/v2",
544
+ * },
545
+ * },
546
+ * });
167
547
  */
168
548
  export declare const connection: <T extends DefaultConnectionDefinition>(definition: T) => T;
169
549
  /**
170
550
  * This function creates an on-prem connection for a code-native integration or custom component.
171
- * For information on writing custom component connections using on-prem resources, see
172
- * https://prismatic.io/docs/integrations/connections/on-prem-agent/#supporting-on-prem-connections-in-a-custom-connector.
551
+ * On-prem connections include `host` and `port` fields that are automatically overridden by the
552
+ * on-prem agent with local tunnel endpoints.
173
553
  *
174
554
  * @param definition An OnPremConnectionDefinition object that describes the type of a connection for a custom component action or trigger, and information on how it should be displayed in the Prismatic WebApp.
555
+ * @see {@link https://prismatic.io/docs/integrations/connections/on-prem-agent/#supporting-on-prem-connections-in-a-custom-connector | On-Prem Connections}
175
556
  * @returns This function validates the shape of the `definition` object provided and returns the same connection object.
557
+ * @example
558
+ * import { onPremConnection } from "@prismatic-io/spectral";
559
+ *
560
+ * const databaseConnection = onPremConnection({
561
+ * key: "onPremDatabase",
562
+ * display: {
563
+ * label: "On-Prem Database",
564
+ * description: "Connect to an on-premise database through the Prismatic agent",
565
+ * },
566
+ * inputs: {
567
+ * host: {
568
+ * label: "Host",
569
+ * type: "string",
570
+ * required: true,
571
+ * onPremControlled: true,
572
+ * comments: "Overridden when on-prem is enabled",
573
+ * },
574
+ * port: {
575
+ * label: "Port",
576
+ * type: "string",
577
+ * required: true,
578
+ * onPremControlled: true,
579
+ * default: "5432",
580
+ * },
581
+ * username: {
582
+ * label: "Username",
583
+ * type: "string",
584
+ * required: true,
585
+ * },
586
+ * password: {
587
+ * label: "Password",
588
+ * type: "password",
589
+ * required: true,
590
+ * },
591
+ * },
592
+ * });
176
593
  */
177
594
  export declare const onPremConnection: <T extends OnPremConnectionDefinition>(definition: T) => T;
178
595
  /**
179
596
  * This function creates an OAuth 2.0 connection for a code-native integration or custom component.
180
- * For information on writing an OAuth 2.0 connection, see
181
- * https://prismatic.io/docs/custom-connectors/connections/#writing-oauth-20-connections.
597
+ * Supports both Authorization Code and Client Credentials grant types.
182
598
  *
183
599
  * @param definition An OAuth2ConnectionDefinition object that describes the type of a connection for a custom component action or trigger, and information on how it should be displayed in the Prismatic WebApp.
184
- * @returns This functions validates the shape of the `definition` object provided and returns the same connection object.
600
+ * @see {@link https://prismatic.io/docs/custom-connectors/connections/#writing-oauth-20-connections | OAuth 2.0 Connections}
601
+ * @returns This function validates the shape of the `definition` object provided and returns the same connection object.
602
+ * @example
603
+ * import { oauth2Connection, OAuth2Type } from "@prismatic-io/spectral";
604
+ *
605
+ * // Authorization Code OAuth 2.0 connection
606
+ * const acmeOAuth = oauth2Connection({
607
+ * key: "acmeOAuth",
608
+ * display: {
609
+ * label: "Acme OAuth 2.0",
610
+ * description: "Authenticate with Acme using OAuth 2.0",
611
+ * },
612
+ * oauth2Type: OAuth2Type.AuthorizationCode,
613
+ * inputs: {
614
+ * authorizeUrl: {
615
+ * label: "Authorize URL",
616
+ * type: "string",
617
+ * required: true,
618
+ * default: "https://app.acme.com/oauth2/authorize",
619
+ * shown: false,
620
+ * },
621
+ * tokenUrl: {
622
+ * label: "Token URL",
623
+ * type: "string",
624
+ * required: true,
625
+ * default: "https://app.acme.com/oauth2/token",
626
+ * shown: false,
627
+ * },
628
+ * scopes: {
629
+ * label: "Scopes",
630
+ * type: "string",
631
+ * required: true,
632
+ * default: "read write",
633
+ * comments: "Space-delimited OAuth 2.0 permission scopes",
634
+ * },
635
+ * clientId: {
636
+ * label: "Client ID",
637
+ * type: "string",
638
+ * required: true,
639
+ * },
640
+ * clientSecret: {
641
+ * label: "Client Secret",
642
+ * type: "password",
643
+ * required: true,
644
+ * },
645
+ * },
646
+ * });
185
647
  */
186
648
  export declare const oauth2Connection: <T extends OAuth2ConnectionDefinition>(definition: T) => T;
649
+ /**
650
+ * Register multiple component manifests for a code-native integration.
651
+ * Each manifest declares a published Prismatic component and the specific
652
+ * actions, triggers, connections, and data sources your integration uses.
653
+ *
654
+ * @param definition A record of Component Manifest objects keyed by component name.
655
+ * @returns This function returns the same record of component manifests.
656
+ * @see {@link https://prismatic.io/docs/integrations/code-native/existing-components/ | Using Existing Components}
657
+ * @example
658
+ * import { componentManifests } from "@prismatic-io/spectral";
659
+ *
660
+ * export const componentRegistry = componentManifests({
661
+ * slack: {
662
+ * key: "slack",
663
+ * public: true,
664
+ * actions: {
665
+ * postMessage: { inputs: { message: { label: "Message" } } },
666
+ * },
667
+ * },
668
+ * dropbox: {
669
+ * key: "dropbox",
670
+ * public: true,
671
+ * actions: {
672
+ * uploadFile: { inputs: { filePath: { label: "File Path" } } },
673
+ * },
674
+ * },
675
+ * });
676
+ */
187
677
  export declare const componentManifests: <T extends Record<string, ComponentManifest>>(definition: T) => T;
188
- export { default as util } from "./util";
189
- export * from "./types";
190
- export { default as testing } from "./testing";
191
678
  export * from "./errors";
679
+ export { default as testing } from "./testing";
680
+ export * from "./types";
681
+ export { default as util } from "./util";