@prismatic-io/spectral 9.0.0-rc.8 → 9.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/generators/componentManifest/cli.js +2 -1
- package/dist/generators/componentManifest/createActions.js +0 -15
- package/dist/generators/componentManifest/createConnections.js +0 -25
- package/dist/generators/componentManifest/createDataSources.js +1 -15
- package/dist/generators/componentManifest/createTriggers.js +0 -15
- package/dist/generators/componentManifest/docBlock.d.ts +10 -0
- package/dist/generators/componentManifest/docBlock.js +40 -0
- package/dist/generators/componentManifest/getImports.js +6 -6
- package/dist/generators/componentManifest/getInputs.d.ts +9 -10
- package/dist/generators/componentManifest/getInputs.js +25 -46
- package/dist/generators/componentManifest/removeComponentManifest.js +4 -2
- package/dist/generators/componentManifest/templates/actions/action.ts.ejs +2 -2
- package/dist/generators/componentManifest/templates/connections/connection.ts.ejs +2 -2
- package/dist/generators/componentManifest/templates/dataSources/dataSource.ts.ejs +3 -2
- package/dist/generators/componentManifest/templates/index.ts.ejs +1 -1
- package/dist/generators/componentManifest/templates/partials/inputs.ejs +3 -3
- package/dist/generators/componentManifest/templates/partials/performArgs.ejs +2 -8
- package/dist/generators/componentManifest/templates/triggers/trigger.ts.ejs +2 -2
- package/dist/generators/utils/createTemplate.js +9 -3
- package/dist/index.d.ts +3 -3
- package/dist/index.js +2 -2
- package/dist/serverTypes/convertIntegration.js +39 -28
- package/dist/serverTypes/integration.d.ts +2 -0
- package/dist/types/ComponentManifest.d.ts +15 -15
- package/dist/types/ComponentRegistry.d.ts +89 -0
- package/dist/types/ComponentRegistry.js +5 -0
- package/dist/types/ConfigPages.d.ts +46 -0
- package/dist/types/ConfigPages.js +2 -0
- package/dist/types/ConfigVars.d.ts +241 -0
- package/dist/types/ConfigVars.js +30 -0
- package/dist/types/Inputs.d.ts +13 -13
- package/dist/types/IntegrationDefinition.d.ts +1 -220
- package/dist/types/IntegrationDefinition.js +0 -17
- package/dist/types/index.d.ts +3 -0
- package/dist/types/index.js +3 -0
- package/package.json +3 -2
- /package/dist/serverTypes/{convert.d.ts → convertComponent.d.ts} +0 -0
- /package/dist/serverTypes/{convert.js → convertComponent.js} +0 -0
|
@@ -17,6 +17,7 @@ exports.runMain = void 0;
|
|
|
17
17
|
/* eslint-disable @typescript-eslint/no-unsafe-member-access */
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
19
|
const fs_extra_1 = require("fs-extra");
|
|
20
|
+
const lodash_1 = require("lodash");
|
|
20
21
|
const index_1 = require("./index");
|
|
21
22
|
const createFlagHelpText_1 = require("../utils/createFlagHelpText");
|
|
22
23
|
const getFlagStringValue_1 = require("../utils/getFlagStringValue");
|
|
@@ -116,7 +117,7 @@ const runMain = (process) => __awaiter(void 0, void 0, void 0, function* () {
|
|
|
116
117
|
component,
|
|
117
118
|
dryRun: flags.dry_run.value,
|
|
118
119
|
skipSignatureVerify: flags.skip_signature_verify.value,
|
|
119
|
-
packageName: (_a = flags.name.value) !== null && _a !== void 0 ? _a : `@component-manifests/${component.key}`,
|
|
120
|
+
packageName: (_a = flags.name.value) !== null && _a !== void 0 ? _a : `@component-manifests/${(0, lodash_1.kebabCase)(component.key)}`,
|
|
120
121
|
dependencies: {
|
|
121
122
|
spectral: packageJson.version,
|
|
122
123
|
dependencies: packageJson.dependencies,
|
|
@@ -18,20 +18,6 @@ const getInputs_1 = require("./getInputs");
|
|
|
18
18
|
const getImports_1 = require("./getImports");
|
|
19
19
|
const helpers_1 = require("./helpers");
|
|
20
20
|
const createTemplate_1 = require("../utils/createTemplate");
|
|
21
|
-
const DOC_BLOCK = [
|
|
22
|
-
{
|
|
23
|
-
propertyKey: "comments",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
propertyKey: "default",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
propertyKey: "example",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
propertyKey: "placeholder",
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
21
|
const createActions = ({ component, dryRun, verbose, sourceDir, destinationDir, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
22
|
var _a, _b;
|
|
37
23
|
if (verbose) {
|
|
@@ -51,7 +37,6 @@ const createActions = ({ component, dryRun, verbose, sourceDir, destinationDir,
|
|
|
51
37
|
const actions = yield Promise.all(Object.entries((_b = component.actions) !== null && _b !== void 0 ? _b : {}).map(([actionKey, action]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
38
|
const inputs = (0, getInputs_1.getInputs)({
|
|
53
39
|
inputs: action.inputs,
|
|
54
|
-
docBlock: DOC_BLOCK,
|
|
55
40
|
});
|
|
56
41
|
const imports = (0, getImports_1.getImports)({ inputs });
|
|
57
42
|
return yield renderAction({
|
|
@@ -18,30 +18,6 @@ const getInputs_1 = require("./getInputs");
|
|
|
18
18
|
const getImports_1 = require("./getImports");
|
|
19
19
|
const helpers_1 = require("./helpers");
|
|
20
20
|
const createTemplate_1 = require("../utils/createTemplate");
|
|
21
|
-
const DOC_BLOCK = [
|
|
22
|
-
{
|
|
23
|
-
propertyKey: "comments",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
propertyKey: "default",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
propertyKey: "example",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
propertyKey: "placeholder",
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
propertyKey: "onPremControlled",
|
|
36
|
-
propertyValue: true,
|
|
37
|
-
output: "This input will be supplied when using an on prem resource.",
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
propertyKey: "onPremiseControlled",
|
|
41
|
-
propertyValue: true,
|
|
42
|
-
output: "This input will be supplied when using an on prem resource.",
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
21
|
const createConnections = ({ component, dryRun, verbose, sourceDir, destinationDir, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
22
|
var _a, _b;
|
|
47
23
|
if (verbose) {
|
|
@@ -61,7 +37,6 @@ const createConnections = ({ component, dryRun, verbose, sourceDir, destinationD
|
|
|
61
37
|
const connections = yield Promise.all(((_b = component.connections) !== null && _b !== void 0 ? _b : []).map((connection) => __awaiter(void 0, void 0, void 0, function* () {
|
|
62
38
|
const inputs = (0, getInputs_1.getInputs)({
|
|
63
39
|
inputs: connection.inputs,
|
|
64
|
-
docBlock: DOC_BLOCK,
|
|
65
40
|
});
|
|
66
41
|
const imports = (0, getImports_1.getImports)({ inputs });
|
|
67
42
|
const onPremAvailable = connection.inputs.some((input) => input.onPremControlled || input.onPremiseControlled);
|
|
@@ -18,20 +18,6 @@ const getInputs_1 = require("./getInputs");
|
|
|
18
18
|
const getImports_1 = require("./getImports");
|
|
19
19
|
const helpers_1 = require("./helpers");
|
|
20
20
|
const createTemplate_1 = require("../utils/createTemplate");
|
|
21
|
-
const DOC_BLOCK = [
|
|
22
|
-
{
|
|
23
|
-
propertyKey: "comments",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
propertyKey: "default",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
propertyKey: "example",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
propertyKey: "placeholder",
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
21
|
const createDataSources = ({ component, dryRun, verbose, sourceDir, destinationDir, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
22
|
var _a, _b;
|
|
37
23
|
if (verbose) {
|
|
@@ -51,7 +37,6 @@ const createDataSources = ({ component, dryRun, verbose, sourceDir, destinationD
|
|
|
51
37
|
const dataSources = yield Promise.all(Object.entries((_b = component.dataSources) !== null && _b !== void 0 ? _b : {}).map(([dataSourceKey, dataSource]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
38
|
const inputs = (0, getInputs_1.getInputs)({
|
|
53
39
|
inputs: dataSource.inputs,
|
|
54
|
-
docBlock: DOC_BLOCK,
|
|
55
40
|
});
|
|
56
41
|
const imports = (0, getImports_1.getImports)({ inputs });
|
|
57
42
|
return yield renderDataSource({
|
|
@@ -59,6 +44,7 @@ const createDataSources = ({ component, dryRun, verbose, sourceDir, destinationD
|
|
|
59
44
|
key: dataSource.key || dataSourceKey,
|
|
60
45
|
label: dataSource.display.label,
|
|
61
46
|
description: dataSource.display.description,
|
|
47
|
+
dataSourceType: dataSource.dataSourceType,
|
|
62
48
|
inputs,
|
|
63
49
|
},
|
|
64
50
|
imports,
|
|
@@ -18,20 +18,6 @@ const getInputs_1 = require("./getInputs");
|
|
|
18
18
|
const getImports_1 = require("./getImports");
|
|
19
19
|
const helpers_1 = require("./helpers");
|
|
20
20
|
const createTemplate_1 = require("../utils/createTemplate");
|
|
21
|
-
const DOC_BLOCK = [
|
|
22
|
-
{
|
|
23
|
-
propertyKey: "comments",
|
|
24
|
-
},
|
|
25
|
-
{
|
|
26
|
-
propertyKey: "default",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
propertyKey: "example",
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
propertyKey: "placeholder",
|
|
33
|
-
},
|
|
34
|
-
];
|
|
35
21
|
const createTriggers = ({ component, dryRun, verbose, sourceDir, destinationDir, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
36
22
|
var _a, _b;
|
|
37
23
|
if (verbose) {
|
|
@@ -51,7 +37,6 @@ const createTriggers = ({ component, dryRun, verbose, sourceDir, destinationDir,
|
|
|
51
37
|
const triggers = yield Promise.all(Object.entries((_b = component.triggers) !== null && _b !== void 0 ? _b : {}).map(([triggerKey, trigger]) => __awaiter(void 0, void 0, void 0, function* () {
|
|
52
38
|
const inputs = (0, getInputs_1.getInputs)({
|
|
53
39
|
inputs: trigger.inputs,
|
|
54
|
-
docBlock: DOC_BLOCK,
|
|
55
40
|
});
|
|
56
41
|
const imports = (0, getImports_1.getImports)({ inputs });
|
|
57
42
|
return yield renderTrigger({
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { ServerTypeInput } from "./getInputs";
|
|
2
|
+
export declare const DOC_BLOCK_DEFAULT: (input: ServerTypeInput) => string;
|
|
3
|
+
interface AddLineProps {
|
|
4
|
+
key?: string;
|
|
5
|
+
value?: string | unknown | undefined | null;
|
|
6
|
+
raw?: string;
|
|
7
|
+
}
|
|
8
|
+
export declare const addLine: ({ key, value, raw }: AddLineProps) => string;
|
|
9
|
+
export declare const addPunctuation: (value: string | undefined) => string;
|
|
10
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.addPunctuation = exports.addLine = exports.DOC_BLOCK_DEFAULT = void 0;
|
|
4
|
+
const DOC_BLOCK_DEFAULT = (input) => {
|
|
5
|
+
const comments = (0, exports.addPunctuation)(input.comments);
|
|
6
|
+
const onPrem = input.onPremControlled || input.onPremiseControlled
|
|
7
|
+
? " This input will be supplied when using an on prem resource."
|
|
8
|
+
: "";
|
|
9
|
+
return ((0, exports.addLine)({ raw: "/**" }) +
|
|
10
|
+
(0, exports.addLine)({ value: input.label }) +
|
|
11
|
+
(0, exports.addLine)({ value: comments + onPrem }) +
|
|
12
|
+
(0, exports.addLine)({ raw: "*" }) +
|
|
13
|
+
(0, exports.addLine)({ key: "default", value: input.default }) +
|
|
14
|
+
(0, exports.addLine)({ key: "example", value: input.example }) +
|
|
15
|
+
(0, exports.addLine)({ key: "placeholder", value: input.placeholder }) +
|
|
16
|
+
(0, exports.addLine)({ raw: "*/" }));
|
|
17
|
+
};
|
|
18
|
+
exports.DOC_BLOCK_DEFAULT = DOC_BLOCK_DEFAULT;
|
|
19
|
+
const addLine = ({ key, value, raw }) => {
|
|
20
|
+
if (raw) {
|
|
21
|
+
return ` ${raw}\n`;
|
|
22
|
+
}
|
|
23
|
+
if (typeof value === "undefined" || value === null || value === "") {
|
|
24
|
+
return "";
|
|
25
|
+
}
|
|
26
|
+
const sanitizedValue = JSON.stringify(value)
|
|
27
|
+
.replace(/(^"|"$)|(^'|'$)/g, "")
|
|
28
|
+
.trim();
|
|
29
|
+
return ` * ${key ? `@${key} ${sanitizedValue}` : sanitizedValue}\n`;
|
|
30
|
+
};
|
|
31
|
+
exports.addLine = addLine;
|
|
32
|
+
const addPunctuation = (value) => {
|
|
33
|
+
if (typeof value === "undefined" || value === null || value === "") {
|
|
34
|
+
return "";
|
|
35
|
+
}
|
|
36
|
+
return value.endsWith(".") || value.endsWith("!") || value.endsWith("?")
|
|
37
|
+
? value
|
|
38
|
+
: value + ".";
|
|
39
|
+
};
|
|
40
|
+
exports.addPunctuation = addPunctuation;
|
|
@@ -3,14 +3,14 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.getImports = void 0;
|
|
4
4
|
const getImports = ({ inputs }) => {
|
|
5
5
|
return inputs.reduce((acc, input) => {
|
|
6
|
-
if (typeof input.
|
|
6
|
+
if (typeof input.valueType === "string") {
|
|
7
7
|
return acc;
|
|
8
8
|
}
|
|
9
|
-
return Object.assign(Object.assign({}, acc), { [input.
|
|
10
|
-
? !acc[input.
|
|
11
|
-
? [...acc[input.
|
|
12
|
-
: acc[input.
|
|
13
|
-
: [input.
|
|
9
|
+
return Object.assign(Object.assign({}, acc), { [input.valueType.module]: acc[input.valueType.module]
|
|
10
|
+
? !acc[input.valueType.module].includes(input.valueType.type)
|
|
11
|
+
? [...acc[input.valueType.module], input.valueType.type]
|
|
12
|
+
: acc[input.valueType.module]
|
|
13
|
+
: [input.valueType.type] });
|
|
14
14
|
}, {});
|
|
15
15
|
};
|
|
16
16
|
exports.getImports = getImports;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
1
|
import type { Input as InputBase } from "../../serverTypes";
|
|
2
2
|
import type { InputFieldDefinition } from "../../types/Inputs";
|
|
3
|
-
declare type ServerTypeInput = InputBase & {
|
|
3
|
+
export declare type ServerTypeInput = InputBase & {
|
|
4
4
|
onPremControlled?: boolean;
|
|
5
|
+
shown?: boolean;
|
|
5
6
|
};
|
|
6
7
|
export interface Input {
|
|
7
8
|
key: string;
|
|
8
9
|
label: string;
|
|
9
|
-
|
|
10
|
+
inputType: string;
|
|
11
|
+
valueType: ValueType;
|
|
12
|
+
docBlock: string;
|
|
10
13
|
required: boolean | undefined;
|
|
11
|
-
properties: {
|
|
12
|
-
key: keyof ServerTypeInput;
|
|
13
|
-
value: string;
|
|
14
|
-
}[];
|
|
15
14
|
}
|
|
16
|
-
export declare type
|
|
15
|
+
export declare type ValueType = string | {
|
|
17
16
|
type: string;
|
|
18
17
|
module: string;
|
|
19
18
|
};
|
|
@@ -25,8 +24,8 @@ export declare type DocBlock = {
|
|
|
25
24
|
}[];
|
|
26
25
|
interface GetInputsProps {
|
|
27
26
|
inputs: ServerTypeInput[];
|
|
28
|
-
docBlock:
|
|
27
|
+
docBlock?: (input: ServerTypeInput) => string;
|
|
29
28
|
}
|
|
30
|
-
export declare const getInputs: ({ inputs, docBlock }: GetInputsProps) => Input[];
|
|
31
|
-
export declare const INPUT_TYPE_MAP: Record<InputFieldDefinition["type"],
|
|
29
|
+
export declare const getInputs: ({ inputs, docBlock, }: GetInputsProps) => Input[];
|
|
30
|
+
export declare const INPUT_TYPE_MAP: Record<InputFieldDefinition["type"], ValueType>;
|
|
32
31
|
export {};
|
|
@@ -1,50 +1,29 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.INPUT_TYPE_MAP = exports.getInputs = void 0;
|
|
4
|
-
const
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
type
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
];
|
|
28
|
-
}
|
|
29
|
-
if (typeof input[propertyKey] === "undefined" ||
|
|
30
|
-
input[propertyKey] === null ||
|
|
31
|
-
input[propertyKey] === "" ||
|
|
32
|
-
(typeof propertyValue !== "undefined" &&
|
|
33
|
-
input[propertyKey] !== propertyValue)) {
|
|
34
|
-
return acc;
|
|
35
|
-
}
|
|
36
|
-
return [
|
|
37
|
-
...acc,
|
|
38
|
-
{
|
|
39
|
-
key: propertyKey,
|
|
40
|
-
value: JSON.stringify(input[propertyKey])
|
|
41
|
-
.replace(/(^"|"$)|(^'|'$)/g, "")
|
|
42
|
-
.trim(),
|
|
43
|
-
},
|
|
44
|
-
];
|
|
45
|
-
}, []),
|
|
46
|
-
};
|
|
47
|
-
});
|
|
4
|
+
const docBlock_1 = require("./docBlock");
|
|
5
|
+
const getInputs = ({ inputs, docBlock = docBlock_1.DOC_BLOCK_DEFAULT, }) => {
|
|
6
|
+
return inputs.reduce((acc, input) => {
|
|
7
|
+
if ((typeof input.shown === "boolean" && input.shown === false) ||
|
|
8
|
+
input.type === "dynamicObjectSelection" ||
|
|
9
|
+
input.type === "dynamicFieldSelection") {
|
|
10
|
+
return acc;
|
|
11
|
+
}
|
|
12
|
+
return [
|
|
13
|
+
...acc,
|
|
14
|
+
{
|
|
15
|
+
key: input.key,
|
|
16
|
+
label: input.label,
|
|
17
|
+
inputType: input.type,
|
|
18
|
+
valueType: getInputValueType(input),
|
|
19
|
+
required: input.required &&
|
|
20
|
+
(input.default === undefined || input.default === ""),
|
|
21
|
+
collection: input.collection,
|
|
22
|
+
onPremControlled: input.onPremiseControlled || input.onPremControlled,
|
|
23
|
+
docBlock: docBlock(input),
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
}, []);
|
|
48
27
|
};
|
|
49
28
|
exports.getInputs = getInputs;
|
|
50
29
|
exports.INPUT_TYPE_MAP = {
|
|
@@ -77,12 +56,12 @@ exports.INPUT_TYPE_MAP = {
|
|
|
77
56
|
dynamicObjectSelection: "string",
|
|
78
57
|
dynamicFieldSelection: "string",
|
|
79
58
|
};
|
|
80
|
-
const
|
|
59
|
+
const getInputValueType = (input) => {
|
|
81
60
|
const valueType = input.model
|
|
82
61
|
? input.model.map((choice) => `"${choice.value}"`).join(" | ")
|
|
83
62
|
: exports.INPUT_TYPE_MAP[input.type] || "never";
|
|
84
63
|
if (input.collection === "keyvaluelist") {
|
|
85
|
-
return `Record<string, ${valueType}>`;
|
|
64
|
+
return `Record<string, ${valueType}> | Array<{key: string, value: ${valueType}}>`;
|
|
86
65
|
}
|
|
87
66
|
if (input.collection === "valuelist") {
|
|
88
67
|
return `${valueType}[]`;
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.removeComponentManifest = void 0;
|
|
4
|
-
const
|
|
4
|
+
const fs_1 = require("fs");
|
|
5
5
|
const removeComponentManifest = ({ destinationDir, verbose, }) => {
|
|
6
6
|
if (verbose) {
|
|
7
7
|
console.info("Removing existing component manifest files...");
|
|
8
8
|
}
|
|
9
9
|
try {
|
|
10
|
-
(0,
|
|
10
|
+
if ((0, fs_1.existsSync)(destinationDir)) {
|
|
11
|
+
(0, fs_1.rmSync)(destinationDir, { recursive: true, force: true });
|
|
12
|
+
}
|
|
11
13
|
}
|
|
12
14
|
catch (err) {
|
|
13
15
|
console.error(err);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%- include('../partials/imports.ejs', { imports, helpers })
|
|
1
|
+
<%- include('../partials/imports.ejs', { imports, helpers }) %>
|
|
2
2
|
|
|
3
3
|
export interface <%= helpers.capitalizeFirstLetter(action.key) %>Values {
|
|
4
4
|
<%- include('../partials/performArgs.ejs', { inputs: action.inputs }) -%>
|
|
@@ -16,4 +16,4 @@ export const <%= action.key %> = {
|
|
|
16
16
|
inputs: {
|
|
17
17
|
<%- include('../partials/inputs.ejs', { inputs: action.inputs }) -%>
|
|
18
18
|
}
|
|
19
|
-
}
|
|
19
|
+
} as const;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%- include('../partials/imports.ejs', { imports, helpers })
|
|
1
|
+
<%- include('../partials/imports.ejs', { imports, helpers }) %>
|
|
2
2
|
|
|
3
3
|
export interface <%= helpers.capitalizeFirstLetter(connection.key) %>Values {
|
|
4
4
|
<%- include('../partials/performArgs.ejs', { inputs: connection.inputs }) -%>
|
|
@@ -19,4 +19,4 @@ export const <%= connection.key %> = {
|
|
|
19
19
|
inputs: {
|
|
20
20
|
<%- include('../partials/inputs.ejs', { inputs: connection.inputs }) -%>
|
|
21
21
|
}
|
|
22
|
-
};
|
|
22
|
+
} as const;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%- include('../partials/imports.ejs', { imports, helpers })
|
|
1
|
+
<%- include('../partials/imports.ejs', { imports, helpers }) %>
|
|
2
2
|
|
|
3
3
|
export interface <%= helpers.capitalizeFirstLetter(dataSource.key) %>Values {
|
|
4
4
|
<%- include('../partials/performArgs.ejs', { inputs: dataSource.inputs }) -%>
|
|
@@ -13,7 +13,8 @@ export const <%= dataSource.key %> = {
|
|
|
13
13
|
perform: (
|
|
14
14
|
_values: <%= helpers.capitalizeFirstLetter(dataSource.key) %>Values
|
|
15
15
|
): Promise<void> => Promise.resolve(),
|
|
16
|
+
dataSourceType: "<%= dataSource.dataSourceType %>",
|
|
16
17
|
inputs: {
|
|
17
18
|
<%- include('../partials/inputs.ejs', { inputs: dataSource.inputs }) -%>
|
|
18
19
|
}
|
|
19
|
-
}
|
|
20
|
+
} as const;
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
<% inputs.forEach((input) => { -%>
|
|
2
2
|
<%= input.key %>: {
|
|
3
|
-
inputType: "<%= input.
|
|
3
|
+
inputType: "<%= input.inputType %>",
|
|
4
4
|
<%_ if (input.collection) { -%>
|
|
5
|
-
collection: "<%= input.collection %>"
|
|
5
|
+
collection: "<%= input.collection %>",
|
|
6
6
|
<%_ } else { -%>
|
|
7
|
-
collection:
|
|
7
|
+
collection: undefined,
|
|
8
8
|
<%_ } -%>
|
|
9
9
|
<%_ if (input.default) { -%>
|
|
10
10
|
default: <%= input.default %>,
|
|
@@ -1,10 +1,4 @@
|
|
|
1
1
|
<% inputs.forEach((input) => { -%>
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*
|
|
5
|
-
<%_ input.properties.forEach((property) => { -%>
|
|
6
|
-
* @<%= property.key %> <%- property.value %>
|
|
7
|
-
<%_ }); -%>
|
|
8
|
-
*/
|
|
9
|
-
<%= input.key %><%= input.required ? "" : "?" %>: <%- input.type.type ? input.type.type : input.type %>;
|
|
2
|
+
<%= input.docBlock -%>
|
|
3
|
+
<%= input.key %><%= input.required ? "" : "?" %>: <%- input.valueType.type ? input.valueType.type : input.valueType %>;
|
|
10
4
|
<% }); -%>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
<%- include('../partials/imports.ejs', { imports, helpers })
|
|
1
|
+
<%- include('../partials/imports.ejs', { imports, helpers }) %>
|
|
2
2
|
|
|
3
3
|
export interface <%= helpers.capitalizeFirstLetter(trigger.key) %>Values {
|
|
4
4
|
<%- include('../partials/performArgs.ejs', { inputs: trigger.inputs }) -%>
|
|
@@ -16,4 +16,4 @@ export const <%= trigger.key %> = {
|
|
|
16
16
|
inputs: {
|
|
17
17
|
<%- include('../partials/inputs.ejs', { inputs: trigger.inputs }) -%>
|
|
18
18
|
}
|
|
19
|
-
}
|
|
19
|
+
} as const;
|
|
@@ -16,19 +16,25 @@ exports.createTemplate = void 0;
|
|
|
16
16
|
const ejs_1 = require("ejs");
|
|
17
17
|
const fs_extra_1 = require("fs-extra");
|
|
18
18
|
const path_1 = __importDefault(require("path"));
|
|
19
|
+
const prettier_1 = require("prettier");
|
|
19
20
|
const createTemplate = ({ source, destination = source.replace(/\.ejs$/, ""), data = {}, dryRun, verbose, }) => __awaiter(void 0, void 0, void 0, function* () {
|
|
20
21
|
if (!source) {
|
|
21
22
|
throw new Error("Source is required");
|
|
22
23
|
}
|
|
23
24
|
try {
|
|
24
25
|
if (path_1.default.extname(source) === ".ejs") {
|
|
25
|
-
const
|
|
26
|
+
const render = yield (0, ejs_1.renderFile)(source, data);
|
|
27
|
+
const formattedRender = [".ts", ".js"].includes(path_1.default.extname(destination))
|
|
28
|
+
? (0, prettier_1.format)(render, {
|
|
29
|
+
parser: "typescript",
|
|
30
|
+
})
|
|
31
|
+
: render;
|
|
26
32
|
if (dryRun) {
|
|
27
33
|
console.info("");
|
|
28
34
|
console.info("");
|
|
29
35
|
console.info(`Rendering ${source} to ${destination}`);
|
|
30
36
|
console.info("---------------------------- Start ----------------------------");
|
|
31
|
-
console.info(
|
|
37
|
+
console.info(formattedRender);
|
|
32
38
|
console.info("---------------------------- End ----------------------------");
|
|
33
39
|
console.info("");
|
|
34
40
|
return;
|
|
@@ -36,7 +42,7 @@ const createTemplate = ({ source, destination = source.replace(/\.ejs$/, ""), da
|
|
|
36
42
|
if (verbose) {
|
|
37
43
|
console.info(`Rendering ${source} to ${destination}`);
|
|
38
44
|
}
|
|
39
|
-
yield (0, fs_extra_1.outputFile)(destination,
|
|
45
|
+
yield (0, fs_extra_1.outputFile)(destination, formattedRender, { encoding: "utf-8" });
|
|
40
46
|
}
|
|
41
47
|
else {
|
|
42
48
|
if (dryRun) {
|
package/dist/index.d.ts
CHANGED
|
@@ -3,8 +3,8 @@
|
|
|
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, OnPremConnectionDefinition,
|
|
7
|
-
import { convertComponent } from "./serverTypes/
|
|
6
|
+
import { ActionDefinition, InputFieldDefinition, ComponentDefinition, DefaultConnectionDefinition, OAuth2ConnectionDefinition, Inputs, TriggerDefinition, ActionPerformReturn, TriggerResult, DataSourceDefinition, IntegrationDefinition, Flow, ConfigPage, StandardConfigVar, ConnectionConfigVar, ConfigVarResultCollection, TriggerPayload, DataSourceConfigVar, OnPremConnectionDefinition, ComponentManifest } from "./types";
|
|
7
|
+
import { convertComponent } from "./serverTypes/convertComponent";
|
|
8
8
|
import { convertIntegration } from "./serverTypes/convertIntegration";
|
|
9
9
|
/**
|
|
10
10
|
* This function creates a Integration object that can be
|
|
@@ -35,7 +35,7 @@ export declare const configPage: <T extends ConfigPage = ConfigPage>(definition:
|
|
|
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
|
|
38
|
+
export declare const configVar: <T extends StandardConfigVar>(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.
|
package/dist/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
25
|
exports.testing = exports.util = exports.componentManifests = exports.oauth2Connection = exports.onPremConnection = exports.connection = exports.input = exports.dataSource = exports.trigger = exports.action = exports.component = exports.componentManifest = exports.connectionConfigVar = exports.dataSourceConfigVar = exports.configVar = exports.configPage = exports.flow = exports.integration = void 0;
|
|
26
|
-
const
|
|
26
|
+
const convertComponent_1 = require("./serverTypes/convertComponent");
|
|
27
27
|
const convertIntegration_1 = require("./serverTypes/convertIntegration");
|
|
28
28
|
/**
|
|
29
29
|
* This function creates a Integration object that can be
|
|
@@ -96,7 +96,7 @@ exports.componentManifest = componentManifest;
|
|
|
96
96
|
* @param definition A ComponentDefinition type object, including display information, unique key, and a set of actions the component implements.
|
|
97
97
|
* @returns This function returns a component object that has the shape the Prismatic API expects.
|
|
98
98
|
*/
|
|
99
|
-
const component = (definition) => (0,
|
|
99
|
+
const component = (definition) => (0, convertComponent_1.convertComponent)(definition);
|
|
100
100
|
exports.component = component;
|
|
101
101
|
/**
|
|
102
102
|
* This function creates an action object that can be referenced
|