@tstdl/base 0.71.52 → 0.71.55
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/api/server/error-handler.js +0 -1
- package/api/server/error-handler.js.map +1 -1
- package/api/server/gateway.js +0 -1
- package/api/server/gateway.js.map +1 -1
- package/examples/mail/basic.d.ts +1 -0
- package/examples/mail/basic.js +33 -0
- package/examples/mail/basic.js.map +1 -0
- package/examples/pdf/basic.d.ts +1 -0
- package/examples/pdf/basic.js +23 -0
- package/examples/pdf/basic.js.map +1 -0
- package/image-service/image-service.d.ts +1 -1
- package/mail/mail.service.d.ts +1 -0
- package/mail/mail.service.js +7 -1
- package/mail/mail.service.js.map +1 -1
- package/mail/models/mail-log.model.d.ts +3 -3
- package/mail/models/mail-template.model.d.ts +0 -1
- package/mail/template-providers/file-mail-template.provider.d.ts +4 -6
- package/mail/template-providers/file-mail-template.provider.js +3 -27
- package/mail/template-providers/file-mail-template.provider.js.map +1 -1
- package/mail/template-providers/memory-mail-template.provider.d.ts +3 -5
- package/mail/template-providers/memory-mail-template.provider.js +2 -14
- package/mail/template-providers/memory-mail-template.provider.js.map +1 -1
- package/mail/template-renderers/handlebars.mail-template-renderer.d.ts +6 -4
- package/mail/template-renderers/handlebars.mail-template-renderer.js +25 -10
- package/mail/template-renderers/handlebars.mail-template-renderer.js.map +1 -1
- package/mail/template-renderers/mjml.mail-template-renderer.d.ts +6 -7
- package/mail/template-renderers/mjml.mail-template-renderer.js +28 -30
- package/mail/template-renderers/mjml.mail-template-renderer.js.map +1 -1
- package/module/modules/web-server.module.d.ts +0 -1
- package/module/modules/web-server.module.js +2 -10
- package/module/modules/web-server.module.js.map +1 -1
- package/package.json +7 -5
- package/pdf/pdf.service.d.ts +9 -0
- package/pdf/pdf.service.js +48 -0
- package/pdf/pdf.service.js.map +1 -0
- package/templates/index.d.ts +7 -0
- package/templates/index.js +24 -0
- package/templates/index.js.map +1 -0
- package/templates/module.d.ts +12 -0
- package/templates/module.js +24 -0
- package/templates/module.js.map +1 -0
- package/templates/providers/file-template.provider.base.d.ts +12 -0
- package/templates/providers/file-template.provider.base.js +43 -0
- package/templates/providers/file-template.provider.base.js.map +1 -0
- package/templates/providers/file-template.provider.d.ts +21 -0
- package/templates/providers/file-template.provider.js +44 -0
- package/templates/providers/file-template.provider.js.map +1 -0
- package/templates/providers/memory-template.provider.base.d.ts +9 -0
- package/templates/providers/memory-template.provider.base.js +35 -0
- package/templates/providers/memory-template.provider.base.js.map +1 -0
- package/templates/providers/memory-template.provider.d.ts +4 -0
- package/templates/providers/memory-template.provider.js +18 -0
- package/templates/providers/memory-template.provider.js.map +1 -0
- package/templates/renderers/handlebars.template-renderer.d.ts +11 -0
- package/templates/renderers/handlebars.template-renderer.js +27 -0
- package/templates/renderers/handlebars.template-renderer.js.map +1 -0
- package/templates/renderers/mjml.template-renderer.d.ts +15 -0
- package/templates/renderers/mjml.template-renderer.js +54 -0
- package/templates/renderers/mjml.template-renderer.js.map +1 -0
- package/templates/template-renderer.provider.d.ts +8 -0
- package/templates/template-renderer.provider.js +60 -0
- package/templates/template-renderer.provider.js.map +1 -0
- package/templates/template.model.d.ts +5 -0
- package/templates/template.model.js +3 -0
- package/templates/template.model.js.map +1 -0
- package/templates/template.provider.d.ts +4 -0
- package/templates/template.provider.js +7 -0
- package/templates/template.provider.js.map +1 -0
- package/templates/template.renderer.d.ts +6 -0
- package/templates/template.renderer.js +7 -0
- package/templates/template.renderer.js.map +1 -0
- package/templates/template.service.d.ts +11 -0
- package/templates/template.service.js +37 -0
- package/templates/template.service.js.map +1 -0
- package/templates/tokens.d.ts +3 -0
- package/templates/tokens.js +6 -0
- package/templates/tokens.js.map +1 -0
|
@@ -27,14 +27,8 @@ const server_2 = require("../../http/server");
|
|
|
27
27
|
const module_1 = require("../module");
|
|
28
28
|
const module_base_1 = require("../module-base");
|
|
29
29
|
exports.webServerModuleConfiguration = {
|
|
30
|
-
port: 8000
|
|
31
|
-
prefix: 'api/'
|
|
30
|
+
port: 8000
|
|
32
31
|
};
|
|
33
|
-
function getApiGatewayArgument(config) {
|
|
34
|
-
return {
|
|
35
|
-
prefix: config.prefix
|
|
36
|
-
};
|
|
37
|
-
}
|
|
38
32
|
let WebServerModule = class WebServerModule extends module_base_1.ModuleBase {
|
|
39
33
|
constructor(config, httpServer, apiGateway, apiControllers = []) {
|
|
40
34
|
super('WebServer');
|
|
@@ -91,7 +85,6 @@ let WebServerModule = class WebServerModule extends module_base_1.ModuleBase {
|
|
|
91
85
|
WebServerModule = __decorate([
|
|
92
86
|
(0, container_1.singleton)({ defaultArgumentProvider: () => exports.webServerModuleConfiguration }),
|
|
93
87
|
__param(0, (0, container_1.injectArg)()),
|
|
94
|
-
__param(2, (0, container_1.forwardArg)(getApiGatewayArgument)),
|
|
95
88
|
__param(3, (0, container_1.inject)(server_1.API_MODULE_OPTIONS, undefined, (options) => options.controllers)),
|
|
96
89
|
__param(3, (0, container_1.optional)()),
|
|
97
90
|
__metadata("design:paramtypes", [Object, server_2.HttpServer,
|
|
@@ -99,9 +92,8 @@ WebServerModule = __decorate([
|
|
|
99
92
|
], WebServerModule);
|
|
100
93
|
exports.WebServerModule = WebServerModule;
|
|
101
94
|
function configureWebServerModule(config) {
|
|
102
|
-
var _a
|
|
95
|
+
var _a;
|
|
103
96
|
exports.webServerModuleConfiguration.port = (_a = config === null || config === void 0 ? void 0 : config.port) !== null && _a !== void 0 ? _a : exports.webServerModuleConfiguration.port;
|
|
104
|
-
exports.webServerModuleConfiguration.prefix = (_b = config === null || config === void 0 ? void 0 : config.prefix) !== null && _b !== void 0 ? _b : exports.webServerModuleConfiguration.prefix;
|
|
105
97
|
}
|
|
106
98
|
exports.configureWebServerModule = configureWebServerModule;
|
|
107
99
|
//# sourceMappingURL=web-server.module.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"web-server.module.js","sourceRoot":"","sources":["../../../source/module/modules/web-server.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"web-server.module.js","sourceRoot":"","sources":["../../../source/module/modules/web-server.module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,6CAA8D;AAE9D,+CAAwG;AACxG,4DAAuD;AACvD,8CAA2C;AAI3C,sCAA6C;AAC7C,gDAA4C;AAM/B,QAAA,4BAA4B,GAAiC;IACxE,IAAI,EAAE,IAAI;CACX,CAAC;AAGF,IAAa,eAAe,GAA5B,MAAa,eAAgB,SAAQ,wBAAU;IAiB7C,YACe,MAAoC,EACjD,UAAsB,EACtB,UAAsB,EAC+D,iBAAyB,EAAE;QAEhH,KAAK,CAAC,WAAW,CAAC,CAAC;QAfZ,YAAO,GAAG;YACjB,gBAAgB,EAAE;gBAChB,IAAI,EAAE,yBAAgB,CAAC,KAAK;gBAC5B,QAAQ,EAAE,GAAG,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,qBAAqB;aACtD;SACF,CAAC;QAYA,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,cAAc,GAAG,cAAc,CAAC;QAErC,IAAI,CAAC,WAAW,GAAG,KAAK,CAAC;IAC3B,CAAC;IAED,KAAK,CAAC,UAAU;QACd,IAAI,IAAI,CAAC,WAAW,EAAE;YACpB,OAAO;SACR;QAED,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAExB,KAAK,MAAM,UAAU,IAAI,IAAI,CAAC,cAAc,EAAE;YAC5C,MAAM,IAAI,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;SAC9C;IACH,CAAC;IAED,KAAK,CAAC,CAAC,wBAAY,CAAC;QAClB,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;IAC1B,CAAC;IAED,KAAK,CAAC,qBAAqB,CAAC,UAAgB;QAC1C,MAAM,IAAI,CAAC,UAAU,CAAC,qBAAqB,CAAC,UAAU,CAAC,CAAC;IAC1D,CAAC;IAES,KAAK,CAAC,IAAI,CAAC,iBAA4C;;QAC/D,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;QAExB,MAAM,IAAI,CAAC,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAE/C,MAAM,YAAY,GAAG,iBAAiB,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,EAAE;YAC1D,MAAM,IAAI,CAAC,UAAU,CAAC,yBAAY,CAAC,EAAE,CAAC;QACxC,CAAC,CAAC,CAAC;;YAEH,KAA4B,IAAA,KAAA,cAAA,IAAI,CAAC,UAAU,CAAA,IAAA;gBAAhC,MAAM,OAAO,WAAA,CAAA;gBACtB,KAAK,IAAI,CAAC,UAAU,CAAC,8BAA8B,CAAC,OAAO,CAAC,CAAC;aAC9D;;;;;;;;;QAED,MAAM,YAAY,CAAC;IACrB,CAAC;CACF,CAAA;AApEY,eAAe;IAD3B,IAAA,qBAAS,EAAC,EAAE,uBAAuB,EAAE,GAAG,EAAE,CAAC,oCAA4B,EAAE,CAAC;IAmBtE,WAAA,IAAA,qBAAS,GAAE,CAAA;IAGX,WAAA,IAAA,kBAAM,EAAC,2BAAkB,EAAE,SAAS,EAAE,CAAC,OAAO,EAAE,EAAE,CAAC,OAAO,CAAC,WAAW,CAAC,CAAA;IAAE,WAAA,IAAA,oBAAQ,GAAE,CAAA;6CAFxE,mBAAU;QACV,mBAAU;GApBb,eAAe,CAoE3B;AApEY,0CAAe;AAsE5B,SAAgB,wBAAwB,CAAC,MAA8C;;IACrF,oCAA4B,CAAC,IAAI,GAAG,MAAA,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,IAAI,mCAAI,oCAA4B,CAAC,IAAI,CAAC;AACxF,CAAC;AAFD,4DAEC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tstdl/base",
|
|
3
|
-
"version": "0.71.
|
|
3
|
+
"version": "0.71.55",
|
|
4
4
|
"author": "Patrick Hein",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public"
|
|
@@ -17,7 +17,8 @@
|
|
|
17
17
|
"dependencies": {
|
|
18
18
|
"luxon": "^2",
|
|
19
19
|
"reflect-metadata": "^0.1",
|
|
20
|
-
"rxjs": "^7"
|
|
20
|
+
"rxjs": "^7",
|
|
21
|
+
"type-fest": "^2"
|
|
21
22
|
},
|
|
22
23
|
"devDependencies": {
|
|
23
24
|
"@types/chroma-js": "^2.1",
|
|
@@ -28,8 +29,8 @@
|
|
|
28
29
|
"@types/node": ">=16",
|
|
29
30
|
"@types/nodemailer": "^6.4.4",
|
|
30
31
|
"@types/yup": "0.29",
|
|
31
|
-
"@typescript-eslint/eslint-plugin": "5.
|
|
32
|
-
"@typescript-eslint/parser": "5.
|
|
32
|
+
"@typescript-eslint/eslint-plugin": "5.28",
|
|
33
|
+
"@typescript-eslint/parser": "5.28",
|
|
33
34
|
"eslint": "8.17",
|
|
34
35
|
"ttypescript": "1.5",
|
|
35
36
|
"typedoc": "0.22",
|
|
@@ -48,8 +49,9 @@
|
|
|
48
49
|
"mjml": "^4.12",
|
|
49
50
|
"mongodb": "^4.7",
|
|
50
51
|
"nodemailer": "^6.7",
|
|
52
|
+
"puppeteer": "^14.4.0",
|
|
51
53
|
"superstruct": "^0.16",
|
|
52
|
-
"undici": "^5.
|
|
54
|
+
"undici": "^5.5",
|
|
53
55
|
"urlpattern-polyfill": "^4.0"
|
|
54
56
|
},
|
|
55
57
|
"peerDependenciesMeta": {
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { TemplateService } from "../templates";
|
|
2
|
+
export declare class PdfService {
|
|
3
|
+
private readonly templateService;
|
|
4
|
+
constructor(templateService: TemplateService);
|
|
5
|
+
renderHtml(html: string): Promise<Uint8Array>;
|
|
6
|
+
renderTemplate(key: string, templateContext: object): Promise<Uint8Array>;
|
|
7
|
+
renderUrl(url: string): Promise<Uint8Array>;
|
|
8
|
+
private render;
|
|
9
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.PdfService = void 0;
|
|
13
|
+
const container_1 = require("../container");
|
|
14
|
+
const templates_1 = require("../templates");
|
|
15
|
+
const puppeteer = require("puppeteer");
|
|
16
|
+
let PdfService = class PdfService {
|
|
17
|
+
constructor(templateService) {
|
|
18
|
+
this.templateService = templateService;
|
|
19
|
+
}
|
|
20
|
+
async renderHtml(html) {
|
|
21
|
+
return this.render(async (page) => page.setContent(html, { waitUntil: 'networkidle2' }));
|
|
22
|
+
}
|
|
23
|
+
async renderTemplate(key, templateContext) {
|
|
24
|
+
const html = await this.templateService.render(key, templateContext);
|
|
25
|
+
return this.renderHtml(html);
|
|
26
|
+
}
|
|
27
|
+
async renderUrl(url) {
|
|
28
|
+
return this.render(async (page) => page.goto(url, { waitUntil: 'networkidle2' }));
|
|
29
|
+
}
|
|
30
|
+
async render(handler) {
|
|
31
|
+
const browser = await puppeteer.launch();
|
|
32
|
+
try {
|
|
33
|
+
const page = await browser.newPage();
|
|
34
|
+
await handler(page);
|
|
35
|
+
const result = await page.pdf({ format: 'a4' });
|
|
36
|
+
return result;
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
await browser.close();
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
PdfService = __decorate([
|
|
44
|
+
(0, container_1.singleton)(),
|
|
45
|
+
__metadata("design:paramtypes", [templates_1.TemplateService])
|
|
46
|
+
], PdfService);
|
|
47
|
+
exports.PdfService = PdfService;
|
|
48
|
+
//# sourceMappingURL=pdf.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pdf.service.js","sourceRoot":"","sources":["../../source/pdf/pdf.service.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,4CAAwC;AACxC,4CAA8C;AAC9C,uCAAuC;AAGvC,IAAa,UAAU,GAAvB,MAAa,UAAU;IAGrB,YAAY,eAAgC;QAC1C,IAAI,CAAC,eAAe,GAAG,eAAe,CAAC;IACzC,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,IAAY;QAC3B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;IAC3F,CAAC;IAED,KAAK,CAAC,cAAc,CAAC,GAAW,EAAE,eAAuB;QACvD,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,eAAe,CAAC,MAAM,CAAC,GAAG,EAAE,eAAe,CAAC,CAAC;QACrE,OAAO,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;IAC/B,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,GAAW;QACzB,OAAO,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,IAAI,EAAE,EAAE,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG,EAAE,EAAE,SAAS,EAAE,cAAc,EAAE,CAAC,CAAC,CAAC;IACpF,CAAC;IAEO,KAAK,CAAC,MAAM,CAAC,OAA0C;QAC7D,MAAM,OAAO,GAAG,MAAM,SAAS,CAAC,MAAM,EAAE,CAAC;QAEzC,IAAI;YACF,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,OAAO,EAAE,CAAC;YACrC,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;YACpB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,GAAG,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,CAAC;YAChD,OAAO,MAAM,CAAC;SACf;gBACO;YACN,MAAM,OAAO,CAAC,KAAK,EAAE,CAAC;SACvB;IACH,CAAC;CACF,CAAA;AAjCY,UAAU;IADtB,IAAA,qBAAS,GAAE;qCAImB,2BAAe;GAHjC,UAAU,CAiCtB;AAjCY,gCAAU"}
|
|
@@ -0,0 +1,24 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./module"), exports);
|
|
18
|
+
__exportStar(require("./template-renderer.provider"), exports);
|
|
19
|
+
__exportStar(require("./template.model"), exports);
|
|
20
|
+
__exportStar(require("./template.provider"), exports);
|
|
21
|
+
__exportStar(require("./template.renderer"), exports);
|
|
22
|
+
__exportStar(require("./template.service"), exports);
|
|
23
|
+
__exportStar(require("./tokens"), exports);
|
|
24
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../source/templates/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,+DAA6C;AAC7C,mDAAiC;AACjC,sDAAoC;AACpC,sDAAoC;AACpC,qDAAmC;AACnC,2CAAyB"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Type } from "../types";
|
|
2
|
+
import { TemplateProvider } from './template.provider';
|
|
3
|
+
import type { TemplateRenderer } from './template.renderer';
|
|
4
|
+
export declare type TemplateModuleConfig = {
|
|
5
|
+
templateProvider: Type<TemplateProvider>;
|
|
6
|
+
templateRenderers: Type<TemplateRenderer>[];
|
|
7
|
+
};
|
|
8
|
+
export declare const templateModuleConfig: TemplateModuleConfig;
|
|
9
|
+
/**
|
|
10
|
+
* configure mail module
|
|
11
|
+
*/
|
|
12
|
+
export declare function configureTemplates({ templateProvider, templateRenderers }: Partial<TemplateModuleConfig>): void;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.configureTemplates = exports.templateModuleConfig = void 0;
|
|
4
|
+
const container_1 = require("../container");
|
|
5
|
+
const type_guards_1 = require("../utils/type-guards");
|
|
6
|
+
const template_provider_1 = require("./template.provider");
|
|
7
|
+
const tokens_1 = require("./tokens");
|
|
8
|
+
exports.templateModuleConfig = {
|
|
9
|
+
templateProvider: (0, container_1.stubClass)(template_provider_1.TemplateProvider),
|
|
10
|
+
templateRenderers: []
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* configure mail module
|
|
14
|
+
*/
|
|
15
|
+
function configureTemplates({ templateProvider, templateRenderers }) {
|
|
16
|
+
exports.templateModuleConfig.templateProvider = templateProvider !== null && templateProvider !== void 0 ? templateProvider : exports.templateModuleConfig.templateProvider;
|
|
17
|
+
exports.templateModuleConfig.templateRenderers = [...new Set([...exports.templateModuleConfig.templateRenderers, ...(templateRenderers !== null && templateRenderers !== void 0 ? templateRenderers : [])])];
|
|
18
|
+
if ((0, type_guards_1.isDefined)(templateProvider)) {
|
|
19
|
+
container_1.container.registerSingleton(template_provider_1.TemplateProvider, { useToken: templateProvider });
|
|
20
|
+
}
|
|
21
|
+
container_1.container.registerSingleton(tokens_1.TEMPLATE_RENDERERS, { useValue: exports.templateModuleConfig.templateRenderers });
|
|
22
|
+
}
|
|
23
|
+
exports.configureTemplates = configureTemplates;
|
|
24
|
+
//# sourceMappingURL=module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../source/templates/module.ts"],"names":[],"mappings":";;;AAAA,4CAAmD;AAEnD,sDAAgD;AAChD,2DAAuD;AAEvD,qCAA8C;AAOjC,QAAA,oBAAoB,GAAyB;IACxD,gBAAgB,EAAE,IAAA,qBAAS,EAAC,oCAAgB,CAAC;IAC7C,iBAAiB,EAAE,EAAE;CACtB,CAAC;AAEF;;GAEG;AACH,SAAgB,kBAAkB,CAAC,EAAE,gBAAgB,EAAE,iBAAiB,EAAiC;IACvG,4BAAoB,CAAC,gBAAgB,GAAG,gBAAgB,aAAhB,gBAAgB,cAAhB,gBAAgB,GAAI,4BAAoB,CAAC,gBAAgB,CAAC;IAClG,4BAAoB,CAAC,iBAAiB,GAAG,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,4BAAoB,CAAC,iBAAiB,EAAE,GAAG,CAAC,iBAAiB,aAAjB,iBAAiB,cAAjB,iBAAiB,GAAI,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;IAEjI,IAAI,IAAA,uBAAS,EAAC,gBAAgB,CAAC,EAAE;QAC/B,qBAAS,CAAC,iBAAiB,CAAC,oCAAgB,EAAE,EAAE,QAAQ,EAAE,gBAAgB,EAAE,CAAC,CAAC;KAC/E;IAED,qBAAS,CAAC,iBAAiB,CAAC,2BAAkB,EAAE,EAAE,QAAQ,EAAE,4BAAoB,CAAC,iBAAiB,EAAE,CAAC,CAAC;AACxG,CAAC;AATD,gDASC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { Schema } from "../../schema";
|
|
2
|
+
import type { TypedOmit } from "../../types";
|
|
3
|
+
import type { Template } from '../template.model';
|
|
4
|
+
export declare type FileTemplateBase = TypedOmit<Template, 'template'>;
|
|
5
|
+
export declare type FileForward<T extends FileTemplateBase, U extends FileTemplateBase> = [fileKey: keyof U, targetKey: keyof T];
|
|
6
|
+
export declare class FileTemplateProviderBase<T extends FileTemplateBase, U extends FileTemplateBase> {
|
|
7
|
+
private readonly schema;
|
|
8
|
+
private readonly basePath;
|
|
9
|
+
private readonly fileForwards;
|
|
10
|
+
constructor(schema: Schema<U>, basePath: string, fileForwards: FileForward<T, U>[]);
|
|
11
|
+
get(key: string): Promise<T>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FileTemplateProviderBase = void 0;
|
|
4
|
+
const type_guards_1 = require("../../utils/type-guards");
|
|
5
|
+
const fs = require("fs/promises");
|
|
6
|
+
const path = require("path");
|
|
7
|
+
class FileTemplateProviderBase {
|
|
8
|
+
constructor(schema, basePath, fileForwards) {
|
|
9
|
+
this.schema = schema;
|
|
10
|
+
this.basePath = basePath;
|
|
11
|
+
this.fileForwards = new Map(fileForwards);
|
|
12
|
+
}
|
|
13
|
+
async get(key) {
|
|
14
|
+
const filePath = path.resolve(this.basePath, `${key}.json`);
|
|
15
|
+
const fileContent = await fs.readFile(filePath, { encoding: 'utf8' });
|
|
16
|
+
const fileTemplate = this.schema.parse(JSON.parse(fileContent));
|
|
17
|
+
const result = {};
|
|
18
|
+
const entries = Object.entries(fileTemplate);
|
|
19
|
+
for (const [property, value] of entries) {
|
|
20
|
+
if (!this.fileForwards.has(property)) {
|
|
21
|
+
result[property] = value;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
for (const [fileKey, targetKey] of this.fileForwards) {
|
|
25
|
+
if ((0, type_guards_1.isDefined)(result[targetKey])) {
|
|
26
|
+
if ((0, type_guards_1.isDefined)(fileTemplate[fileKey])) {
|
|
27
|
+
throw new Error(`Either ${fileKey.toString()} or ${targetKey.toString()} must be defined.`);
|
|
28
|
+
}
|
|
29
|
+
continue;
|
|
30
|
+
}
|
|
31
|
+
if ((0, type_guards_1.isDefined)(fileTemplate[fileKey])) {
|
|
32
|
+
const contentFilePath = (0, type_guards_1.assertStringPass)(fileTemplate[fileKey], 'File path must be a string.');
|
|
33
|
+
const content = await fs.readFile(path.resolve(this.basePath, contentFilePath), { encoding: 'utf8' });
|
|
34
|
+
result[targetKey] = content;
|
|
35
|
+
continue;
|
|
36
|
+
}
|
|
37
|
+
throw new Error(`Either ${fileKey.toString()} or ${targetKey.toString()} must be defined.`);
|
|
38
|
+
}
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.FileTemplateProviderBase = FileTemplateProviderBase;
|
|
43
|
+
//# sourceMappingURL=file-template.provider.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-template.provider.base.js","sourceRoot":"","sources":["../../../source/templates/providers/file-template.provider.base.ts"],"names":[],"mappings":";;;AAEA,yDAAkE;AAClE,kCAAkC;AAClC,6BAA6B;AAO7B,MAAa,wBAAwB;IAKnC,YAAY,MAAiB,EAAE,QAAgB,EAAE,YAAiC;QAChF,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;QACzB,IAAI,CAAC,YAAY,GAAG,IAAI,GAAG,CAAC,YAAY,CAAC,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,GAAG,OAAO,CAAC,CAAC;QAC5D,MAAM,WAAW,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;QACtE,MAAM,YAAY,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,CAAC,CAAC;QAEhE,MAAM,MAAM,GAAW,EAAE,CAAC;QAC1B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,YAAY,CAAyB,CAAC;QAErE,KAAK,MAAM,CAAC,QAAQ,EAAE,KAAK,CAAC,IAAI,OAAO,EAAE;YACvC,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,GAAG,CAAC,QAAQ,CAAC,EAAE;gBACpC,MAAM,CAAC,QAAQ,CAAC,GAAG,KAAK,CAAC;aAC1B;SACF;QAED,KAAK,MAAM,CAAC,OAAO,EAAE,SAAS,CAAC,IAAI,IAAI,CAAC,YAAY,EAAE;YACpD,IAAI,IAAA,uBAAS,EAAC,MAAM,CAAC,SAAS,CAAC,CAAC,EAAE;gBAChC,IAAI,IAAA,uBAAS,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE;oBACpC,MAAM,IAAI,KAAK,CAAC,UAAU,OAAO,CAAC,QAAQ,EAAE,OAAO,SAAS,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;iBAC7F;gBAED,SAAS;aACV;YAED,IAAI,IAAA,uBAAS,EAAC,YAAY,CAAC,OAAO,CAAC,CAAC,EAAE;gBACpC,MAAM,eAAe,GAAG,IAAA,8BAAgB,EAAC,YAAY,CAAC,OAAO,CAAC,EAAE,6BAA6B,CAAC,CAAC;gBAC/F,MAAM,OAAO,GAAG,MAAM,EAAE,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,EAAE,EAAE,QAAQ,EAAE,MAAM,EAAE,CAAC,CAAC;gBAEtG,MAAM,CAAC,SAAS,CAAC,GAAG,OAAc,CAAC;gBACnC,SAAS;aACV;YAED,MAAM,IAAI,KAAK,CAAC,UAAU,OAAO,CAAC,QAAQ,EAAE,OAAO,SAAS,CAAC,QAAQ,EAAE,mBAAmB,CAAC,CAAC;SAC7F;QAED,OAAO,MAAM,CAAC;IAChB,CAAC;CACF;AA/CD,4DA+CC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import type { Injectable } from "../../container";
|
|
2
|
+
import { resolveArgumentType } from "../../container";
|
|
3
|
+
import type { Template } from '../template.model';
|
|
4
|
+
import type { TemplateProvider } from '../template.provider';
|
|
5
|
+
import type { FileTemplateBase } from './file-template.provider.base';
|
|
6
|
+
import { FileTemplateProviderBase } from './file-template.provider.base';
|
|
7
|
+
export declare type FileTemplate = FileTemplateBase & {
|
|
8
|
+
template?: string;
|
|
9
|
+
/** subject template file */
|
|
10
|
+
templateFile?: string;
|
|
11
|
+
};
|
|
12
|
+
export declare type FileTemplateProviderConfig = {
|
|
13
|
+
basePath?: string;
|
|
14
|
+
};
|
|
15
|
+
export declare type FileTemplateProviderArgument = string;
|
|
16
|
+
export declare const fileTemplateProviderConfig: FileTemplateProviderConfig;
|
|
17
|
+
export declare class FileTemplateProvider extends FileTemplateProviderBase<Template, FileTemplate> implements TemplateProvider, Injectable<FileTemplateProviderArgument> {
|
|
18
|
+
readonly [resolveArgumentType]: FileTemplateProviderArgument;
|
|
19
|
+
constructor(basePath: string);
|
|
20
|
+
}
|
|
21
|
+
export declare function configureFileTemplateProvider(config?: Partial<FileTemplateProviderConfig>): void;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.configureFileTemplateProvider = exports.FileTemplateProvider = exports.fileTemplateProviderConfig = void 0;
|
|
16
|
+
const container_1 = require("../../container");
|
|
17
|
+
const schema_1 = require("../../schema");
|
|
18
|
+
const file_template_provider_base_1 = require("./file-template.provider.base");
|
|
19
|
+
exports.fileTemplateProviderConfig = {};
|
|
20
|
+
const fileTemplateSchema = (0, schema_1.object)({
|
|
21
|
+
type: (0, schema_1.string)(),
|
|
22
|
+
template: (0, schema_1.optional)((0, schema_1.string)()),
|
|
23
|
+
templateFile: (0, schema_1.optional)((0, schema_1.string)()),
|
|
24
|
+
options: (0, schema_1.optional)((0, schema_1.unknown)())
|
|
25
|
+
});
|
|
26
|
+
let FileTemplateProvider = class FileTemplateProvider extends file_template_provider_base_1.FileTemplateProviderBase {
|
|
27
|
+
constructor(basePath) {
|
|
28
|
+
super(fileTemplateSchema, basePath, [['templateFile', 'template']]);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
FileTemplateProvider = __decorate([
|
|
32
|
+
(0, container_1.singleton)({
|
|
33
|
+
defaultArgumentProvider: () => exports.fileTemplateProviderConfig.basePath
|
|
34
|
+
}),
|
|
35
|
+
__param(0, (0, container_1.injectArg)()),
|
|
36
|
+
__metadata("design:paramtypes", [String])
|
|
37
|
+
], FileTemplateProvider);
|
|
38
|
+
exports.FileTemplateProvider = FileTemplateProvider;
|
|
39
|
+
function configureFileTemplateProvider(config = {}) {
|
|
40
|
+
var _a;
|
|
41
|
+
exports.fileTemplateProviderConfig.basePath = (_a = config.basePath) !== null && _a !== void 0 ? _a : exports.fileTemplateProviderConfig.basePath;
|
|
42
|
+
}
|
|
43
|
+
exports.configureFileTemplateProvider = configureFileTemplateProvider;
|
|
44
|
+
//# sourceMappingURL=file-template.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"file-template.provider.js","sourceRoot":"","sources":["../../../source/templates/providers/file-template.provider.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,+CAAwE;AAExE,yCAA6D;AAI7D,+EAAyE;AAe5D,QAAA,0BAA0B,GAA+B,EAAE,CAAC;AAEzE,MAAM,kBAAkB,GAAyB,IAAA,eAAM,EAAC;IACtD,IAAI,EAAE,IAAA,eAAM,GAAE;IACd,QAAQ,EAAE,IAAA,iBAAQ,EAAC,IAAA,eAAM,GAAE,CAAC;IAC5B,YAAY,EAAE,IAAA,iBAAQ,EAAC,IAAA,eAAM,GAAE,CAAC;IAChC,OAAO,EAAE,IAAA,iBAAQ,EAAC,IAAA,gBAAO,GAAE,CAAC;CAC7B,CAAC,CAAC;AAKH,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,sDAAgD;IAGxF,YAAyB,QAAgB;QACvC,KAAK,CAAC,kBAAkB,EAAE,QAAQ,EAAE,CAAC,CAAC,cAAc,EAAE,UAAU,CAAC,CAAC,CAAC,CAAC;IACtE,CAAC;CACF,CAAA;AANY,oBAAoB;IAHhC,IAAA,qBAAS,EAAC;QACT,uBAAuB,EAAE,GAAG,EAAE,CAAC,kCAA0B,CAAC,QAAQ;KACnE,CAAC;IAIa,WAAA,IAAA,qBAAS,GAAE,CAAA;;GAHb,oBAAoB,CAMhC;AANY,oDAAoB;AAQjC,SAAgB,6BAA6B,CAAC,SAA8C,EAAE;;IAC5F,kCAA0B,CAAC,QAAQ,GAAG,MAAA,MAAM,CAAC,QAAQ,mCAAI,kCAA0B,CAAC,QAAQ,CAAC;AAC/F,CAAC;AAFD,sEAEC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import type { TypedOmit } from "../../types";
|
|
2
|
+
import type { Template } from '../template.model';
|
|
3
|
+
export declare type MemoryTemplateBase = TypedOmit<Template, 'template'>;
|
|
4
|
+
export declare class MemoryTemplateProviderBase<T extends MemoryTemplateBase> {
|
|
5
|
+
private readonly map;
|
|
6
|
+
constructor();
|
|
7
|
+
add(key: string, template: T): void;
|
|
8
|
+
get(key: string): Promise<T>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.MemoryTemplateProviderBase = void 0;
|
|
13
|
+
const container_1 = require("../../container");
|
|
14
|
+
const type_guards_1 = require("../../utils/type-guards");
|
|
15
|
+
let MemoryTemplateProviderBase = class MemoryTemplateProviderBase {
|
|
16
|
+
constructor() {
|
|
17
|
+
this.map = new Map();
|
|
18
|
+
}
|
|
19
|
+
add(key, template) {
|
|
20
|
+
this.map.set(key, template);
|
|
21
|
+
}
|
|
22
|
+
async get(key) {
|
|
23
|
+
const template = this.map.get(key);
|
|
24
|
+
if ((0, type_guards_1.isUndefined)(template)) {
|
|
25
|
+
throw new Error(`Template ${key} not available.`);
|
|
26
|
+
}
|
|
27
|
+
return template;
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
MemoryTemplateProviderBase = __decorate([
|
|
31
|
+
(0, container_1.singleton)(),
|
|
32
|
+
__metadata("design:paramtypes", [])
|
|
33
|
+
], MemoryTemplateProviderBase);
|
|
34
|
+
exports.MemoryTemplateProviderBase = MemoryTemplateProviderBase;
|
|
35
|
+
//# sourceMappingURL=memory-template.provider.base.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-template.provider.base.js","sourceRoot":"","sources":["../../../source/templates/providers/memory-template.provider.base.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAwC;AAExC,yDAAkD;AAMlD,IAAa,0BAA0B,GAAvC,MAAa,0BAA0B;IAGrC;QACE,IAAI,CAAC,GAAG,GAAG,IAAI,GAAG,EAAE,CAAC;IACvB,CAAC;IAED,GAAG,CAAC,GAAW,EAAE,QAAW;QAC1B,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,GAAG,CAAC,GAAW;QACnB,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QAEnC,IAAI,IAAA,yBAAW,EAAC,QAAQ,CAAC,EAAE;YACzB,MAAM,IAAI,KAAK,CAAC,YAAY,GAAG,iBAAiB,CAAC,CAAC;SACnD;QAED,OAAO,QAAQ,CAAC;IAClB,CAAC;CACF,CAAA;AApBY,0BAA0B;IADtC,IAAA,qBAAS,GAAE;;GACC,0BAA0B,CAoBtC;AApBY,gEAA0B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.MemoryTemplateProvider = void 0;
|
|
10
|
+
const container_1 = require("../../container");
|
|
11
|
+
const memory_template_provider_base_1 = require("./memory-template.provider.base");
|
|
12
|
+
let MemoryTemplateProvider = class MemoryTemplateProvider extends memory_template_provider_base_1.MemoryTemplateProviderBase {
|
|
13
|
+
};
|
|
14
|
+
MemoryTemplateProvider = __decorate([
|
|
15
|
+
(0, container_1.singleton)()
|
|
16
|
+
], MemoryTemplateProvider);
|
|
17
|
+
exports.MemoryTemplateProvider = MemoryTemplateProvider;
|
|
18
|
+
//# sourceMappingURL=memory-template.provider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"memory-template.provider.js","sourceRoot":"","sources":["../../../source/templates/providers/memory-template.provider.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAwC;AAExC,mFAA6E;AAG7E,IAAa,sBAAsB,GAAnC,MAAa,sBAAuB,SAAQ,0DAAoC;CAAI,CAAA;AAAvE,sBAAsB;IADlC,IAAA,qBAAS,GAAE;GACC,sBAAsB,CAAiD;AAAvE,wDAAsB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Template } from '../template.model';
|
|
2
|
+
import type { TemplateRenderResult } from '../template.renderer';
|
|
3
|
+
import { TemplateRenderer } from '../template.renderer';
|
|
4
|
+
export declare type HandlebarsTemplateOptions = {
|
|
5
|
+
strict?: boolean;
|
|
6
|
+
};
|
|
7
|
+
export declare type HandlebarsTemplate = Template<'handlebars', HandlebarsTemplateOptions>;
|
|
8
|
+
export declare class HandlebarsTemplateRenderer extends TemplateRenderer<HandlebarsTemplate> {
|
|
9
|
+
canHandleType(type: string): boolean;
|
|
10
|
+
render(template: HandlebarsTemplate, context?: object): Promise<TemplateRenderResult>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.HandlebarsTemplateRenderer = void 0;
|
|
10
|
+
const container_1 = require("../../container");
|
|
11
|
+
const handlebars = require("handlebars");
|
|
12
|
+
const template_renderer_1 = require("../template.renderer");
|
|
13
|
+
let HandlebarsTemplateRenderer = class HandlebarsTemplateRenderer extends template_renderer_1.TemplateRenderer {
|
|
14
|
+
canHandleType(type) {
|
|
15
|
+
return type == 'handlebars';
|
|
16
|
+
}
|
|
17
|
+
async render(template, context) {
|
|
18
|
+
var _a, _b;
|
|
19
|
+
const renderer = handlebars.compile(template.template, { strict: (_b = (_a = template.options) === null || _a === void 0 ? void 0 : _a.strict) !== null && _b !== void 0 ? _b : true });
|
|
20
|
+
return renderer(context);
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
HandlebarsTemplateRenderer = __decorate([
|
|
24
|
+
(0, container_1.singleton)()
|
|
25
|
+
], HandlebarsTemplateRenderer);
|
|
26
|
+
exports.HandlebarsTemplateRenderer = HandlebarsTemplateRenderer;
|
|
27
|
+
//# sourceMappingURL=handlebars.template-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"handlebars.template-renderer.js","sourceRoot":"","sources":["../../../source/templates/renderers/handlebars.template-renderer.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+CAAwC;AACxC,yCAAyC;AAGzC,4DAAwD;AAOxD,IAAa,0BAA0B,GAAvC,MAAa,0BAA2B,SAAQ,oCAAoC;IAClF,aAAa,CAAC,IAAY;QACxB,OAAO,IAAI,IAAI,YAAY,CAAC;IAC9B,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAA4B,EAAE,OAAgB;;QACzD,MAAM,QAAQ,GAAG,UAAU,CAAC,OAAO,CAAC,QAAQ,CAAC,QAAQ,EAAE,EAAE,MAAM,EAAE,MAAA,MAAA,QAAQ,CAAC,OAAO,0CAAE,MAAM,mCAAI,IAAI,EAAE,CAAC,CAAC;QACrG,OAAO,QAAQ,CAAC,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF,CAAA;AATY,0BAA0B;IADtC,IAAA,qBAAS,GAAE;GACC,0BAA0B,CAStC;AATY,gEAA0B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import type { MJMLParsingOptions } from 'mjml-core';
|
|
2
|
+
import { TemplateRendererProvider } from '../template-renderer.provider';
|
|
3
|
+
import type { Template } from '../template.model';
|
|
4
|
+
import type { TemplateRenderResult } from '../template.renderer';
|
|
5
|
+
import { TemplateRenderer } from '../template.renderer';
|
|
6
|
+
export declare type MjmlTemplateOptions = Pick<MJMLParsingOptions, 'fonts' | 'keepComments' | 'validationLevel'> & {
|
|
7
|
+
preprocessorOptions?: any;
|
|
8
|
+
};
|
|
9
|
+
export declare type MjmlTemplate = Template<'mjml' | `mjml-${string}`, MjmlTemplateOptions>;
|
|
10
|
+
export declare class MjmlTemplateRenderer extends TemplateRenderer<MjmlTemplate> {
|
|
11
|
+
private readonly rendererProvider;
|
|
12
|
+
constructor(rendererProvider: TemplateRendererProvider);
|
|
13
|
+
canHandleType(type: string): boolean;
|
|
14
|
+
render(template: MjmlTemplate, context?: object): Promise<TemplateRenderResult>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.MjmlTemplateRenderer = void 0;
|
|
16
|
+
const container_1 = require("../../container");
|
|
17
|
+
// @ts-expect-error import is actually working
|
|
18
|
+
const mjml2html = require("mjml");
|
|
19
|
+
const template_renderer_provider_1 = require("../template-renderer.provider");
|
|
20
|
+
const template_renderer_1 = require("../template.renderer");
|
|
21
|
+
let MjmlTemplateRenderer = class MjmlTemplateRenderer extends template_renderer_1.TemplateRenderer {
|
|
22
|
+
constructor(rendererProvider) {
|
|
23
|
+
super();
|
|
24
|
+
this.rendererProvider = rendererProvider;
|
|
25
|
+
}
|
|
26
|
+
canHandleType(type) {
|
|
27
|
+
if (type == 'mjml') {
|
|
28
|
+
return true;
|
|
29
|
+
}
|
|
30
|
+
if (!type.startsWith('mjml-')) {
|
|
31
|
+
return false;
|
|
32
|
+
}
|
|
33
|
+
const parent = type.slice(5);
|
|
34
|
+
return this.rendererProvider.has(parent);
|
|
35
|
+
}
|
|
36
|
+
async render(template, context) {
|
|
37
|
+
var _a;
|
|
38
|
+
if (template.type.length > 4) {
|
|
39
|
+
const parent = template.type.slice(5);
|
|
40
|
+
const renderer = this.rendererProvider.get(parent);
|
|
41
|
+
const result = await renderer.render(Object.assign(Object.assign({}, template), { type: parent, options: (_a = template.options) === null || _a === void 0 ? void 0 : _a.preprocessorOptions }), context);
|
|
42
|
+
const preprocessedTemplate = Object.assign(Object.assign({}, template), { type: 'mjml', template: result });
|
|
43
|
+
return this.render(preprocessedTemplate);
|
|
44
|
+
}
|
|
45
|
+
return mjml2html(template.template).html;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
MjmlTemplateRenderer = __decorate([
|
|
49
|
+
(0, container_1.singleton)(),
|
|
50
|
+
__param(0, (0, container_1.forwardRef)(() => template_renderer_provider_1.TemplateRendererProvider)),
|
|
51
|
+
__metadata("design:paramtypes", [template_renderer_provider_1.TemplateRendererProvider])
|
|
52
|
+
], MjmlTemplateRenderer);
|
|
53
|
+
exports.MjmlTemplateRenderer = MjmlTemplateRenderer;
|
|
54
|
+
//# sourceMappingURL=mjml.template-renderer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mjml.template-renderer.js","sourceRoot":"","sources":["../../../source/templates/renderers/mjml.template-renderer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAoD;AACpD,8CAA8C;AAC9C,kCAAkC;AAElC,8EAAyE;AAGzE,4DAAwD;AASxD,IAAa,oBAAoB,GAAjC,MAAa,oBAAqB,SAAQ,oCAA8B;IAGtE,YAAwD,gBAA0C;QAChG,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAED,aAAa,CAAC,IAAY;QACxB,IAAI,IAAI,IAAI,MAAM,EAAE;YAClB,OAAO,IAAI,CAAC;SACb;QAED,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,OAAO,CAAC,EAAE;YAC7B,OAAO,KAAK,CAAC;SACd;QAED,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC7B,OAAO,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC3C,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,QAAsB,EAAE,OAAgB;;QACnD,IAAI,QAAQ,CAAC,IAAI,CAAC,MAAM,GAAG,CAAC,EAAE;YAC5B,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;YACtC,MAAM,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;YAEnD,MAAM,MAAM,GAAG,MAAM,QAAQ,CAAC,MAAM,iCAAM,QAAQ,KAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAA,QAAQ,CAAC,OAAO,0CAAE,mBAAmB,KAAI,OAAO,CAAC,CAAC;YAE7H,MAAM,oBAAoB,mCACrB,QAAQ,KACX,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,MAAM,GACjB,CAAC;YAEF,OAAO,IAAI,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC;SAC1C;QAED,OAAO,SAAS,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC,IAAI,CAAC;IAC3C,CAAC;CACF,CAAA;AAxCY,oBAAoB;IADhC,IAAA,qBAAS,GAAE;IAIG,WAAA,IAAA,sBAAU,EAAC,GAAG,EAAE,CAAC,qDAAwB,CAAC,CAAA;qCAAmB,qDAAwB;GAHvF,oBAAoB,CAwChC;AAxCY,oDAAoB"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { TemplateRenderer } from './template.renderer';
|
|
2
|
+
export declare class TemplateRendererProvider {
|
|
3
|
+
private readonly renderers;
|
|
4
|
+
constructor(renderers: TemplateRenderer[]);
|
|
5
|
+
register(renderer: TemplateRenderer): void;
|
|
6
|
+
has(type: string): boolean;
|
|
7
|
+
get(type: string): TemplateRenderer;
|
|
8
|
+
}
|