@prismatic-io/spectral 5.0.0-rc.1 → 5.0.0
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 +10 -3
- package/dist/index.js +10 -2
- package/dist/testing.js +5 -3
- package/dist/types/ActionDefinition.d.ts +2 -0
- package/dist/types/ActionLogger.d.ts +2 -0
- package/dist/types/ActionPerformFunction.d.ts +2 -0
- package/dist/types/ActionPerformReturn.d.ts +3 -1
- package/dist/types/ConnectionDefinition.d.ts +36 -4
- package/dist/types/ConnectionDefinition.js +6 -0
- package/dist/types/DisplayDefinition.d.ts +2 -2
- package/dist/types/Inputs.d.ts +4 -8
- package/dist/types/Inputs.js +0 -6
- package/dist/types/TriggerDefinition.d.ts +2 -0
- package/dist/types/TriggerResult.d.ts +3 -1
- package/dist/types/server-types.d.ts +8 -2
- 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, DefaultConnectionDefinition, OAuth2ConnectionDefinition, 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
|
|
@@ -49,10 +49,17 @@ export declare const input: <T extends InputFieldDefinition>(definition: T) => T
|
|
|
49
49
|
/**
|
|
50
50
|
* For information on writing custom component connections, see
|
|
51
51
|
* https://prismatic.io/docs/custom-components/writing-custom-components/#adding-connections.
|
|
52
|
-
* @param definition A
|
|
52
|
+
* @param definition A DefaultConnectionDefinition 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
|
|
55
|
+
export declare const connection: <T extends DefaultConnectionDefinition>(definition: T) => T;
|
|
56
|
+
/**
|
|
57
|
+
* For information on writing custom component connections, see
|
|
58
|
+
* https://prismatic.io/docs/custom-components/writing-custom-components/#adding-connections.
|
|
59
|
+
* @param definition An OAuth2ConnectionDefinition 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.
|
|
60
|
+
* @returns This functions validates the shape of the `definition` object provided and returns the same connection object.
|
|
61
|
+
*/
|
|
62
|
+
export declare const oauth2Connection: <T extends OAuth2ConnectionDefinition>(definition: T) => T;
|
|
56
63
|
export { default as util } from "./util";
|
|
57
64
|
export * from "./types";
|
|
58
65
|
export { default as testing } from "./testing";
|
package/dist/index.js
CHANGED
|
@@ -18,7 +18,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
18
18
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
19
19
|
};
|
|
20
20
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
21
|
-
exports.testing = exports.util = exports.connection = exports.input = exports.trigger = exports.action = exports.component = void 0;
|
|
21
|
+
exports.testing = exports.util = exports.oauth2Connection = exports.connection = exports.input = exports.trigger = exports.action = exports.component = void 0;
|
|
22
22
|
const convertInput = (key, input) => (Object.assign(Object.assign({}, input), { key }));
|
|
23
23
|
/**
|
|
24
24
|
* This is a helper function for component() to convert an
|
|
@@ -98,11 +98,19 @@ exports.input = input;
|
|
|
98
98
|
/**
|
|
99
99
|
* For information on writing custom component connections, see
|
|
100
100
|
* https://prismatic.io/docs/custom-components/writing-custom-components/#adding-connections.
|
|
101
|
-
* @param definition A
|
|
101
|
+
* @param definition A DefaultConnectionDefinition 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.
|
|
102
102
|
* @returns This functions validates the shape of the `definition` object provided and returns the same connection object.
|
|
103
103
|
*/
|
|
104
104
|
const connection = (definition) => definition;
|
|
105
105
|
exports.connection = connection;
|
|
106
|
+
/**
|
|
107
|
+
* For information on writing custom component connections, see
|
|
108
|
+
* https://prismatic.io/docs/custom-components/writing-custom-components/#adding-connections.
|
|
109
|
+
* @param definition An OAuth2ConnectionDefinition 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.
|
|
110
|
+
* @returns This functions validates the shape of the `definition` object provided and returns the same connection object.
|
|
111
|
+
*/
|
|
112
|
+
const oauth2Connection = (definition) => definition;
|
|
113
|
+
exports.oauth2Connection = oauth2Connection;
|
|
106
114
|
var util_1 = require("./util");
|
|
107
115
|
Object.defineProperty(exports, "util", { enumerable: true, get: function () { return __importDefault(util_1).default; } });
|
|
108
116
|
__exportStar(require("./types"), exports);
|
package/dist/testing.js
CHANGED
|
@@ -18,7 +18,7 @@ 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
20
|
const createConnection = ({ key }, values) => ({
|
|
21
|
-
|
|
21
|
+
configVarKey: "",
|
|
22
22
|
key,
|
|
23
23
|
fields: values,
|
|
24
24
|
});
|
|
@@ -28,6 +28,8 @@ exports.createConnection = createConnection;
|
|
|
28
28
|
* 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.
|
|
29
29
|
*/
|
|
30
30
|
const loggerMock = () => ({
|
|
31
|
+
metric: console.log,
|
|
32
|
+
trace: jest_mock_1.spyOn(console, "trace"),
|
|
31
33
|
debug: jest_mock_1.spyOn(console, "debug"),
|
|
32
34
|
info: jest_mock_1.spyOn(console, "info"),
|
|
33
35
|
log: jest_mock_1.spyOn(console, "log"),
|
|
@@ -43,7 +45,7 @@ exports.loggerMock = loggerMock;
|
|
|
43
45
|
*/
|
|
44
46
|
const invoke = (actionBase, params, context) => __awaiter(void 0, void 0, void 0, function* () {
|
|
45
47
|
const action = (actionBase.perform ? actionBase : Object.values(actionBase)[0]);
|
|
46
|
-
const realizedContext = Object.assign({ logger: exports.loggerMock(), instanceState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
|
|
48
|
+
const realizedContext = Object.assign({ logger: exports.loggerMock(), instanceState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
|
|
47
49
|
const result = yield action.perform(realizedContext, params);
|
|
48
50
|
return {
|
|
49
51
|
result,
|
|
@@ -88,7 +90,7 @@ exports.defaultTriggerPayload = defaultTriggerPayload;
|
|
|
88
90
|
*/
|
|
89
91
|
const invokeTrigger = (triggerBase, context, payload, params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
90
92
|
const trigger = (triggerBase.perform ? triggerBase : Object.values(triggerBase)[0]);
|
|
91
|
-
const realizedContext = Object.assign({ logger: exports.loggerMock(), instanceState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
|
|
93
|
+
const realizedContext = Object.assign({ logger: exports.loggerMock(), instanceState: {}, executionState: {}, stepId: "mockStepId", executionId: "mockExecutionId" }, context);
|
|
92
94
|
const realizedPayload = Object.assign(Object.assign({}, exports.defaultTriggerPayload()), payload);
|
|
93
95
|
const realizedParams = params || {};
|
|
94
96
|
const result = yield trigger.perform(realizedContext, realizedPayload, realizedParams);
|
|
@@ -12,6 +12,8 @@ export interface ActionDefinition<T extends Inputs, AllowsBranching extends bool
|
|
|
12
12
|
inputs: T;
|
|
13
13
|
/** Optional attribute that specifies whether an Action will terminate execution.*/
|
|
14
14
|
terminateExecution?: boolean;
|
|
15
|
+
/** Specifies whether an Action will break out of a loop. */
|
|
16
|
+
breakLoop?: boolean;
|
|
15
17
|
/** Determines whether an Action will allow Conditional Branching.*/
|
|
16
18
|
allowsBranching?: AllowsBranching;
|
|
17
19
|
/** Static Branch names associated with an Action. */
|
|
@@ -12,6 +12,8 @@ export declare type ActionLoggerFunction = (...args: unknown[]) => void;
|
|
|
12
12
|
* An object containing logger functions.
|
|
13
13
|
*/
|
|
14
14
|
export interface ActionLogger {
|
|
15
|
+
metric: ActionLoggerFunction;
|
|
16
|
+
trace: ActionLoggerFunction;
|
|
15
17
|
debug: ActionLoggerFunction;
|
|
16
18
|
info: ActionLoggerFunction;
|
|
17
19
|
log: ActionLoggerFunction;
|
|
@@ -7,6 +7,8 @@ export interface ActionContext {
|
|
|
7
7
|
logger: ActionLogger;
|
|
8
8
|
/** A key/value store that may be used to store small amounts of data that is persisted between Instance executions */
|
|
9
9
|
instanceState: Record<string, unknown>;
|
|
10
|
+
/** A key/value store that may be used to store small amounts of data for use later during the execution */
|
|
11
|
+
executionState: Record<string, unknown>;
|
|
10
12
|
/** A unique id that corresponds to the step on the Integration */
|
|
11
13
|
stepId: string;
|
|
12
14
|
/** A unique id that corresponds to the specific execution of the Integration */
|
|
@@ -7,7 +7,9 @@ export interface ActionPerformDataReturn<ReturnData> {
|
|
|
7
7
|
/** The HTTP Status code that will be used if this terminates a synchronous invocation */
|
|
8
8
|
statusCode?: number;
|
|
9
9
|
/** An optional object, the keys and values of which will be persisted in the instanceState and available for subsequent actions and executions */
|
|
10
|
-
|
|
10
|
+
instanceState?: Record<string, unknown>;
|
|
11
|
+
/** An optional object, the keys and values of which will be persisted in the executionState and available for the duration of the execution */
|
|
12
|
+
executionState?: Record<string, unknown>;
|
|
11
13
|
}
|
|
12
14
|
/** Used to represent a branching return of conventional data and does not require content type to be specified */
|
|
13
15
|
/** Used to represent a binary or serialized data branching return as content type must be specified */
|
|
@@ -1,9 +1,41 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export
|
|
1
|
+
import { ConnectionInput } from ".";
|
|
2
|
+
export declare enum OAuth2Type {
|
|
3
|
+
ClientCredentials = "client_credentials",
|
|
4
|
+
AuthorizationCode = "authorization_code"
|
|
5
|
+
}
|
|
6
|
+
interface BaseConnectionDefinition {
|
|
3
7
|
key: string;
|
|
4
8
|
label: string;
|
|
5
9
|
comments?: string;
|
|
6
|
-
oauth2Type?: OAuth2Type;
|
|
7
10
|
iconPath?: string;
|
|
8
|
-
|
|
11
|
+
oauth2Type?: OAuth2Type;
|
|
12
|
+
}
|
|
13
|
+
export interface DefaultConnectionDefinition extends BaseConnectionDefinition {
|
|
14
|
+
inputs: {
|
|
15
|
+
[key: string]: ConnectionInput;
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
interface OAuth2AuthorizationCodeConnectionDefinition extends BaseConnectionDefinition {
|
|
19
|
+
oauth2Type: OAuth2Type.AuthorizationCode;
|
|
20
|
+
inputs: {
|
|
21
|
+
authorizeUrl: ConnectionInput;
|
|
22
|
+
tokenUrl: ConnectionInput;
|
|
23
|
+
scopes: ConnectionInput;
|
|
24
|
+
clientId: ConnectionInput;
|
|
25
|
+
clientSecret: ConnectionInput;
|
|
26
|
+
[key: string]: ConnectionInput;
|
|
27
|
+
};
|
|
28
|
+
}
|
|
29
|
+
interface OAuth2ClientCredentialConnectionDefinition extends BaseConnectionDefinition {
|
|
30
|
+
oauth2Type: OAuth2Type.ClientCredentials;
|
|
31
|
+
inputs: {
|
|
32
|
+
tokenUrl: ConnectionInput;
|
|
33
|
+
scopes: ConnectionInput;
|
|
34
|
+
clientId: ConnectionInput;
|
|
35
|
+
clientSecret: ConnectionInput;
|
|
36
|
+
[key: string]: ConnectionInput;
|
|
37
|
+
};
|
|
9
38
|
}
|
|
39
|
+
export declare type OAuth2ConnectionDefinition = OAuth2AuthorizationCodeConnectionDefinition | OAuth2ClientCredentialConnectionDefinition;
|
|
40
|
+
export declare type ConnectionDefinition = DefaultConnectionDefinition | OAuth2AuthorizationCodeConnectionDefinition | OAuth2ClientCredentialConnectionDefinition;
|
|
41
|
+
export {};
|
|
@@ -1,2 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OAuth2Type = void 0;
|
|
4
|
+
var OAuth2Type;
|
|
5
|
+
(function (OAuth2Type) {
|
|
6
|
+
OAuth2Type["ClientCredentials"] = "client_credentials";
|
|
7
|
+
OAuth2Type["AuthorizationCode"] = "authorization_code";
|
|
8
|
+
})(OAuth2Type = exports.OAuth2Type || (exports.OAuth2Type = {}));
|
|
@@ -9,8 +9,8 @@ interface DisplayDefinition {
|
|
|
9
9
|
description: string;
|
|
10
10
|
}
|
|
11
11
|
interface ExtraDisplayDefinitionFields {
|
|
12
|
-
/** Path to icon to use for this Component. Path should be relative to component
|
|
13
|
-
iconPath
|
|
12
|
+
/** Path to icon to use for this Component. Path should be relative to the built component source. */
|
|
13
|
+
iconPath: string;
|
|
14
14
|
/** Category of the Component. */
|
|
15
15
|
category?: string;
|
|
16
16
|
}
|
package/dist/types/Inputs.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { InputFieldType } from ".";
|
|
2
2
|
export declare type Inputs = Record<string, InputFieldDefinition>;
|
|
3
|
-
export declare type
|
|
3
|
+
export declare type ConnectionInput = DefaultInputFieldDefinition & {
|
|
4
4
|
shown?: boolean;
|
|
5
|
-
}
|
|
5
|
+
};
|
|
6
6
|
export declare type InputFieldDefinition = DefaultInputFieldDefinition | CodeInputFieldDefinition;
|
|
7
7
|
interface BaseInputFieldDefinition {
|
|
8
8
|
/** Interface label of the InputField. */
|
|
@@ -31,15 +31,11 @@ export interface CodeInputFieldDefinition extends BaseInputFieldDefinition {
|
|
|
31
31
|
type: Extract<InputFieldType, "code">;
|
|
32
32
|
language?: string;
|
|
33
33
|
}
|
|
34
|
-
export declare enum OAuth2Type {
|
|
35
|
-
ClientCredentials = "client_credentials",
|
|
36
|
-
AuthorizationCode = "authorization_code"
|
|
37
|
-
}
|
|
38
34
|
export interface Connection {
|
|
39
35
|
/** Key of the Connection type. */
|
|
40
36
|
key: string;
|
|
41
|
-
/**
|
|
42
|
-
|
|
37
|
+
/** Key for the Config Variable hosting this Connection. */
|
|
38
|
+
configVarKey: string;
|
|
43
39
|
/** Field values supplied to this Connection. */
|
|
44
40
|
fields: {
|
|
45
41
|
[key: string]: unknown;
|
package/dist/types/Inputs.js
CHANGED
|
@@ -1,8 +1,2 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.OAuth2Type = void 0;
|
|
4
|
-
var OAuth2Type;
|
|
5
|
-
(function (OAuth2Type) {
|
|
6
|
-
OAuth2Type["ClientCredentials"] = "client_credentials";
|
|
7
|
-
OAuth2Type["AuthorizationCode"] = "authorization_code";
|
|
8
|
-
})(OAuth2Type = exports.OAuth2Type || (exports.OAuth2Type = {}));
|
|
@@ -19,6 +19,8 @@ export interface TriggerDefinition<T extends Inputs, AllowsBranching extends boo
|
|
|
19
19
|
synchronousResponseSupport: TriggerOptionChoice;
|
|
20
20
|
/** Optional attribute that specifies whether this Trigger will terminate execution. */
|
|
21
21
|
terminateExecution?: boolean;
|
|
22
|
+
/** Specifies whether an Action will break out of a loop. */
|
|
23
|
+
breakLoop?: boolean;
|
|
22
24
|
/** Determines whether this Trigger allows Conditional Branching. */
|
|
23
25
|
allowsBranching?: AllowsBranching;
|
|
24
26
|
/** Static Branch names associated with this Trigger. */
|
|
@@ -7,7 +7,9 @@ export interface TriggerBaseResult {
|
|
|
7
7
|
/** Optional HTTP response to the request that invoked the integration. */
|
|
8
8
|
response?: HttpResponse;
|
|
9
9
|
/** An optional object, the keys and values of which will be persisted in the instanceState and available for subsequent actions and executions */
|
|
10
|
-
|
|
10
|
+
instanceState?: Record<string, unknown>;
|
|
11
|
+
/** An optional object, the keys and values of which will be persisted in the executionState and available for the duration of the execution */
|
|
12
|
+
executionState?: Record<string, unknown>;
|
|
11
13
|
}
|
|
12
14
|
/** Represents the result of a Trigger action that uses branching. */
|
|
13
15
|
export interface TriggerBranchingResult extends TriggerBaseResult {
|
|
@@ -45,6 +45,8 @@ interface BaseAction {
|
|
|
45
45
|
inputs: InputField[];
|
|
46
46
|
/** Optional attribute that specifies whether an Action will terminate execution. */
|
|
47
47
|
terminateExecution?: boolean;
|
|
48
|
+
/** Specifies whether an Action will break out of a loop. */
|
|
49
|
+
breakLoop?: boolean;
|
|
48
50
|
/** Determines whether an Action will allow Conditional Branching. */
|
|
49
51
|
allowsBranching?: boolean;
|
|
50
52
|
/** Static Branch names associated with an Action. */
|
|
@@ -95,7 +97,9 @@ export interface ServerPerformDataStructureReturn {
|
|
|
95
97
|
/** The HTTP Status code that will be used if this terminates a synchronous invocation */
|
|
96
98
|
statusCode?: number;
|
|
97
99
|
/** An optional object, the keys and values of which will be persisted in the instanceState and available for subsequent actions and executions */
|
|
98
|
-
|
|
100
|
+
instanceState?: Record<string, unknown>;
|
|
101
|
+
/** An optional object, the keys and values of which will be persisted in the executionState and available for the duration of the execution */
|
|
102
|
+
executionState?: Record<string, unknown>;
|
|
99
103
|
}
|
|
100
104
|
/** Used to represent a binary or serialized data return as content type must be specified */
|
|
101
105
|
interface ServerPerformDataReturn {
|
|
@@ -106,7 +110,9 @@ interface ServerPerformDataReturn {
|
|
|
106
110
|
/** The HTTP Status code that will be used if this terminates a synchronous invocation */
|
|
107
111
|
statusCode?: number;
|
|
108
112
|
/** An optional object, the keys and values of which will be persisted in the instanceState and available for subsequent actions and executions */
|
|
109
|
-
|
|
113
|
+
instanceState?: Record<string, unknown>;
|
|
114
|
+
/** An optional object, the keys and values of which will be persisted in the executionState and available for the duration of the execution */
|
|
115
|
+
executionState?: Record<string, unknown>;
|
|
110
116
|
}
|
|
111
117
|
/** Used to represent a branching return of conventional data and does not require content type to be specified */
|
|
112
118
|
export interface ServerPerformBranchingDataStructureReturn extends ServerPerformDataStructureReturn {
|