@prismatic-io/spectral 8.0.6 → 8.1.0-preview1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/clients/http/index.js +25 -2
- package/dist/index.d.ts +7 -7
- package/dist/serverTypes/convertIntegration.d.ts +2 -2
- package/dist/serverTypes/convertIntegration.js +81 -17
- package/dist/serverTypes/integration.d.ts +7 -10
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +1 -1
- package/dist/types/IntegrationDefinition.d.ts +79 -76
- package/dist/types/IntegrationDefinition.js +13 -62
- package/dist/util.d.ts +2 -1
- package/dist/util.js +25 -3
- package/package.json +7 -6
|
@@ -51,6 +51,7 @@ const lodash_1 = require("lodash");
|
|
|
51
51
|
const axios_1 = __importDefault(require("axios"));
|
|
52
52
|
const axios_retry_1 = __importStar(require("axios-retry"));
|
|
53
53
|
const form_data_1 = __importDefault(require("form-data"));
|
|
54
|
+
const object_sizeof_1 = __importDefault(require("object-sizeof"));
|
|
54
55
|
const __1 = require("../..");
|
|
55
56
|
const util_1 = __importDefault(require("../../util"));
|
|
56
57
|
const inputs_1 = require("./inputs");
|
|
@@ -103,11 +104,33 @@ const createClient = ({ baseUrl, responseType, headers, timeout, params, debug =
|
|
|
103
104
|
});
|
|
104
105
|
if (debug) {
|
|
105
106
|
client.interceptors.request.use((request) => {
|
|
106
|
-
|
|
107
|
+
const { baseURL, headers, method, timeout, url, data } = request;
|
|
108
|
+
const dataSize = (0, object_sizeof_1.default)(data);
|
|
109
|
+
console.log(util_1.default.types.toJSON({
|
|
110
|
+
type: "request",
|
|
111
|
+
baseURL,
|
|
112
|
+
url,
|
|
113
|
+
headers,
|
|
114
|
+
method,
|
|
115
|
+
timeout,
|
|
116
|
+
data: dataSize > 1024 * 10 || Buffer.isBuffer(data)
|
|
117
|
+
? `<data (${dataSize} bytes)>`
|
|
118
|
+
: data,
|
|
119
|
+
}, true, true));
|
|
107
120
|
return request;
|
|
108
121
|
});
|
|
109
122
|
client.interceptors.response.use((response) => {
|
|
110
|
-
|
|
123
|
+
const { headers, status, statusText, data } = response;
|
|
124
|
+
const dataSize = (0, object_sizeof_1.default)(data);
|
|
125
|
+
console.log(util_1.default.types.toJSON({
|
|
126
|
+
type: "response",
|
|
127
|
+
headers,
|
|
128
|
+
status,
|
|
129
|
+
statusText,
|
|
130
|
+
data: dataSize > 1024 * 10 || Buffer.isBuffer(data)
|
|
131
|
+
? `<data (${dataSize} bytes)>`
|
|
132
|
+
: data,
|
|
133
|
+
}, true, true));
|
|
111
134
|
return response;
|
|
112
135
|
});
|
|
113
136
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
* authors create inputs, actions, and components that can
|
|
4
4
|
* be processed by the Prismatic API.
|
|
5
5
|
*/
|
|
6
|
-
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar, ConfigPages, OnPremiseConnectionDefinition } from "./types";
|
|
6
|
+
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar, ConfigPages, OnPremiseConnectionDefinition, ScheduleConfigVar, ComponentSelector } from "./types";
|
|
7
7
|
import { convertComponent } from "./serverTypes/convert";
|
|
8
8
|
import { convertIntegration } from "./serverTypes/convertIntegration";
|
|
9
9
|
/**
|
|
@@ -14,42 +14,42 @@ import { convertIntegration } from "./serverTypes/convertIntegration";
|
|
|
14
14
|
* @param definition An IntegrationDefinition type object.
|
|
15
15
|
* @returns This function returns an integration object that has the shape the Prismatic API expects.
|
|
16
16
|
*/
|
|
17
|
-
export declare const integration: <TConfigPages extends ConfigPages = ConfigPages>(definition: IntegrationDefinition<TConfigPages>) => ReturnType<typeof convertIntegration>;
|
|
17
|
+
export declare const integration: <TConfigPages extends ConfigPages = ConfigPages, TComponents extends ComponentSelector<any> = ComponentSelector<any>>(definition: IntegrationDefinition<TConfigPages, TComponents>) => ReturnType<typeof convertIntegration>;
|
|
18
18
|
/**
|
|
19
19
|
* For information on writing Code Native Integrations, see
|
|
20
20
|
* https://prismatic.io/docs/code-native-integrations/#adding-flows.
|
|
21
21
|
* @param definition A Flow type object.
|
|
22
22
|
* @returns This function returns a flow object that has the shape the Prismatic API expects.
|
|
23
23
|
*/
|
|
24
|
-
export declare const flow: <TConfigPages extends ConfigPages = ConfigPages, TTriggerPayload extends TriggerPayload = TriggerPayload, T extends Flow<TConfigPages, TTriggerPayload> = Flow<TConfigPages, TTriggerPayload>>(definition: T) => T;
|
|
24
|
+
export declare const flow: <TConfigPages extends ConfigPages = ConfigPages, TComponents extends ComponentSelector<any> = ComponentSelector<any>, TTriggerPayload extends TriggerPayload = TriggerPayload, T extends Flow<TConfigPages, TComponents, TTriggerPayload> = Flow<TConfigPages, TComponents, TTriggerPayload>>(definition: T) => T;
|
|
25
25
|
/**
|
|
26
26
|
* For information on writing Code Native Integrations, see
|
|
27
27
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-pages.
|
|
28
28
|
* @param definition A Config Page type object.
|
|
29
29
|
* @returns This function returns a config page object that has the shape the Prismatic API expects.
|
|
30
30
|
*/
|
|
31
|
-
export declare const configPage: <T extends ConfigPage>(definition: T) => T;
|
|
31
|
+
export declare const configPage: <TComponents extends ComponentSelector<any> = ComponentSelector<any>, T extends ConfigPage<TComponents> = ConfigPage<TComponents>>(definition: T) => T;
|
|
32
32
|
/**
|
|
33
33
|
* For information on writing Code Native Integrations, see
|
|
34
34
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
35
35
|
* @param definition A Config Var type object.
|
|
36
36
|
* @returns This function returns a standard config var object that has the shape the Prismatic API expects.
|
|
37
37
|
*/
|
|
38
|
-
export declare const configVar: <T extends StandardConfigVar>(definition: T) => T;
|
|
38
|
+
export declare const configVar: <T extends StandardConfigVar | ScheduleConfigVar>(definition: T) => T;
|
|
39
39
|
/**
|
|
40
40
|
* For information on writing Code Native Integrations, see
|
|
41
41
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
42
42
|
* @param definition A Data Source Config Var type object.
|
|
43
43
|
* @returns This function returns a data source config var object that has the shape the Prismatic API expects.
|
|
44
44
|
*/
|
|
45
|
-
export declare const dataSourceConfigVar: <T extends DataSourceConfigVar>(definition: T) => T;
|
|
45
|
+
export declare const dataSourceConfigVar: <TComponents extends ComponentSelector<any> = ComponentSelector<any>, T extends DataSourceConfigVar<TComponents> = DataSourceConfigVar<TComponents>>(definition: T) => T;
|
|
46
46
|
/**
|
|
47
47
|
* For information on writing Code Native Integrations, see
|
|
48
48
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
49
49
|
* @param definition A Connection Config Var type object.
|
|
50
50
|
* @returns This function returns a connection config var object that has the shape the Prismatic API expects.
|
|
51
51
|
*/
|
|
52
|
-
export declare const connectionConfigVar: <T extends ConnectionConfigVar>(definition: T) => T;
|
|
52
|
+
export declare const connectionConfigVar: <TComponents extends ComponentSelector<any> = ComponentSelector<any>, T extends ConnectionConfigVar<TComponents> = ConnectionConfigVar<TComponents>>(definition: T) => T;
|
|
53
53
|
/**
|
|
54
54
|
* This function creates a component object that can be
|
|
55
55
|
* imported into the Prismatic API. For information on using
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { IntegrationDefinition, ConfigPages } from "../types";
|
|
1
|
+
import { IntegrationDefinition, ConfigPages, ComponentSelector } from "../types";
|
|
2
2
|
import { Component as ServerComponent } from ".";
|
|
3
|
-
export declare const convertIntegration: (definition: IntegrationDefinition<ConfigPages
|
|
3
|
+
export declare const convertIntegration: (definition: IntegrationDefinition<ConfigPages, ComponentSelector<any>>) => ServerComponent;
|
|
@@ -4,6 +4,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
4
4
|
};
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.convertIntegration = void 0;
|
|
7
|
+
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
7
8
|
const yaml_1 = __importDefault(require("yaml"));
|
|
8
9
|
const uuid_1 = require("uuid");
|
|
9
10
|
const lodash_1 = require("lodash");
|
|
@@ -47,7 +48,11 @@ const codeNativeIntegrationYaml = ({ name, description, category, documentation,
|
|
|
47
48
|
const preprocessFlowConfig = hasPreprocessFlow
|
|
48
49
|
? preprocessFlows[0].preprocessFlowConfig
|
|
49
50
|
: triggerPreprocessFlowConfig;
|
|
50
|
-
|
|
51
|
+
const nonPreprocessFlowTypes = [
|
|
52
|
+
"instance_specific",
|
|
53
|
+
"shared_instance",
|
|
54
|
+
];
|
|
55
|
+
if (nonPreprocessFlowTypes.includes(endpointType || "flow_specific") &&
|
|
51
56
|
!preprocessFlowConfig) {
|
|
52
57
|
throw new Error("Integration with specified EndpointType must define either a Trigger Preprocess Flow Config or a Preprocess Flow.");
|
|
53
58
|
}
|
|
@@ -74,8 +79,35 @@ const codeNativeIntegrationYaml = ({ name, description, category, documentation,
|
|
|
74
79
|
};
|
|
75
80
|
return yaml_1.default.stringify(result);
|
|
76
81
|
};
|
|
82
|
+
const convertComponentReference = ({ key, component: componentRef, values, }) => {
|
|
83
|
+
const component = typeof componentRef === "string"
|
|
84
|
+
? {
|
|
85
|
+
key: componentRef,
|
|
86
|
+
version: "LATEST",
|
|
87
|
+
isPublic: true,
|
|
88
|
+
}
|
|
89
|
+
: {
|
|
90
|
+
key: componentRef.key,
|
|
91
|
+
version: "LATEST",
|
|
92
|
+
isPublic: componentRef.isPublic,
|
|
93
|
+
};
|
|
94
|
+
const inputs = Object.entries(values !== null && values !== void 0 ? values : {}).reduce((result, [key, value]) => {
|
|
95
|
+
if ("value" in value) {
|
|
96
|
+
return Object.assign(Object.assign({}, result), { [key]: { type: "value", value: value.value } });
|
|
97
|
+
}
|
|
98
|
+
if ("configVar" in value) {
|
|
99
|
+
return Object.assign(Object.assign({}, result), { [key]: { type: "configVar", value: value.configVar } });
|
|
100
|
+
}
|
|
101
|
+
return result;
|
|
102
|
+
}, {});
|
|
103
|
+
return {
|
|
104
|
+
ref: { key, component },
|
|
105
|
+
inputs,
|
|
106
|
+
};
|
|
107
|
+
};
|
|
77
108
|
/** Converts a Flow into the structure necessary for YAML generation. */
|
|
78
109
|
const convertFlow = (flow, referenceKey) => {
|
|
110
|
+
var _a;
|
|
79
111
|
const result = Object.assign({}, flow);
|
|
80
112
|
delete result.onTrigger;
|
|
81
113
|
delete result.trigger;
|
|
@@ -90,20 +122,38 @@ const convertFlow = (flow, referenceKey) => {
|
|
|
90
122
|
description: "The function that will be executed by the flow to return an HTTP response.",
|
|
91
123
|
isTrigger: true,
|
|
92
124
|
errorConfig: "errorConfig" in flow ? Object.assign({}, flow.errorConfig) : undefined,
|
|
93
|
-
action: {
|
|
94
|
-
key: flowFunctionKey(flow.name, "onTrigger"),
|
|
95
|
-
component: { key: referenceKey, version: "LATEST", isPublic: false },
|
|
96
|
-
},
|
|
97
125
|
};
|
|
126
|
+
if (typeof flow.onTrigger === "function") {
|
|
127
|
+
triggerStep.action = {
|
|
128
|
+
key: flowFunctionKey(flow.name, "onTrigger"),
|
|
129
|
+
component: {
|
|
130
|
+
key: referenceKey,
|
|
131
|
+
version: "LATEST",
|
|
132
|
+
isPublic: false,
|
|
133
|
+
},
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
else if ((0, types_1.isComponentReference)(flow.onTrigger)) {
|
|
137
|
+
const { ref, inputs } = convertComponentReference(flow.onTrigger);
|
|
138
|
+
triggerStep.action = ref;
|
|
139
|
+
triggerStep.inputs = inputs;
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
const hasSchedule = "schedule" in flow && typeof flow.schedule === "object";
|
|
143
|
+
const key = hasSchedule ? "schedule" : "webhook";
|
|
144
|
+
triggerStep.action = {
|
|
145
|
+
key,
|
|
146
|
+
component: { key: `${key}-triggers`, version: "LATEST", isPublic: true },
|
|
147
|
+
};
|
|
148
|
+
}
|
|
98
149
|
if ("schedule" in flow && typeof flow.schedule === "object") {
|
|
150
|
+
const { schedule } = flow;
|
|
99
151
|
triggerStep.schedule = {
|
|
100
|
-
type: "
|
|
101
|
-
value: "
|
|
102
|
-
? flow.schedule.cronExpression
|
|
103
|
-
: flow.schedule.configVarKey,
|
|
152
|
+
type: "configVar" in schedule ? "configVar" : "value",
|
|
153
|
+
value: "configVar" in schedule ? schedule.configVar : schedule.value,
|
|
104
154
|
meta: {
|
|
105
|
-
scheduleType:
|
|
106
|
-
timeZone:
|
|
155
|
+
scheduleType: "custom",
|
|
156
|
+
timeZone: (_a = schedule.timezone) !== null && _a !== void 0 ? _a : "",
|
|
107
157
|
},
|
|
108
158
|
};
|
|
109
159
|
delete result.schedule;
|
|
@@ -127,7 +177,7 @@ const convertConfigVar = (key, configVar, referenceKey) => {
|
|
|
127
177
|
"visibleToCustomerDeployer",
|
|
128
178
|
"visibleToOrgDeployer",
|
|
129
179
|
]);
|
|
130
|
-
if ((0, types_1.
|
|
180
|
+
if ((0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
|
|
131
181
|
return Object.assign(Object.assign({}, (0, lodash_1.pick)(configVar, ["stableKey", "description", "orgOnly"])), { key, dataType: "connection", connection: {
|
|
132
182
|
component: { key: referenceKey, version: "LATEST", isPublic: false },
|
|
133
183
|
key: (0, lodash_1.camelCase)(key),
|
|
@@ -143,6 +193,10 @@ const convertConfigVar = (key, configVar, referenceKey) => {
|
|
|
143
193
|
return Object.assign(Object.assign({}, result), { [key]: { type: "value", value } });
|
|
144
194
|
}, {}), meta });
|
|
145
195
|
}
|
|
196
|
+
if ((0, types_1.isConnectionReferenceConfigVar)(configVar)) {
|
|
197
|
+
const { ref, inputs } = convertComponentReference(configVar.connection);
|
|
198
|
+
return Object.assign(Object.assign({}, (0, lodash_1.pick)(configVar, ["stableKey", "description", "orgOnly"])), { key, dataType: "connection", connection: ref, inputs });
|
|
199
|
+
}
|
|
146
200
|
const result = (0, lodash_1.assign)({ meta, key }, (0, lodash_1.pick)(configVar, [
|
|
147
201
|
"stableKey",
|
|
148
202
|
"description",
|
|
@@ -150,19 +204,26 @@ const convertConfigVar = (key, configVar, referenceKey) => {
|
|
|
150
204
|
"defaultValue",
|
|
151
205
|
"dataType",
|
|
152
206
|
"pickList",
|
|
153
|
-
"scheduleType",
|
|
154
207
|
"timeZone",
|
|
155
208
|
"codeLanguage",
|
|
156
209
|
"collectionType",
|
|
157
210
|
]));
|
|
158
|
-
|
|
159
|
-
|
|
211
|
+
if ((0, types_1.isScheduleConfigVar)(configVar)) {
|
|
212
|
+
result.scheduleType = "custom";
|
|
213
|
+
}
|
|
214
|
+
if ((0, types_1.isDataSourceDefinitionConfigVar)(configVar)) {
|
|
160
215
|
result.dataType = configVar.dataSourceType;
|
|
161
216
|
result.dataSource = {
|
|
162
217
|
key: (0, lodash_1.camelCase)(key),
|
|
163
218
|
component: { key: referenceKey, version: "LATEST", isPublic: false },
|
|
164
219
|
};
|
|
165
220
|
}
|
|
221
|
+
if ((0, types_1.isDataSourceReferenceConfigVar)(configVar)) {
|
|
222
|
+
const { ref, inputs } = convertComponentReference(configVar.dataSource);
|
|
223
|
+
result.dataType = configVar.dataSourceType;
|
|
224
|
+
result.dataSource = ref;
|
|
225
|
+
result.inputs = inputs;
|
|
226
|
+
}
|
|
166
227
|
return result;
|
|
167
228
|
};
|
|
168
229
|
/** Maps the step name field to a fully qualified input. */
|
|
@@ -199,6 +260,9 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
199
260
|
} });
|
|
200
261
|
}, {});
|
|
201
262
|
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete }) => {
|
|
263
|
+
if (typeof onTrigger !== "function") {
|
|
264
|
+
return result;
|
|
265
|
+
}
|
|
202
266
|
const key = flowFunctionKey(name, "onTrigger");
|
|
203
267
|
return Object.assign(Object.assign({}, result), { [key]: {
|
|
204
268
|
key,
|
|
@@ -217,7 +281,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
217
281
|
} });
|
|
218
282
|
}, {});
|
|
219
283
|
const convertedDataSources = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
220
|
-
if (!(0, types_1.
|
|
284
|
+
if (!(0, types_1.isDataSourceDefinitionConfigVar)(configVar)) {
|
|
221
285
|
return result;
|
|
222
286
|
}
|
|
223
287
|
const camelKey = (0, lodash_1.camelCase)(key);
|
|
@@ -228,7 +292,7 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
228
292
|
}, inputs: [] }) });
|
|
229
293
|
}, {});
|
|
230
294
|
const convertedConnections = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
231
|
-
if (!(0, types_1.
|
|
295
|
+
if (!(0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
|
|
232
296
|
return result;
|
|
233
297
|
}
|
|
234
298
|
const convertedInputs = Object.entries(configVar.inputs).map(([key, value]) => (0, convert_1.convertInput)(key, value));
|
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export declare const DefinitionVersion = 7;
|
|
2
2
|
export interface ComponentReference {
|
|
3
|
+
component: {
|
|
4
|
+
key: string;
|
|
5
|
+
version: number | "LATEST";
|
|
6
|
+
isPublic: boolean;
|
|
7
|
+
};
|
|
3
8
|
key: string;
|
|
4
|
-
version: number | "LATEST";
|
|
5
|
-
isPublic: boolean;
|
|
6
9
|
}
|
|
7
10
|
export declare type Input = {
|
|
8
11
|
name?: string;
|
|
@@ -21,10 +24,7 @@ export interface ConnectionRequiredConfigVariable {
|
|
|
21
24
|
description?: string;
|
|
22
25
|
orgOnly?: boolean;
|
|
23
26
|
dataType: "connection";
|
|
24
|
-
connection:
|
|
25
|
-
component: ComponentReference;
|
|
26
|
-
key: string;
|
|
27
|
-
};
|
|
27
|
+
connection: ComponentReference;
|
|
28
28
|
inputs?: Record<string, Input>;
|
|
29
29
|
meta?: Record<string, unknown>;
|
|
30
30
|
}
|
|
@@ -40,10 +40,7 @@ export interface DefaultRequiredConfigVariable {
|
|
|
40
40
|
description?: string;
|
|
41
41
|
orgOnly?: boolean;
|
|
42
42
|
collectionType?: "valuelist" | "keyvaluelist";
|
|
43
|
-
dataSource?:
|
|
44
|
-
component: ComponentReference;
|
|
45
|
-
key: string;
|
|
46
|
-
};
|
|
43
|
+
dataSource?: ComponentReference;
|
|
47
44
|
inputs?: Record<string, Input>;
|
|
48
45
|
meta?: Record<string, unknown>;
|
|
49
46
|
}
|
package/dist/testing.d.ts
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* https://prismatic.io/docs/custom-components/writing-custom-components/#testing-a-component
|
|
6
6
|
*/
|
|
7
7
|
import { TriggerPayload, TriggerResult, ConnectionValue, ActionLogger, Component, ActionContext, ActionPerformReturn, DataSourceResult, DataSourceContext } from "./serverTypes";
|
|
8
|
-
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceResult as InvokeDataSourceResult, TriggerEventFunctionReturn, Flow, ConfigVarResultCollection, ConfigPages } from "./types";
|
|
8
|
+
import { ConnectionDefinition, ActionDefinition, TriggerDefinition, Inputs, ActionInputParameters, DataSourceDefinition, ActionPerformReturn as InvokeActionPerformReturn, TriggerResult as InvokeTriggerResult, DataSourceResult as InvokeDataSourceResult, TriggerEventFunctionReturn, Flow, ConfigVarResultCollection, ConfigPages, ComponentSelector } from "./types";
|
|
9
9
|
export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>, tokenValues?: Record<string, unknown> | undefined) => ConnectionValue;
|
|
10
10
|
/**
|
|
11
11
|
* Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
|
|
@@ -63,7 +63,7 @@ declare type ToTestValues<TConfigVars extends ConfigVarResultCollection> = {
|
|
|
63
63
|
* Invokes specified Flow of a Code Native Integration using supplied params.
|
|
64
64
|
* Runs the Trigger and then the Action function and returns the result of the Action.
|
|
65
65
|
*/
|
|
66
|
-
export declare const invokeFlow: <TConfigPages extends ConfigPages, TConfigVars extends ConfigVarResultCollection = import("./types/utils").Prettify<{ [Key in keyof (TConfigPages extends ConfigPages ? import("./types/utils").UnionToIntersection<import("./types/utils").ValueOf<TConfigPages>["elements"]> : never)]: import("./types").ElementToRuntimeType<(TConfigPages extends ConfigPages ? import("./types/utils").UnionToIntersection<import("./types/utils").ValueOf<TConfigPages>["elements"]> : never)[Key]>; }>, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>>(flow: Flow<TConfigPages, import("./types").TriggerPayload>, configVars: TConfigVarValues, context?: Partial<ActionContext<TConfigVars>> | undefined, payload?: TriggerPayload | undefined) => Promise<InvokeReturn<InvokeActionPerformReturn<false, unknown>>>;
|
|
66
|
+
export declare const invokeFlow: <TConfigPages extends ConfigPages, TConfigVars extends ConfigVarResultCollection = import("./types/utils").Prettify<{ [Key in keyof (TConfigPages extends ConfigPages ? import("./types/utils").UnionToIntersection<import("./types/utils").ValueOf<TConfigPages>["elements"]> : never) as Key extends string ? Key : never]: import("./types").ElementToRuntimeType<(TConfigPages extends ConfigPages ? import("./types/utils").UnionToIntersection<import("./types/utils").ValueOf<TConfigPages>["elements"]> : never)[Key]>; }>, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>>(flow: Flow<TConfigPages, ComponentSelector<any>, import("./types").TriggerPayload>, configVars: TConfigVarValues, context?: Partial<ActionContext<TConfigVars>> | undefined, payload?: TriggerPayload | undefined) => Promise<InvokeReturn<InvokeActionPerformReturn<false, unknown>>>;
|
|
67
67
|
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
68
68
|
component: TComponent;
|
|
69
69
|
constructor(component: TComponent);
|
package/dist/testing.js
CHANGED
|
@@ -197,7 +197,7 @@ const invokeFlow = (flow, configVars, context, payload) => __awaiter(void 0, voi
|
|
|
197
197
|
const params = {
|
|
198
198
|
onTrigger: { results: null },
|
|
199
199
|
};
|
|
200
|
-
if ("onTrigger" in flow) {
|
|
200
|
+
if ("onTrigger" in flow && typeof flow.onTrigger === "function") {
|
|
201
201
|
const triggerResult = yield flow.onTrigger(realizedContext, realizedPayload, params);
|
|
202
202
|
params.onTrigger = { results: triggerResult === null || triggerResult === void 0 ? void 0 : triggerResult.payload };
|
|
203
203
|
}
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import { DataSourceDefinition, ConnectionDefinition, ActionPerformFunction, ActionPerformReturn, TriggerEventFunction, TriggerPerformFunction, Inputs, TriggerResult, DataSourceType, TriggerPayload, Connection, JSONForm, ObjectFieldMap, ObjectSelection, ConfigVarResultCollection, Schedule } from ".";
|
|
2
2
|
import { Prettify, UnionToIntersection, ValueOf } from "./utils";
|
|
3
3
|
declare type ToDataSourceRuntimeType<TType extends DataSourceType> = TType extends "jsonForm" ? JSONForm : TType extends "objectSelection" ? ObjectSelection : TType extends "objectFieldMap" ? ObjectFieldMap : string;
|
|
4
|
-
declare type
|
|
5
|
-
export declare type ElementToRuntimeType<TElement extends ConfigPageElement> = TElement extends ConnectionConfigVar ? Connection : TElement extends DataSourceConfigVar ? ToDataSourceRuntimeType<TElement["dataSourceType"]> : TElement extends StandardConfigVar ? ToRuntimeType<TElement["dataType"]> : never;
|
|
4
|
+
export declare type ElementToRuntimeType<TElement extends ConfigPageElement> = TElement extends ConnectionConfigVar ? Connection : TElement extends DataSourceConfigVar ? ToDataSourceRuntimeType<TElement["dataSourceType"]> : TElement extends ScheduleConfigVar ? Schedule : TElement extends StandardConfigVar ? string : never;
|
|
6
5
|
declare type GetElements<TConfigPages extends ConfigPages> = TConfigPages extends ConfigPages ? UnionToIntersection<ValueOf<TConfigPages>["elements"]> : never;
|
|
7
6
|
export declare type ExtractConfigVars<TConfigPages extends ConfigPages, TElements extends ConfigPage["elements"] = GetElements<TConfigPages>> = Prettify<{
|
|
8
|
-
[Key in keyof TElements]: ElementToRuntimeType<TElements[Key]>;
|
|
7
|
+
[Key in keyof TElements as Key extends string ? Key : never]: ElementToRuntimeType<TElements[Key]>;
|
|
9
8
|
}>;
|
|
10
9
|
/** Defines attributes of a Code-Native Integration. */
|
|
11
|
-
export declare type IntegrationDefinition<TConfigPages extends ConfigPages
|
|
10
|
+
export declare type IntegrationDefinition<TConfigPages extends ConfigPages, TComponents extends ComponentSelector<any>> = {
|
|
12
11
|
/** The unique name for this Integration. */
|
|
13
12
|
name: string;
|
|
14
13
|
/** Optional description for this Integration. */
|
|
@@ -31,12 +30,12 @@ export declare type IntegrationDefinition<TConfigPages extends ConfigPages> = {
|
|
|
31
30
|
* Cannot specify this if a Preprocess Flow is also configured. */
|
|
32
31
|
triggerPreprocessFlowConfig?: PreprocessFlowConfig;
|
|
33
32
|
/** Flows for this Integration. */
|
|
34
|
-
flows: Flow<TConfigPages>[];
|
|
33
|
+
flows: Flow<TConfigPages, TComponents>[];
|
|
35
34
|
/** Config Wizard Pages for this Integration. */
|
|
36
35
|
configPages?: TConfigPages;
|
|
37
36
|
};
|
|
38
37
|
/** Defines attributes of a Flow of a Code-Native Integration. */
|
|
39
|
-
export interface Flow<TConfigPages extends ConfigPages, TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
38
|
+
export interface Flow<TConfigPages extends ConfigPages, TComponents extends ComponentSelector<any>, TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
40
39
|
/** The unique name for this Flow. */
|
|
41
40
|
name: string;
|
|
42
41
|
/** A unique, unchanging value that is used to maintain identity for the Flow even if the name changes. */
|
|
@@ -54,11 +53,13 @@ export interface Flow<TConfigPages extends ConfigPages, TTriggerPayload extends
|
|
|
54
53
|
/** Optional list of API key(s) to use for the endpoint of this Flow when the endpoint security type is EndpointSecurityType.Organization. */
|
|
55
54
|
organizationApiKeys?: string[];
|
|
56
55
|
/** Optional schedule configuration that defines the frequency with which this Flow will be automatically executed. */
|
|
57
|
-
schedule?:
|
|
56
|
+
schedule?: ValueReference<string, TConfigPages> & {
|
|
57
|
+
timezone?: string;
|
|
58
|
+
};
|
|
58
59
|
/** Optional error handling configuration. */
|
|
59
60
|
errorConfig?: StepErrorConfig;
|
|
60
61
|
/** Specifies the trigger function for this Flow, which returns a payload and optional HTTP response. */
|
|
61
|
-
onTrigger
|
|
62
|
+
onTrigger?: ToComponentReferences<"trigger", TComponents, TConfigPages> | TriggerPerformFunction<Inputs, ExtractConfigVars<TConfigPages>, false, TriggerResult<false, TTriggerPayload>>;
|
|
62
63
|
/** Specifies the function to execute when an Instance of this Integration is deployed. */
|
|
63
64
|
onInstanceDeploy?: TriggerEventFunction<Inputs, ExtractConfigVars<TConfigPages>>;
|
|
64
65
|
/** Specifies the function to execute when an Instance of an Integration is deleted. */
|
|
@@ -90,33 +91,49 @@ declare type BaseConfigVar = {
|
|
|
90
91
|
/** Defines attributes of a standard Config Var. */
|
|
91
92
|
export declare type StandardConfigVar = BaseConfigVar & {
|
|
92
93
|
/** The data type of the Config Var. */
|
|
93
|
-
dataType: ConfigVarDataType
|
|
94
|
+
dataType: Exclude<ConfigVarDataType, "schedule">;
|
|
94
95
|
/** Optional default value for the Config Var. */
|
|
95
96
|
defaultValue?: string;
|
|
96
97
|
/** Optional list of picklist values if the Config Var is a multi-choice selection value. */
|
|
97
98
|
pickList?: string[];
|
|
98
|
-
/** Optional schedule type that defines the cadence of the schedule. */
|
|
99
|
-
scheduleType?: ScheduleType;
|
|
100
|
-
/** Optional value to use as a timezone if the Config Var is a schedule value. */
|
|
101
|
-
timeZone?: string;
|
|
102
99
|
/** Optional value to specify the type of language if the Config Var is a code value. */
|
|
103
100
|
codeLanguage?: CodeLanguageType;
|
|
104
101
|
/** Optional value to specify the type of collection if the Config Var is multi-value. */
|
|
105
102
|
collectionType?: CollectionType;
|
|
106
103
|
};
|
|
104
|
+
export declare type ScheduleConfigVar = BaseConfigVar & {
|
|
105
|
+
/** The data type of the Config Var. */
|
|
106
|
+
dataType: "schedule";
|
|
107
|
+
/** Optional default value for the Config Var. */
|
|
108
|
+
defaultValue?: string;
|
|
109
|
+
/** Optional timezone for the schedule. */
|
|
110
|
+
timeZone?: string;
|
|
111
|
+
};
|
|
112
|
+
declare type DataSourceDefinitionConfigVar = BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, DataSourceType>, "display" | "inputs" | "examplePayload">;
|
|
113
|
+
declare type DataSourceReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseConfigVar & {
|
|
114
|
+
dataSourceType: DataSourceType;
|
|
115
|
+
dataSource: ToComponentReferences<"dataSource", TComponents, ConfigPages>;
|
|
116
|
+
};
|
|
107
117
|
/** Defines attributes of a data source Config Var. */
|
|
108
|
-
export declare type DataSourceConfigVar
|
|
118
|
+
export declare type DataSourceConfigVar<TComponents extends ComponentSelector<any> = ComponentSelector<any>> = DataSourceDefinitionConfigVar | DataSourceReferenceConfigVar<TComponents>;
|
|
119
|
+
declare type ConnectionDefinitionConfigVar = BaseConfigVar & Omit<ConnectionDefinition, "label" | "comments" | "key">;
|
|
120
|
+
declare type ConnectionReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseConfigVar & {
|
|
121
|
+
connection: ToComponentReferences<"connection", TComponents>;
|
|
122
|
+
};
|
|
109
123
|
/** Defines attributes of a Config Var that represents a Connection. */
|
|
110
|
-
export declare type ConnectionConfigVar
|
|
111
|
-
export declare type ConfigVar = StandardConfigVar | DataSourceConfigVar | ConnectionConfigVar
|
|
112
|
-
export declare const
|
|
113
|
-
export declare const
|
|
114
|
-
export declare
|
|
124
|
+
export declare type ConnectionConfigVar<TComponents extends ComponentSelector<any> = ComponentSelector<any>> = ConnectionDefinitionConfigVar | ConnectionReferenceConfigVar<TComponents>;
|
|
125
|
+
export declare type ConfigVar<TComponents extends ComponentSelector<any> = ComponentSelector<any>> = StandardConfigVar | ScheduleConfigVar | DataSourceConfigVar<TComponents> | ConnectionConfigVar<TComponents>;
|
|
126
|
+
export declare const isScheduleConfigVar: (cv: ConfigVar) => cv is ScheduleConfigVar;
|
|
127
|
+
export declare const isDataSourceDefinitionConfigVar: (cv: ConfigVar) => cv is DataSourceDefinitionConfigVar;
|
|
128
|
+
export declare const isDataSourceReferenceConfigVar: <TComponents extends ComponentSelector<any> = ComponentSelector<any>>(cv: ConfigVar<TComponents>) => cv is DataSourceReferenceConfigVar<TComponents>;
|
|
129
|
+
export declare const isConnectionDefinitionConfigVar: (cv: ConfigVar) => cv is ConnectionDefinitionConfigVar;
|
|
130
|
+
export declare const isConnectionReferenceConfigVar: <TComponents extends ComponentSelector<any> = ComponentSelector<any>>(cv: ConfigVar<TComponents>) => cv is ConnectionReferenceConfigVar<TComponents>;
|
|
131
|
+
export declare type ConfigPageElement<TComponents extends ComponentSelector<any> = ComponentSelector<any>> = string | ConfigVar<TComponents>;
|
|
115
132
|
export declare type ConfigPages = Record<string, ConfigPage>;
|
|
116
133
|
/** Defines attributes of a Config Wizard Page used when deploying an Instance of an Integration. */
|
|
117
|
-
export declare type ConfigPage = {
|
|
134
|
+
export declare type ConfigPage<TComponents extends ComponentSelector<any> = ComponentSelector<any>> = {
|
|
118
135
|
/** Elements included on this Config Page. */
|
|
119
|
-
elements: Record<string, ConfigPageElement
|
|
136
|
+
elements: Record<string, ConfigPageElement<TComponents>>;
|
|
120
137
|
/** Specifies an optional tagline for this Config Page. */
|
|
121
138
|
tagline?: string;
|
|
122
139
|
};
|
|
@@ -153,66 +170,52 @@ export declare type StepErrorConfig = {
|
|
|
153
170
|
/** Specifies whether to ignore the final error after the final retry attempt. @default false */
|
|
154
171
|
ignoreFinalError?: boolean;
|
|
155
172
|
};
|
|
156
|
-
/** Defines attributes of a Schedule that controls how often a Flow is automatically executed. */
|
|
157
|
-
export declare type FlowSchedule = {
|
|
158
|
-
/** The cron expression to use for defining an execution schedule. */
|
|
159
|
-
cronExpression: string;
|
|
160
|
-
/** Specifies an optional value to use as the timezone. */
|
|
161
|
-
timeZone?: string;
|
|
162
|
-
} | {
|
|
163
|
-
/** The key of the Config Var whose value will define the execution schedule. */
|
|
164
|
-
configVarKey: string;
|
|
165
|
-
/** Specifies an optional value to use as the timezone. */
|
|
166
|
-
timeZone?: string;
|
|
167
|
-
};
|
|
168
173
|
/** Choices of Endpoint Types that may be used by Instances of an Integration. */
|
|
169
|
-
export declare
|
|
170
|
-
FlowSpecific = "flow_specific",
|
|
171
|
-
InstanceSpecific = "instance_specific",
|
|
172
|
-
SharedInstance = "shared_instance"
|
|
173
|
-
}
|
|
174
|
+
export declare type EndpointType = "flow_specific" | "instance_specific" | "shared_instance";
|
|
174
175
|
/** Choices of Endpoint Security Types that may be used by endpoints of a Flow. */
|
|
175
|
-
export declare
|
|
176
|
-
Unsecured = "unsecured",
|
|
177
|
-
CustomerOptional = "customer_optional",
|
|
178
|
-
CustomerRequired = "customer_required",
|
|
179
|
-
Organization = "organization"
|
|
180
|
-
}
|
|
176
|
+
export declare type EndpointSecurityType = "unsecured" | "customer_optional" | "customer_required" | "organization";
|
|
181
177
|
/** Choices of Step Error Handlers that define the behavior when a step error occurs. */
|
|
182
|
-
export declare
|
|
183
|
-
Fail = "fail",
|
|
184
|
-
Ignore = "ignore",
|
|
185
|
-
Retry = "retry"
|
|
186
|
-
}
|
|
187
|
-
/** Choices for Schedules that add context for the cadence of a given schedule. */
|
|
188
|
-
export declare enum ScheduleType {
|
|
189
|
-
None = "none",
|
|
190
|
-
Custom = "custom",
|
|
191
|
-
Minute = "minute",
|
|
192
|
-
Hour = "hour",
|
|
193
|
-
Day = "day",
|
|
194
|
-
Week = "week"
|
|
195
|
-
}
|
|
178
|
+
export declare type StepErrorHandlerType = "fail" | "ignore" | "retry";
|
|
196
179
|
/** Supported data types for Config Vars. */
|
|
197
|
-
export declare
|
|
198
|
-
String = "string",
|
|
199
|
-
Date = "date",
|
|
200
|
-
Timestamp = "timestamp",
|
|
201
|
-
Picklist = "picklist",
|
|
202
|
-
Schedule = "schedule",
|
|
203
|
-
Code = "code",
|
|
204
|
-
Boolean = "boolean",
|
|
205
|
-
Number = "number"
|
|
206
|
-
}
|
|
180
|
+
export declare type ConfigVarDataType = "string" | "date" | "timestamp" | "picklist" | "schedule" | "code" | "boolean" | "number";
|
|
207
181
|
/** Choices of programming languages that may be used for Config Var code values. */
|
|
208
|
-
export declare
|
|
209
|
-
JSON = "json",
|
|
210
|
-
XML = "xml",
|
|
211
|
-
HTML = "html"
|
|
212
|
-
}
|
|
182
|
+
export declare type CodeLanguageType = "json" | "xml" | "html";
|
|
213
183
|
/** Choices of collection types for multi-value Config Vars. */
|
|
214
|
-
export declare
|
|
215
|
-
|
|
216
|
-
|
|
184
|
+
export declare type CollectionType = "valuelist" | "keyvaluelist";
|
|
185
|
+
/** Choices of component reference types. */
|
|
186
|
+
export declare type ComponentSelectorType = "trigger" | "connection" | "dataSource";
|
|
187
|
+
export declare type ValueReference<TValueType, TConfigPages extends ConfigPages, TConfigVarKeys = keyof ExtractConfigVars<TConfigPages>> = {
|
|
188
|
+
value: TValueType;
|
|
189
|
+
} | (TConfigPages extends ConfigPages ? {
|
|
190
|
+
configVar: TConfigVarKeys;
|
|
191
|
+
} : never);
|
|
192
|
+
export interface ComponentSelector<TValueType> {
|
|
193
|
+
type: ComponentSelectorType;
|
|
194
|
+
component: string | {
|
|
195
|
+
key: string;
|
|
196
|
+
isPublic: boolean;
|
|
197
|
+
};
|
|
198
|
+
key: string;
|
|
199
|
+
values?: {
|
|
200
|
+
[key: string]: TValueType;
|
|
201
|
+
};
|
|
202
|
+
}
|
|
203
|
+
export declare type ToComponentReferences<TReferenceType extends ComponentSelectorType, TSelector extends ComponentSelector<any>, TConfigPages extends ConfigPages = never> = TSelector extends ComponentSelector<infer TValueType> ? TSelector["type"] extends TReferenceType ? {
|
|
204
|
+
component: TSelector["component"];
|
|
205
|
+
key: TSelector["key"];
|
|
206
|
+
values: {
|
|
207
|
+
[K in keyof TSelector["values"]]: ValueReference<TValueType, TConfigPages>;
|
|
208
|
+
};
|
|
209
|
+
} : never : never;
|
|
210
|
+
export interface ComponentReference<TValueType, TConfigPages extends ConfigPages> {
|
|
211
|
+
component: string | {
|
|
212
|
+
key: string;
|
|
213
|
+
isPublic: boolean;
|
|
214
|
+
};
|
|
215
|
+
key: string;
|
|
216
|
+
values?: {
|
|
217
|
+
[key: string]: ValueReference<TValueType, TConfigPages>;
|
|
218
|
+
};
|
|
217
219
|
}
|
|
220
|
+
export declare const isComponentReference: (ref: unknown) => ref is ComponentReference<any, ConfigPages>;
|
|
218
221
|
export {};
|
|
@@ -1,64 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
4
|
-
const
|
|
5
|
-
exports.
|
|
6
|
-
const
|
|
7
|
-
exports.
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
var EndpointSecurityType;
|
|
17
|
-
(function (EndpointSecurityType) {
|
|
18
|
-
EndpointSecurityType["Unsecured"] = "unsecured";
|
|
19
|
-
EndpointSecurityType["CustomerOptional"] = "customer_optional";
|
|
20
|
-
EndpointSecurityType["CustomerRequired"] = "customer_required";
|
|
21
|
-
EndpointSecurityType["Organization"] = "organization";
|
|
22
|
-
})(EndpointSecurityType = exports.EndpointSecurityType || (exports.EndpointSecurityType = {}));
|
|
23
|
-
/** Choices of Step Error Handlers that define the behavior when a step error occurs. */
|
|
24
|
-
var StepErrorHandlerType;
|
|
25
|
-
(function (StepErrorHandlerType) {
|
|
26
|
-
StepErrorHandlerType["Fail"] = "fail";
|
|
27
|
-
StepErrorHandlerType["Ignore"] = "ignore";
|
|
28
|
-
StepErrorHandlerType["Retry"] = "retry";
|
|
29
|
-
})(StepErrorHandlerType = exports.StepErrorHandlerType || (exports.StepErrorHandlerType = {}));
|
|
30
|
-
/** Choices for Schedules that add context for the cadence of a given schedule. */
|
|
31
|
-
var ScheduleType;
|
|
32
|
-
(function (ScheduleType) {
|
|
33
|
-
ScheduleType["None"] = "none";
|
|
34
|
-
ScheduleType["Custom"] = "custom";
|
|
35
|
-
ScheduleType["Minute"] = "minute";
|
|
36
|
-
ScheduleType["Hour"] = "hour";
|
|
37
|
-
ScheduleType["Day"] = "day";
|
|
38
|
-
ScheduleType["Week"] = "week";
|
|
39
|
-
})(ScheduleType = exports.ScheduleType || (exports.ScheduleType = {}));
|
|
40
|
-
/** Supported data types for Config Vars. */
|
|
41
|
-
var ConfigVarDataType;
|
|
42
|
-
(function (ConfigVarDataType) {
|
|
43
|
-
ConfigVarDataType["String"] = "string";
|
|
44
|
-
ConfigVarDataType["Date"] = "date";
|
|
45
|
-
ConfigVarDataType["Timestamp"] = "timestamp";
|
|
46
|
-
ConfigVarDataType["Picklist"] = "picklist";
|
|
47
|
-
ConfigVarDataType["Schedule"] = "schedule";
|
|
48
|
-
ConfigVarDataType["Code"] = "code";
|
|
49
|
-
ConfigVarDataType["Boolean"] = "boolean";
|
|
50
|
-
ConfigVarDataType["Number"] = "number";
|
|
51
|
-
})(ConfigVarDataType = exports.ConfigVarDataType || (exports.ConfigVarDataType = {}));
|
|
52
|
-
/** Choices of programming languages that may be used for Config Var code values. */
|
|
53
|
-
var CodeLanguageType;
|
|
54
|
-
(function (CodeLanguageType) {
|
|
55
|
-
CodeLanguageType["JSON"] = "json";
|
|
56
|
-
CodeLanguageType["XML"] = "xml";
|
|
57
|
-
CodeLanguageType["HTML"] = "html";
|
|
58
|
-
})(CodeLanguageType = exports.CodeLanguageType || (exports.CodeLanguageType = {}));
|
|
59
|
-
/** Choices of collection types for multi-value Config Vars. */
|
|
60
|
-
var CollectionType;
|
|
61
|
-
(function (CollectionType) {
|
|
62
|
-
CollectionType["ValueList"] = "valuelist";
|
|
63
|
-
CollectionType["KeyValueList"] = "keyvaluelist";
|
|
64
|
-
})(CollectionType = exports.CollectionType || (exports.CollectionType = {}));
|
|
3
|
+
exports.isComponentReference = exports.isConnectionReferenceConfigVar = exports.isConnectionDefinitionConfigVar = exports.isDataSourceReferenceConfigVar = exports.isDataSourceDefinitionConfigVar = exports.isScheduleConfigVar = void 0;
|
|
4
|
+
const isScheduleConfigVar = (cv) => "dataType" in cv && cv.dataType === "schedule";
|
|
5
|
+
exports.isScheduleConfigVar = isScheduleConfigVar;
|
|
6
|
+
const isDataSourceDefinitionConfigVar = (cv) => "dataSourceType" in cv && "perform" in cv && typeof cv.perform === "function";
|
|
7
|
+
exports.isDataSourceDefinitionConfigVar = isDataSourceDefinitionConfigVar;
|
|
8
|
+
const isDataSourceReferenceConfigVar = (cv) => "dataSource" in cv && (0, exports.isComponentReference)(cv.dataSource);
|
|
9
|
+
exports.isDataSourceReferenceConfigVar = isDataSourceReferenceConfigVar;
|
|
10
|
+
const isConnectionDefinitionConfigVar = (cv) => "inputs" in cv;
|
|
11
|
+
exports.isConnectionDefinitionConfigVar = isConnectionDefinitionConfigVar;
|
|
12
|
+
const isConnectionReferenceConfigVar = (cv) => "connection" in cv && (0, exports.isComponentReference)(cv.connection);
|
|
13
|
+
exports.isConnectionReferenceConfigVar = isConnectionReferenceConfigVar;
|
|
14
|
+
const isComponentReference = (ref) => typeof ref === "object" && ref !== null && "key" in ref && "component" in ref;
|
|
15
|
+
exports.isComponentReference = isComponentReference;
|
package/dist/util.d.ts
CHANGED
|
@@ -45,7 +45,7 @@ declare const _default: {
|
|
|
45
45
|
toString: (value: unknown, defaultValue?: string) => string;
|
|
46
46
|
keyValPairListToObject: <TValue = unknown>(kvpList: KeyValuePair<unknown>[], valueConverter?: ((value: unknown) => TValue) | undefined) => Record<string, TValue>;
|
|
47
47
|
isJSON: (value: string) => boolean;
|
|
48
|
-
toJSON: (value: unknown) => string;
|
|
48
|
+
toJSON: (value: unknown, prettyPrint?: boolean, retainKeyOrder?: boolean) => string;
|
|
49
49
|
lowerCaseHeaders: (headers: Record<string, string>) => Record<string, string>;
|
|
50
50
|
isObjectSelection: (value: unknown) => value is ObjectSelection;
|
|
51
51
|
toObjectSelection: (value: unknown) => ObjectSelection;
|
|
@@ -58,6 +58,7 @@ declare const _default: {
|
|
|
58
58
|
isConnection: (value: unknown) => value is ConnectionDefinition;
|
|
59
59
|
isElement: (value: unknown) => value is Element;
|
|
60
60
|
toObject: (value: unknown) => object;
|
|
61
|
+
cleanObject: (obj: Record<string, unknown>, predicate?: ((v: any) => boolean) | undefined) => import("lodash").Dictionary<unknown>;
|
|
61
62
|
};
|
|
62
63
|
};
|
|
63
64
|
export default _default;
|
package/dist/util.js
CHANGED
|
@@ -14,6 +14,7 @@ const parseISO_1 = __importDefault(require("date-fns/parseISO"));
|
|
|
14
14
|
const isValid_1 = __importDefault(require("date-fns/isValid"));
|
|
15
15
|
const isDate_1 = __importDefault(require("date-fns/isDate"));
|
|
16
16
|
const fromUnixTime_1 = __importDefault(require("date-fns/fromUnixTime"));
|
|
17
|
+
const lodash_1 = require("lodash");
|
|
17
18
|
const safe_stable_stringify_1 = require("safe-stable-stringify");
|
|
18
19
|
const valid_url_1 = require("valid-url");
|
|
19
20
|
const isObjectWithTruthyKeys = (value, keys) => {
|
|
@@ -457,11 +458,16 @@ const isJSON = (value) => {
|
|
|
457
458
|
* This function accepts an arbitrary object/value and safely serializes it (handles cyclic references).
|
|
458
459
|
*
|
|
459
460
|
* @param value Arbitrary object/value to serialize.
|
|
461
|
+
* @param prettyPrint When true, convert to pretty printed JSON with 2 spaces and newlines. When false, JSON is compact.
|
|
462
|
+
* @param retainKeyOrder When true, the order of keys in the JSON output will be the same as the order in the input object.
|
|
460
463
|
* @returns JSON serialized text that can be safely logged.
|
|
461
464
|
*/
|
|
462
|
-
const toJSON = (value) => {
|
|
463
|
-
const stringify = (0, safe_stable_stringify_1.configure)({
|
|
464
|
-
|
|
465
|
+
const toJSON = (value, prettyPrint = true, retainKeyOrder = false) => {
|
|
466
|
+
const stringify = (0, safe_stable_stringify_1.configure)({
|
|
467
|
+
circularValue: undefined,
|
|
468
|
+
deterministic: !retainKeyOrder,
|
|
469
|
+
});
|
|
470
|
+
return prettyPrint ? stringify(value, null, 2) : stringify(value);
|
|
465
471
|
};
|
|
466
472
|
/**
|
|
467
473
|
* This function returns a lower cased version of the headers passed to it.
|
|
@@ -494,6 +500,21 @@ const toObject = (value) => {
|
|
|
494
500
|
}
|
|
495
501
|
};
|
|
496
502
|
exports.toObject = toObject;
|
|
503
|
+
/**
|
|
504
|
+
* This function removes any properties of an object that match a certain predicate.
|
|
505
|
+
* By default properties with values of undefined, null and "" are removed.
|
|
506
|
+
*
|
|
507
|
+
* - `cleanObject({foo: undefined, bar: "abc", baz: null, buz: ""})` will return `{bar: "abc"}`
|
|
508
|
+
* - `cleanObject({foo: 1, bar: 2, baz: 3}, v => v % 2 === 0)` will filter even number values, returning `{foo: 1, baz: 3}`
|
|
509
|
+
*
|
|
510
|
+
* @param obj A key-value object to remove properties from
|
|
511
|
+
* @param predicate A function that returns true for properties to remove. Defaults to removing properties with undefined, null and "" values.
|
|
512
|
+
* @returns An object with certain properties removed
|
|
513
|
+
*/
|
|
514
|
+
const cleanObject = (obj, predicate) => {
|
|
515
|
+
const defaultPredicate = (v) => v === undefined || v === null || v === "";
|
|
516
|
+
return (0, lodash_1.omitBy)(obj, predicate || defaultPredicate);
|
|
517
|
+
};
|
|
497
518
|
exports.default = {
|
|
498
519
|
types: {
|
|
499
520
|
isBool,
|
|
@@ -528,5 +549,6 @@ exports.default = {
|
|
|
528
549
|
isConnection,
|
|
529
550
|
isElement,
|
|
530
551
|
toObject: exports.toObject,
|
|
552
|
+
cleanObject,
|
|
531
553
|
},
|
|
532
554
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismatic-io/spectral",
|
|
3
|
-
"version": "8.0
|
|
3
|
+
"version": "8.1.0-preview1",
|
|
4
4
|
"description": "Utility library for building Prismatic components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismatic"
|
|
@@ -42,8 +42,9 @@
|
|
|
42
42
|
"axios-retry": "3.9.1",
|
|
43
43
|
"date-fns": "2.30.0",
|
|
44
44
|
"form-data": "4.0.0",
|
|
45
|
-
"jest-mock": "
|
|
45
|
+
"jest-mock": "29.7.0",
|
|
46
46
|
"lodash": "4.17.21",
|
|
47
|
+
"object-sizeof": "^2.6.4",
|
|
47
48
|
"safe-stable-stringify": "2.3.1",
|
|
48
49
|
"serialize-error": "8.1.0",
|
|
49
50
|
"url-join": "5.0.0",
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
"yaml": "2.3.4"
|
|
53
54
|
},
|
|
54
55
|
"devDependencies": {
|
|
55
|
-
"@types/jest": "
|
|
56
|
+
"@types/jest": "29.5.12",
|
|
56
57
|
"@types/lodash": "4.14.202",
|
|
57
58
|
"@types/node": "14.14.35",
|
|
58
59
|
"@types/sax": "1.2.4",
|
|
@@ -63,12 +64,12 @@
|
|
|
63
64
|
"@typescript-eslint/parser": "5.18.0",
|
|
64
65
|
"eslint": "8.12.0",
|
|
65
66
|
"eslint-config-prettier": "8.5.0",
|
|
66
|
-
"eslint-plugin-jest": "
|
|
67
|
+
"eslint-plugin-jest": "27.9.0",
|
|
67
68
|
"eslint-plugin-prettier": "4.0.0",
|
|
68
69
|
"fast-check": "2.16.0",
|
|
69
|
-
"jest": "
|
|
70
|
+
"jest": "29.7.0",
|
|
70
71
|
"prettier": "2.6.2",
|
|
71
|
-
"ts-jest": "
|
|
72
|
+
"ts-jest": "29.1.2",
|
|
72
73
|
"tsd": "0.20.0",
|
|
73
74
|
"typedoc": "0.17.7",
|
|
74
75
|
"typedoc-plugin-markdown": "2.4.2",
|