@tallyui/connector-vendure 5.1.0 → 5.3.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.
- package/dist/index.js +11 -1
- package/package.json +4 -4
- package/src/capabilities.ts +11 -2
- package/src/index.ts +2 -0
package/dist/index.js
CHANGED
|
@@ -59,7 +59,15 @@ async function readVendureCapabilities(baseUrl, headers, init = {}) {
|
|
|
59
59
|
} catch {
|
|
60
60
|
return void 0;
|
|
61
61
|
}
|
|
62
|
-
|
|
62
|
+
const warn = (reason) => console.warn(`@tallyui/connector-vendure: ${reason}`);
|
|
63
|
+
const capabilities = parseInfoCapabilities(body, warn);
|
|
64
|
+
if (!capabilities) return void 0;
|
|
65
|
+
const { chargeTaxMode } = body;
|
|
66
|
+
if (chargeTaxMode !== void 0) {
|
|
67
|
+
if (chargeTaxMode && typeof chargeTaxMode === "object" && !Array.isArray(chargeTaxMode) && "v" in chargeTaxMode && typeof chargeTaxMode.v === "number" && Number.isSafeInteger(chargeTaxMode.v) && chargeTaxMode.v >= 1) capabilities.chargeTaxMode = true;
|
|
68
|
+
else warn("ignoring a malformed chargeTaxMode");
|
|
69
|
+
}
|
|
70
|
+
return capabilities;
|
|
63
71
|
}
|
|
64
72
|
|
|
65
73
|
// src/auth.ts
|
|
@@ -1363,6 +1371,8 @@ var createVendureConnector = (options = {}) => {
|
|
|
1363
1371
|
name: "Vendure",
|
|
1364
1372
|
description: "Connect to Vendure backends via the Admin GraphQL API",
|
|
1365
1373
|
icon: void 0,
|
|
1374
|
+
// ADR-048: Vendure taxes each discounted line as its own TALLY-DISCOUNT row and rounds each row once.
|
|
1375
|
+
discountsAreTaxedRows: true,
|
|
1366
1376
|
auth: vendureAuth,
|
|
1367
1377
|
schemas: {
|
|
1368
1378
|
products: vendureProductSchema
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tallyui/connector-vendure",
|
|
3
|
-
"version": "5.
|
|
3
|
+
"version": "5.3.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Vendure connector for Tally UI",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -27,11 +27,11 @@
|
|
|
27
27
|
"directory": "connectors/vendure"
|
|
28
28
|
},
|
|
29
29
|
"peerDependencies": {
|
|
30
|
-
"@tallyui/core": "^5.
|
|
30
|
+
"@tallyui/core": "^5.3.0"
|
|
31
31
|
},
|
|
32
32
|
"devDependencies": {
|
|
33
|
-
"@tallyui/database": "5.
|
|
34
|
-
"@tallyui/pos": "5.
|
|
33
|
+
"@tallyui/database": "5.3.0",
|
|
34
|
+
"@tallyui/pos": "5.3.0",
|
|
35
35
|
"rxdb": "17.5.0"
|
|
36
36
|
},
|
|
37
37
|
"scripts": {
|
package/src/capabilities.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { signedOut } from './session-probe';
|
|
|
6
6
|
export const CAPABILITIES_PATH = '/tally/v1/info';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
|
-
* Reads the store's contract capabilities (ADR-062)
|
|
9
|
+
* Reads the store's contract capabilities (ADR-062), `taxRounding` (#287) and `chargeTaxMode` with the
|
|
10
10
|
* connector's own headers. A 404 means an old plugin and gives the default; a network failure,
|
|
11
11
|
* non-2xx other than 404/401/403, non-JSON 2xx or malformed `taxRounding` is unknown and gives
|
|
12
12
|
* `undefined`. The route answers a dead session and a missing
|
|
@@ -41,5 +41,14 @@ export async function readVendureCapabilities(
|
|
|
41
41
|
} catch {
|
|
42
42
|
return undefined;
|
|
43
43
|
}
|
|
44
|
-
|
|
44
|
+
const warn = (reason: string) => console.warn(`@tallyui/connector-vendure: ${reason}`);
|
|
45
|
+
const capabilities = parseInfoCapabilities(body, warn);
|
|
46
|
+
if (!capabilities) return undefined;
|
|
47
|
+
const { chargeTaxMode } = body as { chargeTaxMode?: unknown };
|
|
48
|
+
if (chargeTaxMode !== undefined) {
|
|
49
|
+
if (chargeTaxMode && typeof chargeTaxMode === 'object' && !Array.isArray(chargeTaxMode) && 'v' in chargeTaxMode
|
|
50
|
+
&& typeof chargeTaxMode.v === 'number' && Number.isSafeInteger(chargeTaxMode.v) && chargeTaxMode.v >= 1) capabilities.chargeTaxMode = true;
|
|
51
|
+
else warn('ignoring a malformed chargeTaxMode');
|
|
52
|
+
}
|
|
53
|
+
return capabilities;
|
|
45
54
|
}
|
package/src/index.ts
CHANGED
|
@@ -54,6 +54,8 @@ export const createVendureConnector = (options: {
|
|
|
54
54
|
name: 'Vendure',
|
|
55
55
|
description: 'Connect to Vendure backends via the Admin GraphQL API',
|
|
56
56
|
icon: undefined,
|
|
57
|
+
// ADR-048: Vendure taxes each discounted line as its own TALLY-DISCOUNT row and rounds each row once.
|
|
58
|
+
discountsAreTaxedRows: true,
|
|
57
59
|
|
|
58
60
|
auth: vendureAuth,
|
|
59
61
|
|