@prismatic-io/spectral 9.3.1 → 10.0.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/serverTypes/convertComponent.d.ts +3 -2
- package/dist/serverTypes/convertComponent.js +6 -3
- package/dist/serverTypes/convertIntegration.js +14 -7
- package/dist/serverTypes/index.d.ts +1 -0
- package/dist/types/ConfigVars.d.ts +2 -1
- package/dist/types/ConnectionDefinition.d.ts +8 -5
- package/dist/types/DisplayDefinition.d.ts +9 -0
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { InputFieldDefinition, ComponentDefinition, OnPremConnectionInput } from "../types";
|
|
2
|
-
import { Component as ServerComponent, Input as ServerInput } from ".";
|
|
1
|
+
import { InputFieldDefinition, ComponentDefinition, ConnectionDefinition, OnPremConnectionInput } from "../types";
|
|
2
|
+
import { Component as ServerComponent, Connection as ServerConnection, Input as ServerInput } from ".";
|
|
3
3
|
export declare const convertInput: (key: string, { default: defaultValue, type, label, collection, ...rest }: InputFieldDefinition | OnPremConnectionInput) => ServerInput;
|
|
4
|
+
export declare const convertConnection: ({ inputs, ...connection }: ConnectionDefinition) => ServerConnection;
|
|
4
5
|
export declare const convertComponent: <TPublic extends boolean, TKey extends string>({ connections, actions, triggers, dataSources, hooks, ...definition }: ComponentDefinition<TPublic, TKey>) => ServerComponent;
|
|
@@ -11,7 +11,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
11
11
|
return t;
|
|
12
12
|
};
|
|
13
13
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
exports.convertComponent = exports.convertInput = void 0;
|
|
14
|
+
exports.convertComponent = exports.convertConnection = exports.convertInput = void 0;
|
|
15
15
|
const types_1 = require("../types");
|
|
16
16
|
const perform_1 = require("./perform");
|
|
17
17
|
const lodash_1 = require("lodash");
|
|
@@ -72,13 +72,16 @@ const convertDataSource = (dataSourceKey, _a, hooks) => {
|
|
|
72
72
|
const convertConnection = (_a) => {
|
|
73
73
|
var { inputs = {} } = _a, connection = __rest(_a, ["inputs"]);
|
|
74
74
|
const convertedInputs = Object.entries(inputs).map(([key, value]) => (0, exports.convertInput)(key, value));
|
|
75
|
-
|
|
75
|
+
const { display: { label, icons, description: comments } } = connection, remaining = __rest(connection, ["display"]);
|
|
76
|
+
return Object.assign(Object.assign({}, remaining), { label,
|
|
77
|
+
comments, iconPath: icons === null || icons === void 0 ? void 0 : icons.oauth2ConnectionIconPath, avatarIconPath: icons === null || icons === void 0 ? void 0 : icons.avatarPath, inputs: convertedInputs });
|
|
76
78
|
};
|
|
79
|
+
exports.convertConnection = convertConnection;
|
|
77
80
|
const convertComponent = (_a) => {
|
|
78
81
|
var { connections = [], actions = {}, triggers = {}, dataSources = {}, hooks } = _a, definition = __rest(_a, ["connections", "actions", "triggers", "dataSources", "hooks"]);
|
|
79
82
|
const convertedActions = Object.entries(actions).reduce((result, [actionKey, action]) => (Object.assign(Object.assign({}, result), { [actionKey]: convertAction(actionKey, action, hooks) })), {});
|
|
80
83
|
const convertedTriggers = Object.entries(triggers).reduce((result, [triggerKey, trigger]) => (Object.assign(Object.assign({}, result), { [triggerKey]: convertTrigger(triggerKey, trigger, hooks) })), {});
|
|
81
84
|
const convertedDataSources = Object.entries(dataSources).reduce((result, [dataSourceKey, dataSource]) => (Object.assign(Object.assign({}, result), { [dataSourceKey]: convertDataSource(dataSourceKey, dataSource, hooks) })), {});
|
|
82
|
-
return Object.assign(Object.assign({}, definition), { connections: connections.map(convertConnection), actions: convertedActions, triggers: convertedTriggers, dataSources: convertedDataSources });
|
|
85
|
+
return Object.assign(Object.assign({}, definition), { connections: connections.map(exports.convertConnection), actions: convertedActions, triggers: convertedTriggers, dataSources: convertedDataSources });
|
|
83
86
|
};
|
|
84
87
|
exports.convertComponent = convertComponent;
|
|
@@ -334,7 +334,7 @@ const convertInputValue = (value, collectionType) => {
|
|
|
334
334
|
};
|
|
335
335
|
/** Converts a Config Var into the structure necessary for YAML generation. */
|
|
336
336
|
const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
337
|
-
var _a;
|
|
337
|
+
var _a, _b, _c;
|
|
338
338
|
if ((0, types_1.isOrganizationActivatedConnectionConfigVar)(configVar)) {
|
|
339
339
|
const { stableKey } = (0, lodash_1.pick)(configVar, ["stableKey"]);
|
|
340
340
|
return {
|
|
@@ -387,7 +387,7 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
|
387
387
|
} });
|
|
388
388
|
}, {}),
|
|
389
389
|
orgOnly,
|
|
390
|
-
meta,
|
|
390
|
+
meta: Object.assign(Object.assign({}, meta), ("oauth2Config" in configVar ? (_a = configVar.oauth2Config) !== null && _a !== void 0 ? _a : {} : {})),
|
|
391
391
|
};
|
|
392
392
|
}
|
|
393
393
|
if ((0, types_1.isConnectionReferenceConfigVar)(configVar)) {
|
|
@@ -402,7 +402,7 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
|
402
402
|
connection: Object.assign(Object.assign({}, ref), { template }),
|
|
403
403
|
inputs,
|
|
404
404
|
orgOnly,
|
|
405
|
-
meta,
|
|
405
|
+
meta: Object.assign(Object.assign({}, meta), ("oauth2Config" in configVar ? (_b = configVar.oauth2Config) !== null && _b !== void 0 ? _b : {} : {})),
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
408
|
const rawDefaultValue = "defaultValue" in configVar
|
|
@@ -426,7 +426,7 @@ const convertConfigVar = (key, configVar, referenceKey, componentRegistry) => {
|
|
|
426
426
|
result.scheduleType = "custom";
|
|
427
427
|
}
|
|
428
428
|
if ((0, types_1.isJsonFormConfigVar)(configVar) || (0, types_1.isJsonFormDataSourceConfigVar)(configVar)) {
|
|
429
|
-
result.meta = Object.assign(Object.assign({}, result.meta), { validationMode: (
|
|
429
|
+
result.meta = Object.assign(Object.assign({}, result.meta), { validationMode: (_c = configVar === null || configVar === void 0 ? void 0 : configVar.validationMode) !== null && _c !== void 0 ? _c : "ValidateAndShow" });
|
|
430
430
|
}
|
|
431
431
|
if ((0, types_1.isDataSourceDefinitionConfigVar)(configVar)) {
|
|
432
432
|
result.dataType = configVar.dataSourceType;
|
|
@@ -564,7 +564,11 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
564
564
|
} });
|
|
565
565
|
}, {});
|
|
566
566
|
const convertedTriggers = flows.reduce((result, { name, onTrigger, onInstanceDeploy, onInstanceDelete, schedule }) => {
|
|
567
|
-
if (!flowUsesWrapperTrigger({
|
|
567
|
+
if (!flowUsesWrapperTrigger({
|
|
568
|
+
onTrigger,
|
|
569
|
+
onInstanceDelete,
|
|
570
|
+
onInstanceDeploy,
|
|
571
|
+
})) {
|
|
568
572
|
// In this scenario, the user has defined an existing component trigger
|
|
569
573
|
// without any custom behavior, so we don't need to wrap anything.
|
|
570
574
|
return result;
|
|
@@ -614,14 +618,17 @@ const codeNativeIntegrationComponent = ({ name, iconPath, description, flows = [
|
|
|
614
618
|
}, inputs: [] }) });
|
|
615
619
|
}, {});
|
|
616
620
|
const convertedConnections = Object.entries(configVars).reduce((result, [key, configVar]) => {
|
|
621
|
+
var _a;
|
|
617
622
|
if (!(0, types_1.isConnectionDefinitionConfigVar)(configVar)) {
|
|
618
623
|
return result;
|
|
619
624
|
}
|
|
620
625
|
const convertedInputs = Object.entries(configVar.inputs).map(([key, value]) => (0, convertComponent_1.convertInput)(key, value));
|
|
621
|
-
const connection = (0, lodash_1.pick)(configVar, ["oauth2Type"
|
|
626
|
+
const connection = (0, lodash_1.pick)(configVar, ["oauth2Type"]);
|
|
627
|
+
const { avatarPath: avatarIconPath, oauth2ConnectionIconPath: iconPath } = (_a = configVar.icons) !== null && _a !== void 0 ? _a : {};
|
|
622
628
|
return [
|
|
623
629
|
...result,
|
|
624
|
-
Object.assign(Object.assign({}, connection), {
|
|
630
|
+
Object.assign(Object.assign({}, connection), { iconPath,
|
|
631
|
+
avatarIconPath, inputs: convertedInputs, key: (0, lodash_1.camelCase)(key), label: key }),
|
|
625
632
|
];
|
|
626
633
|
}, []);
|
|
627
634
|
return {
|
|
@@ -141,7 +141,8 @@ export type DataSourceConfigVar = DataSourceDefinitionConfigVar | DataSourceRefe
|
|
|
141
141
|
type BaseConnectionConfigVar = BaseConfigVar & {
|
|
142
142
|
dataType: "connection";
|
|
143
143
|
};
|
|
144
|
-
type ConnectionDefinitionConfigVar = ConnectionDefinition extends infer TConnectionDefinitionType extends ConnectionDefinition ? TConnectionDefinitionType extends infer TConnectionDefinition extends ConnectionDefinition ? BaseConnectionConfigVar & Omit<TConnectionDefinition, "inputs" | "
|
|
144
|
+
type ConnectionDefinitionConfigVar = ConnectionDefinition extends infer TConnectionDefinitionType extends ConnectionDefinition ? TConnectionDefinitionType extends infer TConnectionDefinition extends ConnectionDefinition ? BaseConnectionConfigVar & Omit<TConnectionDefinition, "inputs" | "display" | "key"> & {
|
|
145
|
+
icons?: TConnectionDefinition["display"]["icons"];
|
|
145
146
|
inputs: {
|
|
146
147
|
[Key in keyof TConnectionDefinition["inputs"]]: TConnectionDefinition["inputs"][Key] & ConfigVarInputVisibility;
|
|
147
148
|
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { ConnectionInput, OnPremConnectionInput } from ".";
|
|
1
|
+
import type { ConnectionDisplayDefinition, ConnectionInput, OnPremConnectionInput } from ".";
|
|
2
2
|
export declare enum OAuth2Type {
|
|
3
3
|
ClientCredentials = "client_credentials",
|
|
4
4
|
AuthorizationCode = "authorization_code"
|
|
@@ -9,9 +9,7 @@ export declare enum OAuth2PkceMethod {
|
|
|
9
9
|
}
|
|
10
10
|
interface BaseConnectionDefinition {
|
|
11
11
|
key: string;
|
|
12
|
-
|
|
13
|
-
comments?: string;
|
|
14
|
-
iconPath?: string;
|
|
12
|
+
display: ConnectionDisplayDefinition;
|
|
15
13
|
oauth2Type?: OAuth2Type;
|
|
16
14
|
}
|
|
17
15
|
export interface DefaultConnectionDefinition extends BaseConnectionDefinition {
|
|
@@ -30,9 +28,13 @@ interface OAuth2Config {
|
|
|
30
28
|
overrideGrantType?: string;
|
|
31
29
|
allowedTokenParams?: string[];
|
|
32
30
|
}
|
|
31
|
+
export interface OAuth2UrlOverrides {
|
|
32
|
+
oAuthSuccessRedirectUri?: string;
|
|
33
|
+
oAuthFailureRedirectUri?: string;
|
|
34
|
+
}
|
|
33
35
|
interface OAuth2AuthorizationCodeConnectionDefinition extends BaseConnectionDefinition {
|
|
34
36
|
oauth2Type: OAuth2Type.AuthorizationCode;
|
|
35
|
-
oauth2Config?: OAuth2Config;
|
|
37
|
+
oauth2Config?: OAuth2Config & OAuth2UrlOverrides;
|
|
36
38
|
/** The PKCE method (S256 or plain) that this OAuth 2.0 connection uses (if any) */
|
|
37
39
|
oauth2PkceMethod?: OAuth2PkceMethod;
|
|
38
40
|
inputs: {
|
|
@@ -46,6 +48,7 @@ interface OAuth2AuthorizationCodeConnectionDefinition extends BaseConnectionDefi
|
|
|
46
48
|
}
|
|
47
49
|
interface OAuth2ClientCredentialConnectionDefinition extends BaseConnectionDefinition {
|
|
48
50
|
oauth2Type: OAuth2Type.ClientCredentials;
|
|
51
|
+
oauth2Config?: OAuth2UrlOverrides;
|
|
49
52
|
inputs: {
|
|
50
53
|
tokenUrl: ConnectionInput;
|
|
51
54
|
scopes: ConnectionInput;
|
|
@@ -24,4 +24,13 @@ export interface ActionDisplayDefinition extends DisplayDefinition {
|
|
|
24
24
|
/** Indicate that this Action is important and/or commonly used from the parent Component. Should be enabled sparingly. */
|
|
25
25
|
important?: boolean;
|
|
26
26
|
}
|
|
27
|
+
/** Connection-specific Display attributes. */
|
|
28
|
+
export interface ConnectionDisplayDefinition extends DisplayDefinition {
|
|
29
|
+
icons?: {
|
|
30
|
+
/** Path to icon to use for this Connection. Path should be relative to the built component source. */
|
|
31
|
+
avatarPath?: string;
|
|
32
|
+
/** Path to icon to use for this Connection's "Connect" button. Path should be relative to the built component source. */
|
|
33
|
+
oauth2ConnectionIconPath?: string;
|
|
34
|
+
};
|
|
35
|
+
}
|
|
27
36
|
export {};
|