@tallyui/connector-vendure 5.1.0 → 5.2.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 CHANGED
@@ -59,7 +59,15 @@ async function readVendureCapabilities(baseUrl, headers, init = {}) {
59
59
  } catch {
60
60
  return void 0;
61
61
  }
62
- return parseInfoCapabilities(body, (reason) => console.warn(`@tallyui/connector-vendure: ${reason}`));
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tallyui/connector-vendure",
3
- "version": "5.1.0",
3
+ "version": "5.2.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.1.0"
30
+ "@tallyui/core": "^5.2.0"
31
31
  },
32
32
  "devDependencies": {
33
- "@tallyui/database": "5.1.0",
34
- "@tallyui/pos": "5.1.0",
33
+ "@tallyui/database": "5.2.0",
34
+ "@tallyui/pos": "5.2.0",
35
35
  "rxdb": "17.5.0"
36
36
  },
37
37
  "scripts": {
@@ -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) and `taxRounding` (#287) with the
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
- return parseInfoCapabilities(body, (reason) => console.warn(`@tallyui/connector-vendure: ${reason}`));
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
  }