@prismatic-io/spectral 10.11.4 → 10.11.5

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.
@@ -1,4 +1,27 @@
1
1
  "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
2
25
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
26
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
27
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,12 +31,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
32
  });
10
33
  };
11
- var __importDefault = (this && this.__importDefault) || function (mod) {
12
- return (mod && mod.__esModule) ? mod : { "default": mod };
13
- };
14
34
  Object.defineProperty(exports, "__esModule", { value: true });
15
35
  exports.fetchComponentDataForManifest = void 0;
16
- const axios_1 = __importDefault(require("axios"));
36
+ const axios_1 = __importStar(require("axios"));
17
37
  const prism_1 = require("../utils/prism");
18
38
  // Helper to transform input nodes from GraphQL response to the expected format
19
39
  function transformInputNodes(inputs) {
@@ -22,7 +42,7 @@ function transformInputNodes(inputs) {
22
42
  // This function does not return a complete Component as described in ServerTypes;
23
43
  // it instead selectively returns only what's needed to generate a manifest.
24
44
  const fetchComponentDataForManifest = (_a) => __awaiter(void 0, [_a], void 0, function* ({ componentKey, isPrivate, }) {
25
- var _b;
45
+ var _b, _c, _d;
26
46
  const accessToken = yield (0, prism_1.getPrismAccessToken)();
27
47
  const prismaticUrl = (_b = process.env.PRISMATIC_URL) !== null && _b !== void 0 ? _b : "https://app.prismatic.io";
28
48
  const query = `
@@ -138,67 +158,78 @@ const fetchComponentDataForManifest = (_a) => __awaiter(void 0, [_a], void 0, fu
138
158
  };
139
159
  }
140
160
  catch (error) {
141
- throw new Error(error instanceof Error ? error.message : String(error));
161
+ if (error instanceof axios_1.AxiosError && ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.errors)) {
162
+ throw new Error(JSON.stringify(error.response.data.errors, null, 2));
163
+ }
164
+ throw error;
142
165
  }
143
166
  });
144
167
  exports.fetchComponentDataForManifest = fetchComponentDataForManifest;
145
168
  function getComponentActions(componentId, prismaticUrl, accessToken) {
146
169
  return __awaiter(this, void 0, void 0, function* () {
147
- var _a, _b;
170
+ var _a, _b, _c, _d;
148
171
  let hasNextPage = true;
149
172
  let cursor = null;
150
173
  let actions = [];
151
174
  while (hasNextPage) {
152
- const query = `
153
- query componentActionQuery($component: ID!, $after: String) {
154
- actions(component: $component, after: $after) {
155
- nodes {
156
- isDataSource
157
- isDetailDataSource
158
- dataSourceType
159
- isTrigger
160
- isCommonTrigger
161
- key
162
- label
163
- description
164
- inputs {
165
- nodes {
166
- key
167
- label
168
- type
169
- required
170
- default
171
- collection
172
- shown
173
- onPremiseControlled
175
+ try {
176
+ const query = `
177
+ query componentActionQuery($component: ID!, $after: String) {
178
+ actions(component: $component, after: $after) {
179
+ nodes {
180
+ isDataSource
181
+ isDetailDataSource
182
+ dataSourceType
183
+ isTrigger
184
+ isCommonTrigger
185
+ key
186
+ label
187
+ description
188
+ inputs {
189
+ nodes {
190
+ key
191
+ label
192
+ type
193
+ required
194
+ default
195
+ collection
196
+ shown
197
+ onPremiseControlled
198
+ }
174
199
  }
200
+ examplePayload
201
+ }
202
+ pageInfo {
203
+ hasNextPage
204
+ endCursor
175
205
  }
176
- examplePayload
177
- }
178
- pageInfo {
179
- hasNextPage
180
- endCursor
181
206
  }
182
207
  }
183
- }
184
- `;
185
- const response = yield axios_1.default.post(`${prismaticUrl}/api`, {
186
- query: query,
187
- variables: {
188
- component: componentId,
189
- after: cursor,
190
- },
191
- }, {
192
- headers: {
193
- Authorization: `Bearer ${accessToken}`,
194
- "Content-Type": "application/json",
195
- "Prismatic-Client": "spectral",
196
- },
197
- });
198
- const responseActions = response.data.data.actions.nodes;
199
- actions = actions.concat(responseActions);
200
- hasNextPage = (_a = response.data.data.actions.pageInfo) === null || _a === void 0 ? void 0 : _a.hasNextPage;
201
- cursor = (_b = response.data.data.actions.pageInfo) === null || _b === void 0 ? void 0 : _b.endCursor;
208
+ `;
209
+ const response = yield axios_1.default.post(`${prismaticUrl}/api`, {
210
+ query: query,
211
+ variables: {
212
+ component: componentId,
213
+ after: cursor,
214
+ },
215
+ }, {
216
+ headers: {
217
+ Authorization: `Bearer ${accessToken}`,
218
+ "Content-Type": "application/json",
219
+ "Prismatic-Client": "spectral",
220
+ },
221
+ });
222
+ const responseActions = response.data.data.actions.nodes;
223
+ actions = actions.concat(responseActions);
224
+ hasNextPage = (_a = response.data.data.actions.pageInfo) === null || _a === void 0 ? void 0 : _a.hasNextPage;
225
+ cursor = (_b = response.data.data.actions.pageInfo) === null || _b === void 0 ? void 0 : _b.endCursor;
226
+ }
227
+ catch (error) {
228
+ if (error instanceof axios_1.AxiosError && ((_d = (_c = error.response) === null || _c === void 0 ? void 0 : _c.data) === null || _d === void 0 ? void 0 : _d.errors)) {
229
+ throw new Error(JSON.stringify(error.response.data.errors, null, 2));
230
+ }
231
+ throw error;
232
+ }
202
233
  }
203
234
  return actions.sort((a, b) => a.key.localeCompare(b.key));
204
235
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.11.4",
3
+ "version": "10.11.5",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",