@tallyui/connector-medusa 3.0.0-next.0 → 3.0.0-next.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.
- package/README.md +1 -1
- package/dist/index.js +1 -1
- package/package.json +3 -3
- package/src/capabilities.ts +4 -5
- package/src/customers.ts +1 -1
- package/src/reconcile/ids.ts +1 -1
- package/src/reconcile/prices.ts +1 -1
- package/src/reconcile/stock.ts +1 -1
- package/src/replication/products.ts +2 -2
- package/src/replication/variant-feed.ts +1 -1
- package/src/store-settings.ts +1 -1
package/README.md
CHANGED
|
@@ -2,6 +2,6 @@
|
|
|
2
2
|
|
|
3
3
|
## Errors
|
|
4
4
|
|
|
5
|
-
Requests with expired or rejected credentials reject with `ConnectorUnauthorizedError
|
|
5
|
+
Requests with expired or rejected credentials reject with `ConnectorUnauthorizedError`, defined in `@tallyui/core` and re-exported by this connector. `error.status` is `401` (`code: 'unauthorized'`, sign in again) or `403` (`code: 'forbidden'`, signed in but not allowed: the pull retries on the store schedule; don't sign out).
|
|
6
6
|
|
|
7
7
|
Sign-in itself rejects with `SignInError`.
|
package/dist/index.js
CHANGED
|
@@ -19,7 +19,7 @@ async function readCapabilities(baseUrl, headers, init = {}) {
|
|
|
19
19
|
try {
|
|
20
20
|
body = await res.json();
|
|
21
21
|
} catch {
|
|
22
|
-
return
|
|
22
|
+
return void 0;
|
|
23
23
|
}
|
|
24
24
|
return parseInfoCapabilities(body, (reason) => console.warn(`@tallyui/connector-medusa: ${reason}`));
|
|
25
25
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tallyui/connector-medusa",
|
|
3
|
-
"version": "3.0.0-next.
|
|
3
|
+
"version": "3.0.0-next.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MedusaJS v2 connector for Tally UI",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,10 +27,10 @@
|
|
|
27
27
|
"directory": "connectors/medusa"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@tallyui/core": "^3.0.0-next.
|
|
30
|
+
"@tallyui/core": "^3.0.0-next.1"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@tallyui/database": "3.0.0-next.
|
|
33
|
+
"@tallyui/database": "3.0.0-next.1",
|
|
34
34
|
"rxdb": "17.5.0"
|
|
35
35
|
},
|
|
36
36
|
"scripts": {
|
package/src/capabilities.ts
CHANGED
|
@@ -5,10 +5,9 @@ export const CAPABILITIES_PATH = '/tally/v1/info';
|
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Reads the store's contract capabilities (ADR-062) and `taxRounding` (#287), with the
|
|
8
|
-
* connector's usual injectable `fetch`. A
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* `undefined`, never 1. A 401 means rejected/expired credentials and throws.
|
|
8
|
+
* connector's usual injectable `fetch`. A 404 means an old plugin and gives the default;
|
|
9
|
+
* a network failure, non-2xx other than 404/401, non-JSON 2xx or malformed `taxRounding`
|
|
10
|
+
* is unknown and gives `undefined`. A 401 means rejected/expired credentials and throws.
|
|
12
11
|
*/
|
|
13
12
|
export async function readCapabilities(
|
|
14
13
|
baseUrl: string,
|
|
@@ -29,7 +28,7 @@ export async function readCapabilities(
|
|
|
29
28
|
try {
|
|
30
29
|
body = await res.json();
|
|
31
30
|
} catch {
|
|
32
|
-
return
|
|
31
|
+
return undefined;
|
|
33
32
|
}
|
|
34
33
|
return parseInfoCapabilities(body, (reason) => console.warn(`@tallyui/connector-medusa: ${reason}`));
|
|
35
34
|
}
|
package/src/customers.ts
CHANGED
|
@@ -30,7 +30,7 @@ async function customerRequest(url: string, key: 'customers' | 'customer', init:
|
|
|
30
30
|
} catch (error) {
|
|
31
31
|
throw new CustomerServiceError('network', errorMessage(error));
|
|
32
32
|
}
|
|
33
|
-
if (res.status === 401 || res.status === 403) throw new ConnectorUnauthorizedError(`Medusa rejected the credentials (HTTP ${res.status})`, res.status);
|
|
33
|
+
if (res.status === 401 || res.status === 403) throw new ConnectorUnauthorizedError(`Medusa rejected the credentials (HTTP ${res.status})`, res.status as 401 | 403);
|
|
34
34
|
if (res.status === 404 && key === 'customer' && init.method === 'GET') return null;
|
|
35
35
|
if (!res.ok && res.status !== 400) throw new CustomerServiceError('server', `HTTP ${res.status}`);
|
|
36
36
|
let body;
|
package/src/reconcile/ids.ts
CHANGED
|
@@ -20,7 +20,7 @@ async function get(path: string, context: SyncContext) {
|
|
|
20
20
|
});
|
|
21
21
|
if (!response.ok) {
|
|
22
22
|
const error = await response.json().catch(() => ({}));
|
|
23
|
-
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status);
|
|
23
|
+
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status as 401 | 403);
|
|
24
24
|
throw new Error(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`);
|
|
25
25
|
}
|
|
26
26
|
return response.json();
|
package/src/reconcile/prices.ts
CHANGED
|
@@ -17,7 +17,7 @@ async function get(path: string, context: SyncContext) {
|
|
|
17
17
|
});
|
|
18
18
|
if (!response.ok) {
|
|
19
19
|
const error = await response.json().catch(() => ({}));
|
|
20
|
-
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status);
|
|
20
|
+
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status as 401 | 403);
|
|
21
21
|
throw new Error(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`);
|
|
22
22
|
}
|
|
23
23
|
return response.json();
|
package/src/reconcile/stock.ts
CHANGED
|
@@ -30,7 +30,7 @@ export const medusaStockReconcile: StockReconcileAdapter = {
|
|
|
30
30
|
});
|
|
31
31
|
if (!response.ok) {
|
|
32
32
|
const error = await response.json().catch(() => ({}));
|
|
33
|
-
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status);
|
|
33
|
+
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status as 401 | 403);
|
|
34
34
|
throw new Error(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`);
|
|
35
35
|
}
|
|
36
36
|
const data = await response.json() as { inventory_items: Array<{ id: string; location_levels?: Level[] }>; count: number };
|
|
@@ -70,7 +70,7 @@ export const medusaProductReplication: ReplicationAdapter<any, MedusaProductChec
|
|
|
70
70
|
);
|
|
71
71
|
if (!markResponse.ok) {
|
|
72
72
|
const error = await markResponse.json().catch(() => ({}));
|
|
73
|
-
if (markResponse.status === 401 || markResponse.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${markResponse.status}${error?.message ? `: ${error.message}` : ''}`, markResponse.status);
|
|
73
|
+
if (markResponse.status === 401 || markResponse.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${markResponse.status}${error?.message ? `: ${error.message}` : ''}`, markResponse.status as 401 | 403);
|
|
74
74
|
throw new Error(`Medusa API error: ${markResponse.status}${error?.message ? `: ${error.message}` : ''}`);
|
|
75
75
|
}
|
|
76
76
|
const markData = await markResponse.json();
|
|
@@ -107,7 +107,7 @@ export const medusaProductReplication: ReplicationAdapter<any, MedusaProductChec
|
|
|
107
107
|
|
|
108
108
|
if (!response.ok) {
|
|
109
109
|
const error = await response.json().catch(() => ({}));
|
|
110
|
-
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status);
|
|
110
|
+
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status as 401 | 403);
|
|
111
111
|
throw new Error(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`);
|
|
112
112
|
}
|
|
113
113
|
|
|
@@ -17,7 +17,7 @@ async function get(path: string, context: SyncContext) {
|
|
|
17
17
|
});
|
|
18
18
|
if (!response.ok) {
|
|
19
19
|
const error = await response.json().catch(() => ({}));
|
|
20
|
-
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status);
|
|
20
|
+
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`, response.status as 401 | 403);
|
|
21
21
|
throw new Error(`Medusa API error: ${response.status}${error?.message ? `: ${error.message}` : ''}`);
|
|
22
22
|
}
|
|
23
23
|
return response.json();
|
package/src/store-settings.ts
CHANGED
|
@@ -18,7 +18,7 @@ async function get(context: SyncContext, path: string): Promise<any> {
|
|
|
18
18
|
});
|
|
19
19
|
if (!response.ok) {
|
|
20
20
|
const body = await response.json().catch(() => ({}));
|
|
21
|
-
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa store settings request failed (HTTP ${response.status})${body?.message ? `: ${body.message}` : ''}`, response.status);
|
|
21
|
+
if (response.status === 401 || response.status === 403) throw new ConnectorUnauthorizedError(`Medusa store settings request failed (HTTP ${response.status})${body?.message ? `: ${body.message}` : ''}`, response.status as 401 | 403);
|
|
22
22
|
throw new StoreSettingsError('failed', `Medusa store settings request failed (HTTP ${response.status})${body?.message ? `: ${body.message}` : ''}`);
|
|
23
23
|
}
|
|
24
24
|
return response.json();
|