@prismatic-io/spectral 9.1.4 → 9.2.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/dist/clients/http/index.js +2 -1
- package/dist/index.d.ts +10 -1
- package/dist/index.js +11 -1
- package/dist/serverTypes/convertIntegration.d.ts +3 -1
- package/dist/serverTypes/convertIntegration.js +138 -27
- package/dist/serverTypes/integration.d.ts +8 -1
- package/dist/types/ConfigVars.d.ts +8 -3
- package/dist/types/IntegrationDefinition.d.ts +3 -1
- package/dist/types/ScopedConfigVars.d.ts +29 -0
- package/dist/types/ScopedConfigVars.js +9 -0
- package/dist/types/index.d.ts +2 -0
- package/dist/types/index.js +2 -0
- package/package.json +2 -2
|
@@ -104,11 +104,12 @@ const createClient = ({ baseUrl, responseType, headers, timeout, params, debug =
|
|
|
104
104
|
});
|
|
105
105
|
if (debug) {
|
|
106
106
|
client.interceptors.request.use((request) => {
|
|
107
|
-
const { baseURL, headers, method, timeout, url, data } = request;
|
|
107
|
+
const { baseURL, headers, method, timeout, url, data, params } = request;
|
|
108
108
|
const dataSize = (0, object_sizeof_1.default)(data);
|
|
109
109
|
console.log(util_1.default.types.toJSON({
|
|
110
110
|
type: "request",
|
|
111
111
|
baseURL,
|
|
112
|
+
params,
|
|
112
113
|
url,
|
|
113
114
|
headers,
|
|
114
115
|
method,
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* authors create inputs, actions, and components that can
|
|
4
4
|
* be processed by the Prismatic API.
|
|
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 } from "./types";
|
|
6
|
+
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, DataSourceType, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar, OnPremConnectionDefinition, ComponentManifest, OrganizationActivatedConnectionConfigVar } from "./types";
|
|
7
7
|
import { convertComponent } from "./serverTypes/convertComponent";
|
|
8
8
|
import { convertIntegration } from "./serverTypes/convertIntegration";
|
|
9
9
|
/**
|
|
@@ -50,6 +50,15 @@ export declare const dataSourceConfigVar: <TDataSourceConfigVar extends DataSour
|
|
|
50
50
|
* @returns This function returns a connection config var object that has the shape the Prismatic API expects.
|
|
51
51
|
*/
|
|
52
52
|
export declare const connectionConfigVar: <T extends ConnectionConfigVar = ConnectionConfigVar>(definition: T) => T;
|
|
53
|
+
/**
|
|
54
|
+
* For information on writing Code Native Integrations, see
|
|
55
|
+
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
56
|
+
* @param definition A Customer Connection Config Var type object.
|
|
57
|
+
* @returns This function returns a connection config var object that has the shape the Prismatic API expects.
|
|
58
|
+
*/
|
|
59
|
+
export declare const organizationActivatedConnection: <T extends {
|
|
60
|
+
stableKey: string;
|
|
61
|
+
}>(definition: T) => OrganizationActivatedConnectionConfigVar;
|
|
53
62
|
/**
|
|
54
63
|
* @param definition A Component Manifest type object.
|
|
55
64
|
* @returns This function returns a component manifest object that has the shape the Prismatic API expects.
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ 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.testing = exports.util = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0;
|
|
25
|
+
exports.testing = exports.util = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.organizationActivatedConnection = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0;
|
|
26
26
|
const convertComponent_1 = require("./serverTypes/convertComponent");
|
|
27
27
|
const convertIntegration_1 = require("./serverTypes/convertIntegration");
|
|
28
28
|
/**
|
|
@@ -82,6 +82,16 @@ exports.dataSourceConfigVar = dataSourceConfigVar;
|
|
|
82
82
|
*/
|
|
83
83
|
const connectionConfigVar = (definition) => definition;
|
|
84
84
|
exports.connectionConfigVar = connectionConfigVar;
|
|
85
|
+
/**
|
|
86
|
+
* For information on writing Code Native Integrations, see
|
|
87
|
+
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
88
|
+
* @param definition A Customer Connection Config Var type object.
|
|
89
|
+
* @returns This function returns a connection config var object that has the shape the Prismatic API expects.
|
|
90
|
+
*/
|
|
91
|
+
const organizationActivatedConnection = (definition) => {
|
|
92
|
+
return Object.assign(Object.assign({}, definition), { dataType: "connection" });
|
|
93
|
+
};
|
|
94
|
+
exports.organizationActivatedConnection = organizationActivatedConnection;
|
|
85
95
|
/**
|
|
86
96
|
* @param definition A Component Manifest type object.
|
|
87
97
|
* @returns This function returns a component manifest object that has the shape the Prismatic API expects.
|
|
@@ -1,6 +1,8 @@
|
|
|
1
|
-
import { IntegrationDefinition, ConfigVar, ComponentRegistry } from "../types";
|
|
1
|
+
import { IntegrationDefinition, ConfigVar, Flow, ComponentRegistry } from "../types";
|
|
2
2
|
import { Component as ServerComponent } from ".";
|
|
3
3
|
import { RequiredConfigVariable as ServerRequiredConfigVariable } from "./integration";
|
|
4
4
|
export declare const convertIntegration: (definition: IntegrationDefinition) => ServerComponent;
|
|
5
|
+
/** Converts a Flow into the structure necessary for YAML generation. */
|
|
6
|
+
export declare const convertFlow: (flow: Flow, componentRegistry: ComponentRegistry, referenceKey: string) => Record<string, unknown>;
|
|
5
7
|
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
6
8
|
export declare const convertConfigVar: (key: string, configVar: ConfigVar, referenceKey: string, componentRegistry: ComponentRegistry) => ServerRequiredConfigVariable;
|
|
@@ -12,28 +12,30 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.convertConfigVar = exports.convertIntegration = void 0;
|
|
15
|
+
exports.convertConfigVar = exports.convertFlow = exports.convertIntegration = void 0;
|
|
16
16
|
const yaml_1 = __importDefault(require("yaml"));
|
|
17
17
|
const uuid_1 = require("uuid");
|
|
18
18
|
const lodash_1 = require("lodash");
|
|
19
19
|
const types_1 = require("../types");
|
|
20
20
|
const convertComponent_1 = require("./convertComponent");
|
|
21
21
|
const integration_1 = require("./integration");
|
|
22
|
+
const lodash_2 = require("lodash");
|
|
22
23
|
const convertIntegration = (definition) => {
|
|
23
|
-
var _a, _b;
|
|
24
|
+
var _a, _b, _c;
|
|
24
25
|
// Generate a unique reference key that will be used to reference the
|
|
25
26
|
// actions, triggers, data sources, and connections that are created
|
|
26
27
|
// inline as part of the integration definition.
|
|
27
28
|
const referenceKey = (0, uuid_1.v4)();
|
|
29
|
+
const scopedConfigVars = (_a = definition.scopedConfigVars) !== null && _a !== void 0 ? _a : {};
|
|
28
30
|
const configVars = Object.values({
|
|
29
|
-
configPages: (
|
|
30
|
-
userLevelConfigPages: (
|
|
31
|
+
configPages: (_b = definition.configPages) !== null && _b !== void 0 ? _b : {},
|
|
32
|
+
userLevelConfigPages: (_c = definition.userLevelConfigPages) !== null && _c !== void 0 ? _c : {},
|
|
31
33
|
}).reduce((acc, configPages) => (Object.assign(Object.assign({}, acc), Object.values(configPages).reduce((acc, configPage) => Object.entries(configPage.elements).reduce((acc, [key, element]) => {
|
|
32
34
|
// "string" elements are HTML elements and should be ignored.
|
|
33
35
|
if (typeof element === "string") {
|
|
34
36
|
return acc;
|
|
35
37
|
}
|
|
36
|
-
if (key in acc) {
|
|
38
|
+
if (key in acc || key in scopedConfigVars) {
|
|
37
39
|
throw new Error(`Duplicate config var key: "${key}"`);
|
|
38
40
|
}
|
|
39
41
|
return Object.assign(Object.assign({}, acc), { [key]: element });
|
|
@@ -58,7 +60,7 @@ const convertConfigPages = (pages, userLevelConfigured) => {
|
|
|
58
60
|
value: key,
|
|
59
61
|
}) })));
|
|
60
62
|
};
|
|
61
|
-
const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows, configPages, userLevelConfigPages, componentRegistry = {}, }, referenceKey, configVars) => {
|
|
63
|
+
const codeNativeIntegrationYaml = ({ name, description, category, documentation, version, labels, endpointType, triggerPreprocessFlowConfig, flows, configPages, userLevelConfigPages, scopedConfigVars, componentRegistry = {}, }, referenceKey, configVars) => {
|
|
62
64
|
// Find the preprocess flow config on the flow, if one exists.
|
|
63
65
|
const preprocessFlows = flows.filter((flow) => flow.preprocessFlowConfig);
|
|
64
66
|
// Do some validation of preprocess flow configs.
|
|
@@ -76,6 +78,13 @@ const codeNativeIntegrationYaml = ({ name, description, category, documentation,
|
|
|
76
78
|
if (nonPreprocessFlowTypes.includes(endpointType || "flow_specific") && !preprocessFlowConfig) {
|
|
77
79
|
throw new Error("Integration with specified EndpointType must define either a Trigger Preprocess Flow Config or a Preprocess Flow.");
|
|
78
80
|
}
|
|
81
|
+
const configVarMap = Object.entries(scopedConfigVars !== null && scopedConfigVars !== void 0 ? scopedConfigVars : {}).reduce((acc, [key, value]) => {
|
|
82
|
+
if (typeof value === "string") {
|
|
83
|
+
return acc;
|
|
84
|
+
}
|
|
85
|
+
return Object.assign(Object.assign({}, acc), { [key]: value });
|
|
86
|
+
}, Object.assign({}, (configVars !== null && configVars !== void 0 ? configVars : {})));
|
|
87
|
+
const requiredConfigVars = Object.entries(configVarMap).map(([key, configVar]) => (0, exports.convertConfigVar)(key, configVar, referenceKey, componentRegistry));
|
|
79
88
|
// Transform the IntegrationDefinition into the structure that is appropriate
|
|
80
89
|
// for generating YAML, which will then be used by the Prismatic API to import
|
|
81
90
|
// the integration as a Code Native Integration.
|
|
@@ -88,13 +97,13 @@ const codeNativeIntegrationYaml = ({ name, description, category, documentation,
|
|
|
88
97
|
documentation,
|
|
89
98
|
version,
|
|
90
99
|
labels,
|
|
91
|
-
requiredConfigVars
|
|
100
|
+
requiredConfigVars,
|
|
92
101
|
endpointType,
|
|
93
102
|
preprocessFlowName: hasPreprocessFlow ? preprocessFlows[0].name : undefined,
|
|
94
103
|
externalCustomerIdField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.externalCustomerIdField),
|
|
95
104
|
externalCustomerUserIdField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.externalCustomerUserIdField),
|
|
96
105
|
flowNameField: fieldNameToReferenceInput(hasPreprocessFlow ? "onExecution" : "payload", preprocessFlowConfig === null || preprocessFlowConfig === void 0 ? void 0 : preprocessFlowConfig.flowNameField),
|
|
97
|
-
flows: flows.map((flow) => convertFlow(flow, componentRegistry, referenceKey)),
|
|
106
|
+
flows: flows.map((flow) => (0, exports.convertFlow)(flow, componentRegistry, referenceKey)),
|
|
98
107
|
configPages: [
|
|
99
108
|
...convertConfigPages(configPages, false),
|
|
100
109
|
...convertConfigPages(userLevelConfigPages, true),
|
|
@@ -198,11 +207,21 @@ const convertComponentReference = (componentReference, componentRegistry, refere
|
|
|
198
207
|
inputs,
|
|
199
208
|
};
|
|
200
209
|
};
|
|
201
|
-
const convertComponentRegistry = (componentRegistry
|
|
202
|
-
key,
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
210
|
+
const convertComponentRegistry = (componentRegistry, publicSupplementalComponent) => {
|
|
211
|
+
const convertedRegistry = Object.values(componentRegistry).map(({ key, public: isPublic, signature }) => ({
|
|
212
|
+
key,
|
|
213
|
+
signature: signature !== null && signature !== void 0 ? signature : "",
|
|
214
|
+
isPublic,
|
|
215
|
+
}));
|
|
216
|
+
if (publicSupplementalComponent) {
|
|
217
|
+
convertedRegistry.push({
|
|
218
|
+
key: `${publicSupplementalComponent}-triggers`,
|
|
219
|
+
isPublic: true,
|
|
220
|
+
version: "LATEST",
|
|
221
|
+
});
|
|
222
|
+
}
|
|
223
|
+
return convertedRegistry;
|
|
224
|
+
};
|
|
206
225
|
/**
|
|
207
226
|
* Create a reference to the private component built as part of this CNI.
|
|
208
227
|
*
|
|
@@ -214,6 +233,12 @@ const codeNativeIntegrationComponentReference = (referenceKey) => ({
|
|
|
214
233
|
version: "LATEST",
|
|
215
234
|
isPublic: false,
|
|
216
235
|
});
|
|
236
|
+
/* A flow's trigger gets wrapped in a custom component if there's a defined
|
|
237
|
+
* onTrigger function, or if any custom onInstance behavior is defined.
|
|
238
|
+
* */
|
|
239
|
+
const flowUsesWrapperTrigger = (flow) => {
|
|
240
|
+
return typeof flow.onTrigger === "function" || flow.onInstanceDelete || flow.onInstanceDeploy;
|
|
241
|
+
};
|
|
217
242
|
/** Converts a Flow into the structure necessary for YAML generation. */
|
|
218
243
|
const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
219
244
|
var _a;
|
|
@@ -225,6 +250,7 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
225
250
|
result.onExecution = undefined;
|
|
226
251
|
result.preprocessFlowConfig = undefined;
|
|
227
252
|
result.errorConfig = undefined;
|
|
253
|
+
let publicSupplementalComponent;
|
|
228
254
|
const triggerStep = {
|
|
229
255
|
name: "On Trigger",
|
|
230
256
|
stableKey: `${flow.stableKey}-onTrigger`,
|
|
@@ -232,17 +258,21 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
232
258
|
isTrigger: true,
|
|
233
259
|
errorConfig: "errorConfig" in flow ? Object.assign({}, flow.errorConfig) : undefined,
|
|
234
260
|
};
|
|
235
|
-
|
|
261
|
+
const useWrapperTrigger = flowUsesWrapperTrigger(flow);
|
|
262
|
+
if ((0, types_1.isComponentReference)(flow.onTrigger) && !useWrapperTrigger) {
|
|
263
|
+
const { ref, inputs } = convertComponentReference(flow.onTrigger, componentRegistry, "triggers");
|
|
264
|
+
triggerStep.action = ref;
|
|
265
|
+
triggerStep.inputs = inputs;
|
|
266
|
+
}
|
|
267
|
+
else if (useWrapperTrigger) {
|
|
268
|
+
if (!flow.onTrigger) {
|
|
269
|
+
publicSupplementalComponent = flow.schedule ? "schedule" : "webhook";
|
|
270
|
+
}
|
|
236
271
|
triggerStep.action = {
|
|
237
272
|
key: flowFunctionKey(flow.name, "onTrigger"),
|
|
238
273
|
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
239
274
|
};
|
|
240
275
|
}
|
|
241
|
-
else if ((0, types_1.isComponentReference)(flow.onTrigger)) {
|
|
242
|
-
const { ref, inputs } = convertComponentReference(flow.onTrigger, componentRegistry, "triggers");
|
|
243
|
-
triggerStep.action = ref;
|
|
244
|
-
triggerStep.inputs = inputs;
|
|
245
|
-
}
|
|
246
276
|
else {
|
|
247
277
|
const hasSchedule = "schedule" in flow && typeof flow.schedule === "object";
|
|
248
278
|
const key = hasSchedule ? "schedule" : "webhook";
|
|
@@ -281,9 +311,10 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
281
311
|
errorConfig: "errorConfig" in flow ? Object.assign({}, flow.errorConfig) : undefined,
|
|
282
312
|
};
|
|
283
313
|
result.steps = [triggerStep, actionStep];
|
|
284
|
-
result.supplementalComponents = convertComponentRegistry(componentRegistry);
|
|
314
|
+
result.supplementalComponents = convertComponentRegistry(componentRegistry, publicSupplementalComponent);
|
|
285
315
|
return result;
|
|
286
316
|
};
|
|
317
|
+
exports.convertFlow = convertFlow;
|
|
287
318
|
/** Converts an input value to the expected server type by its collection type */
|
|
288
319
|
const convertInputValue = (value, collectionType) => {
|
|
289
320
|
if (collectionType !== "keyvaluelist") {
|
|
@@ -300,6 +331,16 @@ const convertInputValue = (value, collectionType) => {
|
|
|
300
331
|
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
301
332
|
const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
302
333
|
var _a;
|
|
334
|
+
if ((0, types_1.isOrganizationActivatedConnectionConfigVar)(configVar)) {
|
|
335
|
+
const { stableKey } = (0, lodash_1.pick)(configVar, ["stableKey"]);
|
|
336
|
+
return {
|
|
337
|
+
key,
|
|
338
|
+
stableKey,
|
|
339
|
+
dataType: "connection",
|
|
340
|
+
orgOnly: false,
|
|
341
|
+
useScopedConfigVar: stableKey,
|
|
342
|
+
};
|
|
343
|
+
}
|
|
303
344
|
const { orgOnly, meta } = convertConfigVarPermissionAndVisibility((0, lodash_1.pick)(configVar, ["permissionAndVisibilityType", "visibleToOrgDeployer"]));
|
|
304
345
|
if ((0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
|
|
305
346
|
const { stableKey, description } = (0, lodash_1.pick)(configVar, ["stableKey", "description"]);
|
|
@@ -413,6 +454,58 @@ const flowFunctionKey = (flowName, functionName) => {
|
|
|
413
454
|
.join("");
|
|
414
455
|
return `${flowKey}_${functionName}`;
|
|
415
456
|
};
|
|
457
|
+
/* Generates component argument for invokeTrigger calls */
|
|
458
|
+
const invokeTriggerComponentInput = (componentRef, onTrigger, eventName) => {
|
|
459
|
+
const { component } = componentRef;
|
|
460
|
+
const inputComponent = "signature" in componentRef.component
|
|
461
|
+
? {
|
|
462
|
+
key: component.key,
|
|
463
|
+
signature: "signature" in component &&
|
|
464
|
+
component.signature !== null &&
|
|
465
|
+
component.signature !== void 0
|
|
466
|
+
? component.signature
|
|
467
|
+
: "",
|
|
468
|
+
isPublic: component.isPublic,
|
|
469
|
+
}
|
|
470
|
+
: component;
|
|
471
|
+
return {
|
|
472
|
+
component: inputComponent,
|
|
473
|
+
key: onTrigger ? onTrigger.key : componentRef.key,
|
|
474
|
+
triggerEventFunctionName: eventName,
|
|
475
|
+
};
|
|
476
|
+
};
|
|
477
|
+
/* Generates a wrapper function that calls an existing component trigger's perform */
|
|
478
|
+
const generateTriggerPerformFn = (componentRef, onTrigger) => {
|
|
479
|
+
const performFn = componentRef && typeof onTrigger !== "function"
|
|
480
|
+
? (context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
481
|
+
// @ts-expect-error: _components isn't part of the public API
|
|
482
|
+
const { _components } = context;
|
|
483
|
+
const invokeTrigger = _components.invokeTrigger;
|
|
484
|
+
return yield invokeTrigger(invokeTriggerComponentInput(componentRef, onTrigger, "perform"), context, payload, params);
|
|
485
|
+
})
|
|
486
|
+
: onTrigger;
|
|
487
|
+
return performFn;
|
|
488
|
+
};
|
|
489
|
+
/** Generates a wrapper function that calls an existing component's onInstanceDeploy
|
|
490
|
+
* or onInstanceDelete, then calls the flow-defined version if it exists.
|
|
491
|
+
* Returns the deep-merged results of the two, prioritizing the custom response
|
|
492
|
+
* if there's a conflict. */
|
|
493
|
+
const generateOnInstanceWrapperFn = (componentRef, onTrigger, eventName, customFn) => {
|
|
494
|
+
const onInstanceFn = componentRef && typeof onTrigger !== "function"
|
|
495
|
+
? (context, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
496
|
+
// @ts-expect-error: _components isn't part of the public API
|
|
497
|
+
const { _components } = context;
|
|
498
|
+
const invokeTrigger = _components.invokeTrigger;
|
|
499
|
+
const invokeResponse = (yield invokeTrigger(invokeTriggerComponentInput(componentRef, onTrigger, eventName), context, null, params)) || {};
|
|
500
|
+
let customResponse = {};
|
|
501
|
+
if (customFn) {
|
|
502
|
+
customResponse = (yield customFn(context, params)) || {};
|
|
503
|
+
}
|
|
504
|
+
return (0, lodash_2.merge)(invokeResponse, customResponse);
|
|
505
|
+
})
|
|
506
|
+
: customFn;
|
|
507
|
+
return onInstanceFn;
|
|
508
|
+
};
|
|
416
509
|
const convertOnExecution = (onExecution, componentRegistry) => (context, params) => {
|
|
417
510
|
// @ts-expect-error _components isn't part of the public API
|
|
418
511
|
const { _components } = context;
|
|
@@ -463,22 +556,40 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
463
556
|
inputs: [],
|
|
464
557
|
} });
|
|
465
558
|
}, {});
|
|
466
|
-
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete }) => {
|
|
467
|
-
if (
|
|
559
|
+
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, schedule }) => {
|
|
560
|
+
if (!flowUsesWrapperTrigger({ onTrigger, onInstanceDelete, onInstanceDeploy })) {
|
|
561
|
+
// In this scenario, the user has defined an existing component trigger
|
|
562
|
+
// without any custom behavior, so we don't need to wrap anything.
|
|
468
563
|
return result;
|
|
469
564
|
}
|
|
470
565
|
const key = flowFunctionKey(name, "onTrigger");
|
|
566
|
+
const defaultComponentKey = schedule && typeof schedule === "object" ? "schedule" : "webhook";
|
|
567
|
+
const defaultComponentRef = {
|
|
568
|
+
component: {
|
|
569
|
+
key: `${defaultComponentKey}-triggers`,
|
|
570
|
+
version: "LATEST",
|
|
571
|
+
isPublic: true,
|
|
572
|
+
},
|
|
573
|
+
key: defaultComponentKey,
|
|
574
|
+
};
|
|
575
|
+
// The component ref here is undefined if onTrigger is a function.
|
|
576
|
+
const { ref } = (0, types_1.isComponentReference)(onTrigger)
|
|
577
|
+
? convertComponentReference(onTrigger, componentRegistry, "triggers")
|
|
578
|
+
: { ref: onTrigger ? undefined : defaultComponentRef };
|
|
579
|
+
const performFn = generateTriggerPerformFn(ref, onTrigger);
|
|
580
|
+
const deleteFn = generateOnInstanceWrapperFn(ref, onTrigger, "onInstanceDelete", onInstanceDelete);
|
|
581
|
+
const deployFn = generateOnInstanceWrapperFn(ref, onTrigger, "onInstanceDeploy", onInstanceDeploy);
|
|
471
582
|
return Object.assign(Object.assign({}, result), { [key]: {
|
|
472
583
|
key,
|
|
473
584
|
display: {
|
|
474
585
|
label: `${name} - onTrigger`,
|
|
475
586
|
description: "The function that will be executed by the flow to return an HTTP response.",
|
|
476
587
|
},
|
|
477
|
-
perform:
|
|
478
|
-
onInstanceDeploy:
|
|
479
|
-
hasOnInstanceDeploy: !!
|
|
480
|
-
onInstanceDelete:
|
|
481
|
-
hasOnInstanceDelete: !!
|
|
588
|
+
perform: performFn,
|
|
589
|
+
onInstanceDeploy: deployFn,
|
|
590
|
+
hasOnInstanceDeploy: !!deployFn,
|
|
591
|
+
onInstanceDelete: deleteFn,
|
|
592
|
+
hasOnInstanceDelete: !!deleteFn,
|
|
482
593
|
inputs: [],
|
|
483
594
|
scheduleSupport: "valid",
|
|
484
595
|
synchronousResponseSupport: "valid",
|
|
@@ -54,7 +54,14 @@ export interface DefaultRequiredConfigVariable {
|
|
|
54
54
|
inputs?: Record<string, Input>;
|
|
55
55
|
meta?: Record<string, unknown>;
|
|
56
56
|
}
|
|
57
|
-
export
|
|
57
|
+
export interface OrganizationActivatedConnectionRequiredConfigVariable {
|
|
58
|
+
key: string;
|
|
59
|
+
dataType: "connection";
|
|
60
|
+
orgOnly: false;
|
|
61
|
+
inputs?: never;
|
|
62
|
+
useScopedConfigVar: string;
|
|
63
|
+
}
|
|
64
|
+
export type RequiredConfigVariable = DefaultRequiredConfigVariable | ConnectionRequiredConfigVariable | OrganizationActivatedConnectionRequiredConfigVariable;
|
|
58
65
|
export interface ConfigPage {
|
|
59
66
|
name: string;
|
|
60
67
|
tagline?: string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { ValidationMode } from "@jsonforms/core";
|
|
2
|
-
import { type DataSourceDefinition, type ConnectionDefinition, type Inputs, type DataSourceType, type Connection, type JSONForm, type ObjectFieldMap, type ObjectSelection, type ConfigVarResultCollection, type Schedule, type CollectionDataSourceType, type DataSourceReference, type ConfigPage, type ConfigPages, type ConfigPageElement, type ComponentRegistryDataSource, type ComponentRegistryConnection, type UserLevelConfigPages } from ".";
|
|
2
|
+
import { type DataSourceDefinition, type ConnectionDefinition, type Inputs, type DataSourceType, type Connection, type JSONForm, type ObjectFieldMap, type ObjectSelection, type ConfigVarResultCollection, type Schedule, type CollectionDataSourceType, type DataSourceReference, type ConfigPage, type ConfigPages, type ConfigPageElement, type ComponentRegistryDataSource, type ComponentRegistryConnection, type UserLevelConfigPages, type OrganizationActivatedConnectionConfigVar, type ScopedConfigVarMap } from ".";
|
|
3
3
|
import type { Prettify, UnionToIntersection } from "./utils";
|
|
4
4
|
/** Supported data types for Config Vars. */
|
|
5
5
|
export type ConfigVarDataType = "string" | "date" | "timestamp" | "picklist" | "code" | "boolean" | "number" | "schedule" | "objectSelection" | "objectFieldMap" | "jsonForm";
|
|
@@ -161,7 +161,7 @@ type ConnectionReferenceConfigVar = ComponentRegistryConnection extends infer TC
|
|
|
161
161
|
} : never : never;
|
|
162
162
|
/** Defines attributes of a Config Var that represents a Connection. */
|
|
163
163
|
export type ConnectionConfigVar = ConnectionDefinitionConfigVar | ConnectionReferenceConfigVar;
|
|
164
|
-
export type ConfigVar = StandardConfigVar | DataSourceConfigVar | ConnectionConfigVar;
|
|
164
|
+
export type ConfigVar = StandardConfigVar | DataSourceConfigVar | ConnectionConfigVar | OrganizationActivatedConnectionConfigVar;
|
|
165
165
|
type WithCollectionType<TValue, TCollectionType extends CollectionType | undefined> = undefined | unknown extends TCollectionType ? TValue : TCollectionType extends "valuelist" ? TValue[] : Array<{
|
|
166
166
|
key: string;
|
|
167
167
|
value: TValue;
|
|
@@ -174,7 +174,12 @@ type ExtractConfigVars<TConfigPages extends {
|
|
|
174
174
|
}> = keyof TConfigPages extends infer TPageName ? TPageName extends keyof TConfigPages ? TConfigPages[TPageName] extends infer TConfigPage ? TConfigPage extends ConfigPage ? {
|
|
175
175
|
[Key in keyof TConfigPage["elements"] as Key extends string ? TConfigPage["elements"][Key] extends ConfigVar ? Key : never : never]: ElementToRuntimeType<TConfigPage["elements"][Key]>;
|
|
176
176
|
} : never : never : never : never;
|
|
177
|
-
|
|
177
|
+
type ExtractScopedConfigVars<TScopedConfigVarMap extends {
|
|
178
|
+
[key: string]: string | OrganizationActivatedConnectionConfigVar;
|
|
179
|
+
}> = keyof TScopedConfigVarMap extends infer TScopedConfigVarName ? TScopedConfigVarName extends keyof TScopedConfigVarMap ? TScopedConfigVarMap[TScopedConfigVarName] extends infer TScopedConfigVar ? TScopedConfigVar extends OrganizationActivatedConnectionConfigVar ? {
|
|
180
|
+
[Key in keyof TScopedConfigVarMap as Key extends string ? TScopedConfigVarMap[Key] extends OrganizationActivatedConnectionConfigVar ? Key : never : never]: Connection;
|
|
181
|
+
} : never : never : never : never;
|
|
182
|
+
export type ConfigVars = Prettify<UnionToIntersection<ExtractConfigVars<ConfigPages>>> & Prettify<UnionToIntersection<ExtractConfigVars<UserLevelConfigPages>>> & Prettify<UnionToIntersection<ExtractScopedConfigVars<ScopedConfigVarMap>>>;
|
|
178
183
|
export declare const isCodeConfigVar: (cv: ConfigVar) => cv is CodeConfigVar;
|
|
179
184
|
export declare const isScheduleConfigVar: (cv: ConfigVar) => cv is ScheduleConfigVar;
|
|
180
185
|
export declare const isJsonFormConfigVar: (cv: ConfigVar) => cv is JsonFormConfigVar;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, TriggerPayload, ComponentRegistry, TriggerReference, ConfigVars, ConfigPages, UserLevelConfigPages, ValueExpression, ConfigVarExpression, ActionContext } from ".";
|
|
1
|
+
import { ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, TriggerPayload, ComponentRegistry, TriggerReference, ConfigVars, ConfigPages, UserLevelConfigPages, ValueExpression, ConfigVarExpression, ActionContext, ScopedConfigVarMap } from ".";
|
|
2
2
|
/** Defines attributes of a Code-Native Integration. */
|
|
3
3
|
export type IntegrationDefinition = {
|
|
4
4
|
/** The unique name for this Integration. */
|
|
@@ -28,6 +28,8 @@ export type IntegrationDefinition = {
|
|
|
28
28
|
configPages?: ConfigPages;
|
|
29
29
|
/** User Level Config Wizard Pages for this Integration. */
|
|
30
30
|
userLevelConfigPages?: UserLevelConfigPages;
|
|
31
|
+
/** Scoped ConfigVars for this Integration. */
|
|
32
|
+
scopedConfigVars?: ScopedConfigVarMap;
|
|
31
33
|
componentRegistry?: ComponentRegistry;
|
|
32
34
|
};
|
|
33
35
|
export type FlowOnExecution<TTriggerPayload extends TriggerPayload> = ActionPerformFunction<{
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { type ConfigVar } from ".";
|
|
2
|
+
import type { UnionToIntersection } from "./utils";
|
|
3
|
+
export type OrganizationActivatedConnectionConfigVar = {
|
|
4
|
+
dataType: "connection";
|
|
5
|
+
stableKey: string;
|
|
6
|
+
};
|
|
7
|
+
export type ScopedConfigVar = OrganizationActivatedConnectionConfigVar;
|
|
8
|
+
/**
|
|
9
|
+
* Root ScopedConfigVars type exposed for augmentation.
|
|
10
|
+
*
|
|
11
|
+
* The expected interface when augmenting is:
|
|
12
|
+
*
|
|
13
|
+
* ```ts
|
|
14
|
+
* interface IntegrationDefinitionScopedConfigVars {
|
|
15
|
+
* [key: string]: OrganizationActivatedConnectionConfigVar
|
|
16
|
+
* }
|
|
17
|
+
* ```
|
|
18
|
+
*
|
|
19
|
+
*/
|
|
20
|
+
export interface IntegrationDefinitionScopedConfigVars {
|
|
21
|
+
}
|
|
22
|
+
type CreateScopedConfigVars<TScopedConfigVarMap> = keyof TScopedConfigVarMap extends never ? {
|
|
23
|
+
[key: string]: OrganizationActivatedConnectionConfigVar | string;
|
|
24
|
+
} : UnionToIntersection<keyof TScopedConfigVarMap extends infer TScopedConfigVarName ? TScopedConfigVarName extends keyof TScopedConfigVarMap ? TScopedConfigVarMap[TScopedConfigVarName] extends OrganizationActivatedConnectionConfigVar ? {
|
|
25
|
+
[Key in TScopedConfigVarName]: TScopedConfigVarMap[TScopedConfigVarName];
|
|
26
|
+
} : never : never : never>;
|
|
27
|
+
export type ScopedConfigVarMap = CreateScopedConfigVars<IntegrationDefinitionScopedConfigVars>;
|
|
28
|
+
export declare const isOrganizationActivatedConnectionConfigVar: (cv: ConfigVar) => cv is OrganizationActivatedConnectionConfigVar;
|
|
29
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isOrganizationActivatedConnectionConfigVar = void 0;
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
const isOrganizationActivatedConnectionConfigVar = (cv) => "dataType" in cv &&
|
|
6
|
+
cv.dataType === "connection" &&
|
|
7
|
+
!(0, _1.isConnectionDefinitionConfigVar)(cv) &&
|
|
8
|
+
!(0, _1.isConnectionReferenceConfigVar)(cv);
|
|
9
|
+
exports.isOrganizationActivatedConnectionConfigVar = isOrganizationActivatedConnectionConfigVar;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ export * from "./ComponentDefinition";
|
|
|
7
7
|
export * from "./ComponentRegistry";
|
|
8
8
|
export * from "./ConfigPages";
|
|
9
9
|
export * from "./ConfigVars";
|
|
10
|
+
export * from "./ScopedConfigVars";
|
|
10
11
|
export * from "./ConnectionDefinition";
|
|
11
12
|
export * from "./Inputs";
|
|
12
13
|
export * from "./ActionPerformReturn";
|
|
@@ -32,4 +33,5 @@ export * from "./IntegrationAttributes";
|
|
|
32
33
|
export * from "./FlowAttributes";
|
|
33
34
|
export * from "./IntegrationDefinition";
|
|
34
35
|
export * from "./ComponentManifest";
|
|
36
|
+
export * from "./ScopedConfigVars";
|
|
35
37
|
export * as serverTypes from "../serverTypes";
|
package/dist/types/index.js
CHANGED
|
@@ -36,6 +36,7 @@ __exportStar(require("./ComponentDefinition"), exports);
|
|
|
36
36
|
__exportStar(require("./ComponentRegistry"), exports);
|
|
37
37
|
__exportStar(require("./ConfigPages"), exports);
|
|
38
38
|
__exportStar(require("./ConfigVars"), exports);
|
|
39
|
+
__exportStar(require("./ScopedConfigVars"), exports);
|
|
39
40
|
__exportStar(require("./ConnectionDefinition"), exports);
|
|
40
41
|
__exportStar(require("./Inputs"), exports);
|
|
41
42
|
__exportStar(require("./ActionPerformReturn"), exports);
|
|
@@ -61,4 +62,5 @@ __exportStar(require("./IntegrationAttributes"), exports);
|
|
|
61
62
|
__exportStar(require("./FlowAttributes"), exports);
|
|
62
63
|
__exportStar(require("./IntegrationDefinition"), exports);
|
|
63
64
|
__exportStar(require("./ComponentManifest"), exports);
|
|
65
|
+
__exportStar(require("./ScopedConfigVars"), exports);
|
|
64
66
|
exports.serverTypes = __importStar(require("../serverTypes"));
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismatic-io/spectral",
|
|
3
|
-
"version": "9.
|
|
4
|
-
"description": "Utility library for building Prismatic components",
|
|
3
|
+
"version": "9.2.0",
|
|
4
|
+
"description": "Utility library for building Prismatic components and code-native integrations",
|
|
5
5
|
"keywords": ["prismatic"],
|
|
6
6
|
"main": "dist/index.js",
|
|
7
7
|
"types": "dist/index.d.ts",
|