docx-templates
Advanced tools
Comparing version 4.9.0 to 4.9.1
@@ -0,1 +1,4 @@ | ||
## 4.9.1 (2022-02-18) | ||
- [Issue #259](https://github.com/guigrpa/docx-templates/issues/259) Fix issue that caused inserted images to be overwritten when `createReport()` was invoked a second time on the resulting template. | ||
## 4.9.0 (2022-01-20) | ||
@@ -2,0 +5,0 @@ - Updated dependencies. |
@@ -220,2 +220,2 @@ /// <reference types="node" /> | ||
export { CommandExecutionError, CommandSyntaxError, ImageError, InternalError, InvalidCommandError, NullishCommandResultError, ObjectCommandResultError, TemplateParseError, createReport, createReport as default, getMetadata, listCommands }; | ||
export { CommandExecutionError, CommandSyntaxError, ImageError, InternalError, InvalidCommandError, NullishCommandResultError, ObjectCommandResultError, QueryResolver, TemplateParseError, createReport, createReport as default, getMetadata, listCommands }; |
import createReport from './main'; | ||
export { listCommands, getMetadata } from './main'; | ||
export { NullishCommandResultError, CommandSyntaxError, InvalidCommandError, CommandExecutionError, ImageError, InternalError, TemplateParseError, ObjectCommandResultError, } from './errors'; | ||
export { createReport }; | ||
import type { QueryResolver } from './types'; | ||
export { createReport, QueryResolver }; | ||
export default createReport; |
@@ -218,9 +218,9 @@ "use strict"; | ||
numHtmls = Object.keys(htmls1).length; | ||
return [4 /*yield*/, processImages(images1, mainDocument, zip, TEMPLATE_PATH)]; | ||
return [4 /*yield*/, processImages(images1, mainDocument, zip)]; | ||
case 8: | ||
_c.sent(); | ||
return [4 /*yield*/, processLinks(links1, mainDocument, zip, TEMPLATE_PATH)]; | ||
return [4 /*yield*/, processLinks(links1, mainDocument, zip)]; | ||
case 9: | ||
_c.sent(); | ||
return [4 /*yield*/, processHtmls(htmls1, mainDocument, zip, TEMPLATE_PATH)]; | ||
return [4 /*yield*/, processHtmls(htmls1, mainDocument, zip)]; | ||
case 10: | ||
@@ -249,9 +249,9 @@ _c.sent(); | ||
documentComponent = segments[segments.length - 1]; | ||
return [4 /*yield*/, processImages(images2, documentComponent, zip, TEMPLATE_PATH)]; | ||
return [4 /*yield*/, processImages(images2, documentComponent, zip)]; | ||
case 13: | ||
_c.sent(); | ||
return [4 /*yield*/, processLinks(links2, mainDocument, zip, TEMPLATE_PATH)]; | ||
return [4 /*yield*/, processLinks(links2, mainDocument, zip)]; | ||
case 14: | ||
_c.sent(); | ||
return [4 /*yield*/, processHtmls(htmls2, mainDocument, zip, TEMPLATE_PATH)]; | ||
return [4 /*yield*/, processHtmls(htmls2, mainDocument, zip)]; | ||
case 15: | ||
@@ -508,3 +508,3 @@ _c.sent(); | ||
exports.getMainDoc = getMainDoc; | ||
var processImages = function (images, documentComponent, zip, templatePath) { return __awaiter(void 0, void 0, void 0, function () { | ||
var processImages = function (images, documentComponent, zip) { return __awaiter(void 0, void 0, void 0, function () { | ||
var imageIds, relsPath, rels, i, imageId, _a, extension, imgData, imgName, imgPath, finalRelsXml; | ||
@@ -516,5 +516,6 @@ return __generator(this, function (_b) { | ||
imageIds = Object.keys(images); | ||
if (!imageIds.length) return [3 /*break*/, 2]; | ||
if (!imageIds.length) | ||
return [2 /*return*/]; | ||
debug_1.logger.debug('Completing document.xml.rels...'); | ||
relsPath = "".concat(templatePath, "/_rels/").concat(documentComponent, ".rels"); | ||
relsPath = "".concat(TEMPLATE_PATH, "/_rels/").concat(documentComponent, ".rels"); | ||
return [4 /*yield*/, getRelsFromZip(zip, relsPath)]; | ||
@@ -526,5 +527,5 @@ case 1: | ||
_a = images[imageId], extension = _a.extension, imgData = _a.data; | ||
imgName = "template_".concat(documentComponent, "_image").concat(i + 1).concat(extension); | ||
imgName = "template_".concat(documentComponent, "_").concat(imageId).concat(extension); | ||
debug_1.logger.debug("Writing image ".concat(imageId, " (").concat(imgName, ")...")); | ||
imgPath = "".concat(templatePath, "/media/").concat(imgName); | ||
imgPath = "".concat(TEMPLATE_PATH, "/media/").concat(imgName); | ||
if (typeof imgData === 'string') { | ||
@@ -546,8 +547,7 @@ (0, zip_1.zipSetBase64)(zip, imgPath, imgData); | ||
(0, zip_1.zipSetText)(zip, relsPath, finalRelsXml); | ||
_b.label = 2; | ||
case 2: return [2 /*return*/]; | ||
return [2 /*return*/]; | ||
} | ||
}); | ||
}); }; | ||
var processLinks = function (links, documentComponent, zip, templatePath) { return __awaiter(void 0, void 0, void 0, function () { | ||
var processLinks = function (links, documentComponent, zip) { return __awaiter(void 0, void 0, void 0, function () { | ||
var linkIds, relsPath, rels, _i, linkIds_1, linkId, url, finalRelsXml; | ||
@@ -561,3 +561,3 @@ return __generator(this, function (_a) { | ||
debug_1.logger.debug('Completing document.xml.rels...'); | ||
relsPath = "".concat(templatePath, "/_rels/").concat(documentComponent, ".rels"); | ||
relsPath = "".concat(TEMPLATE_PATH, "/_rels/").concat(documentComponent, ".rels"); | ||
return [4 /*yield*/, getRelsFromZip(zip, relsPath)]; | ||
@@ -585,3 +585,3 @@ case 1: | ||
}); }; | ||
var processHtmls = function (htmls, documentComponent, zip, templatePath) { return __awaiter(void 0, void 0, void 0, function () { | ||
var processHtmls = function (htmls, documentComponent, zip) { return __awaiter(void 0, void 0, void 0, function () { | ||
var htmlIds, htmlFiles, relsPath, rels, _i, htmlIds_1, htmlId, htmlData, htmlName, htmlPath, finalRelsXml; | ||
@@ -597,3 +597,3 @@ return __generator(this, function (_a) { | ||
htmlFiles = []; | ||
relsPath = "".concat(templatePath, "/_rels/").concat(documentComponent, ".rels"); | ||
relsPath = "".concat(TEMPLATE_PATH, "/_rels/").concat(documentComponent, ".rels"); | ||
return [4 /*yield*/, getRelsFromZip(zip, relsPath)]; | ||
@@ -607,3 +607,3 @@ case 1: | ||
debug_1.logger.debug("Writing html ".concat(htmlId, " (").concat(htmlName, ")...")); | ||
htmlPath = "".concat(templatePath, "/").concat(htmlName); | ||
htmlPath = "".concat(TEMPLATE_PATH, "/").concat(htmlName); | ||
htmlFiles.push("/".concat(htmlPath)); | ||
@@ -610,0 +610,0 @@ (0, zip_1.zipSetText)(zip, htmlPath, htmlData); |
@@ -25,3 +25,3 @@ /// <reference types="node" /> | ||
export declare type ReportData = any; | ||
declare type QueryResolver = (query: string | undefined, queryVars: any) => ReportData | Promise<ReportData>; | ||
export declare type QueryResolver = (query: string | undefined, queryVars: any) => ReportData | Promise<ReportData>; | ||
declare type ErrorHandler = (e: Error, raw_code?: string) => any; | ||
@@ -28,0 +28,0 @@ declare type RunJSFunc = (o: { |
{ | ||
"name": "docx-templates", | ||
"version": "4.9.0", | ||
"version": "4.9.1", | ||
"description": "Template-based docx report creation", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
3590
1447594