@dk/jolly 0.1.7 → 0.1.8
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.
- package/dist/bootstrap.js +3 -2
- package/dist/index.js +3 -2
- package/package.json +1 -1
- package/src/api/client.ts +3 -2
- package/src/test/e2e-flows.test.ts +3 -3
package/dist/bootstrap.js
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
// src/api/client.ts
|
|
4
4
|
class SaleorCloudClient {
|
|
5
|
-
baseUrl = "https://cloud.saleor.io/api";
|
|
5
|
+
baseUrl = "https://cloud.saleor.io/api/v1";
|
|
6
6
|
token;
|
|
7
7
|
constructor(token) {
|
|
8
8
|
this.token = token || process.env.SALEOR_CLOUD_TOKEN || "";
|
|
@@ -23,7 +23,8 @@ class SaleorCloudClient {
|
|
|
23
23
|
const response = await fetch(`${this.baseUrl}${endpoint}`, mergedOptions);
|
|
24
24
|
if (!response.ok) {
|
|
25
25
|
const body = await response.text();
|
|
26
|
-
|
|
26
|
+
const truncatedBody = body.length > 200 ? body.substring(0, 200) + "..." : body;
|
|
27
|
+
throw new Error(`API error: ${response.status} ${response.statusText} - ${truncatedBody}`);
|
|
27
28
|
}
|
|
28
29
|
return response.json();
|
|
29
30
|
}
|
package/dist/index.js
CHANGED
|
@@ -24,7 +24,7 @@ import { hideBin } from "yargs/helpers";
|
|
|
24
24
|
|
|
25
25
|
// src/api/client.ts
|
|
26
26
|
class SaleorCloudClient {
|
|
27
|
-
baseUrl = "https://cloud.saleor.io/api";
|
|
27
|
+
baseUrl = "https://cloud.saleor.io/api/v1";
|
|
28
28
|
token;
|
|
29
29
|
constructor(token) {
|
|
30
30
|
this.token = token || process.env.SALEOR_CLOUD_TOKEN || "";
|
|
@@ -45,7 +45,8 @@ class SaleorCloudClient {
|
|
|
45
45
|
const response = await fetch(`${this.baseUrl}${endpoint}`, mergedOptions);
|
|
46
46
|
if (!response.ok) {
|
|
47
47
|
const body = await response.text();
|
|
48
|
-
|
|
48
|
+
const truncatedBody = body.length > 200 ? body.substring(0, 200) + "..." : body;
|
|
49
|
+
throw new Error(`API error: ${response.status} ${response.statusText} - ${truncatedBody}`);
|
|
49
50
|
}
|
|
50
51
|
return response.json();
|
|
51
52
|
}
|
package/package.json
CHANGED
package/src/api/client.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export class SaleorCloudClient {
|
|
2
|
-
private baseUrl = 'https://cloud.saleor.io/api';
|
|
2
|
+
private baseUrl = 'https://cloud.saleor.io/api/v1';
|
|
3
3
|
private token: string;
|
|
4
4
|
|
|
5
5
|
constructor(token?: string) {
|
|
@@ -24,7 +24,8 @@ export class SaleorCloudClient {
|
|
|
24
24
|
|
|
25
25
|
if (!response.ok) {
|
|
26
26
|
const body = await response.text();
|
|
27
|
-
|
|
27
|
+
const truncatedBody = body.length > 200 ? body.substring(0, 200) + '...' : body;
|
|
28
|
+
throw new Error(`API error: ${response.status} ${response.statusText} - ${truncatedBody}`);
|
|
28
29
|
}
|
|
29
30
|
|
|
30
31
|
return response.json() as T;
|
|
@@ -186,7 +186,7 @@ describe('End-to-End Flows', () => {
|
|
|
186
186
|
|
|
187
187
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
188
188
|
const [url, opts] = fetchMock.mock.calls[0];
|
|
189
|
-
expect(url).toBe('https://cloud.saleor.io/api/organizations');
|
|
189
|
+
expect(url).toBe('https://cloud.saleor.io/api/v1/organizations');
|
|
190
190
|
expect(opts.method).toBe('GET');
|
|
191
191
|
expect(opts.headers.Authorization).toBe(`Token ${fixtures.token}`);
|
|
192
192
|
});
|
|
@@ -204,7 +204,7 @@ describe('End-to-End Flows', () => {
|
|
|
204
204
|
|
|
205
205
|
expect(fetchMock).toHaveBeenCalledTimes(1);
|
|
206
206
|
const [url, opts] = fetchMock.mock.calls[0];
|
|
207
|
-
expect(url).toBe('https://cloud.saleor.io/api/organizations/default/projects');
|
|
207
|
+
expect(url).toBe('https://cloud.saleor.io/api/v1/organizations/default/projects');
|
|
208
208
|
expect(opts.method).toBe('POST');
|
|
209
209
|
expect(opts.headers.Authorization).toBe(`Token ${fixtures.token}`);
|
|
210
210
|
expect(JSON.parse(opts.body)).toEqual({ name: 'test-store', region: 'eu-west-1' });
|
|
@@ -222,7 +222,7 @@ describe('End-to-End Flows', () => {
|
|
|
222
222
|
await client.registerApp('staging', 'payment', 'my-app');
|
|
223
223
|
|
|
224
224
|
const [url, opts] = fetchMock.mock.calls[0];
|
|
225
|
-
expect(url).toBe('https://cloud.saleor.io/api/environments/staging/apps');
|
|
225
|
+
expect(url).toBe('https://cloud.saleor.io/api/v1/environments/staging/apps');
|
|
226
226
|
expect(JSON.parse(opts.body)).toEqual({ type: 'payment', name: 'my-app' });
|
|
227
227
|
});
|
|
228
228
|
});
|