@tallyui/connector-woocommerce 3.5.2 → 3.6.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 +2 -14
- package/package.json +3 -3
- package/src/store-settings.ts +2 -15
package/dist/index.js
CHANGED
|
@@ -721,11 +721,6 @@ function createWooCustomers(options) {
|
|
|
721
721
|
import { ConnectorUnauthorizedError as ConnectorUnauthorizedError2, StoreSettingsError, minorUnitDigits, woocommerceTax } from "@tallyui/core";
|
|
722
722
|
var WOO_ORDER_CREATE_VERSION = 5;
|
|
723
723
|
var WOO_BASE_ORDER_CREATE_VERSION = 3;
|
|
724
|
-
var WOO_V5_MIN_PLUGIN_VERSION = [1, 10, 20];
|
|
725
|
-
function atLeastVersion(value, min) {
|
|
726
|
-
const parts = typeof value === "string" ? /^(\d+)\.(\d+)\.(\d+)/.exec(value)?.slice(1).map(Number) : void 0;
|
|
727
|
-
return !!parts && (parts[0] > min[0] || parts[0] === min[0] && (parts[1] > min[1] || parts[1] === min[1] && parts[2] >= min[2]));
|
|
728
|
-
}
|
|
729
724
|
async function wooStoreSettings(context) {
|
|
730
725
|
try {
|
|
731
726
|
const init = { method: "GET", headers: context.headers, signal: context.signal };
|
|
@@ -836,14 +831,7 @@ async function readWooCapabilities(context) {
|
|
|
836
831
|
} catch (error) {
|
|
837
832
|
if (error instanceof ConnectorUnauthorizedError2) throw error;
|
|
838
833
|
}
|
|
839
|
-
|
|
840
|
-
if (orderCreate === WOO_BASE_ORDER_CREATE_VERSION) {
|
|
841
|
-
try {
|
|
842
|
-
const response2 = await fetch(`${context.baseUrl}/site`, { method: "GET", headers: context.headers, signal: context.signal });
|
|
843
|
-
if (response2.ok && atLeastVersion((await response2.json())?.wcpos_version, WOO_V5_MIN_PLUGIN_VERSION)) orderCreate = WOO_ORDER_CREATE_VERSION;
|
|
844
|
-
} catch {
|
|
845
|
-
}
|
|
846
|
-
}
|
|
834
|
+
const orderCreate = capabilities.includes("order_create_v5") ? WOO_ORDER_CREATE_VERSION : WOO_BASE_ORDER_CREATE_VERSION;
|
|
847
835
|
return {
|
|
848
836
|
orderCreate,
|
|
849
837
|
taxRounding: { granularity: "woocommerce", roundAtSubtotal: stores[0].tax_round_at_subtotal === "yes" },
|
|
@@ -858,7 +846,7 @@ async function readWooCapabilities(context) {
|
|
|
858
846
|
}
|
|
859
847
|
|
|
860
848
|
// package.json
|
|
861
|
-
var version = "3.
|
|
849
|
+
var version = "3.6.0";
|
|
862
850
|
|
|
863
851
|
// src/commands/transport.ts
|
|
864
852
|
import { minorUnitDigits as minorUnitDigits2, moneyFromDecimalString, moneyFromMajor as moneyFromMajor2 } from "@tallyui/core";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tallyui/connector-woocommerce",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.6.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "WooCommerce connector for Tally UI",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -26,10 +26,10 @@
|
|
|
26
26
|
"directory": "connectors/woocommerce"
|
|
27
27
|
},
|
|
28
28
|
"peerDependencies": {
|
|
29
|
-
"@tallyui/core": "^3.
|
|
29
|
+
"@tallyui/core": "^3.6.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tallyui/database": "3.
|
|
32
|
+
"@tallyui/database": "3.6.0",
|
|
33
33
|
"rxdb": "17.5.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
package/src/store-settings.ts
CHANGED
|
@@ -3,15 +3,8 @@ import type { ServerCapabilities, StoreSettings, SyncContext } from '@tallyui/co
|
|
|
3
3
|
|
|
4
4
|
/** The highest order.create version the WooCommerce transport maps: v4's net discounts, and v5's fees, shipping and custom lines (WCPOS push/orders; orders #146, #161). */
|
|
5
5
|
export const WOO_ORDER_CREATE_VERSION = 5;
|
|
6
|
-
// The order.create version a store gets
|
|
6
|
+
// The order.create version a store gets unless /status lists order_create_v5, which only the TallyUI fork of the plugin advertises.
|
|
7
7
|
const WOO_BASE_ORDER_CREATE_VERSION = 3;
|
|
8
|
-
// The oldest WCPOS release with a proven v5 push (orders #146, #147).
|
|
9
|
-
const WOO_V5_MIN_PLUGIN_VERSION = [1, 10, 20] as const;
|
|
10
|
-
|
|
11
|
-
function atLeastVersion(value: unknown, min: readonly [number, number, number]): boolean {
|
|
12
|
-
const parts = typeof value === 'string' ? /^(\d+)\.(\d+)\.(\d+)/.exec(value)?.slice(1).map(Number) : undefined;
|
|
13
|
-
return !!parts && (parts[0] > min[0] || (parts[0] === min[0] && (parts[1] > min[1] || (parts[1] === min[1] && parts[2] >= min[2]))));
|
|
14
|
-
}
|
|
15
8
|
|
|
16
9
|
export async function wooStoreSettings(context: SyncContext): Promise<StoreSettings> {
|
|
17
10
|
try {
|
|
@@ -125,13 +118,7 @@ export async function readWooCapabilities(context: SyncContext): Promise<ServerC
|
|
|
125
118
|
} catch (error) {
|
|
126
119
|
if (error instanceof ConnectorUnauthorizedError) throw error;
|
|
127
120
|
}
|
|
128
|
-
|
|
129
|
-
if (orderCreate === WOO_BASE_ORDER_CREATE_VERSION) {
|
|
130
|
-
try {
|
|
131
|
-
const response = await fetch(`${context.baseUrl}/site`, { method: 'GET', headers: context.headers, signal: context.signal });
|
|
132
|
-
if (response.ok && atLeastVersion((await response.json())?.wcpos_version, WOO_V5_MIN_PLUGIN_VERSION)) orderCreate = WOO_ORDER_CREATE_VERSION;
|
|
133
|
-
} catch {}
|
|
134
|
-
}
|
|
121
|
+
const orderCreate = capabilities.includes('order_create_v5') ? WOO_ORDER_CREATE_VERSION : WOO_BASE_ORDER_CREATE_VERSION;
|
|
135
122
|
return {
|
|
136
123
|
orderCreate,
|
|
137
124
|
taxRounding: { granularity: 'woocommerce', roundAtSubtotal: stores[0].tax_round_at_subtotal === 'yes' },
|