@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.
@@ -0,0 +1,335 @@
1
+ import {
2
+ DEFAULT_PREVIEW_IMAGE_CONCURRENCY,
3
+ PRICE_LIST_BANNER_ROW_COUNT,
4
+ PRICE_LIST_DATA_ROW_HEIGHT_PT,
5
+ PRICE_LIST_DEFAULT_PHOTO_PX,
6
+ PRICE_LIST_PHOTO_COL_CHARS,
7
+ buildCurrencyTotalSumIfFormula,
8
+ buildLineSumFormula,
9
+ buildPriceListLayout,
10
+ buildTotalSumFormula,
11
+ coerceUnitPrice,
12
+ excelColumnLetter,
13
+ fetchAbsoluteUrlBytes,
14
+ formatGeneratedLabel,
15
+ googleSheetsImageFormula,
16
+ isAnonymousHttpImageUrl,
17
+ isMailooApiKeyedImageUrl,
18
+ mapWithConcurrency,
19
+ mediaIdFromMailooPublicImageUrl,
20
+ normalizePreviewSquare,
21
+ priceListFilename,
22
+ priceListFilenameDate,
23
+ rasterizeLogo,
24
+ resolveLogoBytes,
25
+ resolvePreviewBytes,
26
+ resolvePreviewImageConcurrency,
27
+ resolvePriceListLabels,
28
+ tryNormalizePreviewSquare,
29
+ tryRasterizeLogo,
30
+ validatePriceListInput
31
+ } from "../chunk-SNYTGUGW.js";
32
+
33
+ // src/wholesale-price-list/build-xlsx.ts
34
+ import ExcelJS from "exceljs";
35
+ function uniqueCurrencies(input) {
36
+ const set = /* @__PURE__ */ new Set();
37
+ for (const row of input.rows) {
38
+ const c = row.currency?.trim();
39
+ if (c) set.add(c);
40
+ }
41
+ return [...set].sort();
42
+ }
43
+ async function renderPriceListXlsx(input) {
44
+ const normalized = validatePriceListInput(input);
45
+ const warnings = [];
46
+ const labels = resolvePriceListLabels(normalized.locale, normalized.labels);
47
+ const layout = buildPriceListLayout(normalized);
48
+ const title = labels.title;
49
+ const currencies = uniqueCurrencies(normalized);
50
+ const multiCurrency = currencies.length > 1;
51
+ const concurrency = resolvePreviewImageConcurrency(normalized);
52
+ const workbook = new ExcelJS.Workbook();
53
+ workbook.creator = "Mailoo";
54
+ workbook.created = new Date(normalized.header.generatedAt);
55
+ const sheetName = `${normalized.header.siteName}`.slice(0, 31) || title.slice(0, 31);
56
+ const sheet = workbook.addWorksheet(sheetName, {
57
+ properties: { defaultRowHeight: layout.dataRowHeightPt },
58
+ views: [{ state: "frozen", ySplit: layout.headerRow }],
59
+ pageSetup: {
60
+ orientation: "landscape",
61
+ fitToPage: true,
62
+ fitToWidth: 1,
63
+ fitToHeight: 0
64
+ }
65
+ });
66
+ for (const col of layout.columns) {
67
+ let width = 16;
68
+ if (col.key === "photo") width = layout.photoColWidthChars;
69
+ else if (col.key === "link") width = 14;
70
+ else if (col.key === "quantity" || col.key === "sum" || col.key === "price")
71
+ width = 12;
72
+ else if (col.key === "currencyHidden") width = 0;
73
+ else if (col.key === "product") width = 28;
74
+ sheet.getColumn(col.index).width = width;
75
+ if (col.key === "currencyHidden") {
76
+ sheet.getColumn(col.index).hidden = true;
77
+ }
78
+ }
79
+ sheet.getCell("A1").value = normalized.header.siteName;
80
+ sheet.getCell("A1").font = { bold: true, size: 16 };
81
+ sheet.mergeCells(1, 1, 1, Math.min(5, layout.columns.length));
82
+ sheet.getCell("A2").value = normalized.header.contacts;
83
+ sheet.getCell("A2").alignment = { wrapText: true, vertical: "top" };
84
+ const contactLines = normalized.header.contacts.split(/\r?\n/).length;
85
+ sheet.getRow(2).height = Math.max(36, contactLines * 14);
86
+ sheet.getCell("A3").value = formatGeneratedLabel(
87
+ labels.generated,
88
+ normalized.header.generatedAt,
89
+ normalized.locale,
90
+ normalized.header.timeZone
91
+ );
92
+ sheet.getCell("A3").font = { italic: true, size: 10 };
93
+ const logoBytes = await resolveLogoBytes(normalized);
94
+ if (logoBytes) {
95
+ const { png, error } = await tryRasterizeLogo(logoBytes);
96
+ if (png) {
97
+ const imageId = workbook.addImage({
98
+ buffer: png,
99
+ extension: "png"
100
+ });
101
+ sheet.addImage(imageId, {
102
+ tl: { col: 5, row: 0 },
103
+ ext: { width: 120, height: 40 },
104
+ editAs: "oneCell"
105
+ });
106
+ } else if (error) {
107
+ warnings.push(`header.logo: ${error}`);
108
+ }
109
+ }
110
+ const headerRow = sheet.getRow(layout.headerRow);
111
+ headerRow.font = { bold: true };
112
+ headerRow.height = 22;
113
+ for (const col of layout.columns) {
114
+ if (col.key === "currencyHidden") continue;
115
+ headerRow.getCell(col.index).value = col.header;
116
+ }
117
+ sheet.autoFilter = {
118
+ from: { row: layout.headerRow, column: 1 },
119
+ to: {
120
+ row: layout.headerRow,
121
+ column: layout.columns.find((c) => c.key === "sum").index
122
+ }
123
+ };
124
+ const sheetCells = [];
125
+ const previewImageUrls = [];
126
+ const lastDataRow = normalized.rows.length === 0 ? layout.firstDataRow - 1 : layout.firstDataRow + normalized.rows.length - 1;
127
+ const previewPrep = await mapWithConcurrency(
128
+ normalized.rows,
129
+ concurrency,
130
+ async (row, i) => {
131
+ const candidateUrl = row.previewImageUrl?.trim() || null;
132
+ const sheetsSafeUrl = candidateUrl && isAnonymousHttpImageUrl(candidateUrl) ? candidateUrl : null;
133
+ try {
134
+ const previewBytes = await resolvePreviewBytes(normalized, i);
135
+ if (!previewBytes) {
136
+ return { png: null, sheetsSafeUrl, warning: null };
137
+ }
138
+ const { png, error } = await tryNormalizePreviewSquare(
139
+ previewBytes,
140
+ layout.photoSizePx
141
+ );
142
+ if (png) return { png, sheetsSafeUrl, warning: null };
143
+ return {
144
+ png: null,
145
+ sheetsSafeUrl,
146
+ warning: error ? `rows[${i}].previewImage: ${error}` : `rows[${i}].previewImage: undecodable`
147
+ };
148
+ } catch (e) {
149
+ const msg = e instanceof Error ? e.message : String(e);
150
+ return {
151
+ png: null,
152
+ sheetsSafeUrl,
153
+ warning: `rows[${i}].previewImage: ${msg}`
154
+ };
155
+ }
156
+ }
157
+ );
158
+ for (let i = 0; i < normalized.rows.length; i++) {
159
+ const row = normalized.rows[i];
160
+ const excelRow = layout.firstDataRow + i;
161
+ const sheetRow = sheet.getRow(excelRow);
162
+ sheetRow.height = layout.dataRowHeightPt;
163
+ const photoCol = layout.columns.find((c) => c.key === "photo");
164
+ const catCol = layout.columns.find((c) => c.key === "category");
165
+ const prodCol = layout.columns.find((c) => c.key === "product");
166
+ const varCol = layout.columns.find((c) => c.key === "variant");
167
+ const packCol = layout.columns.find((c) => c.key === "packaging");
168
+ const priceCol = layout.columns.find((c) => c.key === "price");
169
+ const linkCol = layout.columns.find((c) => c.key === "link");
170
+ const qtyCol = layout.columns.find((c) => c.key === "quantity");
171
+ const sumCol = layout.columns.find((c) => c.key === "sum");
172
+ const curCol = layout.columns.find((c) => c.key === "currencyHidden");
173
+ sheetRow.getCell(catCol.index).value = row.category ?? "";
174
+ sheetRow.getCell(prodCol.index).value = row.product;
175
+ sheetRow.getCell(varCol.index).value = row.variant ?? "";
176
+ sheetRow.getCell(packCol.index).value = row.packaging ?? "";
177
+ if (row.unitPrice === null) {
178
+ sheetRow.getCell(priceCol.index).value = labels.onRequest;
179
+ } else {
180
+ sheetRow.getCell(priceCol.index).value = row.unitPrice;
181
+ sheetRow.getCell(priceCol.index).numFmt = "#,##0.00";
182
+ }
183
+ sheetRow.getCell(linkCol.index).value = {
184
+ text: labels.linkText,
185
+ hyperlink: row.productUrl
186
+ };
187
+ sheetCells.push({
188
+ a1: `${linkCol.letter}${excelRow}`,
189
+ value: labels.linkText,
190
+ formula: `HYPERLINK("${row.productUrl.replace(/"/g, '""')}","${labels.linkText.replace(/"/g, '""')}")`
191
+ });
192
+ sheetRow.getCell(qtyCol.index).value = null;
193
+ const sumFormula = buildLineSumFormula({ layout, row: excelRow });
194
+ sheetRow.getCell(sumCol.index).value = { formula: sumFormula };
195
+ sheetRow.getCell(sumCol.index).numFmt = "#,##0.00";
196
+ sheetCells.push({
197
+ a1: `${sumCol.letter}${excelRow}`,
198
+ value: null,
199
+ formula: sumFormula
200
+ });
201
+ sheetRow.getCell(curCol.index).value = row.currency?.trim() || "";
202
+ sheetRow.getCell(qtyCol.index).dataValidation = {
203
+ type: "whole",
204
+ operator: "greaterThanOrEqual",
205
+ formulae: [0],
206
+ allowBlank: true,
207
+ showErrorMessage: true,
208
+ errorTitle: labels.quantity,
209
+ error: ">= 0"
210
+ };
211
+ const prep = previewPrep[i];
212
+ previewImageUrls.push(prep.sheetsSafeUrl);
213
+ if (prep.warning) warnings.push(prep.warning);
214
+ if (prep.png) {
215
+ const imageId = workbook.addImage({
216
+ buffer: prep.png,
217
+ extension: "png"
218
+ });
219
+ sheet.addImage(imageId, {
220
+ tl: { col: photoCol.index - 1, row: excelRow - 1 },
221
+ ext: { width: layout.photoSizePx, height: layout.photoSizePx },
222
+ editAs: "oneCell"
223
+ });
224
+ } else if (prep.sheetsSafeUrl) {
225
+ sheetCells.push({
226
+ a1: `${photoCol.letter}${excelRow}`,
227
+ value: null,
228
+ formula: googleSheetsImageFormula(
229
+ prep.sheetsSafeUrl,
230
+ layout.photoSizePx
231
+ )
232
+ });
233
+ }
234
+ }
235
+ const totalExcelRow = layout.totalRow;
236
+ const qtyColIdx = layout.columns.find((c) => c.key === "quantity").index;
237
+ const sumColIdx = layout.columns.find((c) => c.key === "sum").index;
238
+ sheet.getRow(totalExcelRow).getCell(qtyColIdx).value = labels.total;
239
+ sheet.getRow(totalExcelRow).getCell(qtyColIdx).font = { bold: true };
240
+ if (!multiCurrency) {
241
+ const totalFormula = buildTotalSumFormula({
242
+ layout,
243
+ firstDataRow: layout.firstDataRow,
244
+ lastDataRow
245
+ });
246
+ sheet.getRow(totalExcelRow).getCell(sumColIdx).value = {
247
+ formula: totalFormula
248
+ };
249
+ sheet.getRow(totalExcelRow).getCell(sumColIdx).font = { bold: true };
250
+ sheet.getRow(totalExcelRow).getCell(sumColIdx).numFmt = "#,##0.00";
251
+ sheetCells.push({
252
+ a1: `${layout.sumColLetter}${totalExcelRow}`,
253
+ value: null,
254
+ formula: totalFormula
255
+ });
256
+ } else {
257
+ let offset = 0;
258
+ for (const currency of currencies) {
259
+ const r = totalExcelRow + offset;
260
+ sheet.getRow(r).getCell(qtyColIdx).value = offset === 0 ? `${labels.total} (${currency})` : currency;
261
+ sheet.getRow(r).getCell(qtyColIdx).font = { bold: true };
262
+ const f = buildCurrencyTotalSumIfFormula({
263
+ layout,
264
+ firstDataRow: layout.firstDataRow,
265
+ lastDataRow,
266
+ currency
267
+ });
268
+ sheet.getRow(r).getCell(sumColIdx).value = { formula: f };
269
+ sheet.getRow(r).getCell(sumColIdx).font = { bold: true };
270
+ sheet.getRow(r).getCell(sumColIdx).numFmt = "#,##0.00";
271
+ sheetCells.push({
272
+ a1: `${layout.sumColLetter}${r}`,
273
+ value: null,
274
+ formula: f
275
+ });
276
+ offset += 1;
277
+ }
278
+ }
279
+ const buffer = Buffer.from(await workbook.xlsx.writeBuffer());
280
+ const filename = priceListFilename(
281
+ normalized.locale,
282
+ normalized.header.generatedAt,
283
+ labels.filenamePrefix,
284
+ normalized.header.timeZone
285
+ );
286
+ const sheetModel = {
287
+ title,
288
+ locale: normalized.locale,
289
+ layout,
290
+ cells: sheetCells,
291
+ previewImageUrls,
292
+ logoUrl: normalized.header.logoUrl?.trim() || null
293
+ };
294
+ return {
295
+ buffer,
296
+ filename,
297
+ contentType: "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet",
298
+ layout,
299
+ sheetModel,
300
+ warnings
301
+ };
302
+ }
303
+ var buildWholesalePriceListXlsx = renderPriceListXlsx;
304
+ export {
305
+ DEFAULT_PREVIEW_IMAGE_CONCURRENCY,
306
+ PRICE_LIST_BANNER_ROW_COUNT,
307
+ PRICE_LIST_DATA_ROW_HEIGHT_PT,
308
+ PRICE_LIST_DEFAULT_PHOTO_PX,
309
+ PRICE_LIST_PHOTO_COL_CHARS,
310
+ buildCurrencyTotalSumIfFormula,
311
+ buildLineSumFormula,
312
+ buildPriceListLayout,
313
+ buildTotalSumFormula,
314
+ buildWholesalePriceListXlsx,
315
+ coerceUnitPrice,
316
+ excelColumnLetter,
317
+ fetchAbsoluteUrlBytes,
318
+ formatGeneratedLabel,
319
+ googleSheetsImageFormula,
320
+ isAnonymousHttpImageUrl,
321
+ isMailooApiKeyedImageUrl,
322
+ mapWithConcurrency,
323
+ mediaIdFromMailooPublicImageUrl,
324
+ normalizePreviewSquare,
325
+ priceListFilename,
326
+ priceListFilenameDate,
327
+ rasterizeLogo,
328
+ renderPriceListXlsx,
329
+ resolvePreviewImageConcurrency,
330
+ resolvePriceListLabels,
331
+ tryNormalizePreviewSquare,
332
+ tryRasterizeLogo,
333
+ validatePriceListInput
334
+ };
335
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/wholesale-price-list/build-xlsx.ts"],"sourcesContent":["import ExcelJS from 'exceljs'\nimport { mapWithConcurrency } from './concurrency.js'\nimport { isAnonymousHttpImageUrl } from './fetch-url.js'\nimport {\n formatGeneratedLabel,\n priceListFilename,\n resolvePriceListLabels,\n} from './labels.js'\nimport {\n buildPriceListLayout,\n resolvePreviewImageConcurrency,\n validatePriceListInput,\n} from './layout.js'\nimport {\n googleSheetsImageFormula,\n tryNormalizePreviewSquare,\n tryRasterizeLogo,\n} from './preview-image.js'\nimport { resolveLogoBytes, resolvePreviewBytes } from './resolve-media.js'\nimport {\n buildCurrencyTotalSumIfFormula,\n buildLineSumFormula,\n buildTotalSumFormula,\n} from './sum-formula.js'\nimport type {\n PriceListInput,\n PriceListSheetModel,\n RenderPriceListXlsxResult,\n} from './types.js'\n\nfunction uniqueCurrencies(input: PriceListInput): string[] {\n const set = new Set<string>()\n for (const row of input.rows) {\n const c = row.currency?.trim()\n if (c) set.add(c)\n }\n return [...set].sort()\n}\n\n/**\n * Render a wholesale price-list workbook.\n * Single price column; Sum = Quantity × Price; Total at bottom.\n */\nexport async function renderPriceListXlsx(\n input: PriceListInput,\n): Promise<RenderPriceListXlsxResult> {\n const normalized = validatePriceListInput(input)\n const warnings: string[] = []\n const labels = resolvePriceListLabels(normalized.locale, normalized.labels)\n const layout = buildPriceListLayout(normalized)\n const title = labels.title\n const currencies = uniqueCurrencies(normalized)\n const multiCurrency = currencies.length > 1\n const concurrency = resolvePreviewImageConcurrency(normalized)\n\n const workbook = new ExcelJS.Workbook()\n workbook.creator = 'Mailoo'\n workbook.created = new Date(normalized.header.generatedAt)\n const sheetName =\n `${normalized.header.siteName}`.slice(0, 31) || title.slice(0, 31)\n const sheet = workbook.addWorksheet(sheetName, {\n properties: { defaultRowHeight: layout.dataRowHeightPt },\n views: [{ state: 'frozen', ySplit: layout.headerRow }],\n pageSetup: {\n orientation: 'landscape',\n fitToPage: true,\n fitToWidth: 1,\n fitToHeight: 0,\n },\n })\n\n for (const col of layout.columns) {\n let width = 16\n if (col.key === 'photo') width = layout.photoColWidthChars\n else if (col.key === 'link') width = 14\n else if (col.key === 'quantity' || col.key === 'sum' || col.key === 'price')\n width = 12\n else if (col.key === 'currencyHidden') width = 0\n else if (col.key === 'product') width = 28\n sheet.getColumn(col.index).width = width\n if (col.key === 'currencyHidden') {\n sheet.getColumn(col.index).hidden = true\n }\n }\n\n // Banner: site name, contacts, generated\n sheet.getCell('A1').value = normalized.header.siteName\n sheet.getCell('A1').font = { bold: true, size: 16 }\n sheet.mergeCells(1, 1, 1, Math.min(5, layout.columns.length))\n\n sheet.getCell('A2').value = normalized.header.contacts\n sheet.getCell('A2').alignment = { wrapText: true, vertical: 'top' }\n const contactLines = normalized.header.contacts.split(/\\r?\\n/).length\n sheet.getRow(2).height = Math.max(36, contactLines * 14)\n\n sheet.getCell('A3').value = formatGeneratedLabel(\n labels.generated,\n normalized.header.generatedAt,\n normalized.locale,\n normalized.header.timeZone,\n )\n sheet.getCell('A3').font = { italic: true, size: 10 }\n\n const logoBytes = await resolveLogoBytes(normalized)\n if (logoBytes) {\n const { png, error } = await tryRasterizeLogo(logoBytes)\n if (png) {\n const imageId = workbook.addImage({\n buffer: png as unknown as ExcelJS.Buffer,\n extension: 'png',\n })\n sheet.addImage(imageId, {\n tl: { col: 5, row: 0 },\n ext: { width: 120, height: 40 },\n editAs: 'oneCell',\n })\n } else if (error) {\n warnings.push(`header.logo: ${error}`)\n }\n }\n\n // Column headers\n const headerRow = sheet.getRow(layout.headerRow)\n headerRow.font = { bold: true }\n headerRow.height = 22\n for (const col of layout.columns) {\n if (col.key === 'currencyHidden') continue\n headerRow.getCell(col.index).value = col.header\n }\n sheet.autoFilter = {\n from: { row: layout.headerRow, column: 1 },\n to: {\n row: layout.headerRow,\n column: layout.columns.find((c) => c.key === 'sum')!.index,\n },\n }\n\n const sheetCells: PriceListSheetModel['cells'] = []\n const previewImageUrls: Array<string | null> = []\n\n const lastDataRow =\n normalized.rows.length === 0\n ? layout.firstDataRow - 1\n : layout.firstDataRow + normalized.rows.length - 1\n\n type PreviewPrep = {\n png: Buffer | null\n sheetsSafeUrl: string | null\n warning: string | null\n }\n\n const previewPrep = await mapWithConcurrency(\n normalized.rows,\n concurrency,\n async (row, i): Promise<PreviewPrep> => {\n const candidateUrl = row.previewImageUrl?.trim() || null\n const sheetsSafeUrl =\n candidateUrl && isAnonymousHttpImageUrl(candidateUrl)\n ? candidateUrl\n : null\n try {\n const previewBytes = await resolvePreviewBytes(normalized, i)\n if (!previewBytes) {\n return { png: null, sheetsSafeUrl, warning: null }\n }\n const { png, error } = await tryNormalizePreviewSquare(\n previewBytes,\n layout.photoSizePx,\n )\n if (png) return { png, sheetsSafeUrl, warning: null }\n return {\n png: null,\n sheetsSafeUrl,\n warning: error\n ? `rows[${i}].previewImage: ${error}`\n : `rows[${i}].previewImage: undecodable`,\n }\n } catch (e) {\n const msg = e instanceof Error ? e.message : String(e)\n return {\n png: null,\n sheetsSafeUrl,\n warning: `rows[${i}].previewImage: ${msg}`,\n }\n }\n },\n )\n\n for (let i = 0; i < normalized.rows.length; i++) {\n const row = normalized.rows[i]!\n const excelRow = layout.firstDataRow + i\n const sheetRow = sheet.getRow(excelRow)\n sheetRow.height = layout.dataRowHeightPt\n\n const photoCol = layout.columns.find((c) => c.key === 'photo')!\n const catCol = layout.columns.find((c) => c.key === 'category')!\n const prodCol = layout.columns.find((c) => c.key === 'product')!\n const varCol = layout.columns.find((c) => c.key === 'variant')!\n const packCol = layout.columns.find((c) => c.key === 'packaging')!\n const priceCol = layout.columns.find((c) => c.key === 'price')!\n const linkCol = layout.columns.find((c) => c.key === 'link')!\n const qtyCol = layout.columns.find((c) => c.key === 'quantity')!\n const sumCol = layout.columns.find((c) => c.key === 'sum')!\n const curCol = layout.columns.find((c) => c.key === 'currencyHidden')!\n\n sheetRow.getCell(catCol.index).value = row.category ?? ''\n sheetRow.getCell(prodCol.index).value = row.product\n sheetRow.getCell(varCol.index).value = row.variant ?? ''\n sheetRow.getCell(packCol.index).value = row.packaging ?? ''\n\n if (row.unitPrice === null) {\n sheetRow.getCell(priceCol.index).value = labels.onRequest\n } else {\n sheetRow.getCell(priceCol.index).value = row.unitPrice\n sheetRow.getCell(priceCol.index).numFmt = '#,##0.00'\n }\n\n sheetRow.getCell(linkCol.index).value = {\n text: labels.linkText,\n hyperlink: row.productUrl,\n }\n sheetCells.push({\n a1: `${linkCol.letter}${excelRow}`,\n value: labels.linkText,\n formula: `HYPERLINK(\"${row.productUrl.replace(/\"/g, '\"\"')}\",\"${labels.linkText.replace(/\"/g, '\"\"')}\")`,\n })\n\n sheetRow.getCell(qtyCol.index).value = null\n const sumFormula = buildLineSumFormula({ layout, row: excelRow })\n sheetRow.getCell(sumCol.index).value = { formula: sumFormula }\n sheetRow.getCell(sumCol.index).numFmt = '#,##0.00'\n sheetCells.push({\n a1: `${sumCol.letter}${excelRow}`,\n value: null,\n formula: sumFormula,\n })\n\n sheetRow.getCell(curCol.index).value = row.currency?.trim() || ''\n\n sheetRow.getCell(qtyCol.index).dataValidation = {\n type: 'whole',\n operator: 'greaterThanOrEqual',\n formulae: [0],\n allowBlank: true,\n showErrorMessage: true,\n errorTitle: labels.quantity,\n error: '>= 0',\n }\n\n const prep = previewPrep[i]!\n previewImageUrls.push(prep.sheetsSafeUrl)\n if (prep.warning) warnings.push(prep.warning)\n if (prep.png) {\n const imageId = workbook.addImage({\n buffer: prep.png as unknown as ExcelJS.Buffer,\n extension: 'png',\n })\n sheet.addImage(imageId, {\n tl: { col: photoCol.index - 1, row: excelRow - 1 },\n ext: { width: layout.photoSizePx, height: layout.photoSizePx },\n editAs: 'oneCell',\n })\n } else if (prep.sheetsSafeUrl) {\n sheetCells.push({\n a1: `${photoCol.letter}${excelRow}`,\n value: null,\n formula: googleSheetsImageFormula(\n prep.sheetsSafeUrl,\n layout.photoSizePx,\n ),\n })\n }\n }\n\n // Total row\n const totalExcelRow = layout.totalRow\n const qtyColIdx = layout.columns.find((c) => c.key === 'quantity')!.index\n const sumColIdx = layout.columns.find((c) => c.key === 'sum')!.index\n sheet.getRow(totalExcelRow).getCell(qtyColIdx).value = labels.total\n sheet.getRow(totalExcelRow).getCell(qtyColIdx).font = { bold: true }\n\n if (!multiCurrency) {\n const totalFormula = buildTotalSumFormula({\n layout,\n firstDataRow: layout.firstDataRow,\n lastDataRow,\n })\n sheet.getRow(totalExcelRow).getCell(sumColIdx).value = {\n formula: totalFormula,\n }\n sheet.getRow(totalExcelRow).getCell(sumColIdx).font = { bold: true }\n sheet.getRow(totalExcelRow).getCell(sumColIdx).numFmt = '#,##0.00'\n sheetCells.push({\n a1: `${layout.sumColLetter}${totalExcelRow}`,\n value: null,\n formula: totalFormula,\n })\n } else {\n let offset = 0\n for (const currency of currencies) {\n const r = totalExcelRow + offset\n sheet.getRow(r).getCell(qtyColIdx).value =\n offset === 0 ? `${labels.total} (${currency})` : currency\n sheet.getRow(r).getCell(qtyColIdx).font = { bold: true }\n const f = buildCurrencyTotalSumIfFormula({\n layout,\n firstDataRow: layout.firstDataRow,\n lastDataRow,\n currency,\n })\n sheet.getRow(r).getCell(sumColIdx).value = { formula: f }\n sheet.getRow(r).getCell(sumColIdx).font = { bold: true }\n sheet.getRow(r).getCell(sumColIdx).numFmt = '#,##0.00'\n sheetCells.push({\n a1: `${layout.sumColLetter}${r}`,\n value: null,\n formula: f,\n })\n offset += 1\n }\n }\n\n const buffer = Buffer.from(await workbook.xlsx.writeBuffer())\n const filename = priceListFilename(\n normalized.locale,\n normalized.header.generatedAt,\n labels.filenamePrefix,\n normalized.header.timeZone,\n )\n\n const sheetModel: PriceListSheetModel = {\n title,\n locale: normalized.locale,\n layout,\n cells: sheetCells,\n previewImageUrls,\n logoUrl: normalized.header.logoUrl?.trim() || null,\n }\n\n return {\n buffer,\n filename,\n contentType:\n 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',\n layout,\n sheetModel,\n warnings,\n }\n}\n\n/** @deprecated Use `renderPriceListXlsx`. */\nexport const buildWholesalePriceListXlsx = renderPriceListXlsx\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,aAAa;AA8BpB,SAAS,iBAAiB,OAAiC;AACzD,QAAM,MAAM,oBAAI,IAAY;AAC5B,aAAW,OAAO,MAAM,MAAM;AAC5B,UAAM,IAAI,IAAI,UAAU,KAAK;AAC7B,QAAI,EAAG,KAAI,IAAI,CAAC;AAAA,EAClB;AACA,SAAO,CAAC,GAAG,GAAG,EAAE,KAAK;AACvB;AAMA,eAAsB,oBACpB,OACoC;AACpC,QAAM,aAAa,uBAAuB,KAAK;AAC/C,QAAM,WAAqB,CAAC;AAC5B,QAAM,SAAS,uBAAuB,WAAW,QAAQ,WAAW,MAAM;AAC1E,QAAM,SAAS,qBAAqB,UAAU;AAC9C,QAAM,QAAQ,OAAO;AACrB,QAAM,aAAa,iBAAiB,UAAU;AAC9C,QAAM,gBAAgB,WAAW,SAAS;AAC1C,QAAM,cAAc,+BAA+B,UAAU;AAE7D,QAAM,WAAW,IAAI,QAAQ,SAAS;AACtC,WAAS,UAAU;AACnB,WAAS,UAAU,IAAI,KAAK,WAAW,OAAO,WAAW;AACzD,QAAM,YACJ,GAAG,WAAW,OAAO,QAAQ,GAAG,MAAM,GAAG,EAA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W,KAAK;AAAA,QACd,IAAI,GAAG,OAAO,YAAY,GAAG,CAAC;AAAA,QAC9B,OAAO;AAAA,QACP,SAAS;AAAA,MACX,CAAC;AACD,gBAAU;AAAA,IACZ;AAAA,EACF;AAEA,QAAM,SAAS,OAAO,KAAK,MAAM,SAAS,KAAK,YAAY,CAAC;AAC5D,QAAM,WAAW;AAAA,IACf,WAAW;AAAA,IACX,WAAW,OAAO;AAAA,IAClB,OAAO;AAAA,IACP,WAAW,OAAO;AAAA,EACpB;AAEA,QAAM,aAAkC;AAAA,IACtC;AAAA,IACA,QAAQ,WAAW;AAAA,IACnB;AAAA,IACA,OAAO;AAAA,IACP;AAAA,IACA,SAAS,WAAW,OAAO,SAAS,KAAK,KAAK;AAAA,EAChD;AAEA,SAAO;AAAA,IACL;AAAA,IACA;AAAA,IACA,aACE;AAAA,IACF;AAAA,IACA;AAAA,IACA;AAAA,EACF;AACF;AAGO,IAAM,8BAA8B;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@mailoo/market",
3
- "version": "1.35.10",
3
+ "version": "1.35.13",
4
4
  "description": "Mailoo Market typed catalog, writes, pricing, orders and offers clients for Next.js and Node jobs",
5
5
  "license": "LicenseRef-Mailoo-NoModification",
6
6
  "homepage": "https://mailoo.app/en/support/docs/integrations/nextjs-packages",
@@ -40,6 +40,16 @@
40
40
  "types": "./dist/node/index.d.ts",
41
41
  "import": "./dist/node/index.js",
42
42
  "require": "./dist/node/index.cjs"
43
+ },
44
+ "./wholesale-price-list": {
45
+ "types": "./dist/wholesale-price-list/index.d.ts",
46
+ "import": "./dist/wholesale-price-list/index.js",
47
+ "require": "./dist/wholesale-price-list/index.cjs"
48
+ },
49
+ "./wholesale-price-list/google-sheets": {
50
+ "types": "./dist/wholesale-price-list/google-sheets/index.d.ts",
51
+ "import": "./dist/wholesale-price-list/google-sheets/index.js",
52
+ "require": "./dist/wholesale-price-list/google-sheets/index.cjs"
43
53
  }
44
54
  },
45
55
  "files": [
@@ -49,11 +59,18 @@
49
59
  ],
50
60
  "peerDependencies": {
51
61
  "@mailoo/next-core": "^1.35.6",
62
+ "googleapis": "^148.0.0",
52
63
  "next": ">=16.4.2"
53
64
  },
65
+ "peerDependenciesMeta": {
66
+ "googleapis": {
67
+ "optional": true
68
+ }
69
+ },
54
70
  "devDependencies": {
55
- "@mailoo/next-core": "1.35.10",
71
+ "@mailoo/next-core": "1.35.13",
56
72
  "@types/node": "^25.9.9",
73
+ "googleapis": "148.0.0",
57
74
  "next": "^16.4.3",
58
75
  "tsup": "^8.5.1",
59
76
  "typescript": "^5.9.3",
@@ -62,6 +79,10 @@
62
79
  "engines": {
63
80
  "node": ">=20.20.2"
64
81
  },
82
+ "dependencies": {
83
+ "exceljs": "4.4.0",
84
+ "sharp": "0.35.5"
85
+ },
65
86
  "scripts": {
66
87
  "build": "tsup",
67
88
  "clean": "rm -rf dist .turbo",