@mailoo/market 1.35.10 → 1.35.13
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 +82 -3
- package/dist/chunk-SNYTGUGW.js +484 -0
- package/dist/chunk-SNYTGUGW.js.map +1 -0
- package/dist/types-ClEuQGG0.d.cts +144 -0
- package/dist/types-ClEuQGG0.d.ts +144 -0
- package/dist/wholesale-price-list/google-sheets/index.cjs +819 -0
- package/dist/wholesale-price-list/google-sheets/index.cjs.map +1 -0
- package/dist/wholesale-price-list/google-sheets/index.d.cts +99 -0
- package/dist/wholesale-price-list/google-sheets/index.d.ts +99 -0
- package/dist/wholesale-price-list/google-sheets/index.js +381 -0
- package/dist/wholesale-price-list/google-sheets/index.js.map +1 -0
- package/dist/wholesale-price-list/index.cjs +822 -0
- package/dist/wholesale-price-list/index.cjs.map +1 -0
- package/dist/wholesale-price-list/index.d.cts +138 -0
- package/dist/wholesale-price-list/index.d.ts +138 -0
- package/dist/wholesale-price-list/index.js +335 -0
- package/dist/wholesale-price-list/index.js.map +1 -0
- package/package.json +23 -2
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared wholesale price-list generator (MAI-110 v1 / AMS-25).
|
|
3
|
+
*
|
|
4
|
+
* Entry: `renderPriceListXlsx(input)` from
|
|
5
|
+
* `@mailoo/market/wholesale-price-list` (Node / Route Handler only).
|
|
6
|
+
* Google Sheets: `@mailoo/market/wholesale-price-list/google-sheets`
|
|
7
|
+
* (optional peer `googleapis`).
|
|
8
|
+
*
|
|
9
|
+
* v1: one unit-price column, no quantity tiers, no min-order column.
|
|
10
|
+
* Quantity breaks / MOQ are deferred (AMS-28).
|
|
11
|
+
*/
|
|
12
|
+
/** Built-in label locales. Other `locale` strings still work; labels fall back to en. */
|
|
13
|
+
type PriceListBuiltinLocale = 'hy' | 'ru' | 'en' | 'de' | 'es';
|
|
14
|
+
type PriceListHeader = {
|
|
15
|
+
siteName: string;
|
|
16
|
+
/**
|
|
17
|
+
* Absolute logo URL, or null. SVG is accepted — the generator rasterizes
|
|
18
|
+
* to PNG for xlsx embed (and for Sheets when bytes are available).
|
|
19
|
+
*/
|
|
20
|
+
logoUrl: string | null;
|
|
21
|
+
/** Optional pre-fetched logo bytes (svg / png / jpeg / webp). */
|
|
22
|
+
logoBytes?: Uint8Array | null;
|
|
23
|
+
/**
|
|
24
|
+
* Contact block as a single pre-formatted string (may contain newlines).
|
|
25
|
+
* Pre-Form: from `MARKET_PRICE_LIST_CONTACTS`. Mailoo admin: see package README —
|
|
26
|
+
* MARKET config has no contacts field yet.
|
|
27
|
+
*/
|
|
28
|
+
contacts: string;
|
|
29
|
+
/** ISO-8601 instant. */
|
|
30
|
+
generatedAt: string;
|
|
31
|
+
/**
|
|
32
|
+
* IANA time zone for the “Generated: …” display (e.g. `Asia/Yerevan`).
|
|
33
|
+
* Omitted → format in UTC.
|
|
34
|
+
*/
|
|
35
|
+
timeZone?: string | null;
|
|
36
|
+
};
|
|
37
|
+
type PriceListRow = {
|
|
38
|
+
productId: string;
|
|
39
|
+
/** null = product has no variants (one row for the product). */
|
|
40
|
+
variantId: string | null;
|
|
41
|
+
category: string | null;
|
|
42
|
+
product: string;
|
|
43
|
+
variant: string | null;
|
|
44
|
+
packaging: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Unit price in the price measurement unit.
|
|
47
|
+
* `null` / negative / NaN / non-finite → cell shows localized “on request”;
|
|
48
|
+
* Sum stays blank (row still renders; does not fail the whole file).
|
|
49
|
+
*
|
|
50
|
+
* AMS-28 (not in v1): row currently has no `measurementUnit` column —
|
|
51
|
+
* packaging / unit labels stay in `packaging` only.
|
|
52
|
+
*/
|
|
53
|
+
unitPrice: number | null;
|
|
54
|
+
/** ISO 4217; null = unknown (still summed in a single Total when alone). */
|
|
55
|
+
currency: string | null;
|
|
56
|
+
/** Absolute storefront PDP (`?variant=` when variantId set). */
|
|
57
|
+
productUrl: string;
|
|
58
|
+
previewMediaId: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Absolute cover URL. Used for Sheets `=IMAGE` only when anonymously
|
|
61
|
+
* fetchable (not Mailoo `…/images/public/content?id=` which needs an API key).
|
|
62
|
+
* Prefer `previewImageBytes` / `loadPreviewImage` for xlsx embed.
|
|
63
|
+
*/
|
|
64
|
+
previewImageUrl: string | null;
|
|
65
|
+
/** Optional pre-fetched cover bytes for xlsx embed. */
|
|
66
|
+
previewImageBytes?: Uint8Array | null;
|
|
67
|
+
};
|
|
68
|
+
type PriceListInput = {
|
|
69
|
+
/** One language per file; row/header strings are already localized by the caller. */
|
|
70
|
+
locale: string;
|
|
71
|
+
header: PriceListHeader;
|
|
72
|
+
rows: PriceListRow[];
|
|
73
|
+
/** Optional overrides of built-in hy/ru/en/de/es strings. */
|
|
74
|
+
labels?: Partial<Record<PriceListLabelKey, string>>;
|
|
75
|
+
/**
|
|
76
|
+
* Fetch cover bytes when `previewImageBytes` is omitted.
|
|
77
|
+
* Return null to leave the photo blank.
|
|
78
|
+
* When omitted, the package tries an anonymous GET of `previewImageUrl`
|
|
79
|
+
* (skips Mailoo API-keyed embed URLs).
|
|
80
|
+
*/
|
|
81
|
+
loadPreviewImage?: (args: {
|
|
82
|
+
previewMediaId: string | null;
|
|
83
|
+
previewImageUrl: string | null;
|
|
84
|
+
}) => Promise<Uint8Array | null>;
|
|
85
|
+
/**
|
|
86
|
+
* Fetch logo bytes when `logoBytes` omitted but `logoUrl` set.
|
|
87
|
+
* When omitted, the package tries an anonymous GET of `logoUrl`.
|
|
88
|
+
*/
|
|
89
|
+
loadLogo?: (logoUrl: string) => Promise<Uint8Array | null>;
|
|
90
|
+
/** Square thumbnail edge in px (default 120). */
|
|
91
|
+
photoSizePx?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Max concurrent preview image loads / rasterizations (default 6).
|
|
94
|
+
* Must be an integer >= 1. Row order in the sheet is preserved.
|
|
95
|
+
*/
|
|
96
|
+
previewImageConcurrency?: number;
|
|
97
|
+
};
|
|
98
|
+
type PriceListLabelKey = 'title' | 'photo' | 'category' | 'product' | 'variant' | 'packaging' | 'price' | 'onRequest' | 'link' | 'linkText' | 'quantity' | 'sum' | 'total' | 'generated' | 'filenamePrefix';
|
|
99
|
+
type PriceListColumnKey = 'photo' | 'category' | 'product' | 'variant' | 'packaging' | 'price' | 'link' | 'quantity' | 'sum' | 'currencyHidden';
|
|
100
|
+
type PriceListLayout = {
|
|
101
|
+
locale: string;
|
|
102
|
+
photoSizePx: number;
|
|
103
|
+
/** Fixed data-row height in Excel points (~96 pt ≈ 130 px). */
|
|
104
|
+
dataRowHeightPt: number;
|
|
105
|
+
photoColWidthChars: number;
|
|
106
|
+
/** 1-based Excel row of visible column headers. */
|
|
107
|
+
headerRow: number;
|
|
108
|
+
firstDataRow: number;
|
|
109
|
+
totalRow: number;
|
|
110
|
+
columns: Array<{
|
|
111
|
+
key: PriceListColumnKey;
|
|
112
|
+
header: string;
|
|
113
|
+
index: number;
|
|
114
|
+
letter: string;
|
|
115
|
+
}>;
|
|
116
|
+
priceColLetter: string;
|
|
117
|
+
quantityColLetter: string;
|
|
118
|
+
sumColLetter: string;
|
|
119
|
+
currencyColLetter: string;
|
|
120
|
+
linkColLetter: string;
|
|
121
|
+
};
|
|
122
|
+
type PriceListSheetModel = {
|
|
123
|
+
title: string;
|
|
124
|
+
locale: string;
|
|
125
|
+
layout: PriceListLayout;
|
|
126
|
+
cells: Array<{
|
|
127
|
+
a1: string;
|
|
128
|
+
value: string | number | null;
|
|
129
|
+
formula?: string;
|
|
130
|
+
}>;
|
|
131
|
+
previewImageUrls: Array<string | null>;
|
|
132
|
+
logoUrl: string | null;
|
|
133
|
+
};
|
|
134
|
+
type RenderPriceListXlsxResult = {
|
|
135
|
+
buffer: Buffer;
|
|
136
|
+
filename: string;
|
|
137
|
+
contentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
138
|
+
layout: PriceListLayout;
|
|
139
|
+
sheetModel: PriceListSheetModel;
|
|
140
|
+
/** Soft failures (e.g. undecodable preview/logo); file still produced. */
|
|
141
|
+
warnings: string[];
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type { PriceListInput as P, RenderPriceListXlsxResult as R, PriceListLayout as a, PriceListLabelKey as b, PriceListBuiltinLocale as c, PriceListColumnKey as d, PriceListHeader as e, PriceListRow as f, PriceListSheetModel as g };
|
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared wholesale price-list generator (MAI-110 v1 / AMS-25).
|
|
3
|
+
*
|
|
4
|
+
* Entry: `renderPriceListXlsx(input)` from
|
|
5
|
+
* `@mailoo/market/wholesale-price-list` (Node / Route Handler only).
|
|
6
|
+
* Google Sheets: `@mailoo/market/wholesale-price-list/google-sheets`
|
|
7
|
+
* (optional peer `googleapis`).
|
|
8
|
+
*
|
|
9
|
+
* v1: one unit-price column, no quantity tiers, no min-order column.
|
|
10
|
+
* Quantity breaks / MOQ are deferred (AMS-28).
|
|
11
|
+
*/
|
|
12
|
+
/** Built-in label locales. Other `locale` strings still work; labels fall back to en. */
|
|
13
|
+
type PriceListBuiltinLocale = 'hy' | 'ru' | 'en' | 'de' | 'es';
|
|
14
|
+
type PriceListHeader = {
|
|
15
|
+
siteName: string;
|
|
16
|
+
/**
|
|
17
|
+
* Absolute logo URL, or null. SVG is accepted — the generator rasterizes
|
|
18
|
+
* to PNG for xlsx embed (and for Sheets when bytes are available).
|
|
19
|
+
*/
|
|
20
|
+
logoUrl: string | null;
|
|
21
|
+
/** Optional pre-fetched logo bytes (svg / png / jpeg / webp). */
|
|
22
|
+
logoBytes?: Uint8Array | null;
|
|
23
|
+
/**
|
|
24
|
+
* Contact block as a single pre-formatted string (may contain newlines).
|
|
25
|
+
* Pre-Form: from `MARKET_PRICE_LIST_CONTACTS`. Mailoo admin: see package README —
|
|
26
|
+
* MARKET config has no contacts field yet.
|
|
27
|
+
*/
|
|
28
|
+
contacts: string;
|
|
29
|
+
/** ISO-8601 instant. */
|
|
30
|
+
generatedAt: string;
|
|
31
|
+
/**
|
|
32
|
+
* IANA time zone for the “Generated: …” display (e.g. `Asia/Yerevan`).
|
|
33
|
+
* Omitted → format in UTC.
|
|
34
|
+
*/
|
|
35
|
+
timeZone?: string | null;
|
|
36
|
+
};
|
|
37
|
+
type PriceListRow = {
|
|
38
|
+
productId: string;
|
|
39
|
+
/** null = product has no variants (one row for the product). */
|
|
40
|
+
variantId: string | null;
|
|
41
|
+
category: string | null;
|
|
42
|
+
product: string;
|
|
43
|
+
variant: string | null;
|
|
44
|
+
packaging: string | null;
|
|
45
|
+
/**
|
|
46
|
+
* Unit price in the price measurement unit.
|
|
47
|
+
* `null` / negative / NaN / non-finite → cell shows localized “on request”;
|
|
48
|
+
* Sum stays blank (row still renders; does not fail the whole file).
|
|
49
|
+
*
|
|
50
|
+
* AMS-28 (not in v1): row currently has no `measurementUnit` column —
|
|
51
|
+
* packaging / unit labels stay in `packaging` only.
|
|
52
|
+
*/
|
|
53
|
+
unitPrice: number | null;
|
|
54
|
+
/** ISO 4217; null = unknown (still summed in a single Total when alone). */
|
|
55
|
+
currency: string | null;
|
|
56
|
+
/** Absolute storefront PDP (`?variant=` when variantId set). */
|
|
57
|
+
productUrl: string;
|
|
58
|
+
previewMediaId: string | null;
|
|
59
|
+
/**
|
|
60
|
+
* Absolute cover URL. Used for Sheets `=IMAGE` only when anonymously
|
|
61
|
+
* fetchable (not Mailoo `…/images/public/content?id=` which needs an API key).
|
|
62
|
+
* Prefer `previewImageBytes` / `loadPreviewImage` for xlsx embed.
|
|
63
|
+
*/
|
|
64
|
+
previewImageUrl: string | null;
|
|
65
|
+
/** Optional pre-fetched cover bytes for xlsx embed. */
|
|
66
|
+
previewImageBytes?: Uint8Array | null;
|
|
67
|
+
};
|
|
68
|
+
type PriceListInput = {
|
|
69
|
+
/** One language per file; row/header strings are already localized by the caller. */
|
|
70
|
+
locale: string;
|
|
71
|
+
header: PriceListHeader;
|
|
72
|
+
rows: PriceListRow[];
|
|
73
|
+
/** Optional overrides of built-in hy/ru/en/de/es strings. */
|
|
74
|
+
labels?: Partial<Record<PriceListLabelKey, string>>;
|
|
75
|
+
/**
|
|
76
|
+
* Fetch cover bytes when `previewImageBytes` is omitted.
|
|
77
|
+
* Return null to leave the photo blank.
|
|
78
|
+
* When omitted, the package tries an anonymous GET of `previewImageUrl`
|
|
79
|
+
* (skips Mailoo API-keyed embed URLs).
|
|
80
|
+
*/
|
|
81
|
+
loadPreviewImage?: (args: {
|
|
82
|
+
previewMediaId: string | null;
|
|
83
|
+
previewImageUrl: string | null;
|
|
84
|
+
}) => Promise<Uint8Array | null>;
|
|
85
|
+
/**
|
|
86
|
+
* Fetch logo bytes when `logoBytes` omitted but `logoUrl` set.
|
|
87
|
+
* When omitted, the package tries an anonymous GET of `logoUrl`.
|
|
88
|
+
*/
|
|
89
|
+
loadLogo?: (logoUrl: string) => Promise<Uint8Array | null>;
|
|
90
|
+
/** Square thumbnail edge in px (default 120). */
|
|
91
|
+
photoSizePx?: number;
|
|
92
|
+
/**
|
|
93
|
+
* Max concurrent preview image loads / rasterizations (default 6).
|
|
94
|
+
* Must be an integer >= 1. Row order in the sheet is preserved.
|
|
95
|
+
*/
|
|
96
|
+
previewImageConcurrency?: number;
|
|
97
|
+
};
|
|
98
|
+
type PriceListLabelKey = 'title' | 'photo' | 'category' | 'product' | 'variant' | 'packaging' | 'price' | 'onRequest' | 'link' | 'linkText' | 'quantity' | 'sum' | 'total' | 'generated' | 'filenamePrefix';
|
|
99
|
+
type PriceListColumnKey = 'photo' | 'category' | 'product' | 'variant' | 'packaging' | 'price' | 'link' | 'quantity' | 'sum' | 'currencyHidden';
|
|
100
|
+
type PriceListLayout = {
|
|
101
|
+
locale: string;
|
|
102
|
+
photoSizePx: number;
|
|
103
|
+
/** Fixed data-row height in Excel points (~96 pt ≈ 130 px). */
|
|
104
|
+
dataRowHeightPt: number;
|
|
105
|
+
photoColWidthChars: number;
|
|
106
|
+
/** 1-based Excel row of visible column headers. */
|
|
107
|
+
headerRow: number;
|
|
108
|
+
firstDataRow: number;
|
|
109
|
+
totalRow: number;
|
|
110
|
+
columns: Array<{
|
|
111
|
+
key: PriceListColumnKey;
|
|
112
|
+
header: string;
|
|
113
|
+
index: number;
|
|
114
|
+
letter: string;
|
|
115
|
+
}>;
|
|
116
|
+
priceColLetter: string;
|
|
117
|
+
quantityColLetter: string;
|
|
118
|
+
sumColLetter: string;
|
|
119
|
+
currencyColLetter: string;
|
|
120
|
+
linkColLetter: string;
|
|
121
|
+
};
|
|
122
|
+
type PriceListSheetModel = {
|
|
123
|
+
title: string;
|
|
124
|
+
locale: string;
|
|
125
|
+
layout: PriceListLayout;
|
|
126
|
+
cells: Array<{
|
|
127
|
+
a1: string;
|
|
128
|
+
value: string | number | null;
|
|
129
|
+
formula?: string;
|
|
130
|
+
}>;
|
|
131
|
+
previewImageUrls: Array<string | null>;
|
|
132
|
+
logoUrl: string | null;
|
|
133
|
+
};
|
|
134
|
+
type RenderPriceListXlsxResult = {
|
|
135
|
+
buffer: Buffer;
|
|
136
|
+
filename: string;
|
|
137
|
+
contentType: 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
138
|
+
layout: PriceListLayout;
|
|
139
|
+
sheetModel: PriceListSheetModel;
|
|
140
|
+
/** Soft failures (e.g. undecodable preview/logo); file still produced. */
|
|
141
|
+
warnings: string[];
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
export type { PriceListInput as P, RenderPriceListXlsxResult as R, PriceListLayout as a, PriceListLabelKey as b, PriceListBuiltinLocale as c, PriceListColumnKey as d, PriceListHeader as e, PriceListRow as f, PriceListSheetModel as g };
|