@prismatic-io/prism 5.2.11 → 6.0.0-preview1
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/lib/index.js +32973 -5
- package/lib/run.js +365 -0
- package/lib/templates/action/action.ts.ejs +33 -0
- package/lib/templates/component/assets/icon.png.ejs +0 -0
- package/lib/templates/component/jest.config.js.ejs +4 -0
- package/lib/templates/component/package.json.ejs +6 -0
- package/lib/templates/component/src/client.ts.ejs +10 -0
- package/lib/templates/component/src/index.test.ts.ejs +47 -0
- package/lib/templates/component/src/index.ts.ejs +19 -0
- package/lib/templates/component/tsconfig.json.ejs +12 -0
- package/lib/templates/component/webpack.config.js.ejs +36 -0
- package/lib/templates/connection/basic.ts.ejs +25 -0
- package/lib/templates/connection/oauth.ts.ejs +65 -0
- package/lib/templates/dataSource/dataSource.ts.ejs +34 -0
- package/lib/templates/flow/flow.ts.ejs +37 -0
- package/lib/templates/formats/assets/icon.png.ejs +0 -0
- package/lib/templates/formats/jest.config.js.ejs +4 -0
- package/lib/templates/formats/tsconfig.json.ejs +12 -0
- package/lib/templates/formats/webpack.config.js.ejs +36 -0
- package/lib/templates/integration/assets/icon.png.ejs +0 -0
- package/lib/templates/integration/basic.ts.ejs +29 -0
- package/lib/templates/integration/jest.config.js.ejs +4 -0
- package/lib/templates/integration/oauth.ts.ejs +69 -0
- package/lib/templates/integration/package.json.ejs +6 -0
- package/lib/templates/integration/src/client.ts.ejs +10 -0
- package/lib/templates/integration/src/index.test.ts.ejs +18 -0
- package/lib/templates/integration/src/index.ts.ejs +11 -0
- package/lib/templates/integration/tsconfig.json.ejs +12 -0
- package/lib/templates/integration/webpack.config.js.ejs +36 -0
- package/lib/templates/trigger/trigger.ts.ejs +19 -0
- package/oclif.manifest.json +3153 -2451
- package/package.json +56 -60
- package/bin/run +0 -12
- package/lib/auth.js +0 -323
- package/lib/commands/alerts/events/list.js +0 -56
- package/lib/commands/alerts/groups/create.js +0 -58
- package/lib/commands/alerts/groups/delete.js +0 -35
- package/lib/commands/alerts/groups/list.js +0 -44
- package/lib/commands/alerts/monitors/clear.js +0 -35
- package/lib/commands/alerts/monitors/create.js +0 -102
- package/lib/commands/alerts/monitors/delete.js +0 -35
- package/lib/commands/alerts/monitors/list.js +0 -63
- package/lib/commands/alerts/triggers/list.js +0 -31
- package/lib/commands/alerts/webhooks/create.js +0 -67
- package/lib/commands/alerts/webhooks/delete.js +0 -35
- package/lib/commands/alerts/webhooks/list.js +0 -57
- package/lib/commands/components/actions/list.js +0 -96
- package/lib/commands/components/data-sources/list.js +0 -114
- package/lib/commands/components/delete.js +0 -35
- package/lib/commands/components/dev/run.js +0 -83
- package/lib/commands/components/dev/test.js +0 -266
- package/lib/commands/components/init/action.js +0 -12
- package/lib/commands/components/init/component.js +0 -12
- package/lib/commands/components/init/connection.js +0 -12
- package/lib/commands/components/init/dataSource.js +0 -12
- package/lib/commands/components/init/index.js +0 -126
- package/lib/commands/components/init/trigger.js +0 -12
- package/lib/commands/components/list.js +0 -95
- package/lib/commands/components/publish.js +0 -62
- package/lib/commands/components/triggers/list.js +0 -96
- package/lib/commands/customers/create.js +0 -72
- package/lib/commands/customers/credentials/create.js +0 -68
- package/lib/commands/customers/credentials/delete.js +0 -35
- package/lib/commands/customers/credentials/list.js +0 -56
- package/lib/commands/customers/credentials/update.js +0 -58
- package/lib/commands/customers/delete.js +0 -35
- package/lib/commands/customers/list.js +0 -51
- package/lib/commands/customers/update.js +0 -82
- package/lib/commands/customers/users/create.js +0 -67
- package/lib/commands/customers/users/delete.js +0 -35
- package/lib/commands/customers/users/list.js +0 -65
- package/lib/commands/customers/users/roles.js +0 -33
- package/lib/commands/customers/users/update.js +0 -76
- package/lib/commands/executions/step-result/get.js +0 -73
- package/lib/commands/instances/config-vars/list.js +0 -83
- package/lib/commands/instances/create.js +0 -84
- package/lib/commands/instances/delete.js +0 -35
- package/lib/commands/instances/deploy.js +0 -43
- package/lib/commands/instances/disable.js +0 -36
- package/lib/commands/instances/enable.js +0 -36
- package/lib/commands/instances/flow-configs/list.js +0 -62
- package/lib/commands/instances/flow-configs/test.js +0 -127
- package/lib/commands/instances/list.js +0 -86
- package/lib/commands/instances/update.js +0 -99
- package/lib/commands/integrations/available.js +0 -47
- package/lib/commands/integrations/create.js +0 -58
- package/lib/commands/integrations/delete.js +0 -35
- package/lib/commands/integrations/export.js +0 -29
- package/lib/commands/integrations/flows/list.js +0 -61
- package/lib/commands/integrations/flows/test.js +0 -124
- package/lib/commands/integrations/fork.js +0 -56
- package/lib/commands/integrations/import.js +0 -54
- package/lib/commands/integrations/init/flow.js +0 -12
- package/lib/commands/integrations/init/index.js +0 -45
- package/lib/commands/integrations/init/integration.js +0 -12
- package/lib/commands/integrations/list.js +0 -96
- package/lib/commands/integrations/marketplace.js +0 -80
- package/lib/commands/integrations/open.js +0 -18
- package/lib/commands/integrations/publish.js +0 -44
- package/lib/commands/integrations/update.js +0 -75
- package/lib/commands/integrations/versions/index.js +0 -83
- package/lib/commands/login.js +0 -33
- package/lib/commands/logout.js +0 -23
- package/lib/commands/logs/severities/list.js +0 -29
- package/lib/commands/me/index.js +0 -22
- package/lib/commands/me/token/revoke.js +0 -12
- package/lib/commands/me/token.js +0 -25
- package/lib/commands/on-prem-resources/delete.js +0 -35
- package/lib/commands/on-prem-resources/list.js +0 -69
- package/lib/commands/on-prem-resources/registration-jwt.js +0 -81
- package/lib/commands/organization/credentials/create.js +0 -60
- package/lib/commands/organization/credentials/delete.js +0 -35
- package/lib/commands/organization/credentials/list.js +0 -45
- package/lib/commands/organization/credentials/update.js +0 -58
- package/lib/commands/organization/signingkeys/delete.js +0 -35
- package/lib/commands/organization/signingkeys/generate.js +0 -22
- package/lib/commands/organization/signingkeys/import.js +0 -40
- package/lib/commands/organization/signingkeys/list.js +0 -36
- package/lib/commands/organization/update.js +0 -37
- package/lib/commands/organization/updateAvatarUrl.js +0 -47
- package/lib/commands/organization/users/create.js +0 -51
- package/lib/commands/organization/users/delete.js +0 -35
- package/lib/commands/organization/users/list.js +0 -60
- package/lib/commands/organization/users/roles.js +0 -33
- package/lib/commands/organization/users/update.js +0 -66
- package/lib/commands/translations/list.js +0 -35
- package/lib/config.js +0 -39
- package/lib/errors.js +0 -55
- package/lib/fields.js +0 -12
- package/lib/fs.js +0 -23
- package/lib/generate/action.js +0 -208
- package/lib/generate/index.js +0 -54
- package/lib/generate/input.js +0 -93
- package/lib/generate/parse.js +0 -59
- package/lib/generate/sourceFile.js +0 -90
- package/lib/generate/util.js +0 -17
- package/lib/graphql.js +0 -42
- package/lib/queries.graphql.js +0 -43
- package/lib/types.js +0 -6
- package/lib/utils/avatar.js +0 -48
- package/lib/utils/component/deleteByKey.js +0 -36
- package/lib/utils/component/publish.js +0 -247
- package/lib/utils/component/query.js +0 -23
- package/lib/utils/date.js +0 -14
- package/lib/utils/execution/logs.js +0 -86
- package/lib/utils/execution/stepResults.js +0 -87
- package/lib/utils/generate.js +0 -50
- package/lib/utils/import.js +0 -21
- package/lib/utils/integration/definition.js +0 -101
- package/lib/utils/integration/export.js +0 -36
- package/lib/utils/integration/import.js +0 -179
- package/lib/utils/integration/invoke.js +0 -81
- package/lib/utils/integration/open.js +0 -37
- package/lib/utils/integration/query.js +0 -59
- package/lib/utils/process.js +0 -15
- package/lib/utils/serialize.js +0 -8
- package/lib/utils/translations/processDataForTranslations.js +0 -132
- package/lib/utils/user/query.js +0 -26
- package/lib/yeoman.js +0 -27
- /package/{bin → lib}/run.cmd +0 -0
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { action, input } from "@prismatic-io/spectral";
|
|
2
|
+
import { createClient } from "./client";
|
|
3
|
+
|
|
4
|
+
const myConnectionField = input({
|
|
5
|
+
label: "Connection",
|
|
6
|
+
type: "connection",
|
|
7
|
+
required: true,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const myInputField = input({
|
|
11
|
+
label: "My Input",
|
|
12
|
+
type: "string",
|
|
13
|
+
required: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const <%= action.key %> = action({
|
|
17
|
+
display: {
|
|
18
|
+
label: "<%= action.label %>",
|
|
19
|
+
description: "<%= action.description %>",
|
|
20
|
+
},
|
|
21
|
+
perform: async (context, { connection, myInput }) => {
|
|
22
|
+
const client = createClient(connection);
|
|
23
|
+
return {
|
|
24
|
+
data: await client.call(myInput),
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
inputs: {
|
|
28
|
+
connection: myConnectionField,
|
|
29
|
+
myInput: myInputField,
|
|
30
|
+
},
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
export default { <%= action.key %> };
|
|
Binary file
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Connection } from "@prismatic-io/spectral";
|
|
2
|
+
|
|
3
|
+
export const createClient = (connection: Connection) => {
|
|
4
|
+
// Create a client using the provided Connection for the
|
|
5
|
+
// service you're consuming from this Component.
|
|
6
|
+
return {
|
|
7
|
+
call: async (name: unknown) =>
|
|
8
|
+
Promise.resolve(`Hello, ${name} using connection ${connection.key}`),
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
import { myAction } from "./actions";
|
|
2
|
+
import { myTrigger } from "./triggers";
|
|
3
|
+
import { myDataSource } from "./dataSources";
|
|
4
|
+
import { myConnection } from "./connections";
|
|
5
|
+
import {
|
|
6
|
+
invoke,
|
|
7
|
+
invokeTrigger,
|
|
8
|
+
invokeDataSource,
|
|
9
|
+
defaultTriggerPayload,
|
|
10
|
+
createConnection,
|
|
11
|
+
} from "@prismatic-io/spectral/dist/testing";
|
|
12
|
+
|
|
13
|
+
describe("test my action", () => {
|
|
14
|
+
test("verify the return value of my action", async () => {
|
|
15
|
+
const { result } = await invoke(myAction, {
|
|
16
|
+
connection: createConnection(myConnection, {
|
|
17
|
+
username: process.env.MY_APP_USERNAME, // A username saved as an environment variable
|
|
18
|
+
password: process.env.MY_APP_PASSWORD, // A password saved as an environment variable
|
|
19
|
+
}),
|
|
20
|
+
myInput: "some input",
|
|
21
|
+
});
|
|
22
|
+
expect(result.data).toBe("Hello, some input using connection myConnection");
|
|
23
|
+
});
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
describe("test my trigger", () => {
|
|
27
|
+
test("verify the return value of my trigger", async () => {
|
|
28
|
+
const expectedPayload = defaultTriggerPayload();
|
|
29
|
+
const {
|
|
30
|
+
result: { payload },
|
|
31
|
+
} = await invokeTrigger(myTrigger, {}, defaultTriggerPayload());
|
|
32
|
+
expect(payload).toStrictEqual(expectedPayload);
|
|
33
|
+
});
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
describe("test my data source", () => {
|
|
37
|
+
test("verify the return value of my data source", async () => {
|
|
38
|
+
const { result } = await invokeDataSource(myDataSource, {
|
|
39
|
+
connection: createConnection(myConnection, {
|
|
40
|
+
username: process.env.MY_APP_USERNAME, // A username saved as an environment variable
|
|
41
|
+
password: process.env.MY_APP_PASSWORD, // A password saved as an environment variable
|
|
42
|
+
}),
|
|
43
|
+
myInput: "some input",
|
|
44
|
+
});
|
|
45
|
+
expect(result).toBe("Hello, some input using connection myConnection");
|
|
46
|
+
});
|
|
47
|
+
});
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { component } from "@prismatic-io/spectral";
|
|
2
|
+
import actions from "./actions";
|
|
3
|
+
import triggers from "./triggers";
|
|
4
|
+
import dataSources from "./dataSources";
|
|
5
|
+
import connections from "./connections";
|
|
6
|
+
|
|
7
|
+
export default component({
|
|
8
|
+
key: "<%= component.key %>",
|
|
9
|
+
public: false,
|
|
10
|
+
display: {
|
|
11
|
+
label: "<%= component.name %>",
|
|
12
|
+
description: "<%= component.description %>",
|
|
13
|
+
iconPath: "icon.png",
|
|
14
|
+
},
|
|
15
|
+
actions,
|
|
16
|
+
triggers,
|
|
17
|
+
dataSources,
|
|
18
|
+
connections,
|
|
19
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const CopyPlugin = require("copy-webpack-plugin");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
mode: "production",
|
|
6
|
+
target: "node",
|
|
7
|
+
plugins: [
|
|
8
|
+
new CopyPlugin({
|
|
9
|
+
patterns: [{ from: "assets", to: path.resolve(__dirname, "dist") }],
|
|
10
|
+
}),
|
|
11
|
+
],
|
|
12
|
+
module: {
|
|
13
|
+
rules: [
|
|
14
|
+
{
|
|
15
|
+
sideEffects: false,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
test: /\.ts/,
|
|
19
|
+
use: "ts-loader",
|
|
20
|
+
exclude: /node_modules/,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
resolve: {
|
|
25
|
+
extensions: [".ts", ".js"],
|
|
26
|
+
},
|
|
27
|
+
optimization: {
|
|
28
|
+
usedExports: true,
|
|
29
|
+
},
|
|
30
|
+
entry: "./src/index.ts",
|
|
31
|
+
output: {
|
|
32
|
+
filename: "index.js",
|
|
33
|
+
path: path.resolve(__dirname, "dist"),
|
|
34
|
+
libraryTarget: "commonjs2",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { connection } from "@prismatic-io/spectral";
|
|
2
|
+
|
|
3
|
+
export const <%= connection.key %> = connection({
|
|
4
|
+
key: "<%= connection.key %>",
|
|
5
|
+
label: "<%= connection.label %>",
|
|
6
|
+
comments: "<%= connection.comments %>",
|
|
7
|
+
inputs: {
|
|
8
|
+
username: {
|
|
9
|
+
label: "Username",
|
|
10
|
+
placeholder: "Username",
|
|
11
|
+
type: "string",
|
|
12
|
+
required: true,
|
|
13
|
+
comments: "Username for my Connection",
|
|
14
|
+
},
|
|
15
|
+
password: {
|
|
16
|
+
label: "Password",
|
|
17
|
+
placeholder: "Password",
|
|
18
|
+
type: "password",
|
|
19
|
+
required: true,
|
|
20
|
+
comments: "Password for my Connection",
|
|
21
|
+
},
|
|
22
|
+
},
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
export default [<%= connection.key %>];
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import {
|
|
2
|
+
connection,
|
|
3
|
+
oauth2Connection,
|
|
4
|
+
OAuth2Type,
|
|
5
|
+
} from "@prismatic-io/spectral";
|
|
6
|
+
|
|
7
|
+
export const <%= connection.key %> = oauth2Connection({
|
|
8
|
+
key: "<%= connection.key %>",
|
|
9
|
+
label: "<%= connection.label %>",
|
|
10
|
+
comments: "<%= connection.comments %>",
|
|
11
|
+
oauth2Type: OAuth2Type.AuthorizationCode,
|
|
12
|
+
inputs: {
|
|
13
|
+
authorizeUrl: {
|
|
14
|
+
label: "Authorize URL",
|
|
15
|
+
placeholder: "Authorize URL",
|
|
16
|
+
type: "string",
|
|
17
|
+
required: true,
|
|
18
|
+
shown: true,
|
|
19
|
+
comments: "The OAuth 2.0 Authorization URL for the API",
|
|
20
|
+
},
|
|
21
|
+
tokenUrl: {
|
|
22
|
+
label: "Token URL",
|
|
23
|
+
placeholder: "Token URL",
|
|
24
|
+
type: "string",
|
|
25
|
+
required: true,
|
|
26
|
+
shown: true,
|
|
27
|
+
comments: "The OAuth 2.0 Token URL for the API",
|
|
28
|
+
},
|
|
29
|
+
scopes: {
|
|
30
|
+
label: "Scopes",
|
|
31
|
+
placeholder: "Scopes",
|
|
32
|
+
type: "string",
|
|
33
|
+
required: false,
|
|
34
|
+
shown: true,
|
|
35
|
+
comments: "Space separated OAuth 2.0 permission scopes for the API",
|
|
36
|
+
default: "",
|
|
37
|
+
},
|
|
38
|
+
clientId: {
|
|
39
|
+
label: "Client ID",
|
|
40
|
+
placeholder: "Client ID",
|
|
41
|
+
type: "string",
|
|
42
|
+
required: true,
|
|
43
|
+
shown: true,
|
|
44
|
+
comments: "Client Identifier of your app for the API",
|
|
45
|
+
},
|
|
46
|
+
clientSecret: {
|
|
47
|
+
label: "Client Secret",
|
|
48
|
+
placeholder: "Client Secret",
|
|
49
|
+
type: "password",
|
|
50
|
+
required: true,
|
|
51
|
+
shown: true,
|
|
52
|
+
comments: "Client Secret of your app for the API",
|
|
53
|
+
},
|
|
54
|
+
headers: {
|
|
55
|
+
label: "Headers",
|
|
56
|
+
type: "string",
|
|
57
|
+
collection: "keyvaluelist",
|
|
58
|
+
required: false,
|
|
59
|
+
shown: true,
|
|
60
|
+
comments: "Additional header to supply to authorization requests",
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
export default [<%= connection.key %>];
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { dataSource, input } from "@prismatic-io/spectral";
|
|
2
|
+
import { createClient } from "./client";
|
|
3
|
+
|
|
4
|
+
const myConnectionField = input({
|
|
5
|
+
label: "Connection",
|
|
6
|
+
type: "connection",
|
|
7
|
+
required: true,
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const myInputField = input({
|
|
11
|
+
label: "My Input",
|
|
12
|
+
type: "string",
|
|
13
|
+
required: true,
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
export const <%= dataSource.key %> = dataSource({
|
|
17
|
+
display: {
|
|
18
|
+
label: "<%= dataSource.label %>",
|
|
19
|
+
description: "<%= dataSource.description %>",
|
|
20
|
+
},
|
|
21
|
+
perform: async (context, { connection, myInput }) => {
|
|
22
|
+
const client = createClient(connection);
|
|
23
|
+
return {
|
|
24
|
+
result: await client.call(myInput),
|
|
25
|
+
};
|
|
26
|
+
},
|
|
27
|
+
inputs: {
|
|
28
|
+
connection: myConnectionField,
|
|
29
|
+
myInput: myInputField,
|
|
30
|
+
},
|
|
31
|
+
dataSourceType: "string",
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
export default { <%= dataSource.key %> };
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { flow } from "@prismatic-io/spectral";
|
|
2
|
+
import { createClient } from "./client";
|
|
3
|
+
import type { ConfigPages } from "./configPages";
|
|
4
|
+
|
|
5
|
+
export const <%= flow.key %> = flow<ConfigPages>({
|
|
6
|
+
name: "<%= flow.name %>",
|
|
7
|
+
stableKey: "<%= flow.stableKey %>",
|
|
8
|
+
description: "<%= flow.description %>",
|
|
9
|
+
onTrigger: async (context, payload, params) => {
|
|
10
|
+
const { logger } = context;
|
|
11
|
+
|
|
12
|
+
logger.info(`Trigger context: ${JSON.stringify(context)}`);
|
|
13
|
+
logger.info(`Trigger payload: ${JSON.stringify(payload)}`);
|
|
14
|
+
logger.info(`Trigger params: ${JSON.stringify(params)}`);
|
|
15
|
+
|
|
16
|
+
return Promise.resolve({
|
|
17
|
+
payload,
|
|
18
|
+
});
|
|
19
|
+
},
|
|
20
|
+
onExecution: async (context, params) => {
|
|
21
|
+
const { logger, configVars } = context;
|
|
22
|
+
|
|
23
|
+
if (!configVars?.connection1) {
|
|
24
|
+
throw new Error("Missing connection1 configuration");
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
logger.info(`Action context: ${JSON.stringify(context)}`);
|
|
28
|
+
logger.info(`Action params: ${JSON.stringify(params)}`);
|
|
29
|
+
|
|
30
|
+
const client = createClient(configVars.connection1);
|
|
31
|
+
return {
|
|
32
|
+
data: await client.call("<%= flow.name %>"),
|
|
33
|
+
};
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default [<%= flow.key %>];
|
|
Binary file
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const CopyPlugin = require("copy-webpack-plugin");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
mode: "production",
|
|
6
|
+
target: "node",
|
|
7
|
+
plugins: [
|
|
8
|
+
new CopyPlugin({
|
|
9
|
+
patterns: [{ from: "assets", to: path.resolve(__dirname, "dist") }],
|
|
10
|
+
}),
|
|
11
|
+
],
|
|
12
|
+
module: {
|
|
13
|
+
rules: [
|
|
14
|
+
{
|
|
15
|
+
sideEffects: false,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
test: /\.ts/,
|
|
19
|
+
use: "ts-loader",
|
|
20
|
+
exclude: /node_modules/,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
resolve: {
|
|
25
|
+
extensions: [".ts", ".js"],
|
|
26
|
+
},
|
|
27
|
+
optimization: {
|
|
28
|
+
usedExports: true,
|
|
29
|
+
},
|
|
30
|
+
entry: "./src/index.ts",
|
|
31
|
+
output: {
|
|
32
|
+
filename: "index.js",
|
|
33
|
+
path: path.resolve(__dirname, "dist"),
|
|
34
|
+
libraryTarget: "commonjs2",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
Binary file
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { configPage, connectionConfigVar } from "@prismatic-io/spectral";
|
|
2
|
+
|
|
3
|
+
export const configPages = {
|
|
4
|
+
Connections: configPage({
|
|
5
|
+
elements: {
|
|
6
|
+
"<%= configVar.key %>": connectionConfigVar({
|
|
7
|
+
stableKey: "<%= configVar.stableKey %>",
|
|
8
|
+
inputs: {
|
|
9
|
+
username: {
|
|
10
|
+
label: "Username",
|
|
11
|
+
placeholder: "Username",
|
|
12
|
+
type: "string",
|
|
13
|
+
required: true,
|
|
14
|
+
comments: "Username for my Connection",
|
|
15
|
+
},
|
|
16
|
+
password: {
|
|
17
|
+
label: "Password",
|
|
18
|
+
placeholder: "Password",
|
|
19
|
+
type: "password",
|
|
20
|
+
required: true,
|
|
21
|
+
comments: "Password for my Connection",
|
|
22
|
+
},
|
|
23
|
+
},
|
|
24
|
+
}),
|
|
25
|
+
},
|
|
26
|
+
}),
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export type ConfigPages = typeof configPages;
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import {
|
|
2
|
+
configPage,
|
|
3
|
+
connectionConfigVar,
|
|
4
|
+
OAuth2Type,
|
|
5
|
+
} from "@prismatic-io/spectral";
|
|
6
|
+
|
|
7
|
+
export const configPages = {
|
|
8
|
+
Connections: configPage({
|
|
9
|
+
elements: {
|
|
10
|
+
"<%= configVar.key %>": connectionConfigVar({
|
|
11
|
+
stableKey: "<%= configVar.stableKey %>",
|
|
12
|
+
oauth2Type: OAuth2Type.AuthorizationCode,
|
|
13
|
+
inputs: {
|
|
14
|
+
authorizeUrl: {
|
|
15
|
+
label: "Authorize URL",
|
|
16
|
+
placeholder: "Authorize URL",
|
|
17
|
+
type: "string",
|
|
18
|
+
required: true,
|
|
19
|
+
shown: true,
|
|
20
|
+
comments: "The OAuth 2.0 Authorization URL for the API",
|
|
21
|
+
},
|
|
22
|
+
tokenUrl: {
|
|
23
|
+
label: "Token URL",
|
|
24
|
+
placeholder: "Token URL",
|
|
25
|
+
type: "string",
|
|
26
|
+
required: true,
|
|
27
|
+
shown: true,
|
|
28
|
+
comments: "The OAuth 2.0 Token URL for the API",
|
|
29
|
+
},
|
|
30
|
+
scopes: {
|
|
31
|
+
label: "Scopes",
|
|
32
|
+
placeholder: "Scopes",
|
|
33
|
+
type: "string",
|
|
34
|
+
required: false,
|
|
35
|
+
shown: true,
|
|
36
|
+
comments: "Space separated OAuth 2.0 permission scopes for the API",
|
|
37
|
+
default: "",
|
|
38
|
+
},
|
|
39
|
+
clientId: {
|
|
40
|
+
label: "Client ID",
|
|
41
|
+
placeholder: "Client ID",
|
|
42
|
+
type: "string",
|
|
43
|
+
required: true,
|
|
44
|
+
shown: true,
|
|
45
|
+
comments: "Client Identifier of your app for the API",
|
|
46
|
+
},
|
|
47
|
+
clientSecret: {
|
|
48
|
+
label: "Client Secret",
|
|
49
|
+
placeholder: "Client Secret",
|
|
50
|
+
type: "password",
|
|
51
|
+
required: true,
|
|
52
|
+
shown: true,
|
|
53
|
+
comments: "Client Secret of your app for the API",
|
|
54
|
+
},
|
|
55
|
+
headers: {
|
|
56
|
+
label: "Headers",
|
|
57
|
+
type: "string",
|
|
58
|
+
collection: "keyvaluelist",
|
|
59
|
+
required: false,
|
|
60
|
+
shown: true,
|
|
61
|
+
comments: "Additional header to supply to authorization requests",
|
|
62
|
+
},
|
|
63
|
+
},
|
|
64
|
+
}),
|
|
65
|
+
},
|
|
66
|
+
}),
|
|
67
|
+
};
|
|
68
|
+
|
|
69
|
+
export type ConfigPages = typeof configPages;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Connection } from "@prismatic-io/spectral";
|
|
2
|
+
|
|
3
|
+
export const createClient = (connection: Connection) => {
|
|
4
|
+
// Create a client using the provided Connection for the
|
|
5
|
+
// service you're consuming from this Integration.
|
|
6
|
+
return {
|
|
7
|
+
call: async (name: unknown) =>
|
|
8
|
+
Promise.resolve(`Hello, ${name} using connection ${connection.key}`),
|
|
9
|
+
};
|
|
10
|
+
};
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { flow1 } from "./flows";
|
|
2
|
+
import { invokeFlow } from "@prismatic-io/spectral/dist/testing";
|
|
3
|
+
|
|
4
|
+
describe("test my flow", () => {
|
|
5
|
+
test("verify the return value of my flow", async () => {
|
|
6
|
+
const { result } = await invokeFlow(flow1, {
|
|
7
|
+
connection1: {
|
|
8
|
+
fields: {
|
|
9
|
+
username: process.env.MY_APP_USERNAME, // A username saved as an environment variable
|
|
10
|
+
password: process.env.MY_APP_PASSWORD, // A password saved as an environment variable
|
|
11
|
+
},
|
|
12
|
+
},
|
|
13
|
+
});
|
|
14
|
+
expect(result?.data).toBe(
|
|
15
|
+
"Hello, <%= flow.name %> using connection connection1",
|
|
16
|
+
);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { integration } from "@prismatic-io/spectral";
|
|
2
|
+
import flows from "./flows";
|
|
3
|
+
import { configPages } from "./configPages";
|
|
4
|
+
|
|
5
|
+
export default integration({
|
|
6
|
+
name: "<%= integration.name %>",
|
|
7
|
+
description: "<%= integration.description %>",
|
|
8
|
+
iconPath: "icon.png",
|
|
9
|
+
flows,
|
|
10
|
+
configPages,
|
|
11
|
+
});
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
const path = require("path");
|
|
2
|
+
const CopyPlugin = require("copy-webpack-plugin");
|
|
3
|
+
|
|
4
|
+
module.exports = {
|
|
5
|
+
mode: "production",
|
|
6
|
+
target: "node",
|
|
7
|
+
plugins: [
|
|
8
|
+
new CopyPlugin({
|
|
9
|
+
patterns: [{ from: "assets", to: path.resolve(__dirname, "dist") }],
|
|
10
|
+
}),
|
|
11
|
+
],
|
|
12
|
+
module: {
|
|
13
|
+
rules: [
|
|
14
|
+
{
|
|
15
|
+
sideEffects: false,
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
test: /\.ts/,
|
|
19
|
+
use: "ts-loader",
|
|
20
|
+
exclude: /node_modules/,
|
|
21
|
+
},
|
|
22
|
+
],
|
|
23
|
+
},
|
|
24
|
+
resolve: {
|
|
25
|
+
extensions: [".ts", ".js"],
|
|
26
|
+
},
|
|
27
|
+
optimization: {
|
|
28
|
+
usedExports: true,
|
|
29
|
+
},
|
|
30
|
+
entry: "./src/index.ts",
|
|
31
|
+
output: {
|
|
32
|
+
filename: "index.js",
|
|
33
|
+
path: path.resolve(__dirname, "dist"),
|
|
34
|
+
libraryTarget: "commonjs2",
|
|
35
|
+
},
|
|
36
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { trigger } from "@prismatic-io/spectral";
|
|
2
|
+
|
|
3
|
+
export const <%= trigger.key %> = trigger({
|
|
4
|
+
display: {
|
|
5
|
+
label: "<%= trigger.label %>",
|
|
6
|
+
description: "<%= trigger.description %>",
|
|
7
|
+
},
|
|
8
|
+
perform: async (context, payload, params) => {
|
|
9
|
+
console.log("<%= trigger.label %> params", params);
|
|
10
|
+
return Promise.resolve({
|
|
11
|
+
payload,
|
|
12
|
+
});
|
|
13
|
+
},
|
|
14
|
+
inputs: {},
|
|
15
|
+
synchronousResponseSupport: "valid",
|
|
16
|
+
scheduleSupport: "valid",
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
export default { <%= trigger.key %> };
|