@prismatic-io/spectral 8.1.0-preview1 → 8.1.0-preview3
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/index.d.ts
CHANGED
|
@@ -14,21 +14,28 @@ 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: <
|
|
17
|
+
export declare const integration: <TComponents extends ComponentSelector<any> = ComponentSelector<any>, TConfigPages extends ConfigPages<TComponents> = ConfigPages<TComponents>>(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
|
|
24
|
+
export declare const flow: <TConfigPages extends ConfigPages<any> = ConfigPages<any>, 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: <
|
|
31
|
+
export declare const configPage: <T extends ConfigPage<any> = ConfigPage<any>>(definition: T) => T;
|
|
32
|
+
/**
|
|
33
|
+
* @returns Helper utility to create component references.
|
|
34
|
+
*/
|
|
35
|
+
export declare const reference: <TComponents extends ComponentSelector<any>>() => {
|
|
36
|
+
connection: <T extends ConnectionConfigVar<TComponents>>(definition: T) => T;
|
|
37
|
+
dataSource: <T_1 extends DataSourceConfigVar<TComponents>>(definition: T_1) => T_1;
|
|
38
|
+
};
|
|
32
39
|
/**
|
|
33
40
|
* For information on writing Code Native Integrations, see
|
|
34
41
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
@@ -42,14 +49,14 @@ export declare const configVar: <T extends StandardConfigVar | ScheduleConfigVar
|
|
|
42
49
|
* @param definition A Data Source Config Var type object.
|
|
43
50
|
* @returns This function returns a data source config var object that has the shape the Prismatic API expects.
|
|
44
51
|
*/
|
|
45
|
-
export declare const dataSourceConfigVar: <
|
|
52
|
+
export declare const dataSourceConfigVar: <T extends DataSourceConfigVar<any> = DataSourceConfigVar<any>>(definition: T) => T;
|
|
46
53
|
/**
|
|
47
54
|
* For information on writing Code Native Integrations, see
|
|
48
55
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
49
56
|
* @param definition A Connection Config Var type object.
|
|
50
57
|
* @returns This function returns a connection config var object that has the shape the Prismatic API expects.
|
|
51
58
|
*/
|
|
52
|
-
export declare const connectionConfigVar: <
|
|
59
|
+
export declare const connectionConfigVar: <T extends ConnectionConfigVar<any> = ConnectionConfigVar<any>>(definition: T) => T;
|
|
53
60
|
/**
|
|
54
61
|
* This function creates a component object that can be
|
|
55
62
|
* imported into the Prismatic API. For information on using
|
package/dist/index.js
CHANGED
|
@@ -22,7 +22,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
22
22
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.testing = exports.util = exports.oauth2Connection = exports.onPremiseConnection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0;
|
|
25
|
+
exports.testing = exports.util = exports.oauth2Connection = exports.onPremiseConnection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.reference = exports.configPage = exports.flow = exports.integration = void 0;
|
|
26
26
|
const convert_1 = require("./serverTypes/convert");
|
|
27
27
|
const convertIntegration_1 = require("./serverTypes/convertIntegration");
|
|
28
28
|
/**
|
|
@@ -58,6 +58,14 @@ exports.flow = flow;
|
|
|
58
58
|
*/
|
|
59
59
|
const configPage = (definition) => definition;
|
|
60
60
|
exports.configPage = configPage;
|
|
61
|
+
/**
|
|
62
|
+
* @returns Helper utility to create component references.
|
|
63
|
+
*/
|
|
64
|
+
const reference = () => ({
|
|
65
|
+
connection: (definition) => definition,
|
|
66
|
+
dataSource: (definition) => definition,
|
|
67
|
+
});
|
|
68
|
+
exports.reference = reference;
|
|
61
69
|
/**
|
|
62
70
|
* For information on writing Code Native Integrations, see
|
|
63
71
|
* https://prismatic.io/docs/code-native-integrations/#adding-config-vars.
|
|
@@ -1,3 +1,3 @@
|
|
|
1
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<any>, ComponentSelector<any>>) => ServerComponent;
|
package/dist/testing.d.ts
CHANGED
|
@@ -63,7 +63,11 @@ 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
|
|
66
|
+
export declare const invokeFlow: <TConfigPages extends ConfigPages<any>, TConfigVars extends ConfigVarResultCollection = import("./types/utils").Prettify<{ [Key in keyof import("./types").GetElements<TConfigPages> as Key extends string ? Key : never]: import("./types").ElementToRuntimeType<import("./types").GetElements<TConfigPages>[Key]>; }>, TConfigVarValues extends TestConfigVarValues = ToTestValues<TConfigVars>>(flow: Flow<TConfigPages, ComponentSelector<any>, import("./types").TriggerPayload>, { configVars, context, payload, }?: {
|
|
67
|
+
configVars?: TConfigVarValues | undefined;
|
|
68
|
+
context?: Partial<ActionContext<TConfigVars>> | undefined;
|
|
69
|
+
payload?: Partial<TriggerPayload> | undefined;
|
|
70
|
+
}) => Promise<InvokeReturn<InvokeActionPerformReturn<false, unknown>>>;
|
|
67
71
|
export declare class ComponentTestHarness<TComponent extends Component> {
|
|
68
72
|
component: TComponent;
|
|
69
73
|
constructor(component: TComponent);
|
package/dist/testing.js
CHANGED
|
@@ -178,7 +178,7 @@ const invokeDataSource = ({ perform }, params, context) => __awaiter(void 0, voi
|
|
|
178
178
|
});
|
|
179
179
|
exports.invokeDataSource = invokeDataSource;
|
|
180
180
|
const createConfigVars = (values) => {
|
|
181
|
-
return Object.entries(values).reduce((result, [key, value]) => {
|
|
181
|
+
return Object.entries(values !== null && values !== void 0 ? values : {}).reduce((result, [key, value]) => {
|
|
182
182
|
// Connection
|
|
183
183
|
if (typeof value === "object" && "fields" in value) {
|
|
184
184
|
return Object.assign(Object.assign({}, result), { [key]: Object.assign(Object.assign({}, value), { key, configVarKey: "" }) });
|
|
@@ -190,12 +190,12 @@ const createConfigVars = (values) => {
|
|
|
190
190
|
* Invokes specified Flow of a Code Native Integration using supplied params.
|
|
191
191
|
* Runs the Trigger and then the Action function and returns the result of the Action.
|
|
192
192
|
*/
|
|
193
|
-
const invokeFlow = (flow, configVars, context, payload) => __awaiter(void 0, void 0, void 0, function* () {
|
|
193
|
+
const invokeFlow = (flow, { configVars, context, payload, } = {}) => __awaiter(void 0, void 0, void 0, function* () {
|
|
194
194
|
const realizedConfigVars = createConfigVars(configVars);
|
|
195
195
|
const realizedContext = createActionContext(Object.assign(Object.assign({}, context), { configVars: realizedConfigVars }));
|
|
196
196
|
const realizedPayload = Object.assign(Object.assign({}, (0, exports.defaultTriggerPayload)()), payload);
|
|
197
197
|
const params = {
|
|
198
|
-
onTrigger: { results:
|
|
198
|
+
onTrigger: { results: realizedPayload },
|
|
199
199
|
};
|
|
200
200
|
if ("onTrigger" in flow && typeof flow.onTrigger === "function") {
|
|
201
201
|
const triggerResult = yield flow.onTrigger(realizedContext, realizedPayload, params);
|
|
@@ -1,13 +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
|
-
declare type ToDataSourceRuntimeType<TType extends DataSourceType> = TType extends "jsonForm" ? JSONForm : TType extends "objectSelection" ? ObjectSelection : TType extends "objectFieldMap" ? ObjectFieldMap : string;
|
|
4
|
-
export declare type ElementToRuntimeType<TElement extends ConfigPageElement
|
|
5
|
-
declare type GetElements<TConfigPages extends ConfigPages
|
|
6
|
-
export declare type ExtractConfigVars<TConfigPages extends ConfigPages
|
|
3
|
+
export declare type ToDataSourceRuntimeType<TType extends DataSourceType> = TType extends "jsonForm" ? JSONForm : TType extends "objectSelection" ? ObjectSelection : TType extends "objectFieldMap" ? ObjectFieldMap : string;
|
|
4
|
+
export declare type ElementToRuntimeType<TElement extends ConfigPageElement<any>> = TElement extends ConnectionConfigVar<any> ? Connection : TElement extends DataSourceConfigVar<any> ? ToDataSourceRuntimeType<TElement["dataSourceType"]> : TElement extends ScheduleConfigVar ? Schedule : TElement extends StandardConfigVar ? string : never;
|
|
5
|
+
export declare type GetElements<TConfigPages extends ConfigPages<any>> = TConfigPages extends ConfigPages<any> ? UnionToIntersection<ValueOf<TConfigPages>["elements"]> : never;
|
|
6
|
+
export declare type ExtractConfigVars<TConfigPages extends ConfigPages<any>, TElements extends ConfigPage<any>["elements"] = GetElements<TConfigPages>> = Prettify<{
|
|
7
7
|
[Key in keyof TElements as Key extends string ? Key : never]: ElementToRuntimeType<TElements[Key]>;
|
|
8
8
|
}>;
|
|
9
9
|
/** Defines attributes of a Code-Native Integration. */
|
|
10
|
-
export declare type IntegrationDefinition<TConfigPages extends ConfigPages
|
|
10
|
+
export declare type IntegrationDefinition<TConfigPages extends ConfigPages<TComponents>, TComponents extends ComponentSelector<any>> = {
|
|
11
11
|
/** The unique name for this Integration. */
|
|
12
12
|
name: string;
|
|
13
13
|
/** Optional description for this Integration. */
|
|
@@ -35,7 +35,7 @@ export declare type IntegrationDefinition<TConfigPages extends ConfigPages, TCom
|
|
|
35
35
|
configPages?: TConfigPages;
|
|
36
36
|
};
|
|
37
37
|
/** Defines attributes of a Flow of a Code-Native Integration. */
|
|
38
|
-
export interface Flow<TConfigPages extends ConfigPages
|
|
38
|
+
export interface Flow<TConfigPages extends ConfigPages<TComponents>, TComponents extends ComponentSelector<any>, TTriggerPayload extends TriggerPayload = TriggerPayload> {
|
|
39
39
|
/** The unique name for this Flow. */
|
|
40
40
|
name: string;
|
|
41
41
|
/** A unique, unchanging value that is used to maintain identity for the Flow even if the name changes. */
|
|
@@ -112,26 +112,26 @@ export declare type ScheduleConfigVar = BaseConfigVar & {
|
|
|
112
112
|
declare type DataSourceDefinitionConfigVar = BaseConfigVar & Omit<DataSourceDefinition<Inputs, ConfigVarResultCollection, DataSourceType>, "display" | "inputs" | "examplePayload">;
|
|
113
113
|
declare type DataSourceReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseConfigVar & {
|
|
114
114
|
dataSourceType: DataSourceType;
|
|
115
|
-
dataSource: ToComponentReferences<"dataSource", TComponents, ConfigPages
|
|
115
|
+
dataSource: ToComponentReferences<"dataSource", TComponents, ConfigPages<TComponents>>;
|
|
116
116
|
};
|
|
117
117
|
/** Defines attributes of a data source Config Var. */
|
|
118
|
-
export declare type DataSourceConfigVar<TComponents extends ComponentSelector<any
|
|
118
|
+
export declare type DataSourceConfigVar<TComponents extends ComponentSelector<any>> = DataSourceDefinitionConfigVar | DataSourceReferenceConfigVar<TComponents>;
|
|
119
119
|
declare type ConnectionDefinitionConfigVar = BaseConfigVar & Omit<ConnectionDefinition, "label" | "comments" | "key">;
|
|
120
120
|
declare type ConnectionReferenceConfigVar<TComponents extends ComponentSelector<any>> = BaseConfigVar & {
|
|
121
121
|
connection: ToComponentReferences<"connection", TComponents>;
|
|
122
122
|
};
|
|
123
123
|
/** Defines attributes of a Config Var that represents a Connection. */
|
|
124
|
-
export declare type ConnectionConfigVar<TComponents extends ComponentSelector<any
|
|
125
|
-
export declare type ConfigVar<TComponents extends ComponentSelector<any
|
|
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
|
|
129
|
-
export declare const isConnectionDefinitionConfigVar: (cv: ConfigVar) => cv is ConnectionDefinitionConfigVar;
|
|
130
|
-
export declare const isConnectionReferenceConfigVar: <TComponents extends ComponentSelector<any
|
|
131
|
-
export declare type ConfigPageElement<TComponents extends ComponentSelector<any
|
|
132
|
-
export declare type ConfigPages = Record<string, ConfigPage
|
|
124
|
+
export declare type ConnectionConfigVar<TComponents extends ComponentSelector<any>> = ConnectionDefinitionConfigVar | ConnectionReferenceConfigVar<TComponents>;
|
|
125
|
+
export declare type ConfigVar<TComponents extends ComponentSelector<any>> = StandardConfigVar | ScheduleConfigVar | DataSourceConfigVar<TComponents> | ConnectionConfigVar<TComponents>;
|
|
126
|
+
export declare const isScheduleConfigVar: (cv: ConfigVar<any>) => cv is ScheduleConfigVar;
|
|
127
|
+
export declare const isDataSourceDefinitionConfigVar: (cv: ConfigVar<any>) => cv is DataSourceDefinitionConfigVar;
|
|
128
|
+
export declare const isDataSourceReferenceConfigVar: <TComponents extends ComponentSelector<any>>(cv: ConfigVar<TComponents>) => cv is DataSourceReferenceConfigVar<TComponents>;
|
|
129
|
+
export declare const isConnectionDefinitionConfigVar: (cv: ConfigVar<any>) => cv is ConnectionDefinitionConfigVar;
|
|
130
|
+
export declare const isConnectionReferenceConfigVar: <TComponents extends ComponentSelector<any>>(cv: ConfigVar<TComponents>) => cv is ConnectionReferenceConfigVar<TComponents>;
|
|
131
|
+
export declare type ConfigPageElement<TComponents extends ComponentSelector<any>> = string | ConfigVar<TComponents>;
|
|
132
|
+
export declare type ConfigPages<TComponents extends ComponentSelector<any>> = Record<string, ConfigPage<TComponents>>;
|
|
133
133
|
/** Defines attributes of a Config Wizard Page used when deploying an Instance of an Integration. */
|
|
134
|
-
export declare type ConfigPage<TComponents extends ComponentSelector<any
|
|
134
|
+
export declare type ConfigPage<TComponents extends ComponentSelector<any>> = {
|
|
135
135
|
/** Elements included on this Config Page. */
|
|
136
136
|
elements: Record<string, ConfigPageElement<TComponents>>;
|
|
137
137
|
/** Specifies an optional tagline for this Config Page. */
|
|
@@ -184,9 +184,9 @@ export declare type CodeLanguageType = "json" | "xml" | "html";
|
|
|
184
184
|
export declare type CollectionType = "valuelist" | "keyvaluelist";
|
|
185
185
|
/** Choices of component reference types. */
|
|
186
186
|
export declare type ComponentSelectorType = "trigger" | "connection" | "dataSource";
|
|
187
|
-
export declare type ValueReference<TValueType, TConfigPages extends ConfigPages
|
|
187
|
+
export declare type ValueReference<TValueType, TConfigPages extends ConfigPages<any>, TConfigVarKeys = keyof ExtractConfigVars<TConfigPages>> = {
|
|
188
188
|
value: TValueType;
|
|
189
|
-
} | (TConfigPages extends ConfigPages ? {
|
|
189
|
+
} | (TConfigPages extends ConfigPages<any> ? {
|
|
190
190
|
configVar: TConfigVarKeys;
|
|
191
191
|
} : never);
|
|
192
192
|
export interface ComponentSelector<TValueType> {
|
|
@@ -200,14 +200,14 @@ export interface ComponentSelector<TValueType> {
|
|
|
200
200
|
[key: string]: TValueType;
|
|
201
201
|
};
|
|
202
202
|
}
|
|
203
|
-
export declare type ToComponentReferences<TReferenceType extends ComponentSelectorType,
|
|
204
|
-
component:
|
|
205
|
-
key:
|
|
203
|
+
export declare type ToComponentReferences<TReferenceType extends ComponentSelectorType, TComponents extends ComponentSelector<any>, TConfigPages extends ConfigPages<TComponents> = never> = TComponents extends ComponentSelector<infer TValueType> ? TComponents["type"] extends TReferenceType ? {
|
|
204
|
+
component: TComponents["component"];
|
|
205
|
+
key: TComponents["key"];
|
|
206
206
|
values: {
|
|
207
|
-
[K in keyof
|
|
207
|
+
[K in keyof TComponents["values"]]: ValueReference<TValueType, TConfigPages>;
|
|
208
208
|
};
|
|
209
209
|
} : never : never;
|
|
210
|
-
export interface ComponentReference<TValueType, TConfigPages extends ConfigPages
|
|
210
|
+
export interface ComponentReference<TValueType, TConfigPages extends ConfigPages<any>> {
|
|
211
211
|
component: string | {
|
|
212
212
|
key: string;
|
|
213
213
|
isPublic: boolean;
|
|
@@ -217,5 +217,5 @@ export interface ComponentReference<TValueType, TConfigPages extends ConfigPages
|
|
|
217
217
|
[key: string]: ValueReference<TValueType, TConfigPages>;
|
|
218
218
|
};
|
|
219
219
|
}
|
|
220
|
-
export declare const isComponentReference: (ref: unknown) => ref is ComponentReference<any, ConfigPages
|
|
220
|
+
export declare const isComponentReference: (ref: unknown) => ref is ComponentReference<any, ConfigPages<any>>;
|
|
221
221
|
export {};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@prismatic-io/spectral",
|
|
3
|
-
"version": "8.1.0-
|
|
3
|
+
"version": "8.1.0-preview3",
|
|
4
4
|
"description": "Utility library for building Prismatic components",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"prismatic"
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
"jest": "29.7.0",
|
|
71
71
|
"prettier": "2.6.2",
|
|
72
72
|
"ts-jest": "29.1.2",
|
|
73
|
-
"tsd": "0.
|
|
73
|
+
"tsd": "0.31.0",
|
|
74
74
|
"typedoc": "0.17.7",
|
|
75
75
|
"typedoc-plugin-markdown": "2.4.2",
|
|
76
76
|
"typedoc-plugin-remove-references": "0.0.5",
|