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