@mailoo/market 1.35.10 → 1.35.12
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 +70 -0
- package/dist/wholesale-price-list/index.cjs +1068 -0
- package/dist/wholesale-price-list/index.cjs.map +1 -0
- package/dist/wholesale-price-list/index.d.cts +327 -0
- package/dist/wholesale-price-list/index.d.ts +327 -0
- package/dist/wholesale-price-list/index.js +1006 -0
- package/dist/wholesale-price-list/index.js.map +1 -0
- package/package.json +12 -2
package/README.md
CHANGED
|
@@ -114,6 +114,76 @@ status-only fallback and never return raw transport exceptions. The explicit
|
|
|
114
114
|
diagnostics method uses the same redaction. The Next server
|
|
115
115
|
adapter preserves framework control-flow rethrows.
|
|
116
116
|
|
|
117
|
+
## Wholesale price list (.xlsx) — server only
|
|
118
|
+
|
|
119
|
+
Shared generator used by Mailoo Market admin and integrators (e.g. Pre-Form).
|
|
120
|
+
**Node / Route Handler only** (depends on `exceljs` + `sharp`; do not import from
|
|
121
|
+
client components).
|
|
122
|
+
|
|
123
|
+
```ts
|
|
124
|
+
import { renderPriceListXlsx } from '@mailoo/market/wholesale-price-list'
|
|
125
|
+
|
|
126
|
+
const { buffer, filename } = await renderPriceListXlsx({
|
|
127
|
+
locale: 'en', // one language per file
|
|
128
|
+
header: {
|
|
129
|
+
siteName: 'Demo Shop',
|
|
130
|
+
logoUrl: 'https://example.com/logo.svg', // SVG rasterized by the generator
|
|
131
|
+
logoBytes: null, // or pass bytes / use loadLogo
|
|
132
|
+
contacts: 'sales@example.com\n+374 …', // single string (newlines OK)
|
|
133
|
+
generatedAt: new Date().toISOString(),
|
|
134
|
+
timeZone: 'Asia/Yerevan', // optional; omit → UTC display
|
|
135
|
+
},
|
|
136
|
+
rows: [
|
|
137
|
+
{
|
|
138
|
+
productId: '…',
|
|
139
|
+
variantId: null,
|
|
140
|
+
category: 'Tea',
|
|
141
|
+
product: 'Green tea',
|
|
142
|
+
variant: null,
|
|
143
|
+
packaging: 'box',
|
|
144
|
+
unitPrice: 12.5, // null → "on request"
|
|
145
|
+
currency: 'USD',
|
|
146
|
+
productUrl: 'https://shop.example/p/green-tea',
|
|
147
|
+
previewMediaId: null,
|
|
148
|
+
previewImageUrl: null,
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
})
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
v1 sheet columns: Photo | Category | Product | Variant | Packaging | Price |
|
|
155
|
+
Link (HYPERLINK) | Quantity | Sum (= qty × price). Total row at bottom; mixed
|
|
156
|
+
currencies use hidden currency column + `SUMIF`. No quantity tiers / min-order
|
|
157
|
+
(AMS-28 later). AMS-28 note: rows also lack a `measurementUnit` field in v1 —
|
|
158
|
+
unit/packaging stays in `packaging` only. Negative / NaN / non-finite
|
|
159
|
+
`unitPrice` soft-coerces to localized “on request” (does not fail the file).
|
|
160
|
+
Built-in labels: `hy` / `ru` / `en` / `de` / `es`. Filename date uses
|
|
161
|
+
`header.timeZone` (fallback UTC).
|
|
162
|
+
|
|
163
|
+
When `loadPreviewImage` / `loadLogo` are omitted, the package tries an anonymous
|
|
164
|
+
GET of absolute http(s) URLs (skips Mailoo `…/images/public/content?id=` which
|
|
165
|
+
needs an API key). Mailoo admin export supplies its own S3 loaders by media id.
|
|
166
|
+
|
|
167
|
+
Google Sheets (same structure). Callers supply a service-account JSON string
|
|
168
|
+
(Mailoo stores it encrypted on the MARKET integration as
|
|
169
|
+
`config.googleSheetsExport`):
|
|
170
|
+
|
|
171
|
+
```ts
|
|
172
|
+
import { renderPriceListGoogleSheet } from '@mailoo/market/wholesale-price-list'
|
|
173
|
+
|
|
174
|
+
const { spreadsheetUrl } = await renderPriceListGoogleSheet(input, {
|
|
175
|
+
serviceAccountJson, // SA key JSON string
|
|
176
|
+
shareWithEmail, // optional
|
|
177
|
+
driveFolderId, // optional
|
|
178
|
+
})
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
Requires GCP **Sheets API** + **Drive API**. Share the Drive folder with the SA
|
|
182
|
+
`client_email`. Photos/logo for `=IMAGE`: prefer Drive-uploaded PNGs
|
|
183
|
+
(`https://drive.google.com/uc?export=view&id=…`, anyone-reader) when bytes are
|
|
184
|
+
available; otherwise only anonymously fetchable URLs (never Mailoo API-keyed
|
|
185
|
+
embed URLs). SVG logos are rasterized and uploaded.
|
|
186
|
+
|
|
117
187
|
## Native Node jobs (no Next runtime import)
|
|
118
188
|
|
|
119
189
|
```ts
|