@memberjunction/core-actions 5.23.0 → 5.25.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/custom/files/add-document-content.action.d.ts +20 -0
- package/dist/custom/files/add-document-content.action.d.ts.map +1 -0
- package/dist/custom/files/add-document-content.action.js +74 -0
- package/dist/custom/files/add-document-content.action.js.map +1 -0
- package/dist/custom/files/base-file-storage.action.d.ts +6 -9
- package/dist/custom/files/base-file-storage.action.d.ts.map +1 -1
- package/dist/custom/files/base-file-storage.action.js +14 -39
- package/dist/custom/files/base-file-storage.action.js.map +1 -1
- package/dist/custom/files/create-document.action.d.ts +19 -0
- package/dist/custom/files/create-document.action.d.ts.map +1 -0
- package/dist/custom/files/create-document.action.js +65 -0
- package/dist/custom/files/create-document.action.js.map +1 -0
- package/dist/custom/files/excel-reader.action.js +1 -1
- package/dist/custom/files/excel-reader.action.js.map +1 -1
- package/dist/custom/files/finalize-document.action.d.ts +21 -0
- package/dist/custom/files/finalize-document.action.d.ts.map +1 -0
- package/dist/custom/files/finalize-document.action.js +94 -0
- package/dist/custom/files/finalize-document.action.js.map +1 -0
- package/dist/custom/files/index.d.ts +5 -0
- package/dist/custom/files/index.d.ts.map +1 -1
- package/dist/custom/files/index.js +6 -0
- package/dist/custom/files/index.js.map +1 -1
- package/dist/custom/files/list-storage-providers.action.d.ts.map +1 -1
- package/dist/custom/files/list-storage-providers.action.js +6 -33
- package/dist/custom/files/list-storage-providers.action.js.map +1 -1
- package/dist/custom/files/modify-document-section.action.d.ts +19 -0
- package/dist/custom/files/modify-document-section.action.d.ts.map +1 -0
- package/dist/custom/files/modify-document-section.action.js +85 -0
- package/dist/custom/files/modify-document-section.action.js.map +1 -0
- package/dist/custom/files/pdf-extractor.action.d.ts +8 -14
- package/dist/custom/files/pdf-extractor.action.d.ts.map +1 -1
- package/dist/custom/files/pdf-extractor.action.js +89 -91
- package/dist/custom/files/pdf-extractor.action.js.map +1 -1
- package/dist/custom/files/preview-document.action.d.ts +17 -0
- package/dist/custom/files/preview-document.action.d.ts.map +1 -0
- package/dist/custom/files/preview-document.action.js +50 -0
- package/dist/custom/files/preview-document.action.js.map +1 -0
- package/dist/custom/geo/scheduled-geocoding.action.d.ts +135 -0
- package/dist/custom/geo/scheduled-geocoding.action.d.ts.map +1 -0
- package/dist/custom/geo/scheduled-geocoding.action.js +428 -0
- package/dist/custom/geo/scheduled-geocoding.action.js.map +1 -0
- package/dist/custom/search/search.action.d.ts +67 -0
- package/dist/custom/search/search.action.d.ts.map +1 -0
- package/dist/custom/search/search.action.js +211 -0
- package/dist/custom/search/search.action.js.map +1 -0
- package/dist/custom/utilities/artifact-builder-service.d.ts +139 -0
- package/dist/custom/utilities/artifact-builder-service.d.ts.map +1 -0
- package/dist/custom/utilities/artifact-builder-service.js +338 -0
- package/dist/custom/utilities/artifact-builder-service.js.map +1 -0
- package/dist/custom/utilities/base-file-handler.d.ts +25 -3
- package/dist/custom/utilities/base-file-handler.d.ts.map +1 -1
- package/dist/custom/utilities/base-file-handler.js +81 -28
- package/dist/custom/utilities/base-file-handler.js.map +1 -1
- package/dist/custom/utilities/docx-renderer.d.ts +61 -0
- package/dist/custom/utilities/docx-renderer.d.ts.map +1 -0
- package/dist/custom/utilities/docx-renderer.js +409 -0
- package/dist/custom/utilities/docx-renderer.js.map +1 -0
- package/dist/custom/utilities/pdf-renderer.d.ts +53 -0
- package/dist/custom/utilities/pdf-renderer.d.ts.map +1 -0
- package/dist/custom/utilities/pdf-renderer.js +315 -0
- package/dist/custom/utilities/pdf-renderer.js.map +1 -0
- package/dist/custom/utilities/xlsx-renderer.d.ts +120 -0
- package/dist/custom/utilities/xlsx-renderer.d.ts.map +1 -0
- package/dist/custom/utilities/xlsx-renderer.js +165 -0
- package/dist/custom/utilities/xlsx-renderer.js.map +1 -0
- package/dist/index.d.ts +2 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -2
- package/dist/index.js.map +1 -1
- package/package.json +31 -27
- package/dist/custom/files/excel-writer.action.d.ts +0 -88
- package/dist/custom/files/excel-writer.action.d.ts.map +0 -1
- package/dist/custom/files/excel-writer.action.js +0 -326
- package/dist/custom/files/excel-writer.action.js.map +0 -1
- package/dist/custom/files/pdf-generator.action.d.ts +0 -66
- package/dist/custom/files/pdf-generator.action.d.ts.map +0 -1
- package/dist/custom/files/pdf-generator.action.js +0 -254
- package/dist/custom/files/pdf-generator.action.js.map +0 -1
|
@@ -0,0 +1,338 @@
|
|
|
1
|
+
import { DEFAULT_PDF_OPTIONS, renderPDFFromNodes } from './pdf-renderer.js';
|
|
2
|
+
import { DEFAULT_WORD_OPTIONS, renderDocxFromSections } from './docx-renderer.js';
|
|
3
|
+
import { renderExcelFromSheets } from './xlsx-renderer.js';
|
|
4
|
+
// ── TTL ───────────────────────────────────────────────────────────────────────
|
|
5
|
+
const TTL_MS = 30 * 60 * 1000; // 30 minutes
|
|
6
|
+
const CLEANUP_INTERVAL_MS = 5 * 60 * 1000; // Check every 5 minutes
|
|
7
|
+
// ── Service ───────────────────────────────────────────────────────────────────
|
|
8
|
+
/**
|
|
9
|
+
* Singleton service managing in-progress documents.
|
|
10
|
+
* Each document is identified by a UUID handle and persists across agent turns
|
|
11
|
+
* within the same Node.js process.
|
|
12
|
+
*/
|
|
13
|
+
export class ArtifactBuilderService {
|
|
14
|
+
static { this._instance = null; }
|
|
15
|
+
constructor() {
|
|
16
|
+
this.documents = new Map();
|
|
17
|
+
this.cleanupTimer = null;
|
|
18
|
+
this.startCleanupTimer();
|
|
19
|
+
}
|
|
20
|
+
static get Instance() {
|
|
21
|
+
if (!ArtifactBuilderService._instance) {
|
|
22
|
+
ArtifactBuilderService._instance = new ArtifactBuilderService();
|
|
23
|
+
}
|
|
24
|
+
return ArtifactBuilderService._instance;
|
|
25
|
+
}
|
|
26
|
+
// ── Lifecycle ─────────────────────────────────────────────────────────────
|
|
27
|
+
/**
|
|
28
|
+
* Create a new in-progress document and return its handle.
|
|
29
|
+
*/
|
|
30
|
+
CreateDocument(documentType, fileName, options) {
|
|
31
|
+
const handle = crypto.randomUUID();
|
|
32
|
+
const defaultFileName = this.defaultFileName(documentType);
|
|
33
|
+
const doc = {
|
|
34
|
+
handle,
|
|
35
|
+
documentType,
|
|
36
|
+
fileName: fileName || defaultFileName,
|
|
37
|
+
options: options || {},
|
|
38
|
+
sections: [],
|
|
39
|
+
createdAt: new Date(),
|
|
40
|
+
lastModifiedAt: new Date(),
|
|
41
|
+
};
|
|
42
|
+
this.documents.set(handle, doc);
|
|
43
|
+
return handle;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Add content operations as a new section to an existing document.
|
|
47
|
+
* Returns the section ID(s) created.
|
|
48
|
+
*/
|
|
49
|
+
AddContent(handle, operations) {
|
|
50
|
+
const doc = this.getDocument(handle);
|
|
51
|
+
const sectionId = crypto.randomUUID();
|
|
52
|
+
doc.sections.push({ id: sectionId, operations });
|
|
53
|
+
doc.lastModifiedAt = new Date();
|
|
54
|
+
return [sectionId];
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Get a preview of the document's current state.
|
|
58
|
+
*/
|
|
59
|
+
GetPreview(handle) {
|
|
60
|
+
const doc = this.getDocument(handle);
|
|
61
|
+
return {
|
|
62
|
+
handle: doc.handle,
|
|
63
|
+
documentType: doc.documentType,
|
|
64
|
+
fileName: doc.fileName,
|
|
65
|
+
sectionCount: doc.sections.length,
|
|
66
|
+
sections: doc.sections.map(s => ({
|
|
67
|
+
id: s.id,
|
|
68
|
+
operationCount: s.operations.length,
|
|
69
|
+
summary: this.summarizeSection(s),
|
|
70
|
+
})),
|
|
71
|
+
totalOperations: doc.sections.reduce((sum, s) => sum + s.operations.length, 0),
|
|
72
|
+
};
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Replace a section's content by ID.
|
|
76
|
+
*/
|
|
77
|
+
ReplaceSection(handle, sectionId, operations) {
|
|
78
|
+
const doc = this.getDocument(handle);
|
|
79
|
+
const section = doc.sections.find(s => s.id === sectionId);
|
|
80
|
+
if (!section) {
|
|
81
|
+
throw new Error(`Section "${sectionId}" not found in document "${handle}"`);
|
|
82
|
+
}
|
|
83
|
+
section.operations = operations;
|
|
84
|
+
doc.lastModifiedAt = new Date();
|
|
85
|
+
}
|
|
86
|
+
/**
|
|
87
|
+
* Remove a section by ID.
|
|
88
|
+
*/
|
|
89
|
+
RemoveSection(handle, sectionId) {
|
|
90
|
+
const doc = this.getDocument(handle);
|
|
91
|
+
const index = doc.sections.findIndex(s => s.id === sectionId);
|
|
92
|
+
if (index === -1) {
|
|
93
|
+
throw new Error(`Section "${sectionId}" not found in document "${handle}"`);
|
|
94
|
+
}
|
|
95
|
+
doc.sections.splice(index, 1);
|
|
96
|
+
doc.lastModifiedAt = new Date();
|
|
97
|
+
}
|
|
98
|
+
/**
|
|
99
|
+
* Render the accumulated document to a binary buffer.
|
|
100
|
+
* The handle is disposed after finalization.
|
|
101
|
+
*/
|
|
102
|
+
async Finalize(handle) {
|
|
103
|
+
const doc = this.getDocument(handle);
|
|
104
|
+
if (doc.sections.length === 0) {
|
|
105
|
+
throw new Error(`Cannot finalize an empty document (handle: "${handle}")`);
|
|
106
|
+
}
|
|
107
|
+
const allOperations = doc.sections.flatMap(s => s.operations);
|
|
108
|
+
let buffer;
|
|
109
|
+
let mimeType;
|
|
110
|
+
switch (doc.documentType) {
|
|
111
|
+
case 'pdf':
|
|
112
|
+
buffer = await this.finalizePDF(allOperations, doc.options.pdf);
|
|
113
|
+
mimeType = 'application/pdf';
|
|
114
|
+
break;
|
|
115
|
+
case 'docx':
|
|
116
|
+
buffer = await this.finalizeDocx(allOperations, doc.options.word);
|
|
117
|
+
mimeType = 'application/vnd.openxmlformats-officedocument.wordprocessingml.document';
|
|
118
|
+
break;
|
|
119
|
+
case 'xlsx':
|
|
120
|
+
buffer = await this.finalizeXlsx(allOperations, doc.options.excel);
|
|
121
|
+
mimeType = 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet';
|
|
122
|
+
break;
|
|
123
|
+
default:
|
|
124
|
+
throw new Error(`Unsupported document type: ${doc.documentType}`);
|
|
125
|
+
}
|
|
126
|
+
const fileName = doc.fileName;
|
|
127
|
+
this.documents.delete(handle);
|
|
128
|
+
return { buffer, fileName, mimeType };
|
|
129
|
+
}
|
|
130
|
+
/**
|
|
131
|
+
* Dispose a document handle without finalizing.
|
|
132
|
+
*/
|
|
133
|
+
Dispose(handle) {
|
|
134
|
+
this.documents.delete(handle);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Check if a handle exists.
|
|
138
|
+
*/
|
|
139
|
+
HasDocument(handle) {
|
|
140
|
+
return this.documents.has(handle);
|
|
141
|
+
}
|
|
142
|
+
// ── Finalization renderers ────────────────────────────────────────────────
|
|
143
|
+
async finalizePDF(operations, pdfOpts) {
|
|
144
|
+
const options = { ...DEFAULT_PDF_OPTIONS, ...pdfOpts };
|
|
145
|
+
const nodes = this.operationsToPDFNodes(operations);
|
|
146
|
+
return renderPDFFromNodes(nodes, options);
|
|
147
|
+
}
|
|
148
|
+
async finalizeDocx(operations, wordOpts) {
|
|
149
|
+
const options = { ...DEFAULT_WORD_OPTIONS, ...wordOpts };
|
|
150
|
+
const sections = this.operationsToDocxSections(operations);
|
|
151
|
+
return renderDocxFromSections(sections, options);
|
|
152
|
+
}
|
|
153
|
+
async finalizeXlsx(operations, excelOpts) {
|
|
154
|
+
const sheets = this.operationsToSheets(operations);
|
|
155
|
+
if (sheets.length === 0) {
|
|
156
|
+
throw new Error('No sheet operations found. Excel documents require at least one "sheet" operation.');
|
|
157
|
+
}
|
|
158
|
+
const result = await renderExcelFromSheets(sheets, excelOpts || {});
|
|
159
|
+
return result.buffer;
|
|
160
|
+
}
|
|
161
|
+
// ── Operation → renderer format converters ────────────────────────────────
|
|
162
|
+
operationsToPDFNodes(operations) {
|
|
163
|
+
const nodes = [];
|
|
164
|
+
for (const op of operations) {
|
|
165
|
+
switch (op.type) {
|
|
166
|
+
case 'heading':
|
|
167
|
+
nodes.push({ type: 'heading', level: op.level, text: op.text });
|
|
168
|
+
break;
|
|
169
|
+
case 'paragraph':
|
|
170
|
+
nodes.push({ type: 'paragraph', text: op.text, bold: op.bold, italic: op.italic });
|
|
171
|
+
break;
|
|
172
|
+
case 'table':
|
|
173
|
+
nodes.push({ type: 'table', headers: op.headers, rows: op.rows });
|
|
174
|
+
break;
|
|
175
|
+
case 'list':
|
|
176
|
+
nodes.push({ type: 'list', items: op.items, ordered: op.ordered ?? false });
|
|
177
|
+
break;
|
|
178
|
+
case 'image':
|
|
179
|
+
nodes.push({ type: 'image', src: op.src, alt: op.caption });
|
|
180
|
+
break;
|
|
181
|
+
case 'hr':
|
|
182
|
+
nodes.push({ type: 'hr' });
|
|
183
|
+
break;
|
|
184
|
+
case 'pageBreak':
|
|
185
|
+
// pdfkit doesn't have a direct page break node; use hr as separator
|
|
186
|
+
nodes.push({ type: 'br' });
|
|
187
|
+
break;
|
|
188
|
+
// Skip Excel-specific operations in PDF
|
|
189
|
+
case 'sheet':
|
|
190
|
+
case 'formula':
|
|
191
|
+
break;
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return nodes;
|
|
195
|
+
}
|
|
196
|
+
operationsToDocxSections(operations) {
|
|
197
|
+
const sections = [];
|
|
198
|
+
let currentSection = { content: [] };
|
|
199
|
+
for (const op of operations) {
|
|
200
|
+
switch (op.type) {
|
|
201
|
+
case 'heading':
|
|
202
|
+
// Headings start new sections
|
|
203
|
+
if (currentSection.heading || (currentSection.content?.length ?? 0) > 0) {
|
|
204
|
+
sections.push(currentSection);
|
|
205
|
+
}
|
|
206
|
+
currentSection = {
|
|
207
|
+
heading: op.text,
|
|
208
|
+
level: op.level,
|
|
209
|
+
content: [],
|
|
210
|
+
};
|
|
211
|
+
break;
|
|
212
|
+
case 'paragraph':
|
|
213
|
+
currentSection.content = currentSection.content ?? [];
|
|
214
|
+
currentSection.content.push({
|
|
215
|
+
type: 'paragraph',
|
|
216
|
+
text: op.text,
|
|
217
|
+
bold: op.bold,
|
|
218
|
+
italic: op.italic,
|
|
219
|
+
align: op.align,
|
|
220
|
+
});
|
|
221
|
+
break;
|
|
222
|
+
case 'table':
|
|
223
|
+
currentSection.content = currentSection.content ?? [];
|
|
224
|
+
currentSection.content.push({
|
|
225
|
+
type: 'table',
|
|
226
|
+
headers: op.headers,
|
|
227
|
+
rows: op.rows,
|
|
228
|
+
});
|
|
229
|
+
break;
|
|
230
|
+
case 'list':
|
|
231
|
+
currentSection.content = currentSection.content ?? [];
|
|
232
|
+
currentSection.content.push({
|
|
233
|
+
type: 'list',
|
|
234
|
+
items: op.items,
|
|
235
|
+
ordered: op.ordered ?? false,
|
|
236
|
+
});
|
|
237
|
+
break;
|
|
238
|
+
case 'image':
|
|
239
|
+
currentSection.content = currentSection.content ?? [];
|
|
240
|
+
currentSection.content.push({
|
|
241
|
+
type: 'image',
|
|
242
|
+
url: op.src,
|
|
243
|
+
width: op.width,
|
|
244
|
+
height: op.height,
|
|
245
|
+
caption: op.caption,
|
|
246
|
+
});
|
|
247
|
+
break;
|
|
248
|
+
// Skip page breaks, hr, and Excel-specific ops for DOCX
|
|
249
|
+
case 'pageBreak':
|
|
250
|
+
case 'hr':
|
|
251
|
+
case 'sheet':
|
|
252
|
+
case 'formula':
|
|
253
|
+
break;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
// Push remaining section
|
|
257
|
+
if (currentSection.heading || (currentSection.content?.length ?? 0) > 0) {
|
|
258
|
+
sections.push(currentSection);
|
|
259
|
+
}
|
|
260
|
+
return sections;
|
|
261
|
+
}
|
|
262
|
+
operationsToSheets(operations) {
|
|
263
|
+
const sheets = [];
|
|
264
|
+
const formulasBySheet = new Map();
|
|
265
|
+
// Collect formulas first
|
|
266
|
+
for (const op of operations) {
|
|
267
|
+
if (op.type === 'formula') {
|
|
268
|
+
const existing = formulasBySheet.get(op.sheet) || [];
|
|
269
|
+
existing.push({ cell: op.cell, formula: op.formula });
|
|
270
|
+
formulasBySheet.set(op.sheet, existing);
|
|
271
|
+
}
|
|
272
|
+
}
|
|
273
|
+
// Build sheets
|
|
274
|
+
for (const op of operations) {
|
|
275
|
+
if (op.type === 'sheet') {
|
|
276
|
+
const sheet = {
|
|
277
|
+
name: op.name,
|
|
278
|
+
data: op.data,
|
|
279
|
+
headers: op.headers,
|
|
280
|
+
columnWidths: op.columnWidths,
|
|
281
|
+
};
|
|
282
|
+
const formulas = formulasBySheet.get(op.name);
|
|
283
|
+
if (formulas) {
|
|
284
|
+
sheet.formulas = formulas;
|
|
285
|
+
}
|
|
286
|
+
sheets.push(sheet);
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
return sheets;
|
|
290
|
+
}
|
|
291
|
+
// ── Helpers ───────────────────────────────────────────────────────────────
|
|
292
|
+
getDocument(handle) {
|
|
293
|
+
const doc = this.documents.get(handle);
|
|
294
|
+
if (!doc) {
|
|
295
|
+
throw new Error(`Document handle "${handle}" not found. It may have been finalized or expired.`);
|
|
296
|
+
}
|
|
297
|
+
return doc;
|
|
298
|
+
}
|
|
299
|
+
defaultFileName(documentType) {
|
|
300
|
+
switch (documentType) {
|
|
301
|
+
case 'pdf': return 'document.pdf';
|
|
302
|
+
case 'docx': return 'document.docx';
|
|
303
|
+
case 'xlsx': return 'workbook.xlsx';
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
summarizeSection(section) {
|
|
307
|
+
const ops = section.operations;
|
|
308
|
+
if (ops.length === 0)
|
|
309
|
+
return '(empty)';
|
|
310
|
+
const typeCounts = {};
|
|
311
|
+
for (const op of ops) {
|
|
312
|
+
typeCounts[op.type] = (typeCounts[op.type] || 0) + 1;
|
|
313
|
+
}
|
|
314
|
+
const parts = Object.entries(typeCounts).map(([type, count]) => count === 1 ? type : `${count} ${type}s`);
|
|
315
|
+
// Include first heading text if present
|
|
316
|
+
const firstHeading = ops.find(op => op.type === 'heading');
|
|
317
|
+
if (firstHeading && firstHeading.type === 'heading') {
|
|
318
|
+
return `"${firstHeading.text}" — ${parts.join(', ')}`;
|
|
319
|
+
}
|
|
320
|
+
return parts.join(', ');
|
|
321
|
+
}
|
|
322
|
+
// ── TTL cleanup ───────────────────────────────────────────────────────────
|
|
323
|
+
startCleanupTimer() {
|
|
324
|
+
this.cleanupTimer = setInterval(() => {
|
|
325
|
+
const now = Date.now();
|
|
326
|
+
for (const [handle, doc] of this.documents) {
|
|
327
|
+
if (now - doc.lastModifiedAt.getTime() > TTL_MS) {
|
|
328
|
+
this.documents.delete(handle);
|
|
329
|
+
}
|
|
330
|
+
}
|
|
331
|
+
}, CLEANUP_INTERVAL_MS);
|
|
332
|
+
// Don't prevent Node.js from exiting
|
|
333
|
+
if (this.cleanupTimer && typeof this.cleanupTimer === 'object' && 'unref' in this.cleanupTimer) {
|
|
334
|
+
this.cleanupTimer.unref();
|
|
335
|
+
}
|
|
336
|
+
}
|
|
337
|
+
}
|
|
338
|
+
//# sourceMappingURL=artifact-builder-service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"artifact-builder-service.js","sourceRoot":"","sources":["../../../src/custom/utilities/artifact-builder-service.ts"],"names":[],"mappings":"AAYA,OAAO,EAA2B,mBAAmB,EAAE,kBAAkB,EAAa,MAAM,gBAAgB,CAAC;AAC7G,OAAO,EAA6C,oBAAoB,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC1H,OAAO,EAAsC,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAyD5F,iFAAiF;AAEjF,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,aAAa;AAC5C,MAAM,mBAAmB,GAAG,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC,wBAAwB;AAEnE,iFAAiF;AAEjF;;;;GAIG;AACH,MAAM,OAAO,sBAAsB;aAChB,cAAS,GAAkC,IAAI,AAAtC,CAAuC;IAI/D;QAHQ,cAAS,GAAoC,IAAI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I,IAAI,GAAG,CAC3C,CAAC;QAEF,wCAAwC;QACxC,MAAM,YAAY,GAAG,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;QAC3D,IAAI,YAAY,IAAI,YAAY,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAClD,OAAO,IAAI,YAAY,CAAC,IAAI,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;QAC1D,CAAC;QAED,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IAC5B,CAAC;IAED,6EAA6E;IAErE,iBAAiB;QACrB,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC,GAAG,EAAE;YACjC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;YACvB,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;gBACzC,IAAI,GAAG,GAAG,GAAG,CAAC,cAAc,CAAC,OAAO,EAAE,GAAG,MAAM,EAAE,CAAC;oBAC9C,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;gBAClC,CAAC;YACL,CAAC;QACL,CAAC,EAAE,mBAAmB,CAAC,CAAC;QAExB,qCAAqC;QACrC,IAAI,IAAI,CAAC,YAAY,IAAI,OAAO,IAAI,CAAC,YAAY,KAAK,QAAQ,IAAI,OAAO,IAAI,IAAI,CAAC,YAAY,EAAE,CAAC;YAC7F,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;QAC9B,CAAC;IACL,CAAC"}
|
|
@@ -25,7 +25,7 @@ export declare abstract class BaseFileHandlerAction extends BaseAction {
|
|
|
25
25
|
source: 'storage' | 'url' | 'direct';
|
|
26
26
|
}>;
|
|
27
27
|
/**
|
|
28
|
-
* Load file from MJ Storage (
|
|
28
|
+
* Load file from MJ Storage (MJ: Files entity)
|
|
29
29
|
*/
|
|
30
30
|
private loadFromMJStorage;
|
|
31
31
|
/**
|
|
@@ -33,9 +33,31 @@ export declare abstract class BaseFileHandlerAction extends BaseAction {
|
|
|
33
33
|
*/
|
|
34
34
|
private loadFromURL;
|
|
35
35
|
/**
|
|
36
|
-
* Save file to MJ Storage
|
|
36
|
+
* Save file to MJ Storage. Uploads the content to a FileStorageAccount
|
|
37
|
+
* and creates the corresponding MJ: Files entity record.
|
|
38
|
+
*
|
|
39
|
+
* @param content - File content as string or Buffer
|
|
40
|
+
* @param fileName - Name for the file
|
|
41
|
+
* @param mimeType - MIME type of the file
|
|
42
|
+
* @param params - Action parameters (for contextUser)
|
|
43
|
+
* @param storageAccountName - Optional: name of the storage account to use (falls back to first active)
|
|
44
|
+
* @param storagePath - Optional: custom storage path prefix (falls back to `artifacts/{date}/{uuid}/`)
|
|
45
|
+
* @returns The ID of the newly created MJ: Files record
|
|
46
|
+
*/
|
|
47
|
+
protected saveToMJStorage(content: string | Buffer, fileName: string, mimeType: string, params: RunActionParams, storageAccountName?: string, storagePath?: string): Promise<string>;
|
|
48
|
+
/**
|
|
49
|
+
* Finds a FileStorageAccount by name using the engine's cached metadata.
|
|
50
|
+
*/
|
|
51
|
+
private loadStorageAccountByName;
|
|
52
|
+
/**
|
|
53
|
+
* Resolves a storage account ID from the agent's resolution chain (via Context)
|
|
54
|
+
* or falls back to the first active account via FileStorageEngine.
|
|
55
|
+
*/
|
|
56
|
+
private resolveStorageAccountId;
|
|
57
|
+
/**
|
|
58
|
+
* Initializes a storage driver for the given file using the engine's cached metadata.
|
|
37
59
|
*/
|
|
38
|
-
|
|
60
|
+
private initializeDriverForFile;
|
|
39
61
|
/**
|
|
40
62
|
* Extract parameter value by name (case-insensitive)
|
|
41
63
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-file-handler.d.ts","sourceRoot":"","sources":["../../../src/custom/utilities/base-file-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;
|
|
1
|
+
{"version":3,"file":"base-file-handler.d.ts","sourceRoot":"","sources":["../../../src/custom/utilities/base-file-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,eAAe,EAAE,MAAM,8BAA8B,CAAC;AAK/D;;;;;;GAMG;AACH,8BAAsB,qBAAsB,SAAQ,UAAU;IAC1D;;;;;;;;;OASG;cACa,cAAc,CAC1B,MAAM,EAAE,eAAe,EACvB,aAAa,EAAE,MAAM,EACrB,aAAa,GAAE,MAAiB,EAChC,YAAY,GAAE,MAAkB,GACjC,OAAO,CAAC;QACP,OAAO,EAAE,MAAM,GAAG,MAAM,CAAC;QACzB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,MAAM,EAAE,SAAS,GAAG,KAAK,GAAG,QAAQ,CAAC;KACxC,CAAC;IAyBF;;OAEG;YACW,iBAAiB;IAkC/B;;OAEG;YACW,WAAW;IAgDzB;;;;;;;;;;;OAWG;cACa,eAAe,CAC3B,OAAO,EAAE,MAAM,GAAG,MAAM,EACxB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,eAAe,EACvB,kBAAkB,CAAC,EAAE,MAAM,EAC3B,WAAW,CAAC,EAAE,MAAM,GACrB,OAAO,CAAC,MAAM,CAAC;IAiClB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAQhC;;;OAGG;YACW,uBAAuB;IAarC;;OAEG;YACW,uBAAuB;IASrC;;OAEG;IACH,SAAS,CAAC,aAAa,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,GAAG,GAAG;IAKxE;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,OAAe,GAAG,OAAO;IAM7G;;OAEG;IACH,SAAS,CAAC,eAAe,CAAC,MAAM,EAAE,eAAe,EAAE,SAAS,EAAE,MAAM,EAAE,YAAY,GAAE,MAAU,GAAG,MAAM;CAM1G"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { BaseAction } from "@memberjunction/actions";
|
|
2
|
-
import {
|
|
2
|
+
import { RunView } from "@memberjunction/core";
|
|
3
|
+
import { FileStorageEngine } from "@memberjunction/storage";
|
|
3
4
|
/**
|
|
4
5
|
* Base class for actions that handle file inputs from multiple sources
|
|
5
6
|
* Provides common functionality for loading files from:
|
|
@@ -40,26 +41,27 @@ export class BaseFileHandlerAction extends BaseAction {
|
|
|
40
41
|
throw new Error(`No input provided. Please provide ${fileParamName}, ${urlParamName}, or ${dataParamName}`);
|
|
41
42
|
}
|
|
42
43
|
/**
|
|
43
|
-
* Load file from MJ Storage (
|
|
44
|
+
* Load file from MJ Storage (MJ: Files entity)
|
|
44
45
|
*/
|
|
45
46
|
async loadFromMJStorage(fileId, params) {
|
|
46
47
|
try {
|
|
47
48
|
const rv = new RunView();
|
|
48
|
-
const
|
|
49
|
-
EntityName: '
|
|
49
|
+
const fileResult = await rv.RunView({
|
|
50
|
+
EntityName: 'MJ: Files',
|
|
50
51
|
ExtraFilter: `ID = '${fileId}'`,
|
|
51
52
|
ResultType: 'entity_object'
|
|
52
53
|
}, params.ContextUser);
|
|
53
|
-
if (!
|
|
54
|
-
throw new Error(`File not found in
|
|
54
|
+
if (!fileResult.Success || fileResult.Results.length === 0) {
|
|
55
|
+
throw new Error(`File not found in MJ: Files: ${fileId}`);
|
|
55
56
|
}
|
|
56
|
-
const
|
|
57
|
-
|
|
58
|
-
|
|
57
|
+
const file = fileResult.Results[0];
|
|
58
|
+
const driver = await this.initializeDriverForFile(file, params);
|
|
59
|
+
const objectName = file.ProviderKey ?? file.Name;
|
|
60
|
+
const content = await driver.GetObject({ fullPath: objectName });
|
|
59
61
|
return {
|
|
60
|
-
content
|
|
61
|
-
fileName:
|
|
62
|
-
mimeType:
|
|
62
|
+
content,
|
|
63
|
+
fileName: file.Name,
|
|
64
|
+
mimeType: file.ContentType ?? undefined,
|
|
63
65
|
source: 'storage'
|
|
64
66
|
};
|
|
65
67
|
}
|
|
@@ -108,31 +110,82 @@ export class BaseFileHandlerAction extends BaseAction {
|
|
|
108
110
|
}
|
|
109
111
|
}
|
|
110
112
|
/**
|
|
111
|
-
* Save file to MJ Storage
|
|
113
|
+
* Save file to MJ Storage. Uploads the content to a FileStorageAccount
|
|
114
|
+
* and creates the corresponding MJ: Files entity record.
|
|
115
|
+
*
|
|
116
|
+
* @param content - File content as string or Buffer
|
|
117
|
+
* @param fileName - Name for the file
|
|
118
|
+
* @param mimeType - MIME type of the file
|
|
119
|
+
* @param params - Action parameters (for contextUser)
|
|
120
|
+
* @param storageAccountName - Optional: name of the storage account to use (falls back to first active)
|
|
121
|
+
* @param storagePath - Optional: custom storage path prefix (falls back to `artifacts/{date}/{uuid}/`)
|
|
122
|
+
* @returns The ID of the newly created MJ: Files record
|
|
112
123
|
*/
|
|
113
|
-
async saveToMJStorage(content, fileName, mimeType, params) {
|
|
124
|
+
async saveToMJStorage(content, fileName, mimeType, params, storageAccountName, storagePath) {
|
|
114
125
|
try {
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
126
|
+
await FileStorageEngine.Instance.Config(false, params.ContextUser);
|
|
127
|
+
// Resolve storage account ID
|
|
128
|
+
let storageAccountId;
|
|
129
|
+
if (storageAccountName) {
|
|
130
|
+
const account = this.loadStorageAccountByName(storageAccountName);
|
|
131
|
+
storageAccountId = account.ID;
|
|
119
132
|
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
// TODO: Set appropriate fields based on your Document Libraries schema
|
|
123
|
-
// doc.Set('FileSize', Buffer.byteLength(content));
|
|
124
|
-
// doc.Set('StorageProvider', 'default');
|
|
125
|
-
const saveResult = await doc.Save();
|
|
126
|
-
if (!saveResult) {
|
|
127
|
-
throw new Error('Failed to save document to library');
|
|
133
|
+
else {
|
|
134
|
+
storageAccountId = await this.resolveStorageAccountId(params);
|
|
128
135
|
}
|
|
129
|
-
|
|
130
|
-
|
|
136
|
+
const buffer = Buffer.isBuffer(content) ? content : Buffer.from(content);
|
|
137
|
+
const pathPrefix = storagePath
|
|
138
|
+
? storagePath.replace(/\/+$/, '')
|
|
139
|
+
: undefined;
|
|
140
|
+
const result = await FileStorageEngine.Instance.UploadFile({
|
|
141
|
+
content: buffer,
|
|
142
|
+
fileName,
|
|
143
|
+
mimeType,
|
|
144
|
+
contextUser: params.ContextUser,
|
|
145
|
+
storageAccountId,
|
|
146
|
+
pathPrefix
|
|
147
|
+
});
|
|
148
|
+
return result.FileID;
|
|
131
149
|
}
|
|
132
150
|
catch (error) {
|
|
133
151
|
throw new Error(`Failed to save file to storage: ${error instanceof Error ? error.message : String(error)}`);
|
|
134
152
|
}
|
|
135
153
|
}
|
|
154
|
+
/**
|
|
155
|
+
* Finds a FileStorageAccount by name using the engine's cached metadata.
|
|
156
|
+
*/
|
|
157
|
+
loadStorageAccountByName(accountName) {
|
|
158
|
+
const account = FileStorageEngine.Instance.GetAccountByName(accountName);
|
|
159
|
+
if (!account) {
|
|
160
|
+
throw new Error(`FileStorageAccount "${accountName}" not found. Check account name or use default.`);
|
|
161
|
+
}
|
|
162
|
+
return account;
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* Resolves a storage account ID from the agent's resolution chain (via Context)
|
|
166
|
+
* or falls back to the first active account via FileStorageEngine.
|
|
167
|
+
*/
|
|
168
|
+
async resolveStorageAccountId(params) {
|
|
169
|
+
// Check for agent-resolved storage account ID (passed via Context by BaseAgent)
|
|
170
|
+
const context = params.Context;
|
|
171
|
+
const resolvedId = context?.__resolvedStorageAccountId;
|
|
172
|
+
if (resolvedId) {
|
|
173
|
+
return resolvedId.toString();
|
|
174
|
+
}
|
|
175
|
+
// Fallback: pick first active via engine
|
|
176
|
+
const resolved = FileStorageEngine.Instance.ResolveStorageAccount();
|
|
177
|
+
return resolved?.account.ID;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Initializes a storage driver for the given file using the engine's cached metadata.
|
|
181
|
+
*/
|
|
182
|
+
async initializeDriverForFile(file, params) {
|
|
183
|
+
const accounts = FileStorageEngine.Instance.GetAccountsByProviderID(file.ProviderID);
|
|
184
|
+
if (accounts.length === 0) {
|
|
185
|
+
throw new Error(`No FileStorageAccount found for ProviderID ${file.ProviderID}`);
|
|
186
|
+
}
|
|
187
|
+
return FileStorageEngine.Instance.GetDriver(accounts[0].ID, params.ContextUser);
|
|
188
|
+
}
|
|
136
189
|
/**
|
|
137
190
|
* Extract parameter value by name (case-insensitive)
|
|
138
191
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"base-file-handler.js","sourceRoot":"","sources":["../../../src/custom/utilities/base-file-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"base-file-handler.js","sourceRoot":"","sources":["../../../src/custom/utilities/base-file-handler.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAErD,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAE/C,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAE5D;;;;;;GAMG;AACH,MAAM,OAAgB,qBAAsB,SAAQ,UAAU;IAC1D;;;;;;;;;OASG;IACO,KAAK,CAAC,cAAc,CAC1B,MAAuB,EACvB,aAAqB,EACrB,gBAAwB,QAAQ,EAChC,eAAuB,SAAS;QAOhC,sCAAsC;QACtC,MAAM,WAAW,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC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EG;IACO,aAAa,CAAC,MAAuB,EAAE,SAAiB;QAC9D,MAAM,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,KAAK,SAAS,CAAC,WAAW,EAAE,CAAC,CAAC;QAC/F,OAAO,KAAK,EAAE,KAAK,CAAC;IACxB,CAAC;IAED;;OAEG;IACO,eAAe,CAAC,MAAuB,EAAE,SAAiB,EAAE,eAAwB,KAAK;QAC/F,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACpD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,YAAY,CAAC;QAC/D,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,KAAK,MAAM,CAAC;IAClD,CAAC;IAED;;OAEG;IACO,eAAe,CAAC,MAAuB,EAAE,SAAiB,EAAE,eAAuB,CAAC;QAC1F,MAAM,KAAK,GAAG,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE,SAAS,CAAC,CAAC;QACpD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI;YAAE,OAAO,YAAY,CAAC;QAC/D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,CAAC;QAC1B,OAAO,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC,GAAG,CAAC;IAC3C,CAAC;CACJ"}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
export interface WordOptions {
|
|
2
|
+
pageSize: 'Letter' | 'A4';
|
|
3
|
+
orientation: 'portrait' | 'landscape';
|
|
4
|
+
margins: {
|
|
5
|
+
top: number;
|
|
6
|
+
bottom: number;
|
|
7
|
+
left: number;
|
|
8
|
+
right: number;
|
|
9
|
+
};
|
|
10
|
+
defaultFontSize: number;
|
|
11
|
+
defaultFont: string;
|
|
12
|
+
}
|
|
13
|
+
export type DocxContentItem = {
|
|
14
|
+
type: 'paragraph';
|
|
15
|
+
text: string;
|
|
16
|
+
bold?: boolean;
|
|
17
|
+
italic?: boolean;
|
|
18
|
+
align?: string;
|
|
19
|
+
} | {
|
|
20
|
+
type: 'list';
|
|
21
|
+
items: string[];
|
|
22
|
+
ordered: boolean;
|
|
23
|
+
} | {
|
|
24
|
+
type: 'table';
|
|
25
|
+
headers: string[];
|
|
26
|
+
rows: string[][];
|
|
27
|
+
} | {
|
|
28
|
+
type: 'image';
|
|
29
|
+
url: string;
|
|
30
|
+
width?: number;
|
|
31
|
+
height?: number;
|
|
32
|
+
caption?: string;
|
|
33
|
+
};
|
|
34
|
+
export interface DocxSection {
|
|
35
|
+
heading?: string;
|
|
36
|
+
level?: number;
|
|
37
|
+
content?: DocxContentItem[];
|
|
38
|
+
}
|
|
39
|
+
export declare const DEFAULT_WORD_OPTIONS: WordOptions;
|
|
40
|
+
/** A raw item as an agent might send it — either a content item or a section wrapper */
|
|
41
|
+
type RawSectionItem = Record<string, unknown>;
|
|
42
|
+
/**
|
|
43
|
+
* Render an array of DocxSection to a DOCX buffer.
|
|
44
|
+
*/
|
|
45
|
+
export declare function renderDocxFromSections(sections: DocxSection[], options: WordOptions): Promise<Buffer>;
|
|
46
|
+
/**
|
|
47
|
+
* Accepts both formats agents may produce:
|
|
48
|
+
*
|
|
49
|
+
* Structured (canonical):
|
|
50
|
+
* [{ heading: "Title", level: 1, content: [{ type: "paragraph", text: "..." }] }]
|
|
51
|
+
*
|
|
52
|
+
* Flat (what most LLM agents naturally emit):
|
|
53
|
+
* [{ type: "heading", level: 1, text: "Title" }, { type: "paragraph", text: "..." }]
|
|
54
|
+
*/
|
|
55
|
+
export declare function normalizeSections(items: RawSectionItem[]): DocxSection[];
|
|
56
|
+
/**
|
|
57
|
+
* Lightweight HTML → structured sections converter using htmlparser2.
|
|
58
|
+
*/
|
|
59
|
+
export declare function htmlToSections(html: string): DocxSection[];
|
|
60
|
+
export {};
|
|
61
|
+
//# sourceMappingURL=docx-renderer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"docx-renderer.d.ts","sourceRoot":"","sources":["../../../src/custom/utilities/docx-renderer.ts"],"names":[],"mappings":"AAsBA,MAAM,WAAW,WAAW;IACxB,QAAQ,EAAE,QAAQ,GAAG,IAAI,CAAC;IAC1B,WAAW,EAAE,UAAU,GAAG,WAAW,CAAC;IACtC,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,MAAM,CAAC;QAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC;IACtE,eAAe,EAAE,MAAM,CAAC;IACxB,WAAW,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,MAAM,eAAe,GACrB;IAAE,IAAI,EAAE,WAAW,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,GACrF;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,OAAO,CAAA;CAAE,GACnD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAC;IAAC,IAAI,EAAE,MAAM,EAAE,EAAE,CAAA;CAAE,GACtD;IAAE,IAAI,EAAE,OAAO,CAAC;IAAC,GAAG,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAExF,MAAM,WAAW,WAAW;IACxB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,M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