@prismatic-io/prism 3.0.8 → 3.2.2

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 (67) hide show
  1. package/README.md +10 -9
  2. package/lib/commands/alerts/events/list.js +8 -6
  3. package/lib/commands/alerts/events/list.js.map +1 -1
  4. package/lib/commands/alerts/groups/create.js +2 -0
  5. package/lib/commands/alerts/groups/create.js.map +1 -1
  6. package/lib/commands/alerts/monitors/create.js +11 -0
  7. package/lib/commands/alerts/monitors/create.js.map +1 -1
  8. package/lib/commands/alerts/webhooks/create.js +1 -0
  9. package/lib/commands/alerts/webhooks/create.js.map +1 -1
  10. package/lib/commands/components/init.js +6 -4
  11. package/lib/commands/components/init.js.map +1 -1
  12. package/lib/commands/components/list.js +1 -0
  13. package/lib/commands/components/list.js.map +1 -1
  14. package/lib/commands/components/publish.js +43 -5
  15. package/lib/commands/components/publish.js.map +1 -1
  16. package/lib/commands/customers/create.js +1 -0
  17. package/lib/commands/customers/create.js.map +1 -1
  18. package/lib/commands/customers/update.js +2 -0
  19. package/lib/commands/customers/update.js.map +1 -1
  20. package/lib/commands/customers/users/create.js +5 -1
  21. package/lib/commands/customers/users/create.js.map +1 -1
  22. package/lib/commands/customers/users/list.js +8 -6
  23. package/lib/commands/customers/users/list.js.map +1 -1
  24. package/lib/commands/customers/users/update.js +12 -2
  25. package/lib/commands/customers/users/update.js.map +1 -1
  26. package/lib/commands/instances/config-vars/list.js +8 -6
  27. package/lib/commands/instances/config-vars/list.js.map +1 -1
  28. package/lib/commands/instances/create.js +2 -0
  29. package/lib/commands/instances/create.js.map +1 -1
  30. package/lib/commands/instances/flow-configs/list.js +3 -1
  31. package/lib/commands/instances/flow-configs/list.js.map +1 -1
  32. package/lib/commands/instances/flow-configs/test.js +8 -1
  33. package/lib/commands/instances/flow-configs/test.js.map +1 -1
  34. package/lib/commands/integrations/export.js +1 -1
  35. package/lib/commands/integrations/flows/list.js +7 -1
  36. package/lib/commands/integrations/flows/list.js.map +1 -1
  37. package/lib/commands/integrations/flows/test.js +6 -1
  38. package/lib/commands/integrations/flows/test.js.map +1 -1
  39. package/lib/commands/organization/updateAvatarUrl.js +1 -0
  40. package/lib/commands/organization/updateAvatarUrl.js.map +1 -1
  41. package/lib/generate/action.js +47 -34
  42. package/lib/generate/action.js.map +1 -1
  43. package/lib/generate/{auth.js → client.js} +14 -25
  44. package/lib/generate/client.js.map +1 -0
  45. package/lib/generate/connection.js +86 -0
  46. package/lib/generate/connection.js.map +1 -0
  47. package/lib/generate/index.js +8 -6
  48. package/lib/generate/index.js.map +1 -1
  49. package/lib/generate/input.js +5 -2
  50. package/lib/generate/input.js.map +1 -1
  51. package/lib/generate/parse.js +4 -1
  52. package/lib/generate/parse.js.map +1 -1
  53. package/lib/generate/sourceFile.js +13 -7
  54. package/lib/generate/sourceFile.js.map +1 -1
  55. package/lib/generate/util.js +2 -2
  56. package/lib/generate/util.js.map +1 -1
  57. package/oclif.manifest.json +1 -1
  58. package/package.json +2 -2
  59. package/templates/component/openapi/{auth.ts → client.ts} +10 -35
  60. package/templates/component/src/actions.ts +14 -2
  61. package/templates/component/src/client.ts +7 -0
  62. package/templates/component/src/connections.ts +25 -0
  63. package/templates/component/src/index.test.ts +6 -0
  64. package/templates/component/src/index.ts +2 -0
  65. package/lib/commands/instances/credentials/list.js +0 -98
  66. package/lib/commands/instances/credentials/list.js.map +0 -1
  67. package/lib/generate/auth.js.map +0 -1
@@ -1,5 +1,5 @@
1
1
  ({
2
- credential,
2
+ connection,
3
3
  apiBaseUrl,
4
4
  debugRequest,
5
5
  maxRetries,
@@ -60,39 +60,14 @@
60
60
  );
61
61
  }
62
62
 
63
- switch (credential.authorizationMethod) {
64
- case "basic": {
65
- const {
66
- fields: { username, password },
67
- } = credential;
68
-
69
- EnhancedOpenAPI.USERNAME = username;
70
-
71
- EnhancedOpenAPI.PASSWORD = password;
72
- break;
73
- }
74
-
75
- case "oauth2": {
76
- const {
77
- token: { access_token: accessToken },
78
- } = credential;
79
-
80
- EnhancedOpenAPI.TOKEN = accessToken;
81
- break;
82
- }
83
-
84
- case "api_key": {
85
- const {
86
- fields: { api_key: apiKey },
87
- } = credential;
88
-
89
- EnhancedOpenAPI.TOKEN = apiKey;
90
- break;
91
- }
92
-
93
- default:
94
- throw new Error(
95
- `Unsupported authorization method: \${credential.authorizationMethod}`
96
- );
63
+ const { key, fields } = connection;
64
+ if (key === "basicAuth") {
65
+ EnhancedOpenAPI.USERNAME = fields.username as string;
66
+ EnhancedOpenAPI.PASSWORD = fields.password as string;
67
+ } else {
68
+ throw new ConnectionError(
69
+ connection,
70
+ `Invalid connection type provided: \${key}`
71
+ );
97
72
  }
98
73
  };
@@ -1,4 +1,12 @@
1
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
+
2
10
  const myInputField = input({
3
11
  label: "My Input",
4
12
  type: "string",
@@ -10,12 +18,16 @@ export const myAction = action({
10
18
  label: "My Action",
11
19
  description: "This is my action",
12
20
  },
13
- perform: async (context, { myInput }) => {
21
+ perform: async (context, { connection, myInput }) => {
22
+ const client = createClient(connection);
14
23
  return {
15
24
  data: `Hello, ${myInput}`,
16
25
  };
17
26
  },
18
- inputs: { myInput: myInputField },
27
+ inputs: {
28
+ connection: myConnectionField,
29
+ myInput: myInputField,
30
+ },
19
31
  });
20
32
 
21
33
  export default { myAction };
@@ -0,0 +1,7 @@
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
+ };
@@ -0,0 +1,25 @@
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,14 +1,20 @@
1
1
  import { myAction } from "./actions";
2
2
  import { myTrigger } from "./triggers";
3
+ import { myConnection } from "./connections";
3
4
  import {
4
5
  invoke,
5
6
  invokeTrigger,
6
7
  defaultTriggerPayload,
8
+ createConnection,
7
9
  } from "@prismatic-io/spectral/dist/testing";
8
10
 
9
11
  describe("test my action", () => {
10
12
  test("verify the return value of my action", async () => {
11
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
+ }),
12
18
  myInput: "some input",
13
19
  });
14
20
  expect(result.data).toBe("Hello, some input");
@@ -1,6 +1,7 @@
1
1
  import { component } from "@prismatic-io/spectral";
2
2
  import actions from "./actions";
3
3
  import triggers from "./triggers";
4
+ import connections from "./connections";
4
5
 
5
6
  export default component({
6
7
  key: "<<COMPONENT_NAME>>",
@@ -12,4 +13,5 @@ export default component({
12
13
  },
13
14
  actions,
14
15
  triggers,
16
+ connections,
15
17
  });
@@ -1,98 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
5
- }) : (function(o, m, k, k2) {
6
- if (k2 === undefined) k2 = k;
7
- o[k2] = m[k];
8
- }));
9
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
10
- Object.defineProperty(o, "default", { enumerable: true, value: v });
11
- }) : function(o, v) {
12
- o["default"] = v;
13
- });
14
- var __importStar = (this && this.__importStar) || function (mod) {
15
- if (mod && mod.__esModule) return mod;
16
- var result = {};
17
- if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
18
- __setModuleDefault(result, mod);
19
- return result;
20
- };
21
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
22
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
23
- return new (P || (P = Promise))(function (resolve, reject) {
24
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
26
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
27
- step((generator = generator.apply(thisArg, _arguments || [])).next());
28
- });
29
- };
30
- Object.defineProperty(exports, "__esModule", { value: true });
31
- const command_1 = require("@oclif/command");
32
- const graphql_1 = __importStar(require("../../../graphql"));
33
- const cli_ux_1 = require("cli-ux");
34
- class ListCommand extends command_1.Command {
35
- run() {
36
- return __awaiter(this, void 0, void 0, function* () {
37
- const { flags } = this.parse(ListCommand);
38
- const { instance } = flags;
39
- const result = yield graphql_1.default.query({
40
- query: graphql_1.gql `
41
- query listInstanceCredentials($id: ID!) {
42
- instance(id: $id) {
43
- credentials {
44
- nodes {
45
- id
46
- action {
47
- id
48
- name
49
- }
50
- credential {
51
- id
52
- label
53
- authorizationMethod {
54
- id
55
- label
56
- }
57
- readyForUse
58
- }
59
- }
60
- }
61
- }
62
- }
63
- `,
64
- variables: {
65
- id: instance,
66
- },
67
- });
68
- cli_ux_1.cli.table(result.data.instance.credentials.nodes, {
69
- id: {
70
- minWidth: 8,
71
- extended: true,
72
- },
73
- step: {
74
- get: (row) => row.action.name,
75
- },
76
- label: {
77
- get: (row) => row.credential.label,
78
- },
79
- authorizationMethod: {
80
- header: "Authorization Method",
81
- get: (row) => row.credential.authorizationMethod.label,
82
- },
83
- readyForUse: {
84
- get: (row) => row.credential.readyForUse,
85
- header: "Ready for Use",
86
- },
87
- }, Object.assign({}, flags));
88
- });
89
- }
90
- }
91
- exports.default = ListCommand;
92
- ListCommand.description = "List Credentials used on an Instance";
93
- ListCommand.flags = Object.assign({ instance: command_1.flags.string({
94
- char: "i",
95
- required: true,
96
- description: "ID of an instance",
97
- }) }, cli_ux_1.cli.table.flags());
98
- //# sourceMappingURL=list.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"list.js","sourceRoot":"","sources":["../../../../src/commands/instances/credentials/list.tsx"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,4CAAgD;AAChD,4DAA+C;AAC/C,mCAA6B;AAE7B,MAAqB,WAAY,SAAQ,iBAAO;IAWxC,GAAG;;YACP,MAAM,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC;YAC1C,MAAM,EAAE,QAAQ,EAAE,GAAG,KAAK,CAAC;YAE3B,MAAM,MAAM,GAAG,MAAM,iBAAM,CAAC,KAAK,CAAC;gBAChC,KAAK,EAAE,aAAG,CAAA;;;;;;;;;;;;;;;;;;;;;;;OAuBT;gBACD,SAAS,EAAE;oBACT,EAAE,EAAE,QAAQ;iBACb;aACF,CAAC,CAAC;YAEH,YAAG,CAAC,KAAK,CACP,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,KAAK,EACtC;gBACE,EAAE,EAAE;oBACF,QAAQ,EAAE,CAAC;oBACX,QAAQ,EAAE,IAAI;iBACf;gBACD,IAAI,EAAE;oBACJ,GAAG,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI;iBACnC;gBACD,KAAK,EAAE;oBACL,GAAG,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK;iBACxC;gBACD,mBAAmB,EAAE;oBACnB,MAAM,EAAE,sBAAsB;oBAC9B,GAAG,EAAE,CAAC,GAAQ,EAAE,EAAE,CAAC,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