@prismatic-io/spectral 10.18.7-preview.5 → 10.18.7
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/generators/componentManifest/getInputs.js +7 -82
- package/dist/index.d.ts +1 -64
- package/dist/index.js +1 -58
- package/dist/serverTypes/convertComponent.d.ts +1 -13
- package/dist/serverTypes/convertComponent.js +13 -104
- package/dist/serverTypes/convertIntegration.js +45 -29
- package/dist/serverTypes/index.d.ts +4 -19
- package/dist/types/ActionInputParameters.d.ts +2 -31
- package/dist/types/Inputs.d.ts +1 -47
- package/dist/types/Inputs.js +0 -2
- package/dist/types/IntegrationDefinition.d.ts +2 -20
- package/dist/types/PollingTriggerDefinition.d.ts +1 -7
- package/dist/types/TriggerDefinition.d.ts +2 -35
- package/dist/types/TriggerPayload.d.ts +2 -11
- package/package.json +1 -1
|
@@ -3,6 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.INPUT_TYPE_MAP = exports.getInputs = void 0;
|
|
4
4
|
const escapeSpecialCharacters_1 = require("../utils/escapeSpecialCharacters");
|
|
5
5
|
const docBlock_1 = require("./docBlock");
|
|
6
|
+
const getDefaultValue = (value, isCollection) => {
|
|
7
|
+
if (value === undefined || value === "") {
|
|
8
|
+
return isCollection ? [] : value;
|
|
9
|
+
}
|
|
10
|
+
const stringValue = typeof value === "string" ? value : JSON.stringify(value);
|
|
11
|
+
return (0, escapeSpecialCharacters_1.escapeSpecialCharacters)(stringValue);
|
|
12
|
+
};
|
|
6
13
|
const getInputs = ({ inputs, docBlock = docBlock_1.DOC_BLOCK_DEFAULT }) => {
|
|
7
14
|
return inputs.reduce((acc, input) => {
|
|
8
15
|
if ((typeof input.shown === "boolean" && input.shown === false) ||
|
|
@@ -61,23 +68,8 @@ exports.INPUT_TYPE_MAP = {
|
|
|
61
68
|
timestamp: "string",
|
|
62
69
|
flow: "string",
|
|
63
70
|
template: "string",
|
|
64
|
-
structuredObject: {
|
|
65
|
-
module: "@prismatic-io/spectral/dist/types",
|
|
66
|
-
type: "StructuredObject",
|
|
67
|
-
},
|
|
68
|
-
dynamicObject: {
|
|
69
|
-
module: "@prismatic-io/spectral/dist/types",
|
|
70
|
-
type: "DynamicObject",
|
|
71
|
-
},
|
|
72
71
|
};
|
|
73
72
|
const getInputValueType = (input) => {
|
|
74
|
-
var _a, _b;
|
|
75
|
-
if (input.type === "structuredObject") {
|
|
76
|
-
return structuredObjectTypeString((_a = input.inputs) !== null && _a !== void 0 ? _a : []);
|
|
77
|
-
}
|
|
78
|
-
if (input.type === "dynamicObject") {
|
|
79
|
-
return dynamicObjectTypeString((_b = input.inputs) !== null && _b !== void 0 ? _b : []);
|
|
80
|
-
}
|
|
81
73
|
const inputType = exports.INPUT_TYPE_MAP[input.type];
|
|
82
74
|
const valueType = input.model
|
|
83
75
|
? input.model
|
|
@@ -102,70 +94,3 @@ const getInputValueType = (input) => {
|
|
|
102
94
|
}
|
|
103
95
|
return valueType;
|
|
104
96
|
};
|
|
105
|
-
const getDefaultValue = (value, isCollection) => {
|
|
106
|
-
if (value === undefined || value === "") {
|
|
107
|
-
return isCollection ? [] : value;
|
|
108
|
-
}
|
|
109
|
-
const stringValue = typeof value === "string" ? value : JSON.stringify(value);
|
|
110
|
-
return (0, escapeSpecialCharacters_1.escapeSpecialCharacters)(stringValue);
|
|
111
|
-
};
|
|
112
|
-
const isValidIdentifier = (key) => /^[a-zA-Z_$][a-zA-Z0-9_$]*$/.test(key);
|
|
113
|
-
const wrapCollection = (valueType, collection) => {
|
|
114
|
-
if (collection === "valuelist") {
|
|
115
|
-
return `Array<${valueType}>`;
|
|
116
|
-
}
|
|
117
|
-
if (collection === "keyvaluelist") {
|
|
118
|
-
return `Record<string, ${valueType}> | Array<{key: string, value: ${valueType}}>`;
|
|
119
|
-
}
|
|
120
|
-
return valueType;
|
|
121
|
-
};
|
|
122
|
-
const getLeafBaseType = (child) => {
|
|
123
|
-
var _a;
|
|
124
|
-
if ((_a = child.model) === null || _a === void 0 ? void 0 : _a.length) {
|
|
125
|
-
return child.model
|
|
126
|
-
.map(({ value }) => `\`${value.replaceAll("\r", "\\r").replaceAll("\n", "\\n")}\``)
|
|
127
|
-
.join(" | ");
|
|
128
|
-
}
|
|
129
|
-
const mapped = exports.INPUT_TYPE_MAP[child.type];
|
|
130
|
-
if (!mapped) {
|
|
131
|
-
return "unknown";
|
|
132
|
-
}
|
|
133
|
-
if (typeof mapped === "string") {
|
|
134
|
-
return mapped;
|
|
135
|
-
}
|
|
136
|
-
return `import("${mapped.module}").${mapped.type}`;
|
|
137
|
-
};
|
|
138
|
-
const getLeafTypeString = (child) => {
|
|
139
|
-
var _a;
|
|
140
|
-
if (child.type === "structuredObject") {
|
|
141
|
-
return structuredObjectTypeString((_a = child.inputs) !== null && _a !== void 0 ? _a : []);
|
|
142
|
-
}
|
|
143
|
-
return wrapCollection(getLeafBaseType(child), child.collection);
|
|
144
|
-
};
|
|
145
|
-
const SPECTRAL_TYPES_MODULE = "@prismatic-io/spectral/dist/types";
|
|
146
|
-
const structuredObjectTypeString = (inputs) => {
|
|
147
|
-
if (!inputs.length) {
|
|
148
|
-
return `import("${SPECTRAL_TYPES_MODULE}").StructuredObject`;
|
|
149
|
-
}
|
|
150
|
-
const fields = inputs
|
|
151
|
-
.map((child) => {
|
|
152
|
-
const key = isValidIdentifier(child.key) ? child.key : JSON.stringify(child.key);
|
|
153
|
-
return `${key}: ${getLeafTypeString(child)}`;
|
|
154
|
-
})
|
|
155
|
-
.join("; ");
|
|
156
|
-
return `{ ${fields} }`;
|
|
157
|
-
};
|
|
158
|
-
const dynamicObjectTypeString = (configurations) => {
|
|
159
|
-
if (!configurations.length) {
|
|
160
|
-
return `import("${SPECTRAL_TYPES_MODULE}").DynamicObject`;
|
|
161
|
-
}
|
|
162
|
-
return configurations
|
|
163
|
-
.map((config) => {
|
|
164
|
-
var _a;
|
|
165
|
-
const valuesType = ((_a = config.inputs) === null || _a === void 0 ? void 0 : _a.length)
|
|
166
|
-
? structuredObjectTypeString(config.inputs)
|
|
167
|
-
: `import("${SPECTRAL_TYPES_MODULE}").StructuredObject`;
|
|
168
|
-
return `{ configuration: ${JSON.stringify(config.key)}; values: ${valuesType} }`;
|
|
169
|
-
})
|
|
170
|
-
.join(" | ");
|
|
171
|
-
};
|
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
*/
|
|
6
6
|
import { convertComponent } from "./serverTypes/convertComponent";
|
|
7
7
|
import { convertIntegration } from "./serverTypes/convertIntegration";
|
|
8
|
-
import type { ActionDefinition, ActionPerformReturn, ComponentDefinition, ComponentManifest, ConfigPage, ConfigVarResultCollection, ConnectionConfigVar, CustomerActivatedConnectionConfigVar, DataSourceConfigVar, DataSourceDefinition, DataSourceType, DefaultConnectionDefinition,
|
|
8
|
+
import type { 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
|
|
@@ -512,69 +512,6 @@ export declare const dataSource: <TInputs extends Inputs, TConfigVars extends Co
|
|
|
512
512
|
* });
|
|
513
513
|
*/
|
|
514
514
|
export declare const input: <T extends InputFieldDefinition>(definition: T) => T;
|
|
515
|
-
/**
|
|
516
|
-
* Groups related primitive inputs under a single named container. Children
|
|
517
|
-
* may not themselves be structuredObject inputs (the type signature enforces
|
|
518
|
-
* this at compile time).
|
|
519
|
-
*
|
|
520
|
-
* @example
|
|
521
|
-
* import { input, structuredObjectInput } from "@prismatic-io/spectral";
|
|
522
|
-
*
|
|
523
|
-
* const name = structuredObjectInput({
|
|
524
|
-
* label: "Name",
|
|
525
|
-
* inputs: {
|
|
526
|
-
* first: input({ type: "string", label: "First Name", required: true }),
|
|
527
|
-
* last: input({ type: "string", label: "Last Name", required: true }),
|
|
528
|
-
* },
|
|
529
|
-
* });
|
|
530
|
-
*/
|
|
531
|
-
export declare const structuredObjectInput: <T extends Omit<StructuredObjectInputField, "type"> & {
|
|
532
|
-
type?: never;
|
|
533
|
-
}>(definition: T) => T & {
|
|
534
|
-
type: "structuredObject";
|
|
535
|
-
};
|
|
536
|
-
/**
|
|
537
|
-
* Presents a discriminated set of input configurations; the integration builder
|
|
538
|
-
* picks a configuration and its inputs become available. Configurations may
|
|
539
|
-
* contain leaf inputs and structuredObject inputs but not nested dynamicObjects
|
|
540
|
-
* (the type signature enforces this at compile time).
|
|
541
|
-
*
|
|
542
|
-
* @example
|
|
543
|
-
* import { input, structuredObjectInput, dynamicObjectInput } from "@prismatic-io/spectral";
|
|
544
|
-
*
|
|
545
|
-
* const recordData = dynamicObjectInput({
|
|
546
|
-
* label: "Record Data",
|
|
547
|
-
* required: true,
|
|
548
|
-
* configurations: {
|
|
549
|
-
* contact: {
|
|
550
|
-
* label: "Contact",
|
|
551
|
-
* comments: "Create a new contact",
|
|
552
|
-
* inputs: {
|
|
553
|
-
* name: structuredObjectInput({
|
|
554
|
-
* label: "Name",
|
|
555
|
-
* inputs: {
|
|
556
|
-
* first: input({ type: "string", label: "First Name", required: true }),
|
|
557
|
-
* last: input({ type: "string", label: "Last Name", required: true }),
|
|
558
|
-
* },
|
|
559
|
-
* }),
|
|
560
|
-
* email: input({ type: "string", label: "Email", required: true }),
|
|
561
|
-
* },
|
|
562
|
-
* },
|
|
563
|
-
* account: {
|
|
564
|
-
* label: "Account",
|
|
565
|
-
* comments: "Create a new account",
|
|
566
|
-
* inputs: {
|
|
567
|
-
* companyName: input({ type: "string", label: "Company Name", required: true }),
|
|
568
|
-
* },
|
|
569
|
-
* },
|
|
570
|
-
* },
|
|
571
|
-
* });
|
|
572
|
-
*/
|
|
573
|
-
export declare const dynamicObjectInput: <T extends Omit<DynamicObjectInputField, "type"> & {
|
|
574
|
-
type?: never;
|
|
575
|
-
}>(definition: T) => T & {
|
|
576
|
-
type: "dynamicObject";
|
|
577
|
-
};
|
|
578
515
|
/**
|
|
579
516
|
* This function creates a connection that can be used by a code-native integration
|
|
580
517
|
* or custom component. Connections define the fields (API keys, tokens, etc.) needed
|
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.util = exports.testing = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = 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
26
|
const serverTypes_1 = require("./serverTypes");
|
|
27
27
|
const convertComponent_1 = require("./serverTypes/convertComponent");
|
|
28
28
|
const convertIntegration_1 = require("./serverTypes/convertIntegration");
|
|
@@ -557,63 +557,6 @@ exports.dataSource = dataSource;
|
|
|
557
557
|
*/
|
|
558
558
|
const input = (definition) => definition;
|
|
559
559
|
exports.input = input;
|
|
560
|
-
/**
|
|
561
|
-
* Groups related primitive inputs under a single named container. Children
|
|
562
|
-
* may not themselves be structuredObject inputs (the type signature enforces
|
|
563
|
-
* this at compile time).
|
|
564
|
-
*
|
|
565
|
-
* @example
|
|
566
|
-
* import { input, structuredObjectInput } from "@prismatic-io/spectral";
|
|
567
|
-
*
|
|
568
|
-
* const name = structuredObjectInput({
|
|
569
|
-
* label: "Name",
|
|
570
|
-
* inputs: {
|
|
571
|
-
* first: input({ type: "string", label: "First Name", required: true }),
|
|
572
|
-
* last: input({ type: "string", label: "Last Name", required: true }),
|
|
573
|
-
* },
|
|
574
|
-
* });
|
|
575
|
-
*/
|
|
576
|
-
const structuredObjectInput = (definition) => (Object.assign(Object.assign({}, definition), { type: "structuredObject" }));
|
|
577
|
-
exports.structuredObjectInput = structuredObjectInput;
|
|
578
|
-
/**
|
|
579
|
-
* Presents a discriminated set of input configurations; the integration builder
|
|
580
|
-
* picks a configuration and its inputs become available. Configurations may
|
|
581
|
-
* contain leaf inputs and structuredObject inputs but not nested dynamicObjects
|
|
582
|
-
* (the type signature enforces this at compile time).
|
|
583
|
-
*
|
|
584
|
-
* @example
|
|
585
|
-
* import { input, structuredObjectInput, dynamicObjectInput } from "@prismatic-io/spectral";
|
|
586
|
-
*
|
|
587
|
-
* const recordData = dynamicObjectInput({
|
|
588
|
-
* label: "Record Data",
|
|
589
|
-
* required: true,
|
|
590
|
-
* configurations: {
|
|
591
|
-
* contact: {
|
|
592
|
-
* label: "Contact",
|
|
593
|
-
* comments: "Create a new contact",
|
|
594
|
-
* inputs: {
|
|
595
|
-
* name: structuredObjectInput({
|
|
596
|
-
* label: "Name",
|
|
597
|
-
* inputs: {
|
|
598
|
-
* first: input({ type: "string", label: "First Name", required: true }),
|
|
599
|
-
* last: input({ type: "string", label: "Last Name", required: true }),
|
|
600
|
-
* },
|
|
601
|
-
* }),
|
|
602
|
-
* email: input({ type: "string", label: "Email", required: true }),
|
|
603
|
-
* },
|
|
604
|
-
* },
|
|
605
|
-
* account: {
|
|
606
|
-
* label: "Account",
|
|
607
|
-
* comments: "Create a new account",
|
|
608
|
-
* inputs: {
|
|
609
|
-
* companyName: input({ type: "string", label: "Company Name", required: true }),
|
|
610
|
-
* },
|
|
611
|
-
* },
|
|
612
|
-
* },
|
|
613
|
-
* });
|
|
614
|
-
*/
|
|
615
|
-
const dynamicObjectInput = (definition) => (Object.assign(Object.assign({}, definition), { type: "dynamicObject" }));
|
|
616
|
-
exports.dynamicObjectInput = dynamicObjectInput;
|
|
617
560
|
/**
|
|
618
561
|
* This function creates a connection that can be used by a code-native integration
|
|
619
562
|
* or custom component. Connections define the fields (API keys, tokens, etc.) needed
|
|
@@ -1,19 +1,7 @@
|
|
|
1
1
|
import { type ComponentDefinition, type ComponentHooks, type ConfigVarResultCollection, type ConnectionDefinition, type ConnectionInput, type ConnectionTemplateInputField, type InputFieldDefinition, type Inputs, type OnPremConnectionInput, type TriggerDefinition, type TriggerPayload, type TriggerResult } from "../types";
|
|
2
2
|
import { type PollingTriggerDefinition } from "../types/PollingTriggerDefinition";
|
|
3
3
|
import type { Component as ServerComponent, Connection as ServerConnection, Input as ServerInput, Trigger as ServerTrigger } from ".";
|
|
4
|
-
|
|
5
|
-
/** Auto-generated cleaner for structuredObject/dynamicObject containers.
|
|
6
|
-
* Recursively delegates to each child's clean function. Developers do not
|
|
7
|
-
* declare a top-level clean on these containers — the conversion always
|
|
8
|
-
* supplies one so nested clean functions are applied at runtime. */
|
|
9
|
-
export declare const cleanerFor: (input: InputFieldDefinition) => CleanFn | undefined;
|
|
10
|
-
/**
|
|
11
|
-
* Throws if `batchSize` isn't a positive integer; otherwise returns it.
|
|
12
|
-
* Shared by both component-trigger (`TriggerResolver.default.batchSize`) and
|
|
13
|
-
* CNI flow (`TriggerResolverConfig.batchSize`) validation paths.
|
|
14
|
-
*/
|
|
15
|
-
export declare const validateBatchSize: (ownerLabel: string, fieldName: string, batchSize: unknown) => number;
|
|
16
|
-
export declare const convertInput: (key: string, definition: InputFieldDefinition | OnPremConnectionInput | ConnectionInput) => ServerInput;
|
|
4
|
+
export declare const convertInput: (key: string, { default: defaultValue, type, label, collection, ...rest }: InputFieldDefinition | OnPremConnectionInput | ConnectionInput) => ServerInput;
|
|
17
5
|
export declare const _isValidTemplateValue: (template: string, inputs: {
|
|
18
6
|
[key: string]: ConnectionInput | ConnectionTemplateInputField;
|
|
19
7
|
}) => {
|
|
@@ -14,102 +14,21 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
14
14
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.convertTemplateInput = exports._isValidTemplateValue = exports.convertInput =
|
|
17
|
+
exports.convertComponent = exports.convertConnection = exports.convertTrigger = exports.convertTemplateInput = exports._isValidTemplateValue = exports.convertInput = void 0;
|
|
18
18
|
const omit_1 = __importDefault(require("lodash/omit"));
|
|
19
19
|
const types_1 = require("../types");
|
|
20
20
|
const PollingTriggerDefinition_1 = require("../types/PollingTriggerDefinition");
|
|
21
21
|
const perform_1 = require("./perform");
|
|
22
|
-
const
|
|
23
|
-
|
|
24
|
-
* Recursively delegates to each child's clean function. Developers do not
|
|
25
|
-
* declare a top-level clean on these containers — the conversion always
|
|
26
|
-
* supplies one so nested clean functions are applied at runtime. */
|
|
27
|
-
const cleanerFor = (input) => {
|
|
28
|
-
if (input.type === "structuredObject") {
|
|
29
|
-
const childCleaners = Object.entries(input.inputs).reduce((acc, [childKey, childDef]) => (Object.assign(Object.assign({}, acc), { [childKey]: (0, exports.cleanerFor)(childDef) })), {});
|
|
30
|
-
return (value) => {
|
|
31
|
-
if (!isPlainObject(value)) {
|
|
32
|
-
return value;
|
|
33
|
-
}
|
|
34
|
-
return (0, perform_1.cleanParams)(value, childCleaners);
|
|
35
|
-
};
|
|
36
|
-
}
|
|
37
|
-
if (input.type === "dynamicObject") {
|
|
38
|
-
const configCleaners = {};
|
|
39
|
-
for (const [configKey, configDef] of Object.entries(input.configurations)) {
|
|
40
|
-
configCleaners[configKey] = Object.entries(configDef.inputs).reduce((acc, [childKey, childDef]) => (Object.assign(Object.assign({}, acc), { [childKey]: (0, exports.cleanerFor)(childDef) })), {});
|
|
41
|
-
}
|
|
42
|
-
return (value) => {
|
|
43
|
-
if (!isPlainObject(value)) {
|
|
44
|
-
return value;
|
|
45
|
-
}
|
|
46
|
-
const { configuration, values } = value;
|
|
47
|
-
if (typeof configuration !== "string") {
|
|
48
|
-
return value;
|
|
49
|
-
}
|
|
50
|
-
const cleaners = configCleaners[configuration];
|
|
51
|
-
if (!cleaners) {
|
|
52
|
-
return { configuration, values };
|
|
53
|
-
}
|
|
54
|
-
return {
|
|
55
|
-
configuration,
|
|
56
|
-
values: isPlainObject(values) ? (0, perform_1.cleanParams)(values, cleaners) : values,
|
|
57
|
-
};
|
|
58
|
-
};
|
|
59
|
-
}
|
|
60
|
-
return "clean" in input ? input.clean : undefined;
|
|
61
|
-
};
|
|
62
|
-
exports.cleanerFor = cleanerFor;
|
|
63
|
-
/**
|
|
64
|
-
* Throws if `batchSize` isn't a positive integer; otherwise returns it.
|
|
65
|
-
* Shared by both component-trigger (`TriggerResolver.default.batchSize`) and
|
|
66
|
-
* CNI flow (`TriggerResolverConfig.batchSize`) validation paths.
|
|
67
|
-
*/
|
|
68
|
-
const validateBatchSize = (ownerLabel, fieldName, batchSize) => {
|
|
69
|
-
if (typeof batchSize !== "number" || !Number.isInteger(batchSize) || batchSize < 1) {
|
|
70
|
-
throw new Error(`${ownerLabel} has an invalid ${fieldName} batchSize of ${String(batchSize)}. batchSize must be an integer >= 1.`);
|
|
71
|
-
}
|
|
72
|
-
return batchSize;
|
|
73
|
-
};
|
|
74
|
-
exports.validateBatchSize = validateBatchSize;
|
|
75
|
-
const buildTriggerResolverFields = (triggerLabel, support, resolver) => {
|
|
76
|
-
if (!resolver) {
|
|
77
|
-
return support === "invalid" ? {} : { triggerResolverDefaultBatchSize: 1 };
|
|
78
|
-
}
|
|
79
|
-
return Object.assign(Object.assign({ triggerResolverDefaultBatchSize: (0, exports.validateBatchSize)(`Trigger "${triggerLabel}"`, "triggerResolver.default", resolver.default.batchSize) }, (resolver.resolveItems
|
|
80
|
-
? {
|
|
81
|
-
resolveTriggerItems: resolver.resolveItems,
|
|
82
|
-
hasResolveTriggerItems: true,
|
|
83
|
-
}
|
|
84
|
-
: {})), (resolver.getNextDiscoveryState
|
|
85
|
-
? {
|
|
86
|
-
getNextDiscoveryState: resolver.getNextDiscoveryState,
|
|
87
|
-
hasGetNextDiscoveryState: true,
|
|
88
|
-
}
|
|
89
|
-
: {}));
|
|
90
|
-
};
|
|
91
|
-
const convertInput = (key, definition) => {
|
|
92
|
-
// Cast: the field union is wider than any single member; runtime guards below handle it.
|
|
93
|
-
const _a = definition, { default: defaultValue, type, label, collection, inputs: childInputs, configurations } = _a, rest = __rest(_a, ["default", "type", "label", "collection", "inputs", "configurations"]);
|
|
22
|
+
const convertInput = (key, _a) => {
|
|
23
|
+
var { default: defaultValue, type, label, collection } = _a, rest = __rest(_a, ["default", "type", "label", "collection"]);
|
|
94
24
|
const keyLabel = collection === "keyvaluelist" && typeof label === "object" ? label.key : undefined;
|
|
95
|
-
const nestedInputs = type === "structuredObject" && childInputs
|
|
96
|
-
? Object.entries(childInputs).map(([childKey, childDef]) => (0, exports.convertInput)(childKey, childDef))
|
|
97
|
-
: type === "dynamicObject" && configurations
|
|
98
|
-
? Object.entries(configurations).map(([configKey, configDef]) => ({
|
|
99
|
-
key: configKey,
|
|
100
|
-
type: "structuredObject",
|
|
101
|
-
label: typeof configDef.label === "string" ? configDef.label : configDef.label.value,
|
|
102
|
-
comments: configDef.comments,
|
|
103
|
-
inputs: Object.entries(configDef.inputs).map(([childKey, childDef]) => (0, exports.convertInput)(childKey, childDef)),
|
|
104
|
-
}))
|
|
105
|
-
: undefined;
|
|
106
25
|
return Object.assign(Object.assign({}, (0, omit_1.default)(rest, [
|
|
107
26
|
"onPremControlled",
|
|
108
27
|
"permissionAndVisibilityType",
|
|
109
28
|
"visibleToOrgDeployer",
|
|
110
29
|
"writeOnly",
|
|
111
30
|
])), { key,
|
|
112
|
-
type, default: defaultValue !== null && defaultValue !== void 0 ? defaultValue : types_1.InputFieldDefaultMap[type], collection, label: typeof label === "string" ? label : label.value, keyLabel, onPremiseControlled:
|
|
31
|
+
type, default: defaultValue !== null && defaultValue !== void 0 ? defaultValue : types_1.InputFieldDefaultMap[type], collection, label: typeof label === "string" ? label : label.value, keyLabel, onPremiseControlled: ("onPremControlled" in rest && rest.onPremControlled) || undefined });
|
|
113
32
|
};
|
|
114
33
|
exports.convertInput = convertInput;
|
|
115
34
|
const TEMPLATE_VALUE_REGEX = /{{#(\w+)}}/g;
|
|
@@ -154,7 +73,7 @@ exports.convertTemplateInput = convertTemplateInput;
|
|
|
154
73
|
const convertAction = (actionKey, _a, hooks) => {
|
|
155
74
|
var { inputs = {}, perform } = _a, action = __rest(_a, ["inputs", "perform"]);
|
|
156
75
|
const convertedInputs = Object.entries(inputs).map(([key, value]) => (0, exports.convertInput)(key, value));
|
|
157
|
-
const inputCleaners = Object.entries(inputs).reduce((result, [key,
|
|
76
|
+
const inputCleaners = Object.entries(inputs).reduce((result, [key, { clean }]) => (Object.assign(Object.assign({}, result), { [key]: clean })), {});
|
|
158
77
|
return Object.assign(Object.assign({}, action), { key: actionKey, inputs: convertedInputs, perform: (0, perform_1.createPerform)(perform, {
|
|
159
78
|
inputCleaners,
|
|
160
79
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
@@ -165,27 +84,17 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
165
84
|
const { onInstanceDeploy, onInstanceDelete } = trigger;
|
|
166
85
|
const webhookLifecycleHandlers = "webhookLifecycleHandlers" in trigger ? trigger.webhookLifecycleHandlers : undefined;
|
|
167
86
|
const inputs = (_a = trigger.inputs) !== null && _a !== void 0 ? _a : {};
|
|
87
|
+
const isPollingTrigger = (0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger);
|
|
168
88
|
const triggerInputKeys = Object.keys(inputs);
|
|
169
89
|
const convertedTriggerInputs = Object.entries(inputs).map(([key, value]) => {
|
|
170
90
|
return (0, exports.convertInput)(key, value);
|
|
171
91
|
});
|
|
172
|
-
const triggerInputCleaners = Object.entries(inputs).reduce((result, [key,
|
|
92
|
+
const triggerInputCleaners = Object.entries(inputs).reduce((result, [key, { clean }]) => (Object.assign(Object.assign({}, result), { [key]: clean })), {});
|
|
173
93
|
let scheduleSupport = "scheduleSupport" in trigger ? trigger.scheduleSupport : "invalid";
|
|
174
|
-
const triggerResolver = "triggerResolver" in trigger ? trigger.triggerResolver : undefined;
|
|
175
|
-
const triggerResolverSupport = "triggerResolverSupport" in trigger && trigger.triggerResolverSupport !== undefined
|
|
176
|
-
? trigger.triggerResolverSupport
|
|
177
|
-
: triggerResolver
|
|
178
|
-
? "valid"
|
|
179
|
-
: "invalid";
|
|
180
|
-
if (triggerResolverSupport === "required" && !triggerResolver) {
|
|
181
|
-
throw new Error(`Trigger "${trigger.display.label}" declares triggerResolverSupport "required" but is missing triggerResolver.`);
|
|
182
|
-
}
|
|
183
|
-
if (triggerResolverSupport === "invalid" && triggerResolver) {
|
|
184
|
-
throw new Error(`Trigger "${trigger.display.label}" declares triggerResolver but triggerResolverSupport is "invalid".`);
|
|
185
|
-
}
|
|
186
94
|
let convertedActionInputs = [];
|
|
187
95
|
let performToUse;
|
|
188
|
-
if (
|
|
96
|
+
if (isPollingTrigger) {
|
|
97
|
+
// Pull inputs up from the action and make them available on the trigger
|
|
189
98
|
const { pollAction: action } = trigger;
|
|
190
99
|
let actionInputCleaners = {};
|
|
191
100
|
scheduleSupport = "required";
|
|
@@ -197,7 +106,7 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
197
106
|
accum.push((0, exports.convertInput)(key, value));
|
|
198
107
|
return accum;
|
|
199
108
|
}, []);
|
|
200
|
-
actionInputCleaners = Object.entries(action.inputs).reduce((result, [key,
|
|
109
|
+
actionInputCleaners = Object.entries(action.inputs).reduce((result, [key, { clean }]) => (Object.assign(Object.assign({}, result), { [key]: clean })), {});
|
|
201
110
|
}
|
|
202
111
|
const combinedCleaners = Object.assign({}, actionInputCleaners, triggerInputCleaners);
|
|
203
112
|
performToUse = (0, perform_1.createPollingPerform)(trigger, {
|
|
@@ -211,11 +120,11 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
211
120
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
212
121
|
});
|
|
213
122
|
}
|
|
214
|
-
const result = Object.assign(Object.assign(Object.assign(
|
|
123
|
+
const result = Object.assign(Object.assign(Object.assign({}, trigger), { key: triggerKey, inputs: convertedTriggerInputs.concat(convertedActionInputs), perform: performToUse, scheduleSupport, synchronousResponseSupport: "synchronousResponseSupport" in trigger
|
|
215
124
|
? trigger.synchronousResponseSupport
|
|
216
125
|
: scheduleSupport === "invalid"
|
|
217
126
|
? "valid"
|
|
218
|
-
: "invalid"
|
|
127
|
+
: "invalid" }), (isPollingTrigger ? { isPollingTrigger: true } : {}));
|
|
219
128
|
if (onInstanceDeploy) {
|
|
220
129
|
result.onInstanceDeploy = (0, perform_1.createPerform)(onInstanceDeploy, {
|
|
221
130
|
inputCleaners: triggerInputCleaners,
|
|
@@ -249,7 +158,7 @@ exports.convertTrigger = convertTrigger;
|
|
|
249
158
|
const convertDataSource = (dataSourceKey, _a, hooks) => {
|
|
250
159
|
var { inputs = {}, perform } = _a, dataSource = __rest(_a, ["inputs", "perform"]);
|
|
251
160
|
const convertedInputs = Object.entries(inputs).map(([key, value]) => (0, exports.convertInput)(key, value));
|
|
252
|
-
const inputCleaners = Object.entries(inputs).reduce((result, [key,
|
|
161
|
+
const inputCleaners = Object.entries(inputs).reduce((result, [key, { clean }]) => (Object.assign(Object.assign({}, result), { [key]: clean })), {});
|
|
253
162
|
return Object.assign(Object.assign({}, dataSource), { key: dataSourceKey, inputs: convertedInputs, perform: (0, perform_1.createPerform)(perform, {
|
|
254
163
|
inputCleaners,
|
|
255
164
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
@@ -29,12 +29,6 @@ const integration_1 = require("./integration");
|
|
|
29
29
|
const perform_1 = require("./perform");
|
|
30
30
|
exports.CONCURRENCY_LIMIT_MAX = 15;
|
|
31
31
|
exports.CONCURRENCY_LIMIT_MIN = 2;
|
|
32
|
-
const validateFlowResolverBatchSize = (flowName, configName, resolver) => {
|
|
33
|
-
if (!resolver) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
return { batchSize: (0, convertComponent_1.validateBatchSize)(flowName, configName, resolver.batchSize) };
|
|
37
|
-
};
|
|
38
32
|
const convertIntegration = (definition) => {
|
|
39
33
|
var _a, _b, _c;
|
|
40
34
|
// Generate a unique reference key that will be used to reference the
|
|
@@ -347,6 +341,15 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
347
341
|
if (!flow.onTrigger) {
|
|
348
342
|
publicSupplementalComponent = flow.schedule ? "schedule" : "webhook";
|
|
349
343
|
}
|
|
344
|
+
// The step action points at the CNI-generated wrapper trigger rather than
|
|
345
|
+
// the referenced component's trigger. When the flow references a component
|
|
346
|
+
// trigger, still carry that reference's configured input values onto the
|
|
347
|
+
// step so the wrapper trigger receives them as params (and can forward them
|
|
348
|
+
// to the referenced trigger via invokeTrigger).
|
|
349
|
+
if ((0, types_1.isComponentReference)(flow.onTrigger)) {
|
|
350
|
+
const { inputs } = convertComponentReference(flow.onTrigger, componentRegistry, "triggers");
|
|
351
|
+
triggerStep.inputs = inputs;
|
|
352
|
+
}
|
|
350
353
|
triggerStep.action = {
|
|
351
354
|
key: flowFunctionKey(flow.name, "onTrigger"),
|
|
352
355
|
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
@@ -409,10 +412,6 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
409
412
|
}
|
|
410
413
|
: {}));
|
|
411
414
|
}
|
|
412
|
-
const triggerResolver = "triggerResolver" in flow ? flow.triggerResolver : undefined;
|
|
413
|
-
if (triggerResolver) {
|
|
414
|
-
result.triggerResolver = validateFlowResolverBatchSize(flow.name, "triggerResolver", triggerResolver);
|
|
415
|
-
}
|
|
416
415
|
const actionStep = {
|
|
417
416
|
action: {
|
|
418
417
|
key: flowFunctionKey(flow.name, "onExecution"),
|
|
@@ -635,6 +634,22 @@ const invokeTriggerComponentInput = (componentRef, onTrigger, eventName) => {
|
|
|
635
634
|
};
|
|
636
635
|
};
|
|
637
636
|
exports.invokeTriggerComponentInput = invokeTriggerComponentInput;
|
|
637
|
+
/* When a flow references a component trigger but also defines on* lifecycle
|
|
638
|
+
* behavior, the trigger is wrapped in a generated CNI component trigger. That
|
|
639
|
+
* wrapper must declare the referenced trigger's inputs so the platform passes
|
|
640
|
+
* the step's configured values through as params (which the wrapper then
|
|
641
|
+
* forwards to the referenced trigger via invokeTrigger). */
|
|
642
|
+
const wrapperTriggerInputsFromReference = (onTrigger, componentRegistry) => {
|
|
643
|
+
var _a, _b, _c;
|
|
644
|
+
if (!(0, types_1.isComponentReference)(onTrigger)) {
|
|
645
|
+
return [];
|
|
646
|
+
}
|
|
647
|
+
const manifestInputs = (_c = (_b = (_a = componentRegistry[onTrigger.component]) === null || _a === void 0 ? void 0 : _a.triggers) === null || _b === void 0 ? void 0 : _b[onTrigger.key]) === null || _c === void 0 ? void 0 : _c.inputs;
|
|
648
|
+
if (!manifestInputs) {
|
|
649
|
+
return [];
|
|
650
|
+
}
|
|
651
|
+
return Object.entries(manifestInputs).map(([key, input]) => (Object.assign(Object.assign(Object.assign({ key, label: key, type: input.inputType }, (input.collection ? { collection: input.collection } : {})), (input.default !== undefined ? { default: input.default } : {})), (input.required !== undefined ? { required: input.required } : {}))));
|
|
652
|
+
};
|
|
638
653
|
/** Type guard to narrow trigger perform functions based on triggerType.
|
|
639
654
|
* Since TriggerPerformFunction and CodeNativePollingTriggerPerformFunction are
|
|
640
655
|
* structurally identical, TypeScript cannot distinguish them. This guard uses
|
|
@@ -680,11 +695,7 @@ function generateTriggerPerformFn(params) {
|
|
|
680
695
|
case "standard":
|
|
681
696
|
return (0, perform_1.createCNIPerform)({ componentRegistry, onTrigger });
|
|
682
697
|
case "component-ref":
|
|
683
|
-
return (0, perform_1.createCNIComponentRefPerform)({
|
|
684
|
-
componentRegistry,
|
|
685
|
-
componentRef,
|
|
686
|
-
onTrigger,
|
|
687
|
-
});
|
|
698
|
+
return (0, perform_1.createCNIComponentRefPerform)({ componentRegistry, componentRef, onTrigger });
|
|
688
699
|
default:
|
|
689
700
|
throw new Error(`Invalid trigger configuration detected: ${JSON.stringify(params, null, 2)}`);
|
|
690
701
|
}
|
|
@@ -753,7 +764,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
753
764
|
inputs: [],
|
|
754
765
|
} });
|
|
755
766
|
}, {});
|
|
756
|
-
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType,
|
|
767
|
+
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, webhookLifecycleHandlers, schedule, triggerType, }) => {
|
|
757
768
|
if (!flowUsesWrapperTrigger({
|
|
758
769
|
onTrigger,
|
|
759
770
|
onInstanceDelete,
|
|
@@ -788,21 +799,26 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
788
799
|
const deployFn = generateTriggerEventWrapperFn(ref, onTrigger, "onInstanceDeploy", componentRegistry, onInstanceDeploy);
|
|
789
800
|
const webhookCreateFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookCreate", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.create);
|
|
790
801
|
const webhookDeleteFn = generateTriggerEventWrapperFn(ref, onTrigger, "webhookDelete", componentRegistry, webhookLifecycleHandlers === null || webhookLifecycleHandlers === void 0 ? void 0 : webhookLifecycleHandlers.delete);
|
|
791
|
-
return Object.assign(Object.assign({}, result), { [key]:
|
|
802
|
+
return Object.assign(Object.assign({}, result), { [key]: {
|
|
803
|
+
key,
|
|
804
|
+
display: {
|
|
792
805
|
label: `${name} - onTrigger`,
|
|
793
806
|
description: "The function that will be executed by the flow to return an HTTP response.",
|
|
794
|
-
},
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
807
|
+
},
|
|
808
|
+
perform: performFn,
|
|
809
|
+
onInstanceDeploy: deployFn,
|
|
810
|
+
hasOnInstanceDeploy: !!deployFn,
|
|
811
|
+
onInstanceDelete: deleteFn,
|
|
812
|
+
hasOnInstanceDelete: !!deleteFn,
|
|
813
|
+
webhookCreate: webhookCreateFn,
|
|
814
|
+
hasWebhookCreateFunction: !!webhookCreateFn,
|
|
815
|
+
webhookDelete: webhookDeleteFn,
|
|
816
|
+
hasWebhookDeleteFunction: !!webhookDeleteFn,
|
|
817
|
+
inputs: wrapperTriggerInputsFromReference(onTrigger, componentRegistry),
|
|
818
|
+
scheduleSupport: triggerType === "polling" ? "required" : "valid",
|
|
819
|
+
synchronousResponseSupport: "valid",
|
|
820
|
+
isPollingTrigger: triggerType === "polling",
|
|
821
|
+
} });
|
|
806
822
|
}, {});
|
|
807
823
|
const convertedDataSources = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
808
824
|
if (!(0, types_1.isDataSourceDefinitionConfigVar)(configVar)) {
|
|
@@ -112,8 +112,8 @@ interface HttpResponse {
|
|
|
112
112
|
headers?: Record<string, string>;
|
|
113
113
|
body?: string;
|
|
114
114
|
}
|
|
115
|
-
interface TriggerBaseResult
|
|
116
|
-
payload:
|
|
115
|
+
interface TriggerBaseResult {
|
|
116
|
+
payload: TriggerPayload;
|
|
117
117
|
response?: HttpResponse;
|
|
118
118
|
instanceState?: Record<string, unknown>;
|
|
119
119
|
crossFlowState?: Record<string, unknown>;
|
|
@@ -122,18 +122,12 @@ interface TriggerBaseResult<TPayload extends TriggerPayload = TriggerPayload> {
|
|
|
122
122
|
failed?: boolean;
|
|
123
123
|
error?: Record<string, unknown>;
|
|
124
124
|
}
|
|
125
|
-
interface TriggerBranchingResult
|
|
125
|
+
interface TriggerBranchingResult extends TriggerBaseResult {
|
|
126
126
|
branch: string;
|
|
127
127
|
}
|
|
128
|
-
export type TriggerResult
|
|
128
|
+
export type TriggerResult = TriggerBranchingResult | TriggerBaseResult | undefined;
|
|
129
129
|
export type TriggerEventFunctionResult = TriggerEventFunctionReturn | void;
|
|
130
130
|
export type TriggerEventFunction = (context: ActionContext, params: Record<string, unknown>) => Promise<TriggerEventFunctionResult>;
|
|
131
|
-
/**
|
|
132
|
-
* Wire format the platform expects for a trigger. Note: function references
|
|
133
|
-
* (perform, resolveTriggerItems, getNextDiscoveryState, ...) don't survive JSON
|
|
134
|
-
* serialization, so each callback has a paired `hasXxx: boolean` flag the
|
|
135
|
-
* server reads to detect presence. Keep the flag and its callback in sync.
|
|
136
|
-
*/
|
|
137
131
|
export interface Trigger<TInputs extends Inputs, TActionInputs extends Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerPerformResult<TAllowsBranching, TPayload> = TriggerPerformResult<TAllowsBranching, TPayload>> {
|
|
138
132
|
key: string;
|
|
139
133
|
display: DisplayDefinition & {
|
|
@@ -161,12 +155,6 @@ export interface Trigger<TInputs extends Inputs, TActionInputs extends Inputs, T
|
|
|
161
155
|
hasWebhookDeleteFunction?: boolean;
|
|
162
156
|
scheduleSupport: TriggerOptionChoice;
|
|
163
157
|
synchronousResponseSupport: TriggerOptionChoice;
|
|
164
|
-
triggerResolverSupport?: TriggerOptionChoice;
|
|
165
|
-
triggerResolverDefaultBatchSize?: number;
|
|
166
|
-
resolveTriggerItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => unknown[];
|
|
167
|
-
hasResolveTriggerItems?: boolean;
|
|
168
|
-
getNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => Record<string, unknown> | null;
|
|
169
|
-
hasGetNextDiscoveryState?: boolean;
|
|
170
158
|
examplePayload?: unknown;
|
|
171
159
|
isCommonTrigger?: boolean;
|
|
172
160
|
isPollingTrigger?: boolean;
|
|
@@ -274,8 +262,5 @@ export interface Input {
|
|
|
274
262
|
onPremiseControlled?: boolean;
|
|
275
263
|
dataSource?: string;
|
|
276
264
|
shown?: boolean;
|
|
277
|
-
/** Nested children. For `structuredObject`, the declared inputs; for
|
|
278
|
-
* `dynamicObject`, one `structuredObject` per configuration. */
|
|
279
|
-
inputs?: Input[];
|
|
280
265
|
}
|
|
281
266
|
export * from "./asyncContext";
|
|
@@ -1,40 +1,11 @@
|
|
|
1
1
|
import type { ConditionalExpression } from "./conditional-logic";
|
|
2
|
-
import type { Connection,
|
|
3
|
-
/** Resolves a single InputFieldDefinition's runtime value type.
|
|
4
|
-
* - structuredObject: record of declared children's resolved value types.
|
|
5
|
-
* - dynamicObject: discriminated union keyed by the selected configuration,
|
|
6
|
-
* with the configuration's resolved inputs nested under `values` to avoid
|
|
7
|
-
* collisions with the `configuration` discriminant key.
|
|
8
|
-
* The depth caps (`LeafInputFieldDefinition`, `StructuredOrLeafInputFieldDefinition`)
|
|
9
|
-
* prevent unbounded recursion. */
|
|
10
|
-
type InputValue<T> = T extends StructuredObjectInputField ? {
|
|
11
|
-
[K in keyof T["inputs"]]: InputValue<T["inputs"][K]>;
|
|
12
|
-
} : T extends DynamicObjectInputField ? {
|
|
13
|
-
[C in keyof T["configurations"]]: {
|
|
14
|
-
configuration: C;
|
|
15
|
-
values: {
|
|
16
|
-
[K in keyof T["configurations"][C]["inputs"]]: InputValue<T["configurations"][C]["inputs"][K]>;
|
|
17
|
-
};
|
|
18
|
-
};
|
|
19
|
-
}[keyof T["configurations"]] : T extends {
|
|
20
|
-
clean: InputCleanFunction<any>;
|
|
21
|
-
} ? ReturnType<T["clean"]> : T extends {
|
|
22
|
-
type: "connection";
|
|
23
|
-
collection?: InputFieldCollection;
|
|
24
|
-
} ? ExtractValue<Connection, T["collection"]> : T extends {
|
|
25
|
-
type: "conditional";
|
|
26
|
-
collection?: InputFieldCollection;
|
|
27
|
-
} ? ExtractValue<ConditionalExpression, T["collection"]> : T extends {
|
|
28
|
-
default?: unknown;
|
|
29
|
-
collection?: InputFieldCollection;
|
|
30
|
-
} ? ExtractValue<T["default"], T["collection"]> : unknown;
|
|
2
|
+
import type { Connection, InputCleanFunction, InputFieldCollection, Inputs, KeyValuePair } from "./Inputs";
|
|
31
3
|
/**
|
|
32
4
|
* Collection of input parameters.
|
|
33
5
|
* Inputs can be static values, references to config variables, or
|
|
34
6
|
* references to previous steps' outputs.
|
|
35
7
|
*/
|
|
36
8
|
export type ActionInputParameters<TInputs extends Inputs> = {
|
|
37
|
-
[Property in keyof TInputs]:
|
|
9
|
+
[Property in keyof TInputs]: TInputs[Property]["clean"] extends InputCleanFunction<any> ? ReturnType<TInputs[Property]["clean"]> : TInputs[Property]["type"] extends "connection" ? ExtractValue<Connection, TInputs[Property]["collection"]> : TInputs[Property]["type"] extends "conditional" ? ExtractValue<ConditionalExpression, TInputs[Property]["collection"]> : ExtractValue<TInputs[Property]["default"], TInputs[Property]["collection"]>;
|
|
38
10
|
};
|
|
39
11
|
export type ExtractValue<TType, TCollection extends InputFieldCollection | undefined> = TCollection extends "keyvaluelist" ? KeyValuePair<TType>[] : TCollection extends "valuelist" ? TType[] : TType;
|
|
40
|
-
export {};
|
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -63,8 +63,6 @@ export type JSONForm = {
|
|
|
63
63
|
};
|
|
64
64
|
export type DynamicObjectSelection = string;
|
|
65
65
|
export type DynamicFieldSelection = string;
|
|
66
|
-
export type StructuredObject = Record<string, unknown>;
|
|
67
|
-
export type DynamicObject = Record<string, unknown>;
|
|
68
66
|
/** InputField type enumeration. */
|
|
69
67
|
export type InputFieldType = InputFieldDefinition["type"];
|
|
70
68
|
export declare const InputFieldDefaultMap: Record<InputFieldType, string | undefined>;
|
|
@@ -85,7 +83,7 @@ export type OnPremConnectionInput = {
|
|
|
85
83
|
*/
|
|
86
84
|
onPremControlled: true;
|
|
87
85
|
} & ConnectionInput;
|
|
88
|
-
export type InputFieldDefinition = StringInputField | DataInputField | TextInputField | PasswordInputField | BooleanInputField | CodeInputField | ConditionalInputField | ConnectionInputField | ConnectionTemplateInputField | ObjectSelectionInputField | ObjectFieldMapInputField | JSONFormInputField | DynamicObjectSelectionInputField | DynamicFieldSelectionInputField | DateInputField | DateTimeInputField | FlowInputField
|
|
86
|
+
export type InputFieldDefinition = StringInputField | DataInputField | TextInputField | PasswordInputField | BooleanInputField | CodeInputField | ConditionalInputField | ConnectionInputField | ConnectionTemplateInputField | ObjectSelectionInputField | ObjectFieldMapInputField | JSONFormInputField | DynamicObjectSelectionInputField | DynamicFieldSelectionInputField | DateInputField | DateTimeInputField | FlowInputField;
|
|
89
87
|
export type InputCleanFunction<TValue, TResult = TValue> = (value: TValue) => TResult;
|
|
90
88
|
interface BaseInputField {
|
|
91
89
|
/** Name of this field to present in the UI. */
|
|
@@ -291,50 +289,6 @@ export type DateTimeInputField = BaseInputField & {
|
|
|
291
289
|
/** Clean function. */
|
|
292
290
|
clean?: InputCleanFunction<unknown>;
|
|
293
291
|
} & CollectionOptions<string>;
|
|
294
|
-
/** `InputFieldDefinition` minus container input types and connection
|
|
295
|
-
* pickers. Connections resolve to config-var references outside the
|
|
296
|
-
* parent's value tree, so they're only valid at the top level — never as
|
|
297
|
-
* a child of a structuredObject or a dynamicObject configuration. */
|
|
298
|
-
export type LeafInputFieldDefinition = Exclude<InputFieldDefinition, StructuredObjectInputField | DynamicObjectInputField | ConnectionInputField | ConnectionTemplateInputField>;
|
|
299
|
-
/** `LeafInputFieldDefinition` plus `StructuredObjectInputField`; used
|
|
300
|
-
* inside a dynamicObject's `configurations.<key>.inputs` to allow leaves
|
|
301
|
-
* and structuredObject children while still rejecting nested
|
|
302
|
-
* dynamicObjects and connection pickers. */
|
|
303
|
-
export type StructuredOrLeafInputFieldDefinition = LeafInputFieldDefinition | StructuredObjectInputField;
|
|
304
|
-
/** Groups related primitive inputs under a single named container.
|
|
305
|
-
* Nesting is capped at one level. Connection pickers are rejected as
|
|
306
|
-
* children — they may only appear at the top level. */
|
|
307
|
-
export type StructuredObjectInputField = Omit<BaseInputField, "dataSource"> & {
|
|
308
|
-
/** Data type the input will collect. */
|
|
309
|
-
type: "structuredObject";
|
|
310
|
-
/** Nested input fields keyed by their local key. */
|
|
311
|
-
inputs: Record<string, LeafInputFieldDefinition>;
|
|
312
|
-
};
|
|
313
|
-
/** A single configuration within a dynamicObject. Each configuration declares
|
|
314
|
-
* a labeled set of inputs that become available when this configuration is
|
|
315
|
-
* selected at runtime. */
|
|
316
|
-
export interface DynamicObjectConfiguration {
|
|
317
|
-
/** Name of this configuration to present in the UI. */
|
|
318
|
-
label: {
|
|
319
|
-
key: string;
|
|
320
|
-
value: string;
|
|
321
|
-
} | string;
|
|
322
|
-
/** Additional text to give guidance to the user when this configuration is selected. */
|
|
323
|
-
comments?: string;
|
|
324
|
-
/** Inputs that become available when this configuration is selected. */
|
|
325
|
-
inputs: Record<string, StructuredOrLeafInputFieldDefinition>;
|
|
326
|
-
}
|
|
327
|
-
/** Presents a discriminated set of input groups; the user picks a configuration
|
|
328
|
-
* at integration-build time and that configuration's inputs become available.
|
|
329
|
-
* Nesting is capped: configurations may contain structuredObject children
|
|
330
|
-
* (depth-1) but never another dynamicObject. */
|
|
331
|
-
export type DynamicObjectInputField = Omit<BaseInputField, "dataSource"> & {
|
|
332
|
-
/** Data type the input will collect. */
|
|
333
|
-
type: "dynamicObject";
|
|
334
|
-
/** Available configurations keyed by their local key (used as the
|
|
335
|
-
* runtime discriminant). */
|
|
336
|
-
configurations: Record<string, DynamicObjectConfiguration>;
|
|
337
|
-
};
|
|
338
292
|
/** Defines a single Choice option for a InputField. */
|
|
339
293
|
export interface InputFieldChoice {
|
|
340
294
|
/** Label to display for this Choice. */
|
package/dist/types/Inputs.js
CHANGED
|
@@ -4,13 +4,13 @@ import type { ComponentRegistry, ConfigVarExpression, TriggerReference, ValueExp
|
|
|
4
4
|
import type { ConfigPages, UserLevelConfigPages } from "./ConfigPages";
|
|
5
5
|
import type { ConfigVars } from "./ConfigVars";
|
|
6
6
|
import type { FlowDefinitionFlowSchema } from "./FlowSchemas";
|
|
7
|
-
import type {
|
|
7
|
+
import type { Inputs } from "./Inputs";
|
|
8
8
|
import type { PollingTriggerPerformFunction } from "./PollingTriggerDefinition";
|
|
9
9
|
import type { ScopedConfigVarMap } from "./ScopedConfigVars";
|
|
10
10
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
11
11
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
12
12
|
import type { TriggerPerformFunction } from "./TriggerPerformFunction";
|
|
13
|
-
import type {
|
|
13
|
+
import type { TriggerResult } from "./TriggerResult";
|
|
14
14
|
/**
|
|
15
15
|
* Defines attributes of a code-native integration. See
|
|
16
16
|
* https://prismatic.io/docs/integrations/code-native/
|
|
@@ -117,13 +117,6 @@ interface FlowBase<TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
|
117
117
|
*/
|
|
118
118
|
organizationApiKeys?: string[];
|
|
119
119
|
testApiKeys?: string[];
|
|
120
|
-
/**
|
|
121
|
-
* Trigger resolver configuration: batches the records returned by the
|
|
122
|
-
* trigger into parallel dispatches. When using an existing component
|
|
123
|
-
* trigger, that trigger must declare `triggerResolverSupport`. CNI flows
|
|
124
|
-
* infer support from the resolver's presence.
|
|
125
|
-
*/
|
|
126
|
-
triggerResolver?: TriggerResolverConfig<ConfigVars, TTriggerPayload>;
|
|
127
120
|
/** Error handling configuration. */
|
|
128
121
|
errorConfig?: StepErrorConfig;
|
|
129
122
|
/** Optional schemas definitions for the flow. Currently only for use with AI agents. */
|
|
@@ -253,15 +246,4 @@ export type EndpointType = "flow_specific" | "instance_specific" | "shared_insta
|
|
|
253
246
|
export type EndpointSecurityType = "unsecured" | "customer_optional" | "customer_required" | "organization";
|
|
254
247
|
/** Choices of Step Error Handlers that define the behavior when a step error occurs. */
|
|
255
248
|
export type StepErrorHandlerType = "fail" | "ignore" | "retry";
|
|
256
|
-
/** Configures how trigger items are batched when the trigger supports a resolver. */
|
|
257
|
-
export type TriggerResolverConfig<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TItem = unknown> = {
|
|
258
|
-
/** Number of items per batch. Must be an integer >= 1. `1` dispatches each item individually; `>1` groups items into batches. */
|
|
259
|
-
batchSize: number;
|
|
260
|
-
/** Extracts an array of items from the trigger result for batched dispatch. Receives the same context as the trigger's perform function. */
|
|
261
|
-
resolveItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => TItem[];
|
|
262
|
-
/** Called after each trigger run. When defined and returns a non-null object, the platform
|
|
263
|
-
* queues another pagination round (re-invokes the trigger) and stamps the returned object
|
|
264
|
-
* onto `payload.discoveryState` for that next invocation. Return `null` to stop. */
|
|
265
|
-
getNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => Record<string, unknown> | null;
|
|
266
|
-
};
|
|
267
249
|
export {};
|
|
@@ -4,7 +4,6 @@ import type { ActionContext } from "./ActionPerformFunction";
|
|
|
4
4
|
import type { ActionPerformReturn } from "./ActionPerformReturn";
|
|
5
5
|
import type { ActionDisplayDefinition } from "./DisplayDefinition";
|
|
6
6
|
import type { ConfigVarResultCollection, Inputs } from "./Inputs";
|
|
7
|
-
import type { TriggerResolverDecl } from "./TriggerDefinition";
|
|
8
7
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
9
8
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
10
9
|
import type { TriggerResult } from "./TriggerResult";
|
|
@@ -19,12 +18,8 @@ export type PollingTriggerPerformFunction<TInputs extends Inputs, TActionInputs
|
|
|
19
18
|
/**
|
|
20
19
|
* PollingTriggerDefinition is the type of the object that is passed in to `pollingTrigger` function to
|
|
21
20
|
* define a component trigger.
|
|
22
|
-
*
|
|
23
|
-
* Composed from `PollingTriggerDefinitionBase` plus `TriggerResolverDecl`, which
|
|
24
|
-
* enforces the resolver support relationship at the type level.
|
|
25
21
|
*/
|
|
26
|
-
export
|
|
27
|
-
interface PollingTriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TActionInputs extends Inputs = Inputs, TAction extends ActionDefinition<TActionInputs> = ActionDefinition<TActionInputs>, TCombinedInputs extends TInputs & TActionInputs = TInputs & TActionInputs> {
|
|
22
|
+
export interface PollingTriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TPayload> = TriggerResult<TAllowsBranching, TPayload>, TActionInputs extends Inputs = Inputs, TAction extends ActionDefinition<TActionInputs> = ActionDefinition<TActionInputs>, TCombinedInputs extends TInputs & TActionInputs = TInputs & TActionInputs> {
|
|
28
23
|
triggerType?: "polling";
|
|
29
24
|
/** Defines how the Action is displayed in the Prismatic interface. */
|
|
30
25
|
display: ActionDisplayDefinition;
|
|
@@ -44,4 +39,3 @@ interface PollingTriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigV
|
|
|
44
39
|
examplePayload?: Awaited<ReturnType<this["perform"]>>;
|
|
45
40
|
}
|
|
46
41
|
export declare const isPollingTriggerDefinition: (ref: unknown) => ref is PollingTriggerDefinition;
|
|
47
|
-
export {};
|
|
@@ -1,51 +1,18 @@
|
|
|
1
|
-
import type { ActionContext } from "./ActionPerformFunction";
|
|
2
1
|
import type { ActionDisplayDefinition } from "./DisplayDefinition";
|
|
3
2
|
import type { ConfigVarResultCollection, Inputs } from "./Inputs";
|
|
4
3
|
import type { TriggerEventFunction } from "./TriggerEventFunction";
|
|
5
4
|
import type { TriggerPayload } from "./TriggerPayload";
|
|
6
5
|
import type { TriggerPerformFunction } from "./TriggerPerformFunction";
|
|
7
|
-
import type {
|
|
8
|
-
/**
|
|
9
|
-
* Encodes the relationship between `triggerResolverSupport` and `triggerResolver`:
|
|
10
|
-
* - absent or `"invalid"`: no resolver allowed
|
|
11
|
-
* - `"valid"`: resolver optional
|
|
12
|
-
* - `"required"`: resolver required
|
|
13
|
-
*/
|
|
14
|
-
export type TriggerResolverDecl<TConfigVars extends ConfigVarResultCollection, TPayload extends TriggerPayload> = {
|
|
15
|
-
triggerResolverSupport?: "invalid" | undefined;
|
|
16
|
-
triggerResolver?: undefined;
|
|
17
|
-
} | {
|
|
18
|
-
triggerResolverSupport: "valid";
|
|
19
|
-
triggerResolver?: TriggerResolver<TConfigVars, TPayload>;
|
|
20
|
-
} | {
|
|
21
|
-
triggerResolverSupport: "required";
|
|
22
|
-
triggerResolver: TriggerResolver<TConfigVars, TPayload>;
|
|
23
|
-
};
|
|
6
|
+
import type { TriggerResult } from "./TriggerResult";
|
|
24
7
|
declare const optionChoices: readonly ["invalid", "valid", "required"];
|
|
25
8
|
export type TriggerOptionChoice = (typeof optionChoices)[number];
|
|
26
9
|
export declare const TriggerOptionChoices: TriggerOptionChoice[];
|
|
27
|
-
export interface TriggerResolver<TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TPayload extends TriggerPayload = TriggerPayload, TItem = unknown> {
|
|
28
|
-
/** Author-declared defaults for how this trigger's items are batched. */
|
|
29
|
-
default: {
|
|
30
|
-
/** Number of items per batch. Must be an integer >= 1. `1` dispatches each item individually; `>1` groups items into batches. */
|
|
31
|
-
batchSize: number;
|
|
32
|
-
};
|
|
33
|
-
/** Extracts an array of items from the trigger result for batched dispatch. Receives the same context as the trigger's perform function. */
|
|
34
|
-
resolveItems?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => TItem[];
|
|
35
|
-
/** Extracts data from the trigger result to be passed to the next trigger invocation to fetch another page of data. */
|
|
36
|
-
getNextDiscoveryState?: (context: ActionContext<TConfigVars>, result: TriggerBaseResult<TPayload>) => Record<string, unknown> | null;
|
|
37
|
-
}
|
|
38
10
|
/**
|
|
39
11
|
* TriggerDefinition is the type of the object that is passed in to `trigger` function to
|
|
40
12
|
* define a component trigger. See
|
|
41
13
|
* https://prismatic.io/docs/custom-connectors/triggers/
|
|
42
|
-
*
|
|
43
|
-
* Composed from `TriggerDefinitionBase` (static fields) plus the discriminated union
|
|
44
|
-
* `TriggerResolverDecl`, which enforces the resolver support relationship at the type
|
|
45
|
-
* level.
|
|
46
14
|
*/
|
|
47
|
-
export
|
|
48
|
-
interface TriggerDefinitionBase<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload> = TriggerResult<TAllowsBranching, TriggerPayload>> {
|
|
15
|
+
export interface TriggerDefinition<TInputs extends Inputs = Inputs, TConfigVars extends ConfigVarResultCollection = ConfigVarResultCollection, TAllowsBranching extends boolean = boolean, TResult extends TriggerResult<TAllowsBranching, TriggerPayload> = TriggerResult<TAllowsBranching, TriggerPayload>> {
|
|
49
16
|
/** Defines how the trigger is displayed in the Prismatic UI. */
|
|
50
17
|
display: ActionDisplayDefinition;
|
|
51
18
|
/** Function to perform when this trigger is invoked. */
|
|
@@ -3,13 +3,8 @@ import type { FlowAttributes } from "./FlowAttributes";
|
|
|
3
3
|
import type { InstanceAttributes } from "./InstanceAttributes";
|
|
4
4
|
import type { IntegrationAttributes } from "./IntegrationAttributes";
|
|
5
5
|
import type { UserAttributes } from "./UserAttributes";
|
|
6
|
-
/** Represents a Trigger Payload, which is data passed into a Trigger to invoke an Integration execution.
|
|
7
|
-
|
|
8
|
-
* The optional `TDiscoveryState` parameter types the `discoveryState` field, so authors who
|
|
9
|
-
* declare a pagination-state shape on their `getNextDiscoveryState` resolver can read back
|
|
10
|
-
* the same shape on the next round's payload. Defaults to `Record<string, unknown>`.
|
|
11
|
-
*/
|
|
12
|
-
export interface TriggerPayload<TDiscoveryState extends Record<string, unknown> = Record<string, unknown>> {
|
|
6
|
+
/** Represents a Trigger Payload, which is data passed into a Trigger to invoke an Integration execution. */
|
|
7
|
+
export interface TriggerPayload {
|
|
13
8
|
/** The headers sent in the webhook request. */
|
|
14
9
|
headers: {
|
|
15
10
|
[key: string]: string;
|
|
@@ -55,8 +50,4 @@ export interface TriggerPayload<TDiscoveryState extends Record<string, unknown>
|
|
|
55
50
|
startedAt: string;
|
|
56
51
|
/** Determines whether the execution will run in debug mode. */
|
|
57
52
|
globalDebug: boolean;
|
|
58
|
-
/** Managed by the execution when this trigger invocation is a paginated re-run.
|
|
59
|
-
* Contains the object returned by `getNextDiscoveryState` from the previous round.
|
|
60
|
-
* Absent on the initial invocation. */
|
|
61
|
-
discoveryState?: TDiscoveryState;
|
|
62
53
|
}
|