@prismatic-io/spectral 10.18.7-preview.4 → 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 -7
- package/dist/serverTypes/convertComponent.js +12 -63
- package/dist/serverTypes/convertIntegration.js +26 -1
- package/dist/serverTypes/index.d.ts +0 -3
- package/dist/types/ActionInputParameters.d.ts +2 -31
- package/dist/types/Inputs.d.ts +1 -47
- package/dist/types/Inputs.js +0 -2
- 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,13 +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
|
-
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;
|
|
11
5
|
export declare const _isValidTemplateValue: (template: string, inputs: {
|
|
12
6
|
[key: string]: ConnectionInput | ConnectionTemplateInputField;
|
|
13
7
|
}) => {
|
|
@@ -14,74 +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
|
-
const convertInput = (key, definition) => {
|
|
64
|
-
// Cast: the field union is wider than any single member; runtime guards below handle it.
|
|
65
|
-
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"]);
|
|
66
24
|
const keyLabel = collection === "keyvaluelist" && typeof label === "object" ? label.key : undefined;
|
|
67
|
-
const nestedInputs = type === "structuredObject" && childInputs
|
|
68
|
-
? Object.entries(childInputs).map(([childKey, childDef]) => (0, exports.convertInput)(childKey, childDef))
|
|
69
|
-
: type === "dynamicObject" && configurations
|
|
70
|
-
? Object.entries(configurations).map(([configKey, configDef]) => ({
|
|
71
|
-
key: configKey,
|
|
72
|
-
type: "structuredObject",
|
|
73
|
-
label: typeof configDef.label === "string" ? configDef.label : configDef.label.value,
|
|
74
|
-
comments: configDef.comments,
|
|
75
|
-
inputs: Object.entries(configDef.inputs).map(([childKey, childDef]) => (0, exports.convertInput)(childKey, childDef)),
|
|
76
|
-
}))
|
|
77
|
-
: undefined;
|
|
78
25
|
return Object.assign(Object.assign({}, (0, omit_1.default)(rest, [
|
|
79
26
|
"onPremControlled",
|
|
80
27
|
"permissionAndVisibilityType",
|
|
81
28
|
"visibleToOrgDeployer",
|
|
82
29
|
"writeOnly",
|
|
83
30
|
])), { key,
|
|
84
|
-
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 });
|
|
85
32
|
};
|
|
86
33
|
exports.convertInput = convertInput;
|
|
87
34
|
const TEMPLATE_VALUE_REGEX = /{{#(\w+)}}/g;
|
|
@@ -126,7 +73,7 @@ exports.convertTemplateInput = convertTemplateInput;
|
|
|
126
73
|
const convertAction = (actionKey, _a, hooks) => {
|
|
127
74
|
var { inputs = {}, perform } = _a, action = __rest(_a, ["inputs", "perform"]);
|
|
128
75
|
const convertedInputs = Object.entries(inputs).map(([key, value]) => (0, exports.convertInput)(key, value));
|
|
129
|
-
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 })), {});
|
|
130
77
|
return Object.assign(Object.assign({}, action), { key: actionKey, inputs: convertedInputs, perform: (0, perform_1.createPerform)(perform, {
|
|
131
78
|
inputCleaners,
|
|
132
79
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
@@ -137,15 +84,17 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
137
84
|
const { onInstanceDeploy, onInstanceDelete } = trigger;
|
|
138
85
|
const webhookLifecycleHandlers = "webhookLifecycleHandlers" in trigger ? trigger.webhookLifecycleHandlers : undefined;
|
|
139
86
|
const inputs = (_a = trigger.inputs) !== null && _a !== void 0 ? _a : {};
|
|
87
|
+
const isPollingTrigger = (0, PollingTriggerDefinition_1.isPollingTriggerDefinition)(trigger);
|
|
140
88
|
const triggerInputKeys = Object.keys(inputs);
|
|
141
89
|
const convertedTriggerInputs = Object.entries(inputs).map(([key, value]) => {
|
|
142
90
|
return (0, exports.convertInput)(key, value);
|
|
143
91
|
});
|
|
144
|
-
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 })), {});
|
|
145
93
|
let scheduleSupport = "scheduleSupport" in trigger ? trigger.scheduleSupport : "invalid";
|
|
146
94
|
let convertedActionInputs = [];
|
|
147
95
|
let performToUse;
|
|
148
|
-
if (
|
|
96
|
+
if (isPollingTrigger) {
|
|
97
|
+
// Pull inputs up from the action and make them available on the trigger
|
|
149
98
|
const { pollAction: action } = trigger;
|
|
150
99
|
let actionInputCleaners = {};
|
|
151
100
|
scheduleSupport = "required";
|
|
@@ -157,7 +106,7 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
157
106
|
accum.push((0, exports.convertInput)(key, value));
|
|
158
107
|
return accum;
|
|
159
108
|
}, []);
|
|
160
|
-
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 })), {});
|
|
161
110
|
}
|
|
162
111
|
const combinedCleaners = Object.assign({}, actionInputCleaners, triggerInputCleaners);
|
|
163
112
|
performToUse = (0, perform_1.createPollingPerform)(trigger, {
|
|
@@ -175,7 +124,7 @@ const convertTrigger = (triggerKey, trigger, hooks) => {
|
|
|
175
124
|
? trigger.synchronousResponseSupport
|
|
176
125
|
: scheduleSupport === "invalid"
|
|
177
126
|
? "valid"
|
|
178
|
-
: "invalid" }), (
|
|
127
|
+
: "invalid" }), (isPollingTrigger ? { isPollingTrigger: true } : {}));
|
|
179
128
|
if (onInstanceDeploy) {
|
|
180
129
|
result.onInstanceDeploy = (0, perform_1.createPerform)(onInstanceDeploy, {
|
|
181
130
|
inputCleaners: triggerInputCleaners,
|
|
@@ -209,7 +158,7 @@ exports.convertTrigger = convertTrigger;
|
|
|
209
158
|
const convertDataSource = (dataSourceKey, _a, hooks) => {
|
|
210
159
|
var { inputs = {}, perform } = _a, dataSource = __rest(_a, ["inputs", "perform"]);
|
|
211
160
|
const convertedInputs = Object.entries(inputs).map(([key, value]) => (0, exports.convertInput)(key, value));
|
|
212
|
-
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 })), {});
|
|
213
162
|
return Object.assign(Object.assign({}, dataSource), { key: dataSourceKey, inputs: convertedInputs, perform: (0, perform_1.createPerform)(perform, {
|
|
214
163
|
inputCleaners,
|
|
215
164
|
errorHandler: hooks === null || hooks === void 0 ? void 0 : hooks.error,
|
|
@@ -341,6 +341,15 @@ const convertFlow = (flow, componentRegistry, referenceKey) => {
|
|
|
341
341
|
if (!flow.onTrigger) {
|
|
342
342
|
publicSupplementalComponent = flow.schedule ? "schedule" : "webhook";
|
|
343
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
|
+
}
|
|
344
353
|
triggerStep.action = {
|
|
345
354
|
key: flowFunctionKey(flow.name, "onTrigger"),
|
|
346
355
|
component: codeNativeIntegrationComponentReference(referenceKey),
|
|
@@ -625,6 +634,22 @@ const invokeTriggerComponentInput = (componentRef, onTrigger, eventName) => {
|
|
|
625
634
|
};
|
|
626
635
|
};
|
|
627
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
|
+
};
|
|
628
653
|
/** Type guard to narrow trigger perform functions based on triggerType.
|
|
629
654
|
* Since TriggerPerformFunction and CodeNativePollingTriggerPerformFunction are
|
|
630
655
|
* structurally identical, TypeScript cannot distinguish them. This guard uses
|
|
@@ -789,7 +814,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
789
814
|
hasWebhookCreateFunction: !!webhookCreateFn,
|
|
790
815
|
webhookDelete: webhookDeleteFn,
|
|
791
816
|
hasWebhookDeleteFunction: !!webhookDeleteFn,
|
|
792
|
-
inputs:
|
|
817
|
+
inputs: wrapperTriggerInputsFromReference(onTrigger, componentRegistry),
|
|
793
818
|
scheduleSupport: triggerType === "polling" ? "required" : "valid",
|
|
794
819
|
synchronousResponseSupport: "valid",
|
|
795
820
|
isPollingTrigger: triggerType === "polling",
|
|
@@ -262,8 +262,5 @@ export interface Input {
|
|
|
262
262
|
onPremiseControlled?: boolean;
|
|
263
263
|
dataSource?: string;
|
|
264
264
|
shown?: boolean;
|
|
265
|
-
/** Nested children. For `structuredObject`, the declared inputs; for
|
|
266
|
-
* `dynamicObject`, one `structuredObject` per configuration. */
|
|
267
|
-
inputs?: Input[];
|
|
268
265
|
}
|
|
269
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