@prismatic-io/spectral 10.8.0 → 10.8.1

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.
@@ -57,84 +57,89 @@ const fetchComponentDataForManifest = (_a) => __awaiter(void 0, [_a], void 0, fu
57
57
  }
58
58
  }
59
59
  `;
60
- const response = yield axios_1.default.post(`${prismaticUrl}/api`, {
61
- query,
62
- variables: {
63
- componentKey,
64
- public: !isPrivate,
65
- },
66
- }, {
67
- headers: {
68
- Authorization: `Bearer ${accessToken}`,
69
- "Content-Type": "application/json",
70
- "Prismatic-Client": "spectral",
71
- },
72
- });
73
- const component = response.data.data.components.nodes[0];
74
- if (!component) {
75
- throw new Error(`Could not find a ${isPrivate ? "private" : "public"} component with the given key: ${componentKey}. ${!isPrivate ? 'You may need to include the "--private" flag.' : ""}`);
76
- }
77
- const componentActions = yield getComponentActions(component.id, prismaticUrl, accessToken);
78
- const actions = {};
79
- const triggers = {};
80
- const dataSources = {};
81
- componentActions.forEach((node) => {
82
- var _a, _b;
83
- if (node.isTrigger) {
84
- triggers[node.key] = {
85
- key: node.key,
86
- display: {
87
- label: node.label,
88
- description: node.description,
89
- },
90
- inputs: transformInputNodes(node.inputs.nodes),
91
- };
60
+ try {
61
+ const response = yield axios_1.default.post(`${prismaticUrl}/api`, {
62
+ query,
63
+ variables: {
64
+ componentKey,
65
+ public: !isPrivate,
66
+ },
67
+ }, {
68
+ headers: {
69
+ Authorization: `Bearer ${accessToken}`,
70
+ "Content-Type": "application/json",
71
+ "Prismatic-Client": "spectral",
72
+ },
73
+ });
74
+ const component = response.data.data.components.nodes[0];
75
+ if (!component) {
76
+ throw new Error(`Could not find a ${isPrivate ? "private" : "public"} component with the given key: ${componentKey}. ${!isPrivate ? 'You may need to include the "--private" flag.' : ""}`);
92
77
  }
93
- else if (node.isDataSource) {
94
- dataSources[node.key] = {
95
- key: node.key,
96
- display: {
97
- label: node.label,
98
- description: node.description,
99
- },
100
- inputs: transformInputNodes(node.inputs.nodes),
101
- dataSourceType: ((_a = node.dataSourceType) !== null && _a !== void 0 ? _a : "string").toLowerCase(),
102
- examplePayload: (_b = node.examplePayload) !== null && _b !== void 0 ? _b : {},
103
- };
104
- }
105
- else {
106
- actions[node.key] = {
78
+ const componentActions = yield getComponentActions(component.id, prismaticUrl, accessToken);
79
+ const actions = {};
80
+ const triggers = {};
81
+ const dataSources = {};
82
+ componentActions.forEach((node) => {
83
+ var _a, _b;
84
+ if (node.isTrigger) {
85
+ triggers[node.key] = {
86
+ key: node.key,
87
+ display: {
88
+ label: node.label,
89
+ description: node.description,
90
+ },
91
+ inputs: transformInputNodes(node.inputs.nodes),
92
+ };
93
+ }
94
+ else if (node.isDataSource) {
95
+ dataSources[node.key] = {
96
+ key: node.key,
97
+ display: {
98
+ label: node.label,
99
+ description: node.description,
100
+ },
101
+ inputs: transformInputNodes(node.inputs.nodes),
102
+ dataSourceType: ((_a = node.dataSourceType) !== null && _a !== void 0 ? _a : "string").toLowerCase(),
103
+ examplePayload: (_b = node.examplePayload) !== null && _b !== void 0 ? _b : {},
104
+ };
105
+ }
106
+ else {
107
+ actions[node.key] = {
108
+ key: node.key,
109
+ display: {
110
+ label: node.label,
111
+ description: node.description,
112
+ },
113
+ inputs: transformInputNodes(node.inputs.nodes),
114
+ examplePayload: node.examplePayload,
115
+ };
116
+ }
117
+ });
118
+ const connections = component.connections.nodes.map((node) => {
119
+ return {
107
120
  key: node.key,
108
- display: {
109
- label: node.label,
110
- description: node.description,
111
- },
121
+ label: node.label,
122
+ comments: node.comments,
112
123
  inputs: transformInputNodes(node.inputs.nodes),
113
- examplePayload: node.examplePayload,
114
124
  };
115
- }
116
- });
117
- const connections = component.connections.nodes.map((node) => {
125
+ });
118
126
  return {
119
- key: node.key,
120
- label: node.label,
121
- comments: node.comments,
122
- inputs: transformInputNodes(node.inputs.nodes),
127
+ key: component.key,
128
+ signature: component.signature,
129
+ public: !isPrivate,
130
+ display: {
131
+ label: component.label,
132
+ description: component.description,
133
+ },
134
+ actions,
135
+ triggers,
136
+ dataSources,
137
+ connections,
123
138
  };
124
- });
125
- return {
126
- key: component.key,
127
- signature: component.signature,
128
- public: !isPrivate,
129
- display: {
130
- label: component.label,
131
- description: component.description,
132
- },
133
- actions,
134
- triggers,
135
- dataSources,
136
- connections,
137
- };
139
+ }
140
+ catch (error) {
141
+ throw new Error(`There was an error accessing the Prismatic API. Check your login status via 'prism me' or 'prism login'.\n${error instanceof Error ? error.message : String(error)}`);
142
+ }
138
143
  });
139
144
  exports.fetchComponentDataForManifest = fetchComponentDataForManifest;
140
145
  function getComponentActions(componentId, prismaticUrl, accessToken) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prismatic-io/spectral",
3
- "version": "10.8.0",
3
+ "version": "10.8.1",
4
4
  "description": "Utility library for building Prismatic connectors and code-native integrations",
5
5
  "keywords": ["prismatic"],
6
6
  "main": "dist/index.js",