New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

docx-templates

Package Overview
Dependencies
Maintainers
2
Versions
63
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

docx-templates - npm Package Compare versions

Comparing version 4.11.1 to 4.11.2

4

CHANGELOG.md

@@ -0,1 +1,5 @@

## 4.11.2 (2023-07-14)
- Issue [#296](https://github.com/guigrpa/docx-templates/issues/296): Fix bug caused by Shapes having the same ID they are generated from a FOR loop. ([MR #315](https://github.com/guigrpa/docx-templates/pull/315)) Thanks @SuchiraD!
- Issue [#314](https://github.com/guigrpa/docx-templates/issues/314): Ensure all custom error types are exported.
## 4.11.1 (2023-04-04)

@@ -2,0 +6,0 @@ - ([MR #305](https://github.com/guigrpa/docx-templates/pull/305)) the `IncompleteConditionalStatementError` is now thrown when an 'IF' statement lacks a corresponding 'END-IF' command. Thanks @RoXuS !

5

lib/bundled.d.ts

@@ -234,3 +234,6 @@ type Buffer = ArrayBufferLike;

}
declare class IncompleteConditionalStatementError extends Error {
constructor();
}
export { CommandExecutionError, CommandSyntaxError, ImageError, InternalError, InvalidCommandError, NullishCommandResultError, ObjectCommandResultError, QueryResolver, TemplateParseError, createReport, createReport as default, getMetadata, listCommands };
export { CommandExecutionError, CommandSyntaxError, ImageError, IncompleteConditionalStatementError, 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 * from './errors';
import type { QueryResolver } from './types';
export { createReport, QueryResolver };
export default createReport;
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
var desc = Object.getOwnPropertyDescriptor(m, k);
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
desc = { enumerable: true, get: function() { return m[k]; } };
}
Object.defineProperty(o, k2, desc);
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __exportStar = (this && this.__exportStar) || function(m, exports) {
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
};
var __importDefault = (this && this.__importDefault) || function (mod) {

@@ -6,3 +20,3 @@ return (mod && mod.__esModule) ? mod : { "default": mod };

Object.defineProperty(exports, "__esModule", { value: true });
exports.createReport = exports.ObjectCommandResultError = exports.TemplateParseError = exports.InternalError = exports.ImageError = exports.CommandExecutionError = exports.InvalidCommandError = exports.CommandSyntaxError = exports.NullishCommandResultError = exports.getMetadata = exports.listCommands = void 0;
exports.createReport = exports.getMetadata = exports.listCommands = void 0;
var main_1 = __importDefault(require("./main"));

@@ -13,11 +27,3 @@ exports.createReport = main_1.default;

Object.defineProperty(exports, "getMetadata", { enumerable: true, get: function () { return main_2.getMetadata; } });
var errors_1 = require("./errors");
Object.defineProperty(exports, "NullishCommandResultError", { enumerable: true, get: function () { return errors_1.NullishCommandResultError; } });
Object.defineProperty(exports, "CommandSyntaxError", { enumerable: true, get: function () { return errors_1.CommandSyntaxError; } });
Object.defineProperty(exports, "InvalidCommandError", { enumerable: true, get: function () { return errors_1.InvalidCommandError; } });
Object.defineProperty(exports, "CommandExecutionError", { enumerable: true, get: function () { return errors_1.CommandExecutionError; } });
Object.defineProperty(exports, "ImageError", { enumerable: true, get: function () { return errors_1.ImageError; } });
Object.defineProperty(exports, "InternalError", { enumerable: true, get: function () { return errors_1.InternalError; } });
Object.defineProperty(exports, "TemplateParseError", { enumerable: true, get: function () { return errors_1.TemplateParseError; } });
Object.defineProperty(exports, "ObjectCommandResultError", { enumerable: true, get: function () { return errors_1.ObjectCommandResultError; } });
__exportStar(require("./errors"), exports);
exports.default = main_1.default;

@@ -240,3 +240,3 @@ "use strict";

// a fresh one for each secondary XML.
ctx = (0, processTemplate_1.newContext)(createOptions, ctx.imageId);
ctx = (0, processTemplate_1.newContext)(createOptions, ctx.imageAndShapeIdIncrement);
return [4 /*yield*/, (0, processTemplate_1.produceJsReport)(queryResult, js, ctx)];

@@ -516,3 +516,3 @@ case 12:

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;
var imageIds, relsPath, rels, _i, imageIds_1, imageId, _a, extension, imgData, imgName, imgPath, finalRelsXml;
return __generator(this, function (_b) {

@@ -530,4 +530,4 @@ switch (_b.label) {

rels = _b.sent();
for (i = 0; i < imageIds.length; i++) {
imageId = imageIds[i];
for (_i = 0, imageIds_1 = imageIds; _i < imageIds_1.length; _i++) {
imageId = imageIds_1[_i];
_a = images[imageId], extension = _a.extension, imgData = _a.data;

@@ -534,0 +534,0 @@ imgName = "template_".concat(documentComponent, "_").concat(imageId).concat(extension);

import { Node, ReportData, Context, CreateReportOptions, Images, Links, Htmls } from './types';
export declare function newContext(options: CreateReportOptions, imageId?: number): Context;
export declare function newContext(options: CreateReportOptions, imageAndShapeIdIncrement?: number): Context;
export declare function extractQuery(template: Node, options: CreateReportOptions): Promise<string | undefined>;

@@ -4,0 +4,0 @@ type ReportOutput = {

"use strict";
var __assign = (this && this.__assign) || function () {
__assign = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
return __assign.apply(this, arguments);
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {

@@ -45,4 +56,4 @@ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }

var debug_1 = require("./debug");
function newContext(options, imageId) {
if (imageId === void 0) { imageId = 0; }
function newContext(options, imageAndShapeIdIncrement) {
if (imageAndShapeIdIncrement === void 0) { imageAndShapeIdIncrement = 0; }
return {

@@ -59,3 +70,3 @@ gCntIf: 0,

},
imageId: imageId,
imageAndShapeIdIncrement: imageAndShapeIdIncrement,
images: {},

@@ -180,3 +191,3 @@ linkId: 0,

return __awaiter(this, void 0, void 0, function () {
var out, nodeIn, nodeOut, move, deltaJump, errors, curLoop, nextSibling, parent_3, tag, fRemoveNode, buffers, nodeOutParent, imgNode, captionNodes, parent_4, linkNode, parent_5, htmlNode, parent_6, tag, newNode, parent_7, result;
var out, nodeIn, nodeOut, move, deltaJump, errors, curLoop, nextSibling, parent_3, tag, fRemoveNode, buffers, nodeOutParent, imgNode, captionNodes, parent_4, linkNode, parent_5, htmlNode, parent_6, tag, newNode, newNodeTag, parent_7, result;
var _b;

@@ -363,2 +374,8 @@ return __generator(this, function (_c) {

nodeOut._children.push(newNode);
newNodeTag = newNode._tag;
if (!(0, reportUtils_1.isLoopExploring)(ctx) &&
(newNodeTag === 'wp:docPr' || newNodeTag === 'v:shape')) {
debug_1.logger.debug('detected a - ', debugPrintNode(newNode));
updateID(newNode, ctx);
}
parent_7 = nodeIn._parent;

@@ -778,4 +795,4 @@ if (!(nodeIn._fTextNode &&

validateImage(img);
ctx.imageId += 1;
var id = String(ctx.imageId);
ctx.imageAndShapeIdIncrement += 1;
var id = String(ctx.imageAndShapeIdIncrement);
var relId = "img".concat(id);

@@ -810,3 +827,3 @@ ctx.images[relId] = img;

var imgRelId = imageToContext(ctx, getImageData(imagePars));
var id = String(ctx.imageId);
var id = String(ctx.imageAndShapeIdIncrement);
var alt = imagePars.alt || 'desc';

@@ -947,1 +964,6 @@ var node = reportUtils_1.newNonTextNode;

};
function updateID(newNode, ctx) {
ctx.imageAndShapeIdIncrement += 1;
var id = String(ctx.imageAndShapeIdIncrement);
newNode._attrs = __assign(__assign({}, newNode._attrs), { id: "".concat(id) });
}

@@ -136,3 +136,3 @@ /// <reference types="node" />

};
imageId: number;
imageAndShapeIdIncrement: number;
images: Images;

@@ -139,0 +139,0 @@ pendingLinkNode?: NonTextNode;

{
"name": "docx-templates",
"version": "4.11.1",
"version": "4.11.2",
"description": "Template-based docx report creation",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

@@ -658,8 +658,2 @@ # Docx-templates [![Build Status](https://travis-ci.org/guigrpa/docx-templates.svg)](https://travis-ci.org/guigrpa/docx-templates) [![Coverage Status](https://coveralls.io/repos/github/guigrpa/docx-templates/badge.svg?branch=master)](https://coveralls.io/github/guigrpa/docx-templates?branch=master) [![npm version](https://img.shields.io/npm/v/docx-templates.svg)](https://www.npmjs.com/package/docx-templates)

Copyright (c) [Guillermo Grau Panea](https://github.com/guigrpa) 2016-now
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This Project is licensed under the MIT License. See [LICENSE](LICENSE) for more information.

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc