digital-tools 2.0.2 → 2.1.1
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/CHANGELOG.md +17 -0
- package/package.json +3 -4
- package/src/define.js +267 -0
- package/src/entities/advertising.js +999 -0
- package/src/entities/ai.js +756 -0
- package/src/entities/analytics.js +1588 -0
- package/src/entities/automation.js +601 -0
- package/src/entities/communication.js +1150 -0
- package/src/entities/crm.js +1386 -0
- package/src/entities/design.js +546 -0
- package/src/entities/development.js +2212 -0
- package/src/entities/document.js +874 -0
- package/src/entities/ecommerce.js +1429 -0
- package/src/entities/experiment.js +1039 -0
- package/src/entities/finance.js +3478 -0
- package/src/entities/forms.js +1892 -0
- package/src/entities/hr.js +661 -0
- package/src/entities/identity.js +997 -0
- package/src/entities/index.js +282 -0
- package/src/entities/infrastructure.js +1153 -0
- package/src/entities/knowledge.js +1438 -0
- package/src/entities/marketing.js +1610 -0
- package/src/entities/media.js +1634 -0
- package/src/entities/notification.js +1199 -0
- package/src/entities/presentation.js +1274 -0
- package/src/entities/productivity.js +1317 -0
- package/src/entities/project-management.js +1136 -0
- package/src/entities/recruiting.js +736 -0
- package/src/entities/shipping.js +509 -0
- package/src/entities/signature.js +1102 -0
- package/src/entities/site.js +222 -0
- package/src/entities/spreadsheet.js +1341 -0
- package/src/entities/storage.js +1198 -0
- package/src/entities/support.js +1166 -0
- package/src/entities/video-conferencing.js +1750 -0
- package/src/entities/video.js +950 -0
- package/src/entities.js +1663 -0
- package/src/index.js +74 -0
- package/src/providers/analytics/index.js +17 -0
- package/src/providers/analytics/mixpanel.js +255 -0
- package/src/providers/calendar/cal-com.js +303 -0
- package/src/providers/calendar/google-calendar.js +335 -0
- package/src/providers/calendar/index.js +20 -0
- package/src/providers/crm/hubspot.js +566 -0
- package/src/providers/crm/index.js +17 -0
- package/src/providers/development/github.js +472 -0
- package/src/providers/development/index.js +17 -0
- package/src/providers/ecommerce/index.js +17 -0
- package/src/providers/ecommerce/shopify.js +378 -0
- package/src/providers/email/index.js +20 -0
- package/src/providers/email/resend.js +258 -0
- package/src/providers/email/sendgrid.js +161 -0
- package/src/providers/finance/index.js +17 -0
- package/src/providers/finance/stripe.js +549 -0
- package/src/providers/forms/index.js +17 -0
- package/src/providers/forms/typeform.js +500 -0
- package/src/providers/index.js +123 -0
- package/src/providers/knowledge/index.js +17 -0
- package/src/providers/knowledge/notion.js +389 -0
- package/src/providers/marketing/index.js +17 -0
- package/src/providers/marketing/mailchimp.js +443 -0
- package/src/providers/media/cloudinary.js +318 -0
- package/src/providers/media/index.js +17 -0
- package/src/providers/messaging/index.js +20 -0
- package/src/providers/messaging/slack.js +393 -0
- package/src/providers/messaging/twilio-sms.js +249 -0
- package/src/providers/project-management/index.js +17 -0
- package/src/providers/project-management/linear.js +575 -0
- package/src/providers/registry.js +86 -0
- package/src/providers/spreadsheet/google-sheets.js +375 -0
- package/src/providers/spreadsheet/index.js +20 -0
- package/src/providers/spreadsheet/xlsx.js +423 -0
- package/src/providers/storage/index.js +24 -0
- package/src/providers/storage/s3.js +419 -0
- package/src/providers/support/index.js +17 -0
- package/src/providers/support/zendesk.js +373 -0
- package/src/providers/tasks/index.js +17 -0
- package/src/providers/tasks/todoist.js +286 -0
- package/src/providers/types.js +9 -0
- package/src/providers/video-conferencing/google-meet.js +286 -0
- package/src/providers/video-conferencing/index.js +31 -0
- package/src/providers/video-conferencing/jitsi.js +254 -0
- package/src/providers/video-conferencing/teams.js +270 -0
- package/src/providers/video-conferencing/zoom.js +332 -0
- package/src/registry.js +128 -0
- package/src/tools/communication.js +184 -0
- package/src/tools/data.js +205 -0
- package/src/tools/index.js +11 -0
- package/src/tools/web.js +137 -0
- package/src/types.js +10 -0
- package/test/define.test.js +306 -0
- package/test/registry.test.js +357 -0
- package/test/tools.test.js +363 -0
|
@@ -0,0 +1,423 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* XLSX Spreadsheet Provider
|
|
3
|
+
*
|
|
4
|
+
* Concrete implementation of SpreadsheetProvider using SheetJS (xlsx) library.
|
|
5
|
+
* Works with local .xlsx, .xls, .csv files.
|
|
6
|
+
*
|
|
7
|
+
* @packageDocumentation
|
|
8
|
+
*/
|
|
9
|
+
import { defineProvider } from '../registry.js';
|
|
10
|
+
/**
|
|
11
|
+
* XLSX provider info
|
|
12
|
+
*/
|
|
13
|
+
export const xlsxInfo = {
|
|
14
|
+
id: 'spreadsheet.xlsx',
|
|
15
|
+
name: 'XLSX (SheetJS)',
|
|
16
|
+
description: 'Local spreadsheet files using SheetJS library (.xlsx, .xls, .csv)',
|
|
17
|
+
category: 'spreadsheet',
|
|
18
|
+
website: 'https://sheetjs.com',
|
|
19
|
+
docsUrl: 'https://docs.sheetjs.com',
|
|
20
|
+
requiredConfig: [],
|
|
21
|
+
optionalConfig: ['basePath'],
|
|
22
|
+
};
|
|
23
|
+
// In-memory storage for spreadsheets (in real impl, would use filesystem)
|
|
24
|
+
const spreadsheets = new Map();
|
|
25
|
+
/**
|
|
26
|
+
* Create XLSX spreadsheet provider
|
|
27
|
+
*/
|
|
28
|
+
export function createXlsxProvider(config) {
|
|
29
|
+
let basePath;
|
|
30
|
+
function generateId() {
|
|
31
|
+
return `xlsx_${Date.now()}_${Math.random().toString(36).slice(2, 9)}`;
|
|
32
|
+
}
|
|
33
|
+
function parseRange(range) {
|
|
34
|
+
// Parse A1 notation like "Sheet1!A1:C10" or just "A1:C10"
|
|
35
|
+
let sheetName;
|
|
36
|
+
let cellRange = range;
|
|
37
|
+
if (range.includes('!')) {
|
|
38
|
+
const parts = range.split('!');
|
|
39
|
+
sheetName = parts[0].replace(/^'|'$/g, '');
|
|
40
|
+
cellRange = parts[1];
|
|
41
|
+
}
|
|
42
|
+
const [start, end] = cellRange.split(':');
|
|
43
|
+
const startCell = parseCell(start);
|
|
44
|
+
const endCell = end ? parseCell(end) : startCell;
|
|
45
|
+
return {
|
|
46
|
+
sheet: sheetName,
|
|
47
|
+
startRow: startCell.row,
|
|
48
|
+
startCol: startCell.col,
|
|
49
|
+
endRow: endCell.row,
|
|
50
|
+
endCol: endCell.col,
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function parseCell(cell) {
|
|
54
|
+
const match = cell.match(/^([A-Z]+)(\d+)$/);
|
|
55
|
+
if (!match) {
|
|
56
|
+
throw new Error(`Invalid cell reference: ${cell}`);
|
|
57
|
+
}
|
|
58
|
+
const colStr = match[1];
|
|
59
|
+
const row = parseInt(match[2], 10);
|
|
60
|
+
// Convert column letters to number (A=1, B=2, ..., Z=26, AA=27, etc.)
|
|
61
|
+
let col = 0;
|
|
62
|
+
for (let i = 0; i < colStr.length; i++) {
|
|
63
|
+
col = col * 26 + (colStr.charCodeAt(i) - 64);
|
|
64
|
+
}
|
|
65
|
+
return { row, col };
|
|
66
|
+
}
|
|
67
|
+
function colToLetter(col) {
|
|
68
|
+
let letter = '';
|
|
69
|
+
while (col > 0) {
|
|
70
|
+
const remainder = (col - 1) % 26;
|
|
71
|
+
letter = String.fromCharCode(65 + remainder) + letter;
|
|
72
|
+
col = Math.floor((col - 1) / 26);
|
|
73
|
+
}
|
|
74
|
+
return letter;
|
|
75
|
+
}
|
|
76
|
+
return {
|
|
77
|
+
info: xlsxInfo,
|
|
78
|
+
async initialize(cfg) {
|
|
79
|
+
basePath = cfg.basePath || './spreadsheets';
|
|
80
|
+
},
|
|
81
|
+
async healthCheck() {
|
|
82
|
+
return {
|
|
83
|
+
healthy: true,
|
|
84
|
+
latencyMs: 0,
|
|
85
|
+
message: 'XLSX provider ready (in-memory)',
|
|
86
|
+
checkedAt: new Date(),
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
async dispose() {
|
|
90
|
+
// Clear in-memory storage if needed
|
|
91
|
+
},
|
|
92
|
+
async create(name, options) {
|
|
93
|
+
const id = generateId();
|
|
94
|
+
const now = new Date();
|
|
95
|
+
const workbook = {
|
|
96
|
+
id,
|
|
97
|
+
name,
|
|
98
|
+
sheets: new Map(),
|
|
99
|
+
createdAt: now,
|
|
100
|
+
modifiedAt: now,
|
|
101
|
+
};
|
|
102
|
+
// Create default sheet or sheets from options
|
|
103
|
+
const sheetNames = options?.sheets?.map((s) => s.name) || ['Sheet1'];
|
|
104
|
+
sheetNames.forEach((sheetName, index) => {
|
|
105
|
+
workbook.sheets.set(sheetName, {
|
|
106
|
+
name: sheetName,
|
|
107
|
+
index,
|
|
108
|
+
data: [],
|
|
109
|
+
});
|
|
110
|
+
});
|
|
111
|
+
spreadsheets.set(id, workbook);
|
|
112
|
+
return {
|
|
113
|
+
id,
|
|
114
|
+
name,
|
|
115
|
+
sheets: Array.from(workbook.sheets.values()).map((s) => ({
|
|
116
|
+
id: s.name,
|
|
117
|
+
name: s.name,
|
|
118
|
+
index: s.index,
|
|
119
|
+
rowCount: s.data.length,
|
|
120
|
+
columnCount: s.data[0]?.length || 0,
|
|
121
|
+
})),
|
|
122
|
+
createdAt: now,
|
|
123
|
+
modifiedAt: now,
|
|
124
|
+
};
|
|
125
|
+
},
|
|
126
|
+
async get(spreadsheetId) {
|
|
127
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
128
|
+
if (!workbook)
|
|
129
|
+
return null;
|
|
130
|
+
return {
|
|
131
|
+
id: workbook.id,
|
|
132
|
+
name: workbook.name,
|
|
133
|
+
sheets: Array.from(workbook.sheets.values()).map((s) => ({
|
|
134
|
+
id: s.name,
|
|
135
|
+
name: s.name,
|
|
136
|
+
index: s.index,
|
|
137
|
+
rowCount: s.data.length,
|
|
138
|
+
columnCount: s.data[0]?.length || 0,
|
|
139
|
+
})),
|
|
140
|
+
createdAt: workbook.createdAt,
|
|
141
|
+
modifiedAt: workbook.modifiedAt,
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
async list(options) {
|
|
145
|
+
let items = Array.from(spreadsheets.values()).map((wb) => ({
|
|
146
|
+
id: wb.id,
|
|
147
|
+
name: wb.name,
|
|
148
|
+
sheets: Array.from(wb.sheets.values()).map((s) => ({
|
|
149
|
+
id: s.name,
|
|
150
|
+
name: s.name,
|
|
151
|
+
index: s.index,
|
|
152
|
+
})),
|
|
153
|
+
createdAt: wb.createdAt,
|
|
154
|
+
modifiedAt: wb.modifiedAt,
|
|
155
|
+
}));
|
|
156
|
+
if (options?.query) {
|
|
157
|
+
const q = options.query.toLowerCase();
|
|
158
|
+
items = items.filter((i) => i.name.toLowerCase().includes(q));
|
|
159
|
+
}
|
|
160
|
+
const offset = options?.offset || 0;
|
|
161
|
+
const limit = options?.limit || 100;
|
|
162
|
+
return {
|
|
163
|
+
items: items.slice(offset, offset + limit),
|
|
164
|
+
total: items.length,
|
|
165
|
+
hasMore: offset + limit < items.length,
|
|
166
|
+
};
|
|
167
|
+
},
|
|
168
|
+
async delete(spreadsheetId) {
|
|
169
|
+
return spreadsheets.delete(spreadsheetId);
|
|
170
|
+
},
|
|
171
|
+
async getSheet(spreadsheetId, sheetId) {
|
|
172
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
173
|
+
if (!workbook)
|
|
174
|
+
return null;
|
|
175
|
+
let sheet;
|
|
176
|
+
if (typeof sheetId === 'number') {
|
|
177
|
+
sheet = Array.from(workbook.sheets.values()).find((s) => s.index === sheetId);
|
|
178
|
+
}
|
|
179
|
+
else {
|
|
180
|
+
sheet = workbook.sheets.get(sheetId);
|
|
181
|
+
}
|
|
182
|
+
if (!sheet)
|
|
183
|
+
return null;
|
|
184
|
+
return {
|
|
185
|
+
id: sheet.name,
|
|
186
|
+
name: sheet.name,
|
|
187
|
+
index: sheet.index,
|
|
188
|
+
rowCount: sheet.data.length,
|
|
189
|
+
columnCount: sheet.data[0]?.length || 0,
|
|
190
|
+
data: sheet.data,
|
|
191
|
+
frozenRows: sheet.frozenRows,
|
|
192
|
+
frozenColumns: sheet.frozenColumns,
|
|
193
|
+
};
|
|
194
|
+
},
|
|
195
|
+
async addSheet(spreadsheetId, name, options) {
|
|
196
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
197
|
+
if (!workbook) {
|
|
198
|
+
throw new Error(`Spreadsheet ${spreadsheetId} not found`);
|
|
199
|
+
}
|
|
200
|
+
if (workbook.sheets.has(name)) {
|
|
201
|
+
throw new Error(`Sheet ${name} already exists`);
|
|
202
|
+
}
|
|
203
|
+
const index = options?.index ?? workbook.sheets.size;
|
|
204
|
+
const sheet = {
|
|
205
|
+
name,
|
|
206
|
+
index,
|
|
207
|
+
data: [],
|
|
208
|
+
};
|
|
209
|
+
workbook.sheets.set(name, sheet);
|
|
210
|
+
workbook.modifiedAt = new Date();
|
|
211
|
+
return {
|
|
212
|
+
id: name,
|
|
213
|
+
name,
|
|
214
|
+
index,
|
|
215
|
+
rowCount: 0,
|
|
216
|
+
columnCount: 0,
|
|
217
|
+
};
|
|
218
|
+
},
|
|
219
|
+
async deleteSheet(spreadsheetId, sheetId) {
|
|
220
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
221
|
+
if (!workbook)
|
|
222
|
+
return false;
|
|
223
|
+
let sheetName;
|
|
224
|
+
if (typeof sheetId === 'number') {
|
|
225
|
+
const sheet = Array.from(workbook.sheets.values()).find((s) => s.index === sheetId);
|
|
226
|
+
sheetName = sheet?.name;
|
|
227
|
+
}
|
|
228
|
+
else {
|
|
229
|
+
sheetName = sheetId;
|
|
230
|
+
}
|
|
231
|
+
if (!sheetName)
|
|
232
|
+
return false;
|
|
233
|
+
const deleted = workbook.sheets.delete(sheetName);
|
|
234
|
+
if (deleted) {
|
|
235
|
+
workbook.modifiedAt = new Date();
|
|
236
|
+
}
|
|
237
|
+
return deleted;
|
|
238
|
+
},
|
|
239
|
+
async renameSheet(spreadsheetId, sheetId, name) {
|
|
240
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
241
|
+
if (!workbook)
|
|
242
|
+
return false;
|
|
243
|
+
let oldName;
|
|
244
|
+
if (typeof sheetId === 'number') {
|
|
245
|
+
const sheet = Array.from(workbook.sheets.values()).find((s) => s.index === sheetId);
|
|
246
|
+
oldName = sheet?.name;
|
|
247
|
+
}
|
|
248
|
+
else {
|
|
249
|
+
oldName = sheetId;
|
|
250
|
+
}
|
|
251
|
+
if (!oldName || !workbook.sheets.has(oldName))
|
|
252
|
+
return false;
|
|
253
|
+
const sheet = workbook.sheets.get(oldName);
|
|
254
|
+
workbook.sheets.delete(oldName);
|
|
255
|
+
sheet.name = name;
|
|
256
|
+
workbook.sheets.set(name, sheet);
|
|
257
|
+
workbook.modifiedAt = new Date();
|
|
258
|
+
return true;
|
|
259
|
+
},
|
|
260
|
+
async readRange(spreadsheetId, range) {
|
|
261
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
262
|
+
if (!workbook) {
|
|
263
|
+
throw new Error(`Spreadsheet ${spreadsheetId} not found`);
|
|
264
|
+
}
|
|
265
|
+
const { sheet: sheetName, startRow, startCol, endRow, endCol } = parseRange(range);
|
|
266
|
+
// Get sheet (default to first sheet)
|
|
267
|
+
const sheet = sheetName
|
|
268
|
+
? workbook.sheets.get(sheetName)
|
|
269
|
+
: Array.from(workbook.sheets.values())[0];
|
|
270
|
+
if (!sheet) {
|
|
271
|
+
throw new Error(`Sheet not found`);
|
|
272
|
+
}
|
|
273
|
+
const result = [];
|
|
274
|
+
for (let row = startRow; row <= endRow; row++) {
|
|
275
|
+
const rowData = [];
|
|
276
|
+
for (let col = startCol; col <= endCol; col++) {
|
|
277
|
+
const value = sheet.data[row - 1]?.[col - 1] ?? null;
|
|
278
|
+
rowData.push(value);
|
|
279
|
+
}
|
|
280
|
+
result.push(rowData);
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
},
|
|
284
|
+
async writeRange(spreadsheetId, range, values) {
|
|
285
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
286
|
+
if (!workbook) {
|
|
287
|
+
throw new Error(`Spreadsheet ${spreadsheetId} not found`);
|
|
288
|
+
}
|
|
289
|
+
const { sheet: sheetName, startRow, startCol } = parseRange(range);
|
|
290
|
+
// Get sheet (default to first sheet)
|
|
291
|
+
const sheet = sheetName
|
|
292
|
+
? workbook.sheets.get(sheetName)
|
|
293
|
+
: Array.from(workbook.sheets.values())[0];
|
|
294
|
+
if (!sheet) {
|
|
295
|
+
throw new Error(`Sheet not found`);
|
|
296
|
+
}
|
|
297
|
+
let updatedCells = 0;
|
|
298
|
+
values.forEach((rowValues, rowOffset) => {
|
|
299
|
+
const row = startRow + rowOffset - 1;
|
|
300
|
+
if (!sheet.data[row]) {
|
|
301
|
+
sheet.data[row] = [];
|
|
302
|
+
}
|
|
303
|
+
rowValues.forEach((value, colOffset) => {
|
|
304
|
+
const col = startCol + colOffset - 1;
|
|
305
|
+
sheet.data[row][col] = value;
|
|
306
|
+
updatedCells++;
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
workbook.modifiedAt = new Date();
|
|
310
|
+
const endRow = startRow + values.length - 1;
|
|
311
|
+
const endCol = startCol + (values[0]?.length || 0) - 1;
|
|
312
|
+
return {
|
|
313
|
+
updatedRange: `${sheetName || sheet.name}!${colToLetter(startCol)}${startRow}:${colToLetter(endCol)}${endRow}`,
|
|
314
|
+
updatedRows: values.length,
|
|
315
|
+
updatedColumns: values[0]?.length || 0,
|
|
316
|
+
updatedCells,
|
|
317
|
+
};
|
|
318
|
+
},
|
|
319
|
+
async appendRows(spreadsheetId, range, values) {
|
|
320
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
321
|
+
if (!workbook) {
|
|
322
|
+
throw new Error(`Spreadsheet ${spreadsheetId} not found`);
|
|
323
|
+
}
|
|
324
|
+
const { sheet: sheetName, startCol } = parseRange(range);
|
|
325
|
+
const sheet = sheetName
|
|
326
|
+
? workbook.sheets.get(sheetName)
|
|
327
|
+
: Array.from(workbook.sheets.values())[0];
|
|
328
|
+
if (!sheet) {
|
|
329
|
+
throw new Error(`Sheet not found`);
|
|
330
|
+
}
|
|
331
|
+
const startRow = sheet.data.length + 1;
|
|
332
|
+
values.forEach((rowValues, rowOffset) => {
|
|
333
|
+
const row = startRow + rowOffset - 1;
|
|
334
|
+
if (!sheet.data[row]) {
|
|
335
|
+
sheet.data[row] = [];
|
|
336
|
+
}
|
|
337
|
+
rowValues.forEach((value, colOffset) => {
|
|
338
|
+
const col = startCol + colOffset - 1;
|
|
339
|
+
sheet.data[row][col] = value;
|
|
340
|
+
});
|
|
341
|
+
});
|
|
342
|
+
workbook.modifiedAt = new Date();
|
|
343
|
+
const endRow = startRow + values.length - 1;
|
|
344
|
+
const endCol = startCol + (values[0]?.length || 0) - 1;
|
|
345
|
+
return {
|
|
346
|
+
spreadsheetId,
|
|
347
|
+
updatedRange: `${sheetName || sheet.name}!${colToLetter(startCol)}${startRow}:${colToLetter(endCol)}${endRow}`,
|
|
348
|
+
updatedRows: values.length,
|
|
349
|
+
};
|
|
350
|
+
},
|
|
351
|
+
async clearRange(spreadsheetId, range) {
|
|
352
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
353
|
+
if (!workbook)
|
|
354
|
+
return false;
|
|
355
|
+
const { sheet: sheetName, startRow, startCol, endRow, endCol } = parseRange(range);
|
|
356
|
+
const sheet = sheetName
|
|
357
|
+
? workbook.sheets.get(sheetName)
|
|
358
|
+
: Array.from(workbook.sheets.values())[0];
|
|
359
|
+
if (!sheet)
|
|
360
|
+
return false;
|
|
361
|
+
for (let row = startRow; row <= endRow; row++) {
|
|
362
|
+
if (sheet.data[row - 1]) {
|
|
363
|
+
for (let col = startCol; col <= endCol; col++) {
|
|
364
|
+
sheet.data[row - 1][col - 1] = null;
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
workbook.modifiedAt = new Date();
|
|
369
|
+
return true;
|
|
370
|
+
},
|
|
371
|
+
async batchRead(spreadsheetId, ranges) {
|
|
372
|
+
const result = new Map();
|
|
373
|
+
for (const range of ranges) {
|
|
374
|
+
const data = await this.readRange(spreadsheetId, range);
|
|
375
|
+
result.set(range, data);
|
|
376
|
+
}
|
|
377
|
+
return result;
|
|
378
|
+
},
|
|
379
|
+
async batchWrite(spreadsheetId, data) {
|
|
380
|
+
let totalCells = 0;
|
|
381
|
+
let totalRows = 0;
|
|
382
|
+
let totalCols = 0;
|
|
383
|
+
for (const { range, values } of data) {
|
|
384
|
+
const result = await this.writeRange(spreadsheetId, range, values);
|
|
385
|
+
totalCells += result.updatedCells;
|
|
386
|
+
totalRows += result.updatedRows;
|
|
387
|
+
totalCols = Math.max(totalCols, result.updatedColumns);
|
|
388
|
+
}
|
|
389
|
+
return {
|
|
390
|
+
updatedRange: 'batch',
|
|
391
|
+
updatedRows: totalRows,
|
|
392
|
+
updatedColumns: totalCols,
|
|
393
|
+
updatedCells: totalCells,
|
|
394
|
+
};
|
|
395
|
+
},
|
|
396
|
+
async export(spreadsheetId, format) {
|
|
397
|
+
// In a real implementation, this would use SheetJS to generate the file
|
|
398
|
+
const workbook = spreadsheets.get(spreadsheetId);
|
|
399
|
+
if (!workbook) {
|
|
400
|
+
throw new Error(`Spreadsheet ${spreadsheetId} not found`);
|
|
401
|
+
}
|
|
402
|
+
// Placeholder - would use xlsx.write() in real implementation
|
|
403
|
+
const content = JSON.stringify({
|
|
404
|
+
name: workbook.name,
|
|
405
|
+
sheets: Array.from(workbook.sheets.entries()).map(([name, sheet]) => ({
|
|
406
|
+
name,
|
|
407
|
+
data: sheet.data,
|
|
408
|
+
})),
|
|
409
|
+
});
|
|
410
|
+
return Buffer.from(content, 'utf-8');
|
|
411
|
+
},
|
|
412
|
+
async import(file, format, options) {
|
|
413
|
+
// In a real implementation, this would use SheetJS to parse the file
|
|
414
|
+
// For now, create an empty spreadsheet
|
|
415
|
+
const name = options?.name || `Imported_${Date.now()}`;
|
|
416
|
+
return this.create(name);
|
|
417
|
+
},
|
|
418
|
+
};
|
|
419
|
+
}
|
|
420
|
+
/**
|
|
421
|
+
* XLSX provider definition
|
|
422
|
+
*/
|
|
423
|
+
export const xlsxProvider = defineProvider(xlsxInfo, async (config) => createXlsxProvider(config));
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Storage Providers
|
|
3
|
+
*
|
|
4
|
+
* Concrete implementations for storage providers (S3, Google Cloud Storage, etc.)
|
|
5
|
+
*
|
|
6
|
+
* @packageDocumentation
|
|
7
|
+
*/
|
|
8
|
+
import { s3Provider, s3Info, createS3Provider } from './s3.js';
|
|
9
|
+
/**
|
|
10
|
+
* All storage providers
|
|
11
|
+
*/
|
|
12
|
+
export const storageProviders = [s3Provider];
|
|
13
|
+
/**
|
|
14
|
+
* Register all storage providers in the global registry
|
|
15
|
+
*/
|
|
16
|
+
export function registerStorageProviders() {
|
|
17
|
+
for (const provider of storageProviders) {
|
|
18
|
+
provider.register();
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
/**
|
|
22
|
+
* Re-export provider info and factories
|
|
23
|
+
*/
|
|
24
|
+
export { s3Provider, s3Info, createS3Provider };
|