@tallyui/connector-woocommerce 3.7.0 → 3.8.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 +17 -2
- package/package.json +3 -3
- package/src/replication/products.ts +3 -1
- package/src/traits/product.ts +19 -0
package/dist/index.js
CHANGED
|
@@ -257,7 +257,11 @@ function toVariationDocument(payload) {
|
|
|
257
257
|
purchasable,
|
|
258
258
|
tax_class,
|
|
259
259
|
tax_status,
|
|
260
|
-
attributes: (payload.attributes ?? []).map(({ name, option }) => ({
|
|
260
|
+
attributes: (payload.attributes ?? []).map(({ id: id2, name, option }) => ({
|
|
261
|
+
...typeof id2 === "number" ? { id: id2 } : {},
|
|
262
|
+
name,
|
|
263
|
+
option
|
|
264
|
+
}))
|
|
261
265
|
}).filter(([, value]) => value !== void 0));
|
|
262
266
|
}
|
|
263
267
|
function toProductDocument(product) {
|
|
@@ -435,6 +439,12 @@ var wooProductTraits = {
|
|
|
435
439
|
getVariants: (doc, context) => doc.type === "variable" ? (doc.variation_docs ?? []).filter((v) => v.status === "publish" && v.purchasable !== false).map((v) => ({
|
|
436
440
|
id: String(v.id),
|
|
437
441
|
title: (v.attributes ?? []).map((attribute) => attribute.option).join(" / ") || void 0,
|
|
442
|
+
options: (v.attributes ?? []).reduce((options, attribute) => {
|
|
443
|
+
if (typeof attribute.name === "string" && attribute.name.length > 0 && typeof attribute.option === "string" && attribute.option.length > 0 && !Object.prototype.hasOwnProperty.call(options, attribute.name)) {
|
|
444
|
+
return { ...options, [attribute.name]: attribute.option };
|
|
445
|
+
}
|
|
446
|
+
return options;
|
|
447
|
+
}, {}),
|
|
438
448
|
sku: v.sku || void 0,
|
|
439
449
|
barcode: v.barcode || void 0,
|
|
440
450
|
prices: wooProductTraits.getPrices(v, context),
|
|
@@ -446,6 +456,11 @@ var wooProductTraits = {
|
|
|
446
456
|
prices: wooProductTraits.getPrices(doc, context),
|
|
447
457
|
stock: wooProductTraits.getStock(doc)
|
|
448
458
|
}],
|
|
459
|
+
getVariantOptions: (doc) => doc.type !== "variable" ? [] : (doc.attributes ?? []).filter((attribute) => attribute.variation === true && typeof attribute.name === "string" && attribute.name.length > 0).sort((a, b) => (typeof a.position === "number" ? a.position : Infinity) - (typeof b.position === "number" ? b.position : Infinity)).map((attribute) => ({
|
|
460
|
+
...Number.isInteger(attribute.id) && attribute.id > 0 ? { id: String(attribute.id) } : {},
|
|
461
|
+
name: attribute.name,
|
|
462
|
+
values: (attribute.options ?? []).filter((value) => typeof value === "string" && value.length > 0)
|
|
463
|
+
})),
|
|
449
464
|
isSellable: (doc) => doc.status === void 0 || doc.status === "publish",
|
|
450
465
|
getVariantCount: (doc) => doc.type === "variable" ? doc.variations?.length ?? 0 : 1,
|
|
451
466
|
getType: (doc) => doc.type ?? "simple",
|
|
@@ -846,7 +861,7 @@ async function readWooCapabilities(context) {
|
|
|
846
861
|
}
|
|
847
862
|
|
|
848
863
|
// package.json
|
|
849
|
-
var version = "3.
|
|
864
|
+
var version = "3.8.0";
|
|
850
865
|
|
|
851
866
|
// src/commands/transport.ts
|
|
852
867
|
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.8.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.8.0"
|
|
30
30
|
},
|
|
31
31
|
"devDependencies": {
|
|
32
|
-
"@tallyui/database": "3.
|
|
32
|
+
"@tallyui/database": "3.8.0",
|
|
33
33
|
"rxdb": "17.5.0"
|
|
34
34
|
},
|
|
35
35
|
"scripts": {
|
|
@@ -90,7 +90,9 @@ export function toVariationDocument(payload: any) {
|
|
|
90
90
|
id, sku, barcode: wooProductBarcode(payload), price, regular_price, sale_price, on_sale,
|
|
91
91
|
stock_status, stock_quantity, manage_stock, status, purchasable,
|
|
92
92
|
tax_class, tax_status,
|
|
93
|
-
attributes: (payload.attributes ?? []).map(({ name, option }: any) => ({
|
|
93
|
+
attributes: (payload.attributes ?? []).map(({ id, name, option }: any) => ({
|
|
94
|
+
...(typeof id === 'number' ? { id } : {}), name, option,
|
|
95
|
+
})),
|
|
94
96
|
}).filter(([, value]) => value !== undefined));
|
|
95
97
|
}
|
|
96
98
|
|
package/src/traits/product.ts
CHANGED
|
@@ -85,6 +85,14 @@ export const wooProductTraits: ProductTraits = {
|
|
|
85
85
|
.filter((v: any) => v.status === 'publish' && v.purchasable !== false).map((v: any) => ({
|
|
86
86
|
id: String(v.id),
|
|
87
87
|
title: (v.attributes ?? []).map((attribute: any) => attribute.option).join(' / ') || undefined,
|
|
88
|
+
options: (v.attributes ?? []).reduce((options: Record<string, string>, attribute: any) => {
|
|
89
|
+
if (typeof attribute.name === 'string' && attribute.name.length > 0
|
|
90
|
+
&& typeof attribute.option === 'string' && attribute.option.length > 0
|
|
91
|
+
&& !Object.prototype.hasOwnProperty.call(options, attribute.name)) {
|
|
92
|
+
return { ...options, [attribute.name]: attribute.option };
|
|
93
|
+
}
|
|
94
|
+
return options;
|
|
95
|
+
}, {}),
|
|
88
96
|
sku: v.sku || undefined,
|
|
89
97
|
barcode: v.barcode || undefined,
|
|
90
98
|
prices: wooProductTraits.getPrices(v, context),
|
|
@@ -97,6 +105,17 @@ export const wooProductTraits: ProductTraits = {
|
|
|
97
105
|
stock: wooProductTraits.getStock(doc),
|
|
98
106
|
}],
|
|
99
107
|
|
|
108
|
+
getVariantOptions: (doc) => doc.type !== 'variable' ? [] : (doc.attributes ?? [])
|
|
109
|
+
.filter((attribute: any) => attribute.variation === true
|
|
110
|
+
&& typeof attribute.name === 'string' && attribute.name.length > 0)
|
|
111
|
+
.sort((a: any, b: any) => (typeof a.position === 'number' ? a.position : Infinity)
|
|
112
|
+
- (typeof b.position === 'number' ? b.position : Infinity))
|
|
113
|
+
.map((attribute: any) => ({
|
|
114
|
+
...(Number.isInteger(attribute.id) && attribute.id > 0 ? { id: String(attribute.id) } : {}),
|
|
115
|
+
name: attribute.name,
|
|
116
|
+
values: (attribute.options ?? []).filter((value: any) => typeof value === 'string' && value.length > 0),
|
|
117
|
+
})),
|
|
118
|
+
|
|
100
119
|
isSellable: (doc) => doc.status === undefined || doc.status === 'publish',
|
|
101
120
|
|
|
102
121
|
getVariantCount: (doc) => doc.type === 'variable' ? doc.variations?.length ?? 0 : 1,
|