@prismatic-io/prism 3.3.0 → 4.2.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.
Files changed (208) hide show
  1. package/bin/run +9 -8
  2. package/lib/auth.js +183 -201
  3. package/lib/commands/alerts/events/list.js +27 -57
  4. package/lib/commands/alerts/groups/create.js +18 -49
  5. package/lib/commands/alerts/groups/delete.js +10 -41
  6. package/lib/commands/alerts/groups/list.js +15 -47
  7. package/lib/commands/alerts/monitors/clear.js +10 -41
  8. package/lib/commands/alerts/monitors/create.js +27 -58
  9. package/lib/commands/alerts/monitors/delete.js +10 -41
  10. package/lib/commands/alerts/monitors/list.js +16 -48
  11. package/lib/commands/alerts/triggers/list.js +15 -47
  12. package/lib/commands/alerts/webhooks/create.js +18 -49
  13. package/lib/commands/alerts/webhooks/delete.js +10 -41
  14. package/lib/commands/alerts/webhooks/list.js +25 -57
  15. package/lib/commands/authorization-methods/list.js +20 -51
  16. package/lib/commands/components/actions/list.js +29 -61
  17. package/lib/commands/components/delete.js +10 -41
  18. package/lib/commands/components/dev/run.js +89 -0
  19. package/lib/commands/components/dev/test.js +218 -0
  20. package/lib/commands/components/init/action.js +12 -0
  21. package/lib/commands/components/init/component.js +12 -0
  22. package/lib/commands/components/init/connection.js +12 -0
  23. package/lib/commands/components/init/index.js +142 -0
  24. package/lib/commands/components/init/trigger.js +12 -0
  25. package/lib/commands/components/list.js +31 -60
  26. package/lib/commands/components/publish.js +29 -279
  27. package/lib/commands/components/triggers/list.js +29 -61
  28. package/lib/commands/customers/create.js +14 -45
  29. package/lib/commands/customers/credentials/create.js +19 -50
  30. package/lib/commands/customers/credentials/delete.js +10 -41
  31. package/lib/commands/customers/credentials/list.js +30 -59
  32. package/lib/commands/customers/credentials/update.js +16 -47
  33. package/lib/commands/customers/delete.js +10 -41
  34. package/lib/commands/customers/list.js +16 -48
  35. package/lib/commands/customers/update.js +15 -46
  36. package/lib/commands/customers/users/create.js +18 -49
  37. package/lib/commands/customers/users/delete.js +10 -41
  38. package/lib/commands/customers/users/list.js +21 -51
  39. package/lib/commands/customers/users/roles.js +18 -48
  40. package/lib/commands/customers/users/update.js +19 -50
  41. package/lib/commands/executions/step-result/get.js +36 -66
  42. package/lib/commands/instances/config-vars/list.js +32 -62
  43. package/lib/commands/instances/create.js +20 -51
  44. package/lib/commands/instances/delete.js +10 -41
  45. package/lib/commands/instances/deploy.js +20 -44
  46. package/lib/commands/instances/disable.js +11 -42
  47. package/lib/commands/instances/enable.js +11 -42
  48. package/lib/commands/instances/flow-configs/list.js +25 -55
  49. package/lib/commands/instances/flow-configs/test.js +62 -97
  50. package/lib/commands/instances/list.js +31 -59
  51. package/lib/commands/instances/update.js +15 -46
  52. package/lib/commands/integrations/available.js +13 -44
  53. package/lib/commands/integrations/create.js +14 -45
  54. package/lib/commands/integrations/delete.js +10 -41
  55. package/lib/commands/integrations/export.js +11 -68
  56. package/lib/commands/integrations/flows/list.js +22 -52
  57. package/lib/commands/integrations/flows/test.js +62 -96
  58. package/lib/commands/integrations/fork.js +15 -46
  59. package/lib/commands/integrations/import.js +12 -63
  60. package/lib/commands/integrations/list.js +25 -54
  61. package/lib/commands/integrations/publish.js +13 -44
  62. package/lib/commands/integrations/update.js +18 -49
  63. package/lib/commands/integrations/versions/index.js +26 -58
  64. package/lib/commands/login.js +16 -32
  65. package/lib/commands/logout.js +10 -22
  66. package/lib/commands/logs/severities/list.js +15 -47
  67. package/lib/commands/me/index.js +15 -60
  68. package/lib/commands/me/token/revoke.js +12 -0
  69. package/lib/commands/me/token.js +10 -22
  70. package/lib/commands/organization/credentials/create.js +17 -48
  71. package/lib/commands/organization/credentials/delete.js +10 -41
  72. package/lib/commands/organization/credentials/list.js +22 -54
  73. package/lib/commands/organization/credentials/update.js +16 -47
  74. package/lib/commands/organization/update.js +12 -43
  75. package/lib/commands/organization/updateAvatarUrl.js +14 -45
  76. package/lib/commands/organization/users/create.js +16 -47
  77. package/lib/commands/organization/users/delete.js +10 -41
  78. package/lib/commands/organization/users/list.js +16 -48
  79. package/lib/commands/organization/users/roles.js +18 -48
  80. package/lib/commands/organization/users/update.js +19 -50
  81. package/lib/config.js +24 -30
  82. package/lib/errors.js +48 -27
  83. package/lib/fields.js +6 -4
  84. package/lib/fs.js +6 -14
  85. package/lib/generate/action.js +43 -100
  86. package/lib/generate/index.js +27 -23
  87. package/lib/generate/input.js +28 -43
  88. package/lib/generate/parse.js +18 -76
  89. package/lib/generate/sourceFile.js +15 -44
  90. package/lib/generate/util.js +4 -106
  91. package/lib/graphql.js +37 -65
  92. package/lib/index.js +3 -3
  93. package/lib/utils/component/publish.js +219 -0
  94. package/lib/utils/component/query.js +23 -0
  95. package/lib/utils/date.js +14 -0
  96. package/lib/utils/execution/logs.js +86 -0
  97. package/lib/utils/integration/definition.js +101 -0
  98. package/lib/utils/integration/export.js +36 -0
  99. package/lib/utils/integration/import.js +46 -0
  100. package/lib/utils/integration/invoke.js +64 -0
  101. package/lib/utils/integration/query.js +59 -0
  102. package/lib/utils/serialize.js +8 -0
  103. package/lib/utils/user/query.js +24 -0
  104. package/lib/yeoman.js +24 -0
  105. package/oclif.manifest.json +1 -1
  106. package/package.json +50 -58
  107. package/lib/auth.js.map +0 -1
  108. package/lib/commands/alerts/events/list.js.map +0 -1
  109. package/lib/commands/alerts/groups/create.js.map +0 -1
  110. package/lib/commands/alerts/groups/delete.js.map +0 -1
  111. package/lib/commands/alerts/groups/list.js.map +0 -1
  112. package/lib/commands/alerts/monitors/clear.js.map +0 -1
  113. package/lib/commands/alerts/monitors/create.js.map +0 -1
  114. package/lib/commands/alerts/monitors/delete.js.map +0 -1
  115. package/lib/commands/alerts/monitors/list.js.map +0 -1
  116. package/lib/commands/alerts/triggers/list.js.map +0 -1
  117. package/lib/commands/alerts/webhooks/create.js.map +0 -1
  118. package/lib/commands/alerts/webhooks/delete.js.map +0 -1
  119. package/lib/commands/alerts/webhooks/list.js.map +0 -1
  120. package/lib/commands/authorization-methods/list.js.map +0 -1
  121. package/lib/commands/components/actions/list.js.map +0 -1
  122. package/lib/commands/components/delete.js.map +0 -1
  123. package/lib/commands/components/init.js +0 -224
  124. package/lib/commands/components/init.js.map +0 -1
  125. package/lib/commands/components/list.js.map +0 -1
  126. package/lib/commands/components/publish.js.map +0 -1
  127. package/lib/commands/components/triggers/list.js.map +0 -1
  128. package/lib/commands/customers/create.js.map +0 -1
  129. package/lib/commands/customers/credentials/create.js.map +0 -1
  130. package/lib/commands/customers/credentials/delete.js.map +0 -1
  131. package/lib/commands/customers/credentials/list.js.map +0 -1
  132. package/lib/commands/customers/credentials/update.js.map +0 -1
  133. package/lib/commands/customers/delete.js.map +0 -1
  134. package/lib/commands/customers/list.js.map +0 -1
  135. package/lib/commands/customers/update.js.map +0 -1
  136. package/lib/commands/customers/users/create.js.map +0 -1
  137. package/lib/commands/customers/users/delete.js.map +0 -1
  138. package/lib/commands/customers/users/list.js.map +0 -1
  139. package/lib/commands/customers/users/roles.js.map +0 -1
  140. package/lib/commands/customers/users/update.js.map +0 -1
  141. package/lib/commands/executions/step-result/get.js.map +0 -1
  142. package/lib/commands/instances/config-vars/list.js.map +0 -1
  143. package/lib/commands/instances/create.js.map +0 -1
  144. package/lib/commands/instances/delete.js.map +0 -1
  145. package/lib/commands/instances/deploy.js.map +0 -1
  146. package/lib/commands/instances/disable.js.map +0 -1
  147. package/lib/commands/instances/enable.js.map +0 -1
  148. package/lib/commands/instances/flow-configs/list.js.map +0 -1
  149. package/lib/commands/instances/flow-configs/test.js.map +0 -1
  150. package/lib/commands/instances/list.js.map +0 -1
  151. package/lib/commands/instances/update.js.map +0 -1
  152. package/lib/commands/integrations/available.js.map +0 -1
  153. package/lib/commands/integrations/create.js.map +0 -1
  154. package/lib/commands/integrations/delete.js.map +0 -1
  155. package/lib/commands/integrations/export.js.map +0 -1
  156. package/lib/commands/integrations/flows/list.js.map +0 -1
  157. package/lib/commands/integrations/flows/test.js.map +0 -1
  158. package/lib/commands/integrations/fork.js.map +0 -1
  159. package/lib/commands/integrations/import.js.map +0 -1
  160. package/lib/commands/integrations/list.js.map +0 -1
  161. package/lib/commands/integrations/publish.js.map +0 -1
  162. package/lib/commands/integrations/update.js.map +0 -1
  163. package/lib/commands/integrations/versions/index.js.map +0 -1
  164. package/lib/commands/login.js.map +0 -1
  165. package/lib/commands/logout.js.map +0 -1
  166. package/lib/commands/logs/severities/list.js.map +0 -1
  167. package/lib/commands/me/index.js.map +0 -1
  168. package/lib/commands/me/token.js.map +0 -1
  169. package/lib/commands/organization/credentials/create.js.map +0 -1
  170. package/lib/commands/organization/credentials/delete.js.map +0 -1
  171. package/lib/commands/organization/credentials/list.js.map +0 -1
  172. package/lib/commands/organization/credentials/update.js.map +0 -1
  173. package/lib/commands/organization/update.js.map +0 -1
  174. package/lib/commands/organization/updateAvatarUrl.js.map +0 -1
  175. package/lib/commands/organization/users/create.js.map +0 -1
  176. package/lib/commands/organization/users/delete.js.map +0 -1
  177. package/lib/commands/organization/users/list.js.map +0 -1
  178. package/lib/commands/organization/users/roles.js.map +0 -1
  179. package/lib/commands/organization/users/update.js.map +0 -1
  180. package/lib/config.js.map +0 -1
  181. package/lib/errors.js.map +0 -1
  182. package/lib/fields.js.map +0 -1
  183. package/lib/fs.js.map +0 -1
  184. package/lib/generate/action.js.map +0 -1
  185. package/lib/generate/client.js +0 -98
  186. package/lib/generate/client.js.map +0 -1
  187. package/lib/generate/connection.js +0 -86
  188. package/lib/generate/connection.js.map +0 -1
  189. package/lib/generate/index.js.map +0 -1
  190. package/lib/generate/input.js.map +0 -1
  191. package/lib/generate/parse.js.map +0 -1
  192. package/lib/generate/sourceFile.js.map +0 -1
  193. package/lib/generate/util.js.map +0 -1
  194. package/lib/graphql.js.map +0 -1
  195. package/lib/index.js.map +0 -1
  196. package/templates/component/assets/icon.png +0 -0
  197. package/templates/component/jest.config.js +0 -4
  198. package/templates/component/openapi/client.ts +0 -73
  199. package/templates/component/openapi/request.ts +0 -161
  200. package/templates/component/package.json +0 -24
  201. package/templates/component/src/actions.ts +0 -33
  202. package/templates/component/src/client.ts +0 -7
  203. package/templates/component/src/connections.ts +0 -25
  204. package/templates/component/src/index.test.ts +0 -32
  205. package/templates/component/src/index.ts +0 -17
  206. package/templates/component/src/triggers.ts +0 -18
  207. package/templates/component/tsconfig.json +0 -19
  208. package/templates/component/webpack.config.js +0 -44
@@ -1,161 +0,0 @@
1
- /* istanbul ignore file */
2
- /* tslint:disable */
3
- /* eslint-disable */
4
- // @ts-ignore
5
- import FormData from "form-data";
6
- import { AxiosResponse } from "axios";
7
- import { util } from "@prismatic-io/spectral";
8
- import { types } from "util";
9
- // @ts-ignore
10
- import type { ApiRequestOptions } from "./ApiRequestOptions";
11
- // @ts-ignore
12
- import { EnhancedOpenAPI } from "./OpenAPI";
13
-
14
- function isDefined<T>(
15
- value: T | null | undefined
16
- ): value is Exclude<T, null | undefined> {
17
- return value !== undefined && value !== null;
18
- }
19
-
20
- function isString(value: any): value is string {
21
- return typeof value === "string";
22
- }
23
-
24
- function isStringWithValue(value: any): value is string {
25
- return isString(value) && value !== "";
26
- }
27
-
28
- function isBinary(value: any): value is Buffer | ArrayBuffer | ArrayBufferView {
29
- const isBuffer = Buffer.isBuffer(value);
30
- const isArrayBuffer = types.isArrayBuffer(value);
31
- const isArrayBufferView = types.isArrayBufferView(value);
32
- return isBuffer || isArrayBuffer || isArrayBufferView;
33
- }
34
-
35
- function getUrl(options: ApiRequestOptions): string {
36
- const path = options.path.replace(/[:]/g, "_");
37
- const url = `${EnhancedOpenAPI.BASE}${path}`;
38
-
39
- return url;
40
- }
41
-
42
- function getFormData(params: Record<string, any>): FormData {
43
- const formData = new FormData();
44
- Object.entries(params).forEach(([key, value]) => {
45
- if (isDefined(value)) {
46
- formData.append(key, value);
47
- }
48
- });
49
- return formData;
50
- }
51
-
52
- type Resolver<T> = (options: ApiRequestOptions) => Promise<T>;
53
-
54
- async function resolve<T>(
55
- options: ApiRequestOptions,
56
- resolver?: T | Resolver<T>
57
- ): Promise<T | undefined> {
58
- if (typeof resolver === "function") {
59
- return (resolver as Resolver<T>)(options);
60
- }
61
- return resolver;
62
- }
63
-
64
- async function getHeaders(options: ApiRequestOptions): Promise<any> {
65
- const [token, username, password, defaultHeaders] = await Promise.all([
66
- resolve(options, EnhancedOpenAPI.TOKEN),
67
- resolve(options, EnhancedOpenAPI.USERNAME),
68
- resolve(options, EnhancedOpenAPI.PASSWORD),
69
- resolve(options, EnhancedOpenAPI.HEADERS),
70
- ]);
71
-
72
- const headers = {
73
- Accept: "application/json",
74
- ...defaultHeaders,
75
- ...options.headers,
76
- };
77
-
78
- if (EnhancedOpenAPI.timeout) {
79
- headers["timeout"] = util.types.toInt(EnhancedOpenAPI.timeout);
80
- }
81
-
82
- if (isStringWithValue(token)) {
83
- headers["Authorization"] = `Bearer ${token}`;
84
- }
85
-
86
- if (isStringWithValue(username) && isStringWithValue(password)) {
87
- const credentials = Buffer.from(`${username}:${password}`).toString(
88
- "base64"
89
- );
90
- headers["Authorization"] = `Basic ${credentials}`;
91
- }
92
-
93
- if (options.body) {
94
- if (isBinary(options.body)) {
95
- headers["Content-Type"] = "application/octet-stream";
96
- } else if (isString(options.body)) {
97
- headers["Content-Type"], "text/plain";
98
- } else {
99
- headers["Content-Type"] = "application/json";
100
- }
101
- }
102
-
103
- return headers;
104
- }
105
-
106
- function getRequestBody(options: ApiRequestOptions) {
107
- if (options.formData) {
108
- return getFormData(options.formData);
109
- }
110
- if (options.body) {
111
- if (isString(options.body) || isBinary(options.body)) {
112
- return options.body;
113
- } else {
114
- return JSON.stringify(options.body);
115
- }
116
- }
117
- return undefined;
118
- }
119
- interface RequestProps {
120
- options: ApiRequestOptions;
121
- url: string;
122
- }
123
-
124
- async function sendRequest({
125
- options,
126
- url,
127
- }: RequestProps): Promise<Partial<AxiosResponse>> {
128
- const result = await EnhancedOpenAPI.CLIENT.request({
129
- url,
130
- method: options.method,
131
- headers: await getHeaders(options),
132
- data: getRequestBody(options),
133
- params: options.query ? { ...options.query } : undefined,
134
- });
135
-
136
- return result;
137
- }
138
-
139
- /**
140
- * Request using Axios client
141
- * @param options The request options from the the service
142
- * @returns Partial<AxiosResponse> & {
143
- body: AxiosResponse["data"];
144
- }
145
- */
146
- export async function request(
147
- options: ApiRequestOptions
148
- ): Promise<
149
- Partial<AxiosResponse> & {
150
- body: AxiosResponse["data"];
151
- }
152
- > {
153
- const url = getUrl(options);
154
-
155
- const response = await sendRequest({
156
- options,
157
- url,
158
- });
159
-
160
- return { ...response, body: await response.data };
161
- }
@@ -1,24 +0,0 @@
1
- {
2
- "name": "<<COMPONENT_NAME>>",
3
- "version": "0.0.1",
4
- "main": "index.js",
5
- "private": true,
6
- "scripts": {
7
- "build": "webpack",
8
- "publish": "npm run build && prism components:publish",
9
- "test": "jest"
10
- },
11
- "dependencies": {
12
- "extraDeps": ""
13
- },
14
- "devDependencies": {
15
- "@types/jest": "26.0.24",
16
- "copy-webpack-plugin": "9.0.1",
17
- "jest": "27.0.6",
18
- "ts-jest": "27.0.3",
19
- "ts-loader": "9.2.3",
20
- "typescript": "4.3.5",
21
- "webpack": "5.43.0",
22
- "webpack-cli": "4.7.2"
23
- }
24
- }
@@ -1,33 +0,0 @@
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 myAction = action({
17
- display: {
18
- label: "My Action",
19
- description: "This is my action",
20
- },
21
- perform: async (context, { connection, myInput }) => {
22
- const client = createClient(connection);
23
- return {
24
- data: `Hello, ${myInput}`,
25
- };
26
- },
27
- inputs: {
28
- connection: myConnectionField,
29
- myInput: myInputField,
30
- },
31
- });
32
-
33
- export default { myAction };
@@ -1,7 +0,0 @@
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
- };
@@ -1,25 +0,0 @@
1
- import { connection } from "@prismatic-io/spectral";
2
-
3
- export const myConnection = connection({
4
- key: "myConnection",
5
- label: "My Connection",
6
- comments: "My Connection",
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 [myConnection];
@@ -1,32 +0,0 @@
1
- import { myAction } from "./actions";
2
- import { myTrigger } from "./triggers";
3
- import { myConnection } from "./connections";
4
- import {
5
- invoke,
6
- invokeTrigger,
7
- defaultTriggerPayload,
8
- createConnection,
9
- } from "@prismatic-io/spectral/dist/testing";
10
-
11
- describe("test my action", () => {
12
- test("verify the return value of my action", async () => {
13
- const { result } = await invoke(myAction, {
14
- connection: createConnection(myConnection, {
15
- username: process.env.MY_APP_USERNAME, // A username saved as an environment variable
16
- password: process.env.MY_APP_PASSWORD, // A password saved as an environment variable
17
- }),
18
- myInput: "some input",
19
- });
20
- expect(result.data).toBe("Hello, some input");
21
- });
22
- });
23
-
24
- describe("test my trigger", () => {
25
- test("verify the return value of my trigger", async () => {
26
- const expectedPayload = defaultTriggerPayload();
27
- const {
28
- result: { payload },
29
- } = await invokeTrigger(myTrigger, {}, defaultTriggerPayload());
30
- expect(payload).toStrictEqual(expectedPayload);
31
- });
32
- });
@@ -1,17 +0,0 @@
1
- import { component } from "@prismatic-io/spectral";
2
- import actions from "./actions";
3
- import triggers from "./triggers";
4
- import connections from "./connections";
5
-
6
- export default component({
7
- key: "<<COMPONENT_NAME>>",
8
- public: false,
9
- display: {
10
- label: "<<COMPONENT_NAME>>",
11
- description: "Prism-generated Component",
12
- iconPath: "icon.png",
13
- },
14
- actions,
15
- triggers,
16
- connections,
17
- });
@@ -1,18 +0,0 @@
1
- import { trigger } from "@prismatic-io/spectral";
2
-
3
- export const myTrigger = trigger({
4
- display: {
5
- label: "My Trigger",
6
- description: "This is my trigger",
7
- },
8
- perform: async (context, payload, params) => {
9
- return {
10
- payload,
11
- };
12
- },
13
- inputs: {},
14
- synchronousResponseSupport: "valid",
15
- scheduleSupport: "valid",
16
- });
17
-
18
- export default { myTrigger };
@@ -1,19 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- "target": "es6",
4
- "lib": ["esnext"],
5
- "allowJs": true,
6
- "skipLibCheck": true,
7
- "esModuleInterop": true,
8
- "allowSyntheticDefaultImports": true,
9
- "strict": true,
10
- "forceConsistentCasingInFileNames": true,
11
- "module": "esnext",
12
- "moduleResolution": "node",
13
- "resolveJsonModule": true,
14
- "isolatedModules": false,
15
- "strictNullChecks": false,
16
- "noImplicitAny": false
17
- },
18
- "include": ["src"]
19
- }
@@ -1,44 +0,0 @@
1
- const path = require("path");
2
- const webpack = require("webpack");
3
- const CopyPlugin = require("copy-webpack-plugin");
4
-
5
- module.exports = {
6
- mode: "development",
7
- target: "node",
8
- plugins: [
9
- new CopyPlugin({
10
- patterns: [
11
- { from: "assets", to: path.resolve(__dirname, "dist") },
12
- {
13
- from: "*.wsdl",
14
- to: path.resolve(__dirname, "dist"),
15
- noErrorOnMissing: true,
16
- },
17
- ],
18
- }),
19
- ],
20
- module: {
21
- rules: [
22
- {
23
- sideEffects: false,
24
- },
25
- {
26
- test: /\.ts/,
27
- use: "ts-loader",
28
- exclude: /node_modules/,
29
- },
30
- ],
31
- },
32
- resolve: {
33
- extensions: [".ts", ".js"],
34
- },
35
- optimization: {
36
- usedExports: true,
37
- },
38
- entry: "./src/index.ts",
39
- output: {
40
- filename: "index.js",
41
- path: path.resolve(__dirname, "dist"),
42
- libraryTarget: "commonjs2",
43
- },
44
- };