@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,42 +1,12 @@
1
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
2
  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 result = yield graphql_1.default.query({
39
- query: graphql_1.gql `
3
+ const core_1 = require("@oclif/core");
4
+ const graphql_1 = require("../../../graphql");
5
+ class ListCommand extends core_1.Command {
6
+ async run() {
7
+ const { flags } = await this.parse(ListCommand);
8
+ const result = await (0, graphql_1.gqlRequest)({
9
+ document: (0, graphql_1.gql) `
40
10
  query listUsers {
41
11
  organization {
42
12
  users {
@@ -49,19 +19,17 @@ class ListCommand extends command_1.Command {
49
19
  }
50
20
  }
51
21
  `,
52
- });
53
- cli_ux_1.cli.table(result.data.organization.users.nodes, {
54
- id: {
55
- minWidth: 8,
56
- extended: true,
57
- },
58
- name: {},
59
- email: {},
60
- }, Object.assign({}, flags));
61
22
  });
23
+ core_1.CliUx.ux.table(result.organization.users.nodes, {
24
+ id: {
25
+ minWidth: 8,
26
+ extended: true,
27
+ },
28
+ name: {},
29
+ email: {},
30
+ }, { ...flags });
62
31
  }
63
32
  }
64
33
  exports.default = ListCommand;
65
34
  ListCommand.description = "List Users of your Organization";
66
- ListCommand.flags = Object.assign({}, cli_ux_1.cli.table.flags());
67
- //# sourceMappingURL=list.js.map
35
+ ListCommand.flags = { ...core_1.CliUx.ux.table.flags() };
@@ -1,42 +1,12 @@
1
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
2
  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 result = yield graphql_1.default.query({
39
- query: graphql_1.gql `
3
+ const core_1 = require("@oclif/core");
4
+ const graphql_1 = require("../../../graphql");
5
+ class ListCommand extends core_1.Command {
6
+ async run() {
7
+ const { flags } = await this.parse(ListCommand);
8
+ const result = await (0, graphql_1.gqlRequest)({
9
+ document: (0, graphql_1.gql) `
40
10
  query listOrganizationRoles {
41
11
  organizationRoles {
42
12
  id
@@ -45,19 +15,19 @@ class ListCommand extends command_1.Command {
45
15
  }
46
16
  }
47
17
  `,
48
- });
49
- cli_ux_1.cli.table(result.data.organizationRoles, {
50
- id: {
51
- minWidth: 8,
52
- extended: true,
53
- },
54
- name: {},
55
- description: {},
56
- }, Object.assign({}, flags));
57
18
  });
19
+ core_1.CliUx.ux.table(result.organizationRoles, {
20
+ id: {
21
+ minWidth: 8,
22
+ extended: true,
23
+ },
24
+ name: {},
25
+ description: {},
26
+ }, { ...flags });
58
27
  }
59
28
  }
60
29
  exports.default = ListCommand;
61
30
  ListCommand.description = "List Roles you can grant to other users in your Organization";
62
- ListCommand.flags = Object.assign({}, cli_ux_1.cli.table.flags());
63
- //# sourceMappingURL=roles.js.map
31
+ ListCommand.flags = {
32
+ ...core_1.CliUx.ux.table.flags(),
33
+ };
@@ -1,41 +1,12 @@
1
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
2
  Object.defineProperty(exports, "__esModule", { value: true });
31
- const command_1 = require("@oclif/command");
32
- const graphql_1 = __importStar(require("../../../graphql"));
33
- class UpdateCommand extends command_1.Command {
34
- run() {
35
- return __awaiter(this, void 0, void 0, function* () {
36
- const { args: { user }, flags: { name, phone, "dark-mode": darkMode, "dark-mode-os-sync": darkModeOsSync, }, } = this.parse(UpdateCommand);
37
- const result = yield graphql_1.default.mutate({
38
- mutation: graphql_1.gql `
3
+ const core_1 = require("@oclif/core");
4
+ const graphql_1 = require("../../../graphql");
5
+ class UpdateCommand extends core_1.Command {
6
+ async run() {
7
+ const { args: { user }, flags: { name, phone, "dark-mode": darkMode, "dark-mode-os-sync": darkModeOsSync, }, } = await this.parse(UpdateCommand);
8
+ const result = await (0, graphql_1.gqlRequest)({
9
+ document: (0, graphql_1.gql) `
39
10
  mutation updateUser(
40
11
  $user: ID!
41
12
  $name: String
@@ -62,16 +33,15 @@ class UpdateCommand extends command_1.Command {
62
33
  }
63
34
  }
64
35
  `,
65
- variables: {
66
- user,
67
- name,
68
- phone,
69
- darkMode,
70
- darkModeOsSync,
71
- },
72
- });
73
- this.log(result.data.updateUser.user.id);
36
+ variables: {
37
+ user,
38
+ name,
39
+ phone,
40
+ darkMode,
41
+ darkModeOsSync,
42
+ },
74
43
  });
44
+ this.log(result.updateUser.user.id);
75
45
  }
76
46
  }
77
47
  exports.default = UpdateCommand;
@@ -84,15 +54,14 @@ UpdateCommand.args = [
84
54
  },
85
55
  ];
86
56
  UpdateCommand.flags = {
87
- name: command_1.flags.string({ char: "n", description: "name of the user" }),
88
- phone: command_1.flags.string({ char: "p", description: "phone number of the user" }),
89
- "dark-mode": command_1.flags.string({
57
+ name: core_1.Flags.string({ char: "n", description: "name of the user" }),
58
+ phone: core_1.Flags.string({ char: "p", description: "phone number of the user" }),
59
+ "dark-mode": core_1.Flags.string({
90
60
  char: "d",
91
61
  description: "whether the user should have dark mode enabled",
92
62
  }),
93
- "dark-mode-os-sync": command_1.flags.string({
63
+ "dark-mode-os-sync": core_1.Flags.string({
94
64
  char: "o",
95
65
  description: "whether dark mode should sync with OS settings",
96
66
  }),
97
67
  };
98
- //# sourceMappingURL=update.js.map
package/lib/config.js CHANGED
@@ -1,13 +1,4 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  var __importDefault = (this && this.__importDefault) || function (mod) {
12
3
  return (mod && mod.__esModule) ? mod : { "default": mod };
13
4
  };
@@ -16,30 +7,33 @@ exports.readConfig = exports.writeConfig = exports.deleteConfig = exports.config
16
7
  const os_1 = require("os");
17
8
  const path_1 = __importDefault(require("path"));
18
9
  const fs_1 = require("./fs");
19
- const js_yaml_1 = require("js-yaml");
20
- const configDirectory = path_1.default.join(os_1.homedir(), ".config", "prism");
10
+ const serialize_1 = require("./utils/serialize");
11
+ const configDirectory = path_1.default.join((0, os_1.homedir)(), ".config", "prism");
21
12
  const configFilePath = path_1.default.join(configDirectory, "config.yml");
22
- const ensureConfigDirectoryExists = () => __awaiter(void 0, void 0, void 0, function* () {
23
- if (yield fs_1.exists(configDirectory))
13
+ const ensureConfigDirectoryExists = async () => {
14
+ if (await (0, fs_1.exists)(configDirectory))
24
15
  return;
25
- yield fs_1.fs.mkdir(configDirectory, { recursive: true });
26
- });
27
- exports.configFileExists = () => __awaiter(void 0, void 0, void 0, function* () { return fs_1.exists(configFilePath); });
28
- exports.deleteConfig = () => __awaiter(void 0, void 0, void 0, function* () {
29
- if (!(yield exports.configFileExists()))
16
+ await fs_1.fs.mkdir(configDirectory, { recursive: true });
17
+ };
18
+ const configFileExists = async () => (0, fs_1.exists)(configFilePath);
19
+ exports.configFileExists = configFileExists;
20
+ const deleteConfig = async () => {
21
+ if (!(await (0, exports.configFileExists)()))
30
22
  return;
31
23
  return fs_1.fs.unlink(configFilePath);
32
- });
33
- exports.writeConfig = (config) => __awaiter(void 0, void 0, void 0, function* () {
34
- yield ensureConfigDirectoryExists();
35
- const contents = js_yaml_1.safeDump(config, { skipInvalid: true });
36
- yield fs_1.fs.writeFile(configFilePath, contents, { encoding: "utf-8" });
37
- });
38
- exports.readConfig = () => __awaiter(void 0, void 0, void 0, function* () {
39
- if (!(yield exports.configFileExists()))
24
+ };
25
+ exports.deleteConfig = deleteConfig;
26
+ const writeConfig = async (config) => {
27
+ await ensureConfigDirectoryExists();
28
+ const contents = (0, serialize_1.dumpYaml)(config, { skipInvalid: true });
29
+ await fs_1.fs.writeFile(configFilePath, contents, { encoding: "utf-8" });
30
+ };
31
+ exports.writeConfig = writeConfig;
32
+ const readConfig = async () => {
33
+ if (!(await (0, exports.configFileExists)()))
40
34
  return null;
41
- const contents = yield fs_1.fs.readFile(configFilePath, { encoding: "utf-8" });
42
- const config = (yield js_yaml_1.safeLoad(contents.toString()));
35
+ const contents = await fs_1.fs.readFile(configFilePath, { encoding: "utf-8" });
36
+ const config = (await (0, serialize_1.loadYaml)(contents.toString()));
43
37
  return config;
44
- });
45
- //# sourceMappingURL=config.js.map
38
+ };
39
+ exports.readConfig = readConfig;
package/lib/errors.js CHANGED
@@ -1,34 +1,55 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- const apollo_client_1 = require("apollo-client");
3
+ exports.processError = void 0;
4
+ const graphql_request_1 = require("graphql-request");
4
5
  const http_status_codes_1 = require("http-status-codes");
5
- const getErrorMessage = (name, statusCode) => {
6
- if (statusCode && statusCode !== http_status_codes_1.StatusCodes.OK) {
7
- if (statusCode === http_status_codes_1.StatusCodes.UNAUTHORIZED) {
8
- return "You are not logged in.";
9
- }
10
- const reason = http_status_codes_1.getReasonPhrase(statusCode);
11
- return `${name}: ${reason}`;
6
+ const isOclifError = (error) => Boolean(error) &&
7
+ typeof error === "object" &&
8
+ error !== null &&
9
+ "oclif" in error;
10
+ const isError = (error) => Boolean(error) &&
11
+ typeof error === "object" &&
12
+ error !== null &&
13
+ "message" in error;
14
+ const getStatusMessage = (status) => {
15
+ if (status === http_status_codes_1.StatusCodes.OK) {
16
+ return;
12
17
  }
13
- return name;
18
+ return status === http_status_codes_1.StatusCodes.UNAUTHORIZED
19
+ ? "You are not logged in."
20
+ : (0, http_status_codes_1.getReasonPhrase)(status);
14
21
  };
15
- const handle = (err) => {
16
- var _a;
17
- if (err && err instanceof apollo_client_1.ApolloError) {
18
- const { networkError } = err;
19
- if (networkError) {
20
- const { name, statusCode, result } = networkError;
21
- const message = getErrorMessage(name, statusCode);
22
- const errors = (_a = result === null || result === void 0 ? void 0 : result.errors) === null || _a === void 0 ? void 0 : _a.map((error) => error.message).join("\n");
23
- if (errors) {
24
- console.error(`${message}\n ${errors}`);
25
- }
26
- else {
27
- console.error(message);
28
- }
29
- process.exit(1);
30
- }
22
+ const extractResponseError = ({ response: { errors = [], status }, }) => {
23
+ try {
24
+ const statusMessage = getStatusMessage(status);
25
+ const errorMessages = errors.map(({ message }) => message);
26
+ return [statusMessage, ...errorMessages].filter(Boolean).join("\n");
31
27
  }
28
+ catch (e) {
29
+ return `GraphQL Error (Code: ${status})`;
30
+ }
31
+ };
32
+ /** Accept arbitrary errors and convert them to OClif's error types. */
33
+ const processError = (error) => {
34
+ // Pass OclifErrors through unchanged
35
+ if (isOclifError(error)) {
36
+ return error;
37
+ }
38
+ // Try to process GraphQL errors into more user-friendly forms
39
+ if (error instanceof graphql_request_1.ClientError) {
40
+ return {
41
+ message: extractResponseError(error),
42
+ };
43
+ }
44
+ // If a conventional error, only pass along the message for presentation
45
+ if (isError(error)) {
46
+ return {
47
+ message: error.message,
48
+ };
49
+ }
50
+ // Last ditch best effort
51
+ return {
52
+ message: error,
53
+ };
32
54
  };
33
- exports.default = handle;
34
- //# sourceMappingURL=errors.js.map
55
+ exports.processError = processError;
package/lib/fields.js CHANGED
@@ -1,10 +1,12 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.parseJsonOrUndefined = exports.toValues = void 0;
4
- exports.toValues = (rawValues) => {
4
+ const toValues = (rawValues) => {
5
5
  if (!rawValues)
6
6
  return undefined;
7
- return Object.entries(JSON.parse(rawValues)).reduce((result, [key, value]) => [...result, { key, value }], []);
7
+ const obj = JSON.parse(rawValues);
8
+ return Object.entries(obj).reduce((result, [key, value]) => [...result, { key, value }], []);
8
9
  };
9
- exports.parseJsonOrUndefined = (json) => json ? JSON.parse(json) : undefined;
10
- //# sourceMappingURL=fields.js.map
10
+ exports.toValues = toValues;
11
+ const parseJsonOrUndefined = (json) => json ? JSON.parse(json) : undefined;
12
+ exports.parseJsonOrUndefined = parseJsonOrUndefined;
package/lib/fs.js CHANGED
@@ -1,21 +1,13 @@
1
1
  "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
2
  Object.defineProperty(exports, "__esModule", { value: true });
12
3
  exports.fs = exports.readStdin = exports.exists = void 0;
13
4
  const fs_1 = require("fs");
14
5
  Object.defineProperty(exports, "fs", { enumerable: true, get: function () { return fs_1.promises; } });
15
- exports.exists = (path) => __awaiter(void 0, void 0, void 0, function* () {
6
+ const exists = async (path) => {
16
7
  return fs_1.promises.access(path).then(() => true, () => false);
17
- });
18
- exports.readStdin = () => __awaiter(void 0, void 0, void 0, function* () {
8
+ };
9
+ exports.exists = exists;
10
+ const readStdin = async () => {
19
11
  return new Promise((resolve, reject) => {
20
12
  process.stdin
21
13
  .on("readable", () => {
@@ -27,5 +19,5 @@ exports.readStdin = () => __awaiter(void 0, void 0, void 0, function* () {
27
19
  })
28
20
  .on("error", reject);
29
21
  });
30
- });
31
- //# sourceMappingURL=fs.js.map
22
+ };
23
+ exports.readStdin = readStdin;