@spinajs/templates-xlsx 2.0.46 → 2.0.50
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/README.md +11 -11
- package/lib/index.d.ts +1 -2
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +14 -45
- package/lib/index.js.map +1 -1
- package/package.json +59 -57
package/README.md
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
# `email`
|
|
2
|
-
|
|
3
|
-
> TODO: description
|
|
4
|
-
|
|
5
|
-
## Usage
|
|
6
|
-
|
|
7
|
-
```
|
|
8
|
-
const email = require('email');
|
|
9
|
-
|
|
10
|
-
// TODO: DEMONSTRATE API
|
|
11
|
-
```
|
|
1
|
+
# `email`
|
|
2
|
+
|
|
3
|
+
> TODO: description
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
const email = require('email');
|
|
9
|
+
|
|
10
|
+
// TODO: DEMONSTRATE API
|
|
11
|
+
```
|
package/lib/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { TemplateRenderer } from '@spinajs/templates';
|
|
2
|
-
import { Log } from '@spinajs/log';
|
|
3
2
|
export declare class XlsxRenderer extends TemplateRenderer {
|
|
4
|
-
protected Log: Log;
|
|
5
3
|
protected Templates: Map<string, string>;
|
|
6
4
|
protected Options: any;
|
|
7
5
|
get Type(): string;
|
|
@@ -11,3 +9,4 @@ export declare class XlsxRenderer extends TemplateRenderer {
|
|
|
11
9
|
render(_templateName: string, _model: unknown, _language?: string): Promise<string>;
|
|
12
10
|
protected compile(templateName: string, path: string): Promise<void>;
|
|
13
11
|
}
|
|
12
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAMtD,qBACa,YAAa,SAAQ,gBAAgB;IAChD,SAAS,CAAC,SAAS,EAAE,GAAG,CAAC,MAAM,EAAE,MAAM,CAAC,CAA6B;IAGrE,SAAS,CAAC,OAAO,EAAE,GAAG,CAAC;IAEvB,IAAW,IAAI,WAEd;IAED,IAAW,SAAS,WAEnB;IAEY,OAAO,IAAI,OAAO,CAAC,IAAI,CAAC;IAIxB,YAAY,CAAC,QAAQ,EAAE,MAAM,EAAE,KAAK,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAuBnG,MAAM,CAAC,aAAa,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,SAAS,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,CAAC;IAIhG,SAAS,CAAC,OAAO,CAAC,YAAY,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAQrE"}
|
package/lib/index.js
CHANGED
|
@@ -1,46 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
1
|
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
19
2
|
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
20
3
|
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
21
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
22
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
23
6
|
};
|
|
24
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
25
|
-
if (mod && mod.__esModule) return mod;
|
|
26
|
-
var result = {};
|
|
27
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
28
|
-
__setModuleDefault(result, mod);
|
|
29
|
-
return result;
|
|
30
|
-
};
|
|
31
7
|
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
32
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
33
9
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
const xlsx_renderer_1 = require("xlsx-renderer");
|
|
42
|
-
const fs = __importStar(require("fs"));
|
|
43
|
-
let XlsxRenderer = class XlsxRenderer extends templates_1.TemplateRenderer {
|
|
10
|
+
import { NotSupported, IOFail } from '../../exceptions/lib/index.js';
|
|
11
|
+
import { TemplateRenderer } from '@spinajs/templates';
|
|
12
|
+
import { Config } from '@spinajs/configuration';
|
|
13
|
+
import { Injectable } from '@spinajs/di';
|
|
14
|
+
import { Renderer } from 'xlsx-renderer';
|
|
15
|
+
import * as fs from 'fs';
|
|
16
|
+
let XlsxRenderer = class XlsxRenderer extends TemplateRenderer {
|
|
44
17
|
constructor() {
|
|
45
18
|
super(...arguments);
|
|
46
19
|
this.Templates = new Map();
|
|
@@ -56,22 +29,22 @@ let XlsxRenderer = class XlsxRenderer extends templates_1.TemplateRenderer {
|
|
|
56
29
|
}
|
|
57
30
|
async renderToFile(template, model, filePath, _language) {
|
|
58
31
|
if (!this.Templates.has(template)) {
|
|
59
|
-
throw new
|
|
32
|
+
throw new IOFail(`Cannot find template file ${template}`);
|
|
60
33
|
}
|
|
61
34
|
const tFile = this.Templates.get(template);
|
|
62
35
|
if (!fs.existsSync(tFile)) {
|
|
63
|
-
throw new
|
|
36
|
+
throw new IOFail(`File for template ${template} at path ${tFile} not exists`);
|
|
64
37
|
}
|
|
65
38
|
this.Log.trace(`Rendering xlsx template ${template}`);
|
|
66
39
|
this.Log.timeStart(`XlsxTemplate.render.start.${template}`);
|
|
67
|
-
const renderer = new
|
|
40
|
+
const renderer = new Renderer();
|
|
68
41
|
const result = await renderer.renderFromFile(this.Templates.get(template), model);
|
|
69
42
|
await result.xlsx.writeFile(filePath);
|
|
70
43
|
const time = this.Log.timeEnd(`XlsxTemplate.render.start.${template}`);
|
|
71
44
|
this.Log.trace(`Rendering xlsx template ${template} ended, (${time} ms)`);
|
|
72
45
|
}
|
|
73
46
|
async render(_templateName, _model, _language) {
|
|
74
|
-
return Promise.reject(new
|
|
47
|
+
return Promise.reject(new NotSupported('Cannot render xlsx to memory'));
|
|
75
48
|
}
|
|
76
49
|
compile(templateName, path) {
|
|
77
50
|
// we cannot precompile xlsx files, just empty resolve
|
|
@@ -81,15 +54,11 @@ let XlsxRenderer = class XlsxRenderer extends templates_1.TemplateRenderer {
|
|
|
81
54
|
}
|
|
82
55
|
};
|
|
83
56
|
__decorate([
|
|
84
|
-
(
|
|
85
|
-
__metadata("design:type", log_1.Log)
|
|
86
|
-
], XlsxRenderer.prototype, "Log", void 0);
|
|
87
|
-
__decorate([
|
|
88
|
-
(0, configuration_1.Config)('templates.xlsx'),
|
|
57
|
+
Config('templates.xlsx'),
|
|
89
58
|
__metadata("design:type", Object)
|
|
90
59
|
], XlsxRenderer.prototype, "Options", void 0);
|
|
91
60
|
XlsxRenderer = __decorate([
|
|
92
|
-
|
|
61
|
+
Injectable(TemplateRenderer)
|
|
93
62
|
], XlsxRenderer);
|
|
94
|
-
|
|
63
|
+
export { XlsxRenderer };
|
|
95
64
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,+BAA+B,CAAC;AAErE,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAGlB,IAAM,YAAY,GAAlB,MAAM,YAAa,SAAQ,gBAAgB;IAA3C;;QACK,cAAS,GAAwB,IAAI,GAAG,EAAkB,CAAC;IAoDvE,CAAC;IA/CC,IAAW,IAAI;QACb,OAAO,MAAM,CAAC;IAChB,CAAC;IAED,IAAW,SAAS;QAClB,OAAO,OAAO,CAAC;IACjB,CAAC;IAEM,KAAK,CAAC,OAAO;QAClB,MAAM,KAAK,CAAC,OAAO,EAAE,CAAC;IACxB,CAAC;IAEM,KAAK,CAAC,YAAY,CAAC,QAAgB,EAAE,KAAc,EAAE,QAAgB,EAAE,SAAkB;QAC9F,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;YACjC,MAAM,IAAI,MAAM,CA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IAAC,MAAM,CAAC,gBAAgB,CAAC;;6CACF;AAJZ,YAAY;IADxB,UAAU,CAAC,gBAAgB,CAAC;GAChB,YAAY,CAqDxB;SArDY,YAAY"}
|
package/package.json
CHANGED
|
@@ -1,57 +1,59 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@spinajs/templates-xlsx",
|
|
3
|
-
"version": "2.0.
|
|
4
|
-
"description": "templates support eg. html file generation",
|
|
5
|
-
"
|
|
6
|
-
"
|
|
7
|
-
"
|
|
8
|
-
|
|
9
|
-
"
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
"
|
|
15
|
-
"
|
|
16
|
-
"
|
|
17
|
-
"
|
|
18
|
-
"
|
|
19
|
-
"
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
"
|
|
24
|
-
|
|
25
|
-
"
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"spinajs"
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
"
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
"@types/
|
|
45
|
-
"@types/
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
"@spinajs/
|
|
51
|
-
"@spinajs/
|
|
52
|
-
"@spinajs/
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
1
|
+
{
|
|
2
|
+
"name": "@spinajs/templates-xlsx",
|
|
3
|
+
"version": "2.0.50",
|
|
4
|
+
"description": "templates support eg. html file generation",
|
|
5
|
+
"exports": "./lib/index.js",
|
|
6
|
+
"type": "module",
|
|
7
|
+
"private": false,
|
|
8
|
+
"engines": {
|
|
9
|
+
"node": ">=16.11"
|
|
10
|
+
},
|
|
11
|
+
"scripts": {
|
|
12
|
+
"build": "npm run clean && npm run compile",
|
|
13
|
+
"compile": "tsc -b tsconfig.json",
|
|
14
|
+
"rimraf": "./node_modules/rimraf/bin.js",
|
|
15
|
+
"clean": "rimraf lib/ && rimraf tsconfig.tsbuildinfo",
|
|
16
|
+
"test": "ts-mocha -p tsconfig.json test/**/*.test.ts",
|
|
17
|
+
"coverage": "nyc npm run test",
|
|
18
|
+
"build-docs": "rimraf docs && typedoc --options typedoc.json src/",
|
|
19
|
+
"format": "prettier --write \"src/**/*.ts\"",
|
|
20
|
+
"lint": "eslint -c .eslintrc.cjs --ext .ts src --fix",
|
|
21
|
+
"preversion": "npm run lint",
|
|
22
|
+
"version": "npm run format && git add -A src",
|
|
23
|
+
"postinstall": "npm run build"
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"lib/**/*"
|
|
27
|
+
],
|
|
28
|
+
"types": "lib",
|
|
29
|
+
"repository": {
|
|
30
|
+
"type": "git",
|
|
31
|
+
"url": "git+https://github.com/spinajs/main.git"
|
|
32
|
+
},
|
|
33
|
+
"keywords": [
|
|
34
|
+
"spinajs",
|
|
35
|
+
"http"
|
|
36
|
+
],
|
|
37
|
+
"author": "SpinaJS <spinajs@coderush.pl> (https://github.com/spinajs/main)",
|
|
38
|
+
"license": "MIT",
|
|
39
|
+
"bugs": {
|
|
40
|
+
"url": "https://github.com/spinajs/main/issues"
|
|
41
|
+
},
|
|
42
|
+
"homepage": "https://github.com/spinajs/main#readme",
|
|
43
|
+
"devDependencies": {
|
|
44
|
+
"@types/luxon": "^3.2.0",
|
|
45
|
+
"@types/mocha": "10.0.1",
|
|
46
|
+
"@types/node": "^18.11.18",
|
|
47
|
+
"@types/pug": "^2.0.6"
|
|
48
|
+
},
|
|
49
|
+
"dependencies": {
|
|
50
|
+
"@spinajs/configuration": "^2.0.46",
|
|
51
|
+
"@spinajs/di": "^2.0.46",
|
|
52
|
+
"@spinajs/exceptions": "^2.0.39",
|
|
53
|
+
"@spinajs/log": "^2.0.46",
|
|
54
|
+
"@spinajs/templates": "^2.0.46",
|
|
55
|
+
"tempfile": "4.0.0",
|
|
56
|
+
"xlsx-renderer": "^2.4.4"
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "002dc553b0ffffd72193d0121ac425a4083bc9ee"
|
|
59
|
+
}
|