@prismatic-io/spectral 5.0.0-rc.0 → 5.0.0-rc.1
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 +2 -4
- package/dist/index.js +5 -14
- package/dist/testing.d.ts +2 -2
- package/dist/testing.js +2 -2
- package/dist/types/ActionInputParameters.d.ts +4 -4
- package/dist/types/ComponentDefinition.d.ts +2 -2
- package/dist/types/ConnectionDefinition.d.ts +9 -0
- package/dist/types/ConnectionDefinition.js +2 -0
- package/dist/types/InputFieldType.d.ts +2 -1
- package/dist/types/Inputs.d.ts +5 -13
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/server-types.d.ts +12 -11
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
* Both component author-facing types and server types that
|
|
8
8
|
* the Prismatic API expects are imported here.
|
|
9
9
|
*/
|
|
10
|
-
import { ActionDefinition, InputFieldDefinition, ActionPerformReturn, ComponentDefinition,
|
|
10
|
+
import { ActionDefinition, InputFieldDefinition, ActionPerformReturn, ComponentDefinition, ConnectionDefinition, Inputs, TriggerDefinition, TriggerResult } from "./types";
|
|
11
11
|
import { Component } from "./types/server-types";
|
|
12
12
|
/**
|
|
13
13
|
* This function creates a component object that can be
|
|
@@ -52,9 +52,7 @@ export declare const input: <T extends InputFieldDefinition>(definition: T) => T
|
|
|
52
52
|
* @param definition A ConnectionfieldDefinition object that describes the type of a connection for a custom component action or trigger, and information on how it should be displayed in the Prismatic WebApp.
|
|
53
53
|
* @returns This functions validates the shape of the `definition` object provided and returns the same connection object.
|
|
54
54
|
*/
|
|
55
|
-
export declare const connection: <T extends
|
|
56
|
-
type: "connection";
|
|
57
|
-
};
|
|
55
|
+
export declare const connection: <T extends ConnectionDefinition>(definition: T) => T;
|
|
58
56
|
export { default as util } from "./util";
|
|
59
57
|
export * from "./types";
|
|
60
58
|
export { default as testing } from "./testing";
|
package/dist/index.js
CHANGED
|
@@ -19,13 +19,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
21
|
exports.testing = exports.util = exports.connection = exports.input = exports.trigger = exports.action = exports.component = void 0;
|
|
22
|
-
const convertInput = (key, input) => {
|
|
23
|
-
var _a;
|
|
24
|
-
if ("inputs" in input) {
|
|
25
|
-
return Object.assign(Object.assign({}, input), { key, inputs: Object.entries((_a = input.inputs) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => convertInput(key, value)) });
|
|
26
|
-
}
|
|
27
|
-
return Object.assign(Object.assign({}, input), { key });
|
|
28
|
-
};
|
|
22
|
+
const convertInput = (key, input) => (Object.assign(Object.assign({}, input), { key }));
|
|
29
23
|
/**
|
|
30
24
|
* This is a helper function for component() to convert an
|
|
31
25
|
* action defined in TypeScript into an action object that
|
|
@@ -50,9 +44,9 @@ const convertTrigger = (triggerKey, trigger) => {
|
|
|
50
44
|
var _a;
|
|
51
45
|
return (Object.assign(Object.assign({}, trigger), { key: triggerKey, inputs: Object.entries((_a = trigger.inputs) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => convertInput(key, value)), perform: trigger.perform, examplePayload: trigger.examplePayload || undefined }));
|
|
52
46
|
};
|
|
53
|
-
const convertConnection = (
|
|
47
|
+
const convertConnection = (connection) => {
|
|
54
48
|
var _a;
|
|
55
|
-
return (Object.assign(Object.assign({}, connection), {
|
|
49
|
+
return (Object.assign(Object.assign({}, connection), { inputs: Object.entries((_a = connection.inputs) !== null && _a !== void 0 ? _a : {}).map(([key, value]) => convertInput(key, value)) }));
|
|
56
50
|
};
|
|
57
51
|
/**
|
|
58
52
|
* This function creates a component object that can be
|
|
@@ -68,10 +62,7 @@ const component = (definition) => (Object.assign(Object.assign({}, definition),
|
|
|
68
62
|
])), triggers: Object.fromEntries(Object.entries(definition.triggers || {}).map(([triggerKey, trigger]) => [
|
|
69
63
|
triggerKey,
|
|
70
64
|
convertTrigger(triggerKey, trigger),
|
|
71
|
-
])), connections:
|
|
72
|
-
connectionKey,
|
|
73
|
-
convertConnection(connectionKey, connection),
|
|
74
|
-
])) }));
|
|
65
|
+
])), connections: (definition.connections || []).map(convertConnection) }));
|
|
75
66
|
exports.component = component;
|
|
76
67
|
/**
|
|
77
68
|
* This function creates an action object that can be referenced
|
|
@@ -110,7 +101,7 @@ exports.input = input;
|
|
|
110
101
|
* @param definition A ConnectionfieldDefinition object that describes the type of a connection for a custom component action or trigger, and information on how it should be displayed in the Prismatic WebApp.
|
|
111
102
|
* @returns This functions validates the shape of the `definition` object provided and returns the same connection object.
|
|
112
103
|
*/
|
|
113
|
-
const connection = (definition) =>
|
|
104
|
+
const connection = (definition) => definition;
|
|
114
105
|
exports.connection = connection;
|
|
115
106
|
var util_1 = require("./util");
|
|
116
107
|
Object.defineProperty(exports, "util", { enumerable: true, get: function () { return __importDefault(util_1).default; } });
|
package/dist/testing.d.ts
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
* https://prismatic.io/docs/custom-components/writing-custom-components/#testing-a-component
|
|
6
6
|
*/
|
|
7
7
|
/** */
|
|
8
|
-
import { ActionContext, ActionLogger, ActionDefinition, ActionInputParameters,
|
|
9
|
-
export declare const createConnection: <T extends
|
|
8
|
+
import { ActionContext, ActionLogger, ActionDefinition, ActionInputParameters, ConnectionDefinition, Connection, ActionPerformReturn, Inputs, TriggerDefinition, TriggerResult, TriggerPayload } from "./types";
|
|
9
|
+
export declare const createConnection: <T extends ConnectionDefinition>({ key }: T, values: Record<string, unknown>) => Connection;
|
|
10
10
|
/**
|
|
11
11
|
* Pre-built mock of ActionLogger. Suitable for asserting logs are created as expected.
|
|
12
12
|
* See https://prismatic.io/docs/custom-components/writing-custom-components/#verifying-correct-logging-in-action-tests for information on testing correct logging behavior in your custom component.
|
package/dist/testing.js
CHANGED
|
@@ -17,9 +17,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
17
17
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
18
|
exports.invokeTrigger = exports.defaultTriggerPayload = exports.invoke = exports.loggerMock = exports.createConnection = void 0;
|
|
19
19
|
const jest_mock_1 = require("jest-mock");
|
|
20
|
-
const createConnection = ({
|
|
20
|
+
const createConnection = ({ key }, values) => ({
|
|
21
21
|
instanceConfigVarId: "",
|
|
22
|
-
key
|
|
22
|
+
key,
|
|
23
23
|
fields: values,
|
|
24
24
|
});
|
|
25
25
|
exports.createConnection = createConnection;
|
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { InputFieldDefinition, Inputs, InputFieldTypeMap
|
|
1
|
+
import { InputFieldDefinition, Inputs, InputFieldTypeMap } from ".";
|
|
2
2
|
/**
|
|
3
3
|
* Collection of input parameters.
|
|
4
4
|
* Inputs can be static values, references to config variables, or
|
|
5
5
|
* references to previous steps' outputs.
|
|
6
6
|
*/
|
|
7
|
-
export declare type ActionInputParameters<TInputs extends Inputs> = {
|
|
8
|
-
[Property in keyof TInputs]:
|
|
9
|
-
};
|
|
7
|
+
export declare type ActionInputParameters<TInputs extends Inputs> = TInputs extends Record<string, InputFieldDefinition> ? {
|
|
8
|
+
[Property in keyof TInputs]: ExtractValue<TInputs[Property]>;
|
|
9
|
+
} : never;
|
|
10
10
|
export declare type ExtractValue<TValue extends InputFieldDefinition> = MapCollectionValues<InputFieldTypeMap[TValue["type"]], TValue["collection"]>;
|
|
11
11
|
export declare type MapCollectionValues<TType, TCollection extends InputFieldDefinition["collection"] | undefined> = TCollection extends "keyvaluelist" ? KeyValuePair<TType>[] | undefined : TCollection extends "valuelist" ? TType[] | undefined : TType;
|
|
12
12
|
/**
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Component } from "./server-types";
|
|
2
|
-
import { ActionPerformReturn, ActionDefinition, TriggerDefinition, TriggerResult
|
|
2
|
+
import { ActionPerformReturn, ActionDefinition, ConnectionDefinition, TriggerDefinition, TriggerResult } from ".";
|
|
3
3
|
export declare type ComponentDefinition<T extends boolean> = Omit<Component<T>, "actions" | "triggers" | "connections"> & {
|
|
4
4
|
actions?: Record<string, ActionDefinition<any, boolean, ActionPerformReturn<boolean, any>>>;
|
|
5
5
|
triggers?: Record<string, TriggerDefinition<any, boolean, TriggerResult<boolean>>>;
|
|
6
|
-
connections?:
|
|
6
|
+
connections?: ConnectionDefinition[];
|
|
7
7
|
};
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { Connection } from ".";
|
|
1
2
|
import { ConditionalExpression } from "./conditional-logic";
|
|
2
3
|
/** InputField type enumeration. */
|
|
3
4
|
export declare type InputFieldType = keyof InputFieldTypeMap;
|
|
@@ -9,5 +10,5 @@ export declare type InputFieldTypeMap = {
|
|
|
9
10
|
boolean: unknown;
|
|
10
11
|
code: unknown;
|
|
11
12
|
conditional: ConditionalExpression;
|
|
12
|
-
connection:
|
|
13
|
+
connection: Connection;
|
|
13
14
|
};
|
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -3,7 +3,7 @@ export declare type Inputs = Record<string, InputFieldDefinition>;
|
|
|
3
3
|
export declare type ConnectionInputs = Record<string, DefaultInputFieldDefinition & {
|
|
4
4
|
shown?: boolean;
|
|
5
5
|
}>;
|
|
6
|
-
export declare type InputFieldDefinition = DefaultInputFieldDefinition | CodeInputFieldDefinition
|
|
6
|
+
export declare type InputFieldDefinition = DefaultInputFieldDefinition | CodeInputFieldDefinition;
|
|
7
7
|
interface BaseInputFieldDefinition {
|
|
8
8
|
/** Interface label of the InputField. */
|
|
9
9
|
label: string;
|
|
@@ -24,7 +24,7 @@ interface BaseInputFieldDefinition {
|
|
|
24
24
|
}
|
|
25
25
|
/** Defines attributes of a InputField. */
|
|
26
26
|
export interface DefaultInputFieldDefinition extends BaseInputFieldDefinition {
|
|
27
|
-
type: Exclude<InputFieldType, "code"
|
|
27
|
+
type: Exclude<InputFieldType, "code">;
|
|
28
28
|
}
|
|
29
29
|
/** Defines attributes of a CodeInputField. */
|
|
30
30
|
export interface CodeInputFieldDefinition extends BaseInputFieldDefinition {
|
|
@@ -35,22 +35,14 @@ export declare enum OAuth2Type {
|
|
|
35
35
|
ClientCredentials = "client_credentials",
|
|
36
36
|
AuthorizationCode = "authorization_code"
|
|
37
37
|
}
|
|
38
|
-
|
|
39
|
-
export interface ConnectionFieldDefinition extends BaseInputFieldDefinition {
|
|
40
|
-
type: Extract<InputFieldType, "connection">;
|
|
41
|
-
connectionKey: string;
|
|
42
|
-
oauth2Type?: OAuth2Type;
|
|
43
|
-
iconPath?: string;
|
|
44
|
-
inputs: ConnectionInputs;
|
|
45
|
-
}
|
|
46
|
-
export interface Connection<TField extends ConnectionFieldDefinition = ConnectionFieldDefinition> {
|
|
38
|
+
export interface Connection {
|
|
47
39
|
/** Key of the Connection type. */
|
|
48
|
-
key:
|
|
40
|
+
key: string;
|
|
49
41
|
/** Identifier for the Config Variable hosting this Connection. */
|
|
50
42
|
instanceConfigVarId: string;
|
|
51
43
|
/** Field values supplied to this Connection. */
|
|
52
44
|
fields: {
|
|
53
|
-
[
|
|
45
|
+
[key: string]: unknown;
|
|
54
46
|
};
|
|
55
47
|
token?: Record<string, unknown>;
|
|
56
48
|
context?: Record<string, unknown>;
|
package/dist/types/index.d.ts
CHANGED
package/dist/types/index.js
CHANGED
|
@@ -29,6 +29,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
29
29
|
exports.serverTypes = void 0;
|
|
30
30
|
__exportStar(require("./ActionDefinition"), exports);
|
|
31
31
|
__exportStar(require("./ComponentDefinition"), exports);
|
|
32
|
+
__exportStar(require("./ConnectionDefinition"), exports);
|
|
32
33
|
__exportStar(require("./Inputs"), exports);
|
|
33
34
|
__exportStar(require("./ActionPerformReturn"), exports);
|
|
34
35
|
__exportStar(require("./DisplayDefinition"), exports);
|
|
@@ -26,7 +26,7 @@ interface ComponentBase<TPublic extends boolean> {
|
|
|
26
26
|
/** Specifies the supported Triggers of this Component. */
|
|
27
27
|
triggers?: Record<string, Trigger>;
|
|
28
28
|
/** Specifies the supported Connections of this Component. */
|
|
29
|
-
connections?:
|
|
29
|
+
connections?: Connection[];
|
|
30
30
|
}
|
|
31
31
|
export declare type Component<TPublic extends boolean> = ComponentBase<TPublic> & (TPublic extends true ? {
|
|
32
32
|
/** Specified the URL for the Component Documentation. */
|
|
@@ -72,6 +72,16 @@ export interface Trigger extends BaseAction {
|
|
|
72
72
|
/** Specifies if this Trigger appears in the list of 'common' Triggers. Only configurable by Prismatic. @default false */
|
|
73
73
|
isCommonTrigger?: boolean;
|
|
74
74
|
}
|
|
75
|
+
export interface Connection {
|
|
76
|
+
key: string;
|
|
77
|
+
label: string;
|
|
78
|
+
comments?: string;
|
|
79
|
+
oauth2Type?: OAuth2Type;
|
|
80
|
+
iconPath?: string;
|
|
81
|
+
inputs: (InputField & {
|
|
82
|
+
shown?: boolean;
|
|
83
|
+
})[];
|
|
84
|
+
}
|
|
75
85
|
/** Collection of input parameters provided by the user or previous steps' outputs */
|
|
76
86
|
interface ActionInputParameters {
|
|
77
87
|
[key: string]: unknown;
|
|
@@ -116,7 +126,7 @@ export declare type TriggerResult = TriggerBranchingResult | TriggerBaseResult |
|
|
|
116
126
|
/** Definition of the function to perform when a Trigger is invoked. */
|
|
117
127
|
export declare type TriggerPerformFunction = (context: ActionContext, payload: TriggerPayload, params: ActionInputParameters) => Promise<TriggerResult>;
|
|
118
128
|
export declare type TriggerPayload = _TriggerPayload;
|
|
119
|
-
export declare type InputField = DefaultInputField | CodeInputField
|
|
129
|
+
export declare type InputField = DefaultInputField | CodeInputField;
|
|
120
130
|
/** Defines attributes of a InputField. */
|
|
121
131
|
interface DefaultInputField {
|
|
122
132
|
/** Unique identifier of the InputField. Must be unique within an Action. */
|
|
@@ -144,15 +154,6 @@ interface CodeInputField extends DefaultInputField {
|
|
|
144
154
|
type: "code";
|
|
145
155
|
language?: string;
|
|
146
156
|
}
|
|
147
|
-
export interface ConnectionField extends DefaultInputField {
|
|
148
|
-
type: "connection";
|
|
149
|
-
key: string;
|
|
150
|
-
oauth2Type?: OAuth2Type;
|
|
151
|
-
iconPath?: string;
|
|
152
|
-
inputs: (Exclude<InputField, ConnectionField> & {
|
|
153
|
-
shown?: boolean;
|
|
154
|
-
})[];
|
|
155
|
-
}
|
|
156
157
|
/** InputField type enumeration. */
|
|
157
158
|
export declare type InputFieldType = "string" | "text" | "password" | "boolean" | "code" | "data" | "conditional" | "connection";
|
|
158
159
|
/** Binary data payload */
|