@ackplus/nest-dynamic-templates 0.1.6 → 0.1.7
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/package.json +1 -1
- package/src/index.d.ts +1 -2
- package/src/lib/dto/create-template.dto.d.ts +1 -0
- package/src/lib/dto/create-template.dto.js +9 -0
- package/src/lib/dto/create-template.dto.js.map +1 -1
- package/src/lib/dto/render-template-layout.dto.d.ts +3 -3
- package/src/lib/dto/render-template-layout.dto.js +9 -3
- package/src/lib/dto/render-template-layout.dto.js.map +1 -1
- package/src/lib/engines/template/nunjucks.engine.d.ts +1 -1
- package/src/lib/engines/template/nunjucks.engine.js +2 -2
- package/src/lib/engines/template/nunjucks.engine.js.map +1 -1
- package/src/lib/engines/template/pug.engine.d.ts +4 -3
- package/src/lib/engines/template/pug.engine.js +12 -4
- package/src/lib/engines/template/pug.engine.js.map +1 -1
- package/src/lib/entities/template-layout.entity.d.ts +2 -1
- package/src/lib/entities/template-layout.entity.js +16 -13
- package/src/lib/entities/template-layout.entity.js.map +1 -1
- package/src/lib/interfaces/module-config.interface.d.ts +3 -3
- package/src/lib/services/template-layout.service.d.ts +5 -4
- package/src/lib/services/template-layout.service.js +94 -63
- package/src/lib/services/template-layout.service.js.map +1 -1
- package/src/lib/templates.module.js +0 -3
- package/src/lib/templates.module.js.map +1 -1
- package/src/test/helpers.d.ts +4 -0
- package/src/test/helpers.js +34 -0
- package/src/test/helpers.js.map +1 -0
- package/src/lib/controllers/template-layout.controller.d.ts +0 -18
- package/src/lib/controllers/template-layout.controller.js +0 -96
- package/src/lib/controllers/template-layout.controller.js.map +0 -1
- package/src/lib/controllers/template.controller.d.ts +0 -17
- package/src/lib/controllers/template.controller.js +0 -100
- package/src/lib/controllers/template.controller.js.map +0 -1
package/package.json
CHANGED
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { NestDynamicTemplateLayout } from './lib/entities/template-layout.entity';
|
|
2
|
-
import { NestDynamicTemplate } from './lib/entities/template.entity';
|
|
3
2
|
export * from './lib/templates.module';
|
|
4
3
|
export * from './lib/services/template.service';
|
|
5
4
|
export * from './lib/services/template-layout.service';
|
|
6
5
|
export * from './lib/interfaces/module-config.interface';
|
|
7
6
|
export * from './lib/interfaces/template.types';
|
|
8
|
-
export declare const NestDynamicTemplatesEntities: (typeof NestDynamicTemplateLayout
|
|
7
|
+
export declare const NestDynamicTemplatesEntities: (typeof NestDynamicTemplateLayout)[];
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { TemplateEngineEnum, TemplateLanguageEnum, TemplateTypeEnum } from '../interfaces/template.types';
|
|
2
2
|
export declare class CreateTemplateDto {
|
|
3
3
|
name: string;
|
|
4
|
+
templateLayoutName?: string;
|
|
4
5
|
type: TemplateTypeEnum;
|
|
5
6
|
displayName: string;
|
|
6
7
|
description?: string;
|
|
@@ -21,6 +21,12 @@ tslib_1.__decorate([
|
|
|
21
21
|
(0, class_validator_1.Matches)(/^[a-z0-9\-_]+$/, { message: 'Invalid template name format' }),
|
|
22
22
|
tslib_1.__metadata("design:type", String)
|
|
23
23
|
], CreateTemplateDto.prototype, "name", void 0);
|
|
24
|
+
tslib_1.__decorate([
|
|
25
|
+
(0, swagger_1.ApiPropertyOptional)({ type: String, nullable: true }),
|
|
26
|
+
(0, class_validator_1.IsString)(),
|
|
27
|
+
(0, class_validator_1.IsOptional)(),
|
|
28
|
+
tslib_1.__metadata("design:type", String)
|
|
29
|
+
], CreateTemplateDto.prototype, "templateLayoutName", void 0);
|
|
24
30
|
tslib_1.__decorate([
|
|
25
31
|
(0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateTypeEnum, type: String }),
|
|
26
32
|
(0, class_validator_1.IsEnum)(template_types_1.TemplateTypeEnum),
|
|
@@ -52,6 +58,7 @@ tslib_1.__decorate([
|
|
|
52
58
|
tslib_1.__decorate([
|
|
53
59
|
(0, swagger_1.ApiProperty)({ type: String, nullable: true }),
|
|
54
60
|
(0, class_validator_1.IsString)(),
|
|
61
|
+
(0, class_validator_1.IsOptional)(),
|
|
55
62
|
tslib_1.__metadata("design:type", String)
|
|
56
63
|
], CreateTemplateDto.prototype, "content", void 0);
|
|
57
64
|
tslib_1.__decorate([
|
|
@@ -76,6 +83,7 @@ tslib_1.__decorate([
|
|
|
76
83
|
(0, swagger_1.ApiPropertyOptional)({ type: String, nullable: true, default: 'en' }),
|
|
77
84
|
(0, class_validator_1.IsString)(),
|
|
78
85
|
(0, class_validator_1.IsOptional)(),
|
|
86
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
79
87
|
tslib_1.__metadata("design:type", String)
|
|
80
88
|
], CreateTemplateDto.prototype, "locale", void 0);
|
|
81
89
|
tslib_1.__decorate([
|
|
@@ -85,6 +93,7 @@ tslib_1.__decorate([
|
|
|
85
93
|
], CreateTemplateDto.prototype, "previewContext", void 0);
|
|
86
94
|
tslib_1.__decorate([
|
|
87
95
|
(0, swagger_1.ApiPropertyOptional)({ type: Boolean, nullable: true }),
|
|
96
|
+
(0, class_validator_1.IsBoolean)(),
|
|
88
97
|
(0, class_validator_1.IsOptional)(),
|
|
89
98
|
tslib_1.__metadata("design:type", Boolean)
|
|
90
99
|
], CreateTemplateDto.prototype, "isActive", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"create-template.dto.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/dto/create-template.dto.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"create-template.dto.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/dto/create-template.dto.ts"],"names":[],"mappings":";;;;AAAA,qDAA+F;AAC/F,iEAA0G;AAC1G,6CAAmE;AAGnE,MAAa,iBAAiB;IAA9B;QA8BI,WAAM,GAAuB,mCAAkB,CAAC,QAAQ,CAAC;QAmBzD,UAAK,GAAW,QAAQ,CAAC;QAWzB,WAAM,GAAY,IAAI,CAAC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EAAE,IAAI,EAAE,CAAC;IAC7C,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;kDACG;AAKhB;IAHC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;kDACI;AAKjB;IAHC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IACxD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;gDACY;AAKzB;IAHC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACrC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;kDACI;AAMjB;IAJC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;IACpE,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,4BAAU,GAAE;;iDACU;AAIvB;IAFC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrD,IAAA,4BAAU,GAAE;;yDACwB;AAKrC;IAHC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACtD,IAAA,2BAAS,GAAE;IACX,IAAA,4BAAU,GAAE;;mDACa"}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { TemplateTypeEnum } from '../interfaces/template.types';
|
|
2
2
|
export declare class RenderTemplateLayoutDto {
|
|
3
3
|
type: TemplateTypeEnum;
|
|
4
|
-
locale
|
|
4
|
+
locale?: string;
|
|
5
5
|
name: string;
|
|
6
6
|
scope: string;
|
|
7
|
-
scopeId
|
|
8
|
-
context
|
|
7
|
+
scopeId?: string;
|
|
8
|
+
context?: Record<string, any>;
|
|
9
9
|
}
|
|
10
10
|
export declare class RenderTemplateLayoutOutput {
|
|
11
11
|
content: string;
|
|
@@ -6,6 +6,10 @@ const class_validator_1 = require("class-validator");
|
|
|
6
6
|
const template_types_1 = require("../interfaces/template.types");
|
|
7
7
|
const swagger_1 = require("@nestjs/swagger");
|
|
8
8
|
class RenderTemplateLayoutDto {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.locale = 'en';
|
|
11
|
+
this.scopeId = null;
|
|
12
|
+
}
|
|
9
13
|
}
|
|
10
14
|
exports.RenderTemplateLayoutDto = RenderTemplateLayoutDto;
|
|
11
15
|
tslib_1.__decorate([
|
|
@@ -15,12 +19,13 @@ tslib_1.__decorate([
|
|
|
15
19
|
tslib_1.__metadata("design:type", String)
|
|
16
20
|
], RenderTemplateLayoutDto.prototype, "type", void 0);
|
|
17
21
|
tslib_1.__decorate([
|
|
18
|
-
(0, swagger_1.
|
|
22
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
19
23
|
type: String,
|
|
20
24
|
default: 'en',
|
|
21
25
|
description: 'The locale code, i.e en, fr, es, etc.'
|
|
22
26
|
}),
|
|
23
27
|
(0, class_validator_1.IsString)(),
|
|
28
|
+
(0, class_validator_1.IsOptional)(),
|
|
24
29
|
tslib_1.__metadata("design:type", String)
|
|
25
30
|
], RenderTemplateLayoutDto.prototype, "locale", void 0);
|
|
26
31
|
tslib_1.__decorate([
|
|
@@ -39,16 +44,17 @@ tslib_1.__decorate([
|
|
|
39
44
|
tslib_1.__metadata("design:type", String)
|
|
40
45
|
], RenderTemplateLayoutDto.prototype, "scope", void 0);
|
|
41
46
|
tslib_1.__decorate([
|
|
42
|
-
(0, swagger_1.
|
|
47
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
43
48
|
type: String,
|
|
44
49
|
default: null,
|
|
45
50
|
description: 'The scope id of the template, i.e user id, organization id, etc.'
|
|
46
51
|
}),
|
|
47
52
|
(0, class_validator_1.IsString)(),
|
|
53
|
+
(0, class_validator_1.IsOptional)(),
|
|
48
54
|
tslib_1.__metadata("design:type", String)
|
|
49
55
|
], RenderTemplateLayoutDto.prototype, "scopeId", void 0);
|
|
50
56
|
tslib_1.__decorate([
|
|
51
|
-
(0, swagger_1.
|
|
57
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
52
58
|
type: String,
|
|
53
59
|
nullable: true,
|
|
54
60
|
description: 'The context of the template'
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"render-template-layout.dto.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/dto/render-template-layout.dto.ts"],"names":[],"mappings":";;;;AAAA,qDAAqF;AACrF,iEAAgE;AAChE,
|
|
1
|
+
{"version":3,"file":"render-template-layout.dto.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/dto/render-template-layout.dto.ts"],"names":[],"mappings":";;;;AAAA,qDAAqF;AACrF,iEAAgE;AAChE,6CAAmE;AAGnE,MAAa,uBAAuB;IAApC;QAcI,WAAM,GAAY,IAAI,CAAC;QAsBvB,YAAO,GAAY,IAAI,CAAC;IAU5B,CAAC;CAAA;AA9CD,0DA8CC;AAzCG;IAHC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,iCAAgB,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACrD,IAAA,4BAAU,GAAE;IACZ,IAAA,wBAAM,EAAC,iCAAgB,CAAC;;qDACF;AASvB;IAPC,IAAA,6BAAmB,EAAC;QACjB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,uCAAuC;KACvD,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;uDACU;AAKvB;IAHC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;qDACA;AAQb;IANC,IAAA,qBAAW,EAAC;QACT,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,QAAQ;QACjB,WAAW,EAAE,yDAAyD;KACzE,CAAC;IACD,IAAA,0BAAQ,GAAE;;sDACG;AASd;IAPC,IAAA,6BAAmB,EAAC;QACjB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,IAAI;QACb,WAAW,EAAE,kEAAkE;KAClF,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wDACW;AASxB;IAPC,IAAA,6BAAmB,EAAC;QACjB,IAAI,EAAE,MAAM;QACZ,QAAQ,EAAE,IAAI;QACd,WAAW,EAAE,6BAA6B;KAC7C,CAAC;IACD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wDACiB;AAIlC,MAAa,0BAA0B;CAKtC;AALD,gEAKC;AADG;IAHC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;2DACG"}
|
|
@@ -7,7 +7,7 @@ export declare class NunjucksEngine extends TemplateEngine {
|
|
|
7
7
|
private customOptions?;
|
|
8
8
|
static engineName: TemplateEngineEnum;
|
|
9
9
|
private env;
|
|
10
|
-
constructor(options?: EngineOptions<ConfigureOptions>, customOptions?: CustomEngineOptions
|
|
10
|
+
constructor(options?: EngineOptions<ConfigureOptions>, customOptions?: CustomEngineOptions);
|
|
11
11
|
initNunjucks(): Promise<void>;
|
|
12
12
|
render(content: string, data?: Record<string, any>): Promise<string>;
|
|
13
13
|
validate(content: string): Promise<boolean>;
|
|
@@ -52,8 +52,8 @@ class NunjucksEngine extends template_engine_1.TemplateEngine {
|
|
|
52
52
|
throwOnUndefined: true,
|
|
53
53
|
...nunjucksOptions,
|
|
54
54
|
});
|
|
55
|
-
this.customOptions?.filters
|
|
56
|
-
this.registerFilter(
|
|
55
|
+
Object.entries(this.customOptions?.filters || {}).forEach(([name, filter]) => {
|
|
56
|
+
this.registerFilter(name, filter);
|
|
57
57
|
});
|
|
58
58
|
}
|
|
59
59
|
async render(content, data) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"nunjucks.engine.js","sourceRoot":"","sources":["../../../../../../../packages/nest-dynamic-templates/src/lib/engines/template/nunjucks.engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA8B;AAC9B,oEAAqE;AACrE,wDAAoD;AAIpD,MAAa,cAAe,SAAQ,gCAAc;IAM9C,YAAoB,OAAyC,EAAU,
|
|
1
|
+
{"version":3,"file":"nunjucks.engine.js","sourceRoot":"","sources":["../../../../../../../packages/nest-dynamic-templates/src/lib/engines/template/nunjucks.engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAA8B;AAC9B,oEAAqE;AACrE,wDAAoD;AAIpD,MAAa,cAAe,SAAQ,gCAAc;IAM9C,YAAoB,OAAyC,EAAU,aAAmC;QACtG,KAAK,EAAE,CAAC;QADQ,YAAO,GAAP,OAAO,CAAkC;QAAU,kBAAa,GAAb,aAAa,CAAsB;QAEtG,IAAI,CAAC,YAAY,EAAE,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,YAAY;QACd,MAAM,QAAQ,GAAG,wDAAa,UAAU,GAAC,CAAC;QAE1C,MAAM,eAAe,GAAG,IAAA,aAAI,EAAC,IAAI,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;QAEtD,IAAI,CAAC,GAAG,GAAG,QAAQ,CAAC,SAAS,CAAC;YAC1B,UAAU,EAAE,IAAI;YAChB,gBAAgB,EAAE,IAAI;YACtB,GAAG,eAAe;SACrB,CAAC,CAAC;QAEH,MAAM,CAAC,OAAO,CAAC,IAAI,CAAC,aAAa,EAAE,OAAO,IAAI,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,EAAE,M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plateEngine } from '../template-engine';
|
|
4
|
-
import { EngineOptions } from '../../interfaces/module-config.interface';
|
|
4
|
+
import { CustomEngineOptions, EngineOptions } from '../../interfaces/module-config.interface';
|
|
5
5
|
export declare class PugEngine extends TemplateEngine {
|
|
6
|
+
private customOptions?;
|
|
6
7
|
static engineName: TemplateEngineEnum;
|
|
7
8
|
private options;
|
|
8
|
-
constructor(options?: EngineOptions<Options
|
|
9
|
-
render(content: string, data
|
|
9
|
+
constructor(options?: EngineOptions<Options>, customOptions?: CustomEngineOptions);
|
|
10
|
+
render(content: string, data: any): Promise<string>;
|
|
10
11
|
validate(content: string): Promise<boolean>;
|
|
11
12
|
}
|
|
@@ -37,15 +37,23 @@ exports.PugEngine = void 0;
|
|
|
37
37
|
const template_types_1 = require("../../interfaces/template.types");
|
|
38
38
|
const template_engine_1 = require("../template-engine");
|
|
39
39
|
class PugEngine extends template_engine_1.TemplateEngine {
|
|
40
|
-
constructor(options) {
|
|
40
|
+
constructor(options, customOptions) {
|
|
41
41
|
super();
|
|
42
|
-
this.
|
|
42
|
+
this.customOptions = customOptions;
|
|
43
|
+
this.options = options || {};
|
|
43
44
|
}
|
|
44
45
|
async render(content, data) {
|
|
45
46
|
try {
|
|
46
47
|
const pug = await Promise.resolve().then(() => __importStar(require('pug')));
|
|
47
|
-
const template = pug.compile(content,
|
|
48
|
-
|
|
48
|
+
const template = pug.compile(content, {
|
|
49
|
+
...this.options,
|
|
50
|
+
filters: this.customOptions?.filters
|
|
51
|
+
});
|
|
52
|
+
return template({
|
|
53
|
+
...this.options.filters,
|
|
54
|
+
...data,
|
|
55
|
+
...this.customOptions?.filters
|
|
56
|
+
});
|
|
49
57
|
}
|
|
50
58
|
catch (error) {
|
|
51
59
|
throw new Error(`Failed to render Pug template: ${error?.message || 'Unknown error'}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"pug.engine.js","sourceRoot":"","sources":["../../../../../../../packages/nest-dynamic-templates/src/lib/engines/template/pug.engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oEAAqE;AACrE,wDAAoD;AAGpD,MAAa,SAAU,SAAQ,gCAAc;IAMzC,YAAY,OAAgC;
|
|
1
|
+
{"version":3,"file":"pug.engine.js","sourceRoot":"","sources":["../../../../../../../packages/nest-dynamic-templates/src/lib/engines/template/pug.engine.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,oEAAqE;AACrE,wDAAoD;AAGpD,MAAa,SAAU,SAAQ,gCAAc;IAMzC,YAAY,OAAgC,EAAU,aAAmC;QACrF,KAAK,EAAE,CAAC;QAD0C,kBAAa,GAAb,aAAa,CAAsB;QAErF,IAAI,CAAC,OAAO,GAAG,OAAO,IAAI,EAAE,CAAC;IACjC,CAAC;IAED,KAAK,CAAC,MAAM,CAAC,OAAe,EAAE,IAAS;QACnC,IAAI,CAAC;YACD,MAAM,GAAG,GAAG,wDAAa,KAAK,GAAC,CAAC;YAChC,MAAM,QAAQ,GAAG,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE;gBAClC,GAAG,IAAI,CAAC,OAAO;gBACf,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,OAAO;aACvC,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC;gBACZ,GAAG,IAAI,CAAC,OAAO,CAAC,OAAO;gBACvB,GAAG,IAAI;gBACP,GAAG,IAAI,CAAC,aAAa,EAAE,OAAO;aACjC,CAAC,CAAC;QACP,CAAC;QAAC,OAAO,KAAU,EAAE,CAAC;YAClB,MAAM,IAAI,KAAK,CAAC,kCAAkC,KAAK,EAAE,OAAO,IAAI,eAAe,EAAE,CAAC,CAAC;QAC3F,CAAC;IACL,CAAC;IAED,KAAK,CAAC,QAAQ,CAAC,OAAe;QAC1B,IAAI,CAAC;YACD,MAAM,GAAG,GAAG,wDAAa,KAAK,GAAC,CAAC;YAChC,GAAG,CAAC,OAAO,CAAC,OAAO,EAAE,IAAI,CAAC,OAAO,CAAC,CAAC;YACnC,OAAO,IAAI,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACb,OAAO,KAAK,CAAC;QACjB,CAAC;IACL,CAAC;;AApCL,8BAqCC;AAnCmB,oBAAU,GAAG,mCAAkB,CAAC,GAAG,CAAC"}
|
|
@@ -8,7 +8,8 @@ export declare class NestDynamicTemplateLayout {
|
|
|
8
8
|
engine: TemplateEngineEnum;
|
|
9
9
|
language?: TemplateLanguageEnum;
|
|
10
10
|
content: string;
|
|
11
|
-
|
|
11
|
+
templateLayoutName?: string;
|
|
12
|
+
scope?: string;
|
|
12
13
|
scopeId?: string;
|
|
13
14
|
locale?: string;
|
|
14
15
|
previewContext?: Record<string, any>;
|
|
@@ -16,8 +16,9 @@ tslib_1.__decorate([
|
|
|
16
16
|
], NestDynamicTemplateLayout.prototype, "id", void 0);
|
|
17
17
|
tslib_1.__decorate([
|
|
18
18
|
(0, swagger_1.ApiProperty)({ type: String }),
|
|
19
|
+
(0, class_validator_1.IsString)(),
|
|
19
20
|
(0, class_validator_1.IsNotEmpty)(),
|
|
20
|
-
(0, class_validator_1.Matches)(/^[a-z0-9\-_]+$/, { message: 'Invalid
|
|
21
|
+
(0, class_validator_1.Matches)(/^[a-z0-9\-_]+$/, { message: 'Invalid template name format' }),
|
|
21
22
|
(0, typeorm_1.Column)(),
|
|
22
23
|
tslib_1.__metadata("design:type", String)
|
|
23
24
|
], NestDynamicTemplateLayout.prototype, "name", void 0);
|
|
@@ -38,10 +39,7 @@ tslib_1.__decorate([
|
|
|
38
39
|
tslib_1.__decorate([
|
|
39
40
|
(0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateTypeEnum, type: String }),
|
|
40
41
|
(0, class_validator_1.IsEnum)(template_types_1.TemplateTypeEnum),
|
|
41
|
-
(0, typeorm_1.Column)({
|
|
42
|
-
type: 'text',
|
|
43
|
-
default: template_types_1.TemplateTypeEnum.EMAIL
|
|
44
|
-
}),
|
|
42
|
+
(0, typeorm_1.Column)({ type: 'text' }),
|
|
45
43
|
tslib_1.__metadata("design:type", String)
|
|
46
44
|
], NestDynamicTemplateLayout.prototype, "type", void 0);
|
|
47
45
|
tslib_1.__decorate([
|
|
@@ -49,6 +47,7 @@ tslib_1.__decorate([
|
|
|
49
47
|
(0, class_validator_1.IsEnum)(template_types_1.TemplateEngineEnum),
|
|
50
48
|
(0, typeorm_1.Column)({
|
|
51
49
|
type: 'text',
|
|
50
|
+
enum: template_types_1.TemplateEngineEnum,
|
|
52
51
|
default: template_types_1.TemplateEngineEnum.NUNJUCKS
|
|
53
52
|
}),
|
|
54
53
|
tslib_1.__metadata("design:type", String)
|
|
@@ -57,34 +56,38 @@ tslib_1.__decorate([
|
|
|
57
56
|
(0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateLanguageEnum, type: String, nullable: true }),
|
|
58
57
|
(0, class_validator_1.IsEnum)(template_types_1.TemplateLanguageEnum),
|
|
59
58
|
(0, class_validator_1.IsOptional)(),
|
|
60
|
-
(0, typeorm_1.Column)({
|
|
61
|
-
type: 'text',
|
|
62
|
-
nullable: true
|
|
63
|
-
}),
|
|
59
|
+
(0, typeorm_1.Column)({ type: 'text' }),
|
|
64
60
|
tslib_1.__metadata("design:type", String)
|
|
65
61
|
], NestDynamicTemplateLayout.prototype, "language", void 0);
|
|
66
62
|
tslib_1.__decorate([
|
|
67
63
|
(0, swagger_1.ApiProperty)({ type: String }),
|
|
68
64
|
(0, class_validator_1.IsString)(),
|
|
65
|
+
(0, class_validator_1.IsOptional)(),
|
|
69
66
|
(0, typeorm_1.Column)('text'),
|
|
70
67
|
tslib_1.__metadata("design:type", String)
|
|
71
68
|
], NestDynamicTemplateLayout.prototype, "content", void 0);
|
|
72
69
|
tslib_1.__decorate([
|
|
73
|
-
(0, swagger_1.ApiProperty)({ type: String }),
|
|
70
|
+
(0, swagger_1.ApiProperty)({ type: String, nullable: true }),
|
|
74
71
|
(0, class_validator_1.IsString)(),
|
|
75
|
-
(0,
|
|
72
|
+
(0, class_validator_1.IsOptional)(),
|
|
73
|
+
(0, typeorm_1.Column)({ nullable: true }),
|
|
74
|
+
tslib_1.__metadata("design:type", String)
|
|
75
|
+
], NestDynamicTemplateLayout.prototype, "templateLayoutName", void 0);
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, swagger_1.ApiProperty)({ type: String, nullable: true }),
|
|
78
|
+
(0, class_validator_1.IsString)(),
|
|
79
|
+
(0, typeorm_1.Column)({ nullable: true, default: 'system' }),
|
|
76
80
|
tslib_1.__metadata("design:type", String)
|
|
77
81
|
], NestDynamicTemplateLayout.prototype, "scope", void 0);
|
|
78
82
|
tslib_1.__decorate([
|
|
79
83
|
(0, swagger_1.ApiProperty)({ type: String, nullable: true }),
|
|
80
|
-
(0, class_validator_1.
|
|
84
|
+
(0, class_validator_1.IsString)(),
|
|
81
85
|
(0, typeorm_1.Column)({ nullable: true }),
|
|
82
86
|
tslib_1.__metadata("design:type", String)
|
|
83
87
|
], NestDynamicTemplateLayout.prototype, "scopeId", void 0);
|
|
84
88
|
tslib_1.__decorate([
|
|
85
89
|
(0, swagger_1.ApiProperty)({ type: String, nullable: true }),
|
|
86
90
|
(0, class_validator_1.IsString)(),
|
|
87
|
-
(0, class_validator_1.IsOptional)(),
|
|
88
91
|
(0, typeorm_1.Column)({ nullable: true, default: 'en' }),
|
|
89
92
|
tslib_1.__metadata("design:type", String)
|
|
90
93
|
], NestDynamicTemplateLayout.prototype, "locale", void 0);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-layout.entity.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/entities/template-layout.entity.ts"],"names":[],"mappings":";;;;AAAA,qCAA4G;AAC5G,qDAA+F;AAC/F,iEAA0G;AAC1G,6CAA8C;AAKvC,IAAM,yBAAyB,GAA/B,MAAM,yBAAyB;
|
|
1
|
+
{"version":3,"file":"template-layout.entity.js","sourceRoot":"","sources":["../../../../../../pack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|
9
9
|
}
|
|
10
10
|
export type EngineOptions<T> = T & {};
|
|
11
|
-
export type CustomEngineOptions
|
|
12
|
-
filters?: FilterOptions[]
|
|
11
|
+
export type CustomEngineOptions = {
|
|
12
|
+
filters?: Record<string, FilterOptions['filter']>;
|
|
13
13
|
};
|
|
14
14
|
export interface NestDynamicTemplatesModuleConfig {
|
|
15
15
|
enginesOptions?: {
|
|
16
|
-
filters?:
|
|
16
|
+
filters?: CustomEngineOptions['filters'];
|
|
17
17
|
template?: Partial<Record<TemplateEngineEnum, EngineOptions<any>>>;
|
|
18
18
|
language?: Partial<Record<TemplateLanguageEnum, EngineOptions<any>>>;
|
|
19
19
|
};
|
|
@@ -11,9 +11,10 @@ export declare class TemplateLayoutService {
|
|
|
11
11
|
constructor(layoutRepository: Repository<NestDynamicTemplateLayout>, engineRegistry: TemplateEngineRegistryService);
|
|
12
12
|
render(renderDto: RenderTemplateLayoutDto): Promise<RenderTemplateLayoutOutput>;
|
|
13
13
|
getTemplateLayouts(filter?: TemplateLayoutFilterDto): Promise<NestDynamicTemplateLayout[]>;
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
getTemplateLayoutById(id: string): Promise<NestDynamicTemplateLayout | null>;
|
|
15
|
+
findTemplateLayout(type: TemplateTypeEnum, name: string, scope?: string, scopeId?: string, locale?: string): Promise<NestDynamicTemplateLayout | null>;
|
|
16
|
+
createTemplateLayout(data: CreateTemplateLayoutDto): Promise<NestDynamicTemplateLayout>;
|
|
17
|
+
overwriteSystemTemplateLayout(templateId: string, updates: Partial<CreateTemplateLayoutDto>): Promise<NestDynamicTemplateLayout>;
|
|
18
|
+
updateTemplateLayout(id: string, updates: Partial<CreateTemplateLayoutDto>, canUpdateSystemTemplate?: boolean): Promise<NestDynamicTemplateLayout>;
|
|
17
19
|
deleteTemplateLayout(id: string, canDeleteSystemTemplate?: boolean): Promise<void>;
|
|
18
|
-
deleteSystemTemplateLayout(id: string, canDeleteSystemTemplate?: boolean): Promise<void>;
|
|
19
20
|
}
|
|
@@ -14,18 +14,18 @@ let TemplateLayoutService = class TemplateLayoutService {
|
|
|
14
14
|
}
|
|
15
15
|
async render(renderDto) {
|
|
16
16
|
const { type, name, scope, scopeId, locale, context } = renderDto;
|
|
17
|
-
const
|
|
18
|
-
if (!
|
|
17
|
+
const templateLayout = await this.findTemplateLayout(type, name, scope, scopeId, locale);
|
|
18
|
+
if (!templateLayout) {
|
|
19
19
|
throw new common_1.NotFoundException(`Template not found: ${name}`);
|
|
20
20
|
}
|
|
21
|
-
const templateEngine = this.engineRegistry.getTemplateEngine(
|
|
22
|
-
let content = await templateEngine.render(
|
|
23
|
-
if (
|
|
24
|
-
const languageEngine = this.engineRegistry.getLanguageEngine(
|
|
21
|
+
const templateEngine = this.engineRegistry.getTemplateEngine(templateLayout.engine);
|
|
22
|
+
let content = await templateEngine.render(templateLayout.content, context);
|
|
23
|
+
if (templateLayout.language) {
|
|
24
|
+
const languageEngine = this.engineRegistry.getLanguageEngine(templateLayout.language);
|
|
25
25
|
content = await languageEngine.render(content);
|
|
26
26
|
}
|
|
27
27
|
if (content) {
|
|
28
|
-
const contentEngine = this.engineRegistry.getTemplateEngine(
|
|
28
|
+
const contentEngine = this.engineRegistry.getTemplateEngine(templateLayout.engine);
|
|
29
29
|
content = await contentEngine.render(content, context);
|
|
30
30
|
}
|
|
31
31
|
return {
|
|
@@ -72,102 +72,133 @@ let TemplateLayoutService = class TemplateLayoutService {
|
|
|
72
72
|
}
|
|
73
73
|
return Array.from(templateMap.values());
|
|
74
74
|
}
|
|
75
|
-
async
|
|
76
|
-
|
|
77
|
-
where: {
|
|
78
|
-
type,
|
|
79
|
-
name,
|
|
80
|
-
scope,
|
|
81
|
-
scopeId: scopeId || (0, typeorm_2.IsNull)(),
|
|
82
|
-
locale,
|
|
83
|
-
},
|
|
75
|
+
async getTemplateLayoutById(id) {
|
|
76
|
+
return this.layoutRepository.findOne({
|
|
77
|
+
where: { id },
|
|
84
78
|
});
|
|
85
|
-
|
|
86
|
-
|
|
79
|
+
}
|
|
80
|
+
async findTemplateLayout(type, name, scope, scopeId, locale) {
|
|
81
|
+
const locales = (locale ? [locale, 'en'] : ['en']).filter(Boolean);
|
|
82
|
+
for (const currentLocale of locales) {
|
|
83
|
+
const template = await this.layoutRepository.findOne({
|
|
87
84
|
where: {
|
|
88
85
|
type,
|
|
89
86
|
name,
|
|
90
|
-
scope
|
|
91
|
-
scopeId: (0, typeorm_2.IsNull)(),
|
|
92
|
-
locale,
|
|
93
|
-
}
|
|
87
|
+
scope,
|
|
88
|
+
scopeId: scope === 'system' ? (0, typeorm_2.IsNull)() : (0, typeorm_2.Equal)(scopeId),
|
|
89
|
+
locale: currentLocale,
|
|
90
|
+
}
|
|
94
91
|
});
|
|
92
|
+
if (template) {
|
|
93
|
+
return template;
|
|
94
|
+
}
|
|
95
95
|
}
|
|
96
|
-
|
|
96
|
+
if (scope !== 'system') {
|
|
97
|
+
for (const currentLocale of locales) {
|
|
98
|
+
const template = await this.layoutRepository.findOne({
|
|
99
|
+
where: {
|
|
100
|
+
type,
|
|
101
|
+
name,
|
|
102
|
+
scope: 'system',
|
|
103
|
+
scopeId: (0, typeorm_2.IsNull)(),
|
|
104
|
+
locale: currentLocale,
|
|
105
|
+
}
|
|
106
|
+
});
|
|
107
|
+
if (template) {
|
|
108
|
+
return template;
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
return null;
|
|
97
113
|
}
|
|
98
|
-
async
|
|
114
|
+
async createTemplateLayout(data) {
|
|
115
|
+
if (data.scope !== 'system') {
|
|
116
|
+
throw new common_1.ForbiddenException('Only system templates can be created directly');
|
|
117
|
+
}
|
|
99
118
|
const existingTemplate = await this.layoutRepository.findOne({
|
|
100
119
|
where: {
|
|
101
120
|
name: data.name,
|
|
121
|
+
type: data.type,
|
|
102
122
|
scope: 'system',
|
|
103
|
-
scopeId:
|
|
104
|
-
|
|
123
|
+
scopeId: (0, typeorm_2.IsNull)(),
|
|
124
|
+
locale: data.locale,
|
|
125
|
+
},
|
|
105
126
|
});
|
|
106
127
|
if (existingTemplate) {
|
|
107
|
-
throw new
|
|
128
|
+
throw new common_1.ConflictException(`System template already exists`);
|
|
108
129
|
}
|
|
109
130
|
const template = this.layoutRepository.create({
|
|
110
131
|
...data,
|
|
111
|
-
scopeId: null
|
|
132
|
+
scopeId: null,
|
|
112
133
|
});
|
|
113
134
|
return this.layoutRepository.save(template);
|
|
114
135
|
}
|
|
115
|
-
async
|
|
116
|
-
|
|
117
|
-
where: {
|
|
118
|
-
id,
|
|
119
|
-
scope: 'system',
|
|
120
|
-
scopeId: null
|
|
121
|
-
}
|
|
136
|
+
async overwriteSystemTemplateLayout(templateId, updates) {
|
|
137
|
+
let template = await this.layoutRepository.findOne({
|
|
138
|
+
where: { id: templateId },
|
|
122
139
|
});
|
|
123
140
|
if (!template) {
|
|
124
|
-
throw new common_1.NotFoundException(`
|
|
141
|
+
throw new common_1.NotFoundException(`Template not found: ${templateId}`);
|
|
125
142
|
}
|
|
126
|
-
if (
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
let existingTemplate = await this.layoutRepository.findOne({
|
|
143
|
+
if (template.scope === 'system') {
|
|
144
|
+
if (!updates.scope) {
|
|
145
|
+
throw new common_1.BadRequestException('Scope is required when overwriting system template');
|
|
146
|
+
}
|
|
147
|
+
const existingTemplate = await this.layoutRepository.findOne({
|
|
132
148
|
where: {
|
|
133
149
|
name: template.name,
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
150
|
+
type: template.type,
|
|
151
|
+
locale: template.locale,
|
|
152
|
+
scope: updates.scope,
|
|
153
|
+
scopeId: (0, typeorm_2.Equal)(updates.scopeId),
|
|
154
|
+
},
|
|
137
155
|
});
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
...
|
|
156
|
+
if (existingTemplate) {
|
|
157
|
+
template = existingTemplate;
|
|
158
|
+
}
|
|
159
|
+
else {
|
|
160
|
+
const newTemplate = this.layoutRepository.create({
|
|
161
|
+
...template,
|
|
162
|
+
id: undefined,
|
|
163
|
+
createdAt: undefined,
|
|
164
|
+
updatedAt: undefined,
|
|
165
|
+
scope: updates.scope,
|
|
166
|
+
scopeId: updates.scopeId,
|
|
144
167
|
});
|
|
168
|
+
template = newTemplate;
|
|
145
169
|
}
|
|
146
|
-
existingTemplate = this.layoutRepository.merge(existingTemplate, updates);
|
|
147
|
-
return this.layoutRepository.save(existingTemplate);
|
|
148
170
|
}
|
|
171
|
+
template = this.layoutRepository.merge(template, updates);
|
|
172
|
+
await this.layoutRepository.save(template);
|
|
173
|
+
return template;
|
|
149
174
|
}
|
|
150
|
-
async
|
|
151
|
-
|
|
175
|
+
async updateTemplateLayout(id, updates, canUpdateSystemTemplate = false) {
|
|
176
|
+
let template = await this.layoutRepository.findOne({
|
|
152
177
|
where: { id },
|
|
153
178
|
});
|
|
154
179
|
if (!template) {
|
|
155
|
-
throw new
|
|
180
|
+
throw new common_1.NotFoundException(`Template not found: ${id}`);
|
|
156
181
|
}
|
|
157
|
-
if (template.scope === 'system' && !
|
|
158
|
-
|
|
182
|
+
if (template.scope === 'system' && !canUpdateSystemTemplate) {
|
|
183
|
+
if (updates.scope) {
|
|
184
|
+
return this.overwriteSystemTemplateLayout(id, updates);
|
|
185
|
+
}
|
|
186
|
+
else {
|
|
187
|
+
throw new common_1.ForbiddenException('Cannot update system templates');
|
|
188
|
+
}
|
|
159
189
|
}
|
|
160
|
-
|
|
190
|
+
template = this.layoutRepository.merge(template, updates);
|
|
191
|
+
return this.layoutRepository.save(template);
|
|
161
192
|
}
|
|
162
|
-
async
|
|
193
|
+
async deleteTemplateLayout(id, canDeleteSystemTemplate = false) {
|
|
163
194
|
const template = await this.layoutRepository.findOne({
|
|
164
|
-
where: { id }
|
|
195
|
+
where: { id },
|
|
165
196
|
});
|
|
166
197
|
if (!template) {
|
|
167
|
-
throw new
|
|
198
|
+
throw new Error(`Template not found: ${id}`);
|
|
168
199
|
}
|
|
169
200
|
if (template.scope === 'system' && !canDeleteSystemTemplate) {
|
|
170
|
-
throw new
|
|
201
|
+
throw new common_1.ForbiddenException('Cannot delete system templates');
|
|
171
202
|
}
|
|
172
203
|
await this.layoutRepository.remove(template);
|
|
173
204
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"template-layout.service.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/services/template-layout.service.ts"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"template-layout.service.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/services/template-layout.service.ts"],"names":[],"mappings":";;;;AAAA,2CAA2H;AAC3H,6CAAmD;AACnD,qCAA6D;AAC7D,+EAA+E;AAG/E,yEAA2E;AAKpE,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,YAEqB,gBAAuD,EACvD,cAA6C;QAD7C,qBAAgB,GAAhB,gBAAgB,CAAuC;QACvD,mBAAc,GAAd,cAAc,CAA+B;IAC9D,CAAC;IAGL,KAAK,CAAC,MAAM,CAAC,SAAkC;QAC3C,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,GAAG,SAAS,CAAC;QAGlE,MAAM,cAAc,GAAG,MAAM,IAAI,CAAC,kBAAkB,CAAC,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,CAAC,CAAC;QACzF,IAAI,CAAC,cAAc,EAAE,CAAC;YAClB,MAAM,IAAI,0BAAiB,CAAC,uBAAuB,IAAI,EAAE,CAAC,CAAC;QAC/D,CAAC;QAGD,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAAC,cAAc,CAAC,MAAM,CAAC,CAAC;QACpF,IAAI,OAAO,GAAG,MAAM,cAAc,CAAC,MA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AC;QAGD,QAAQ,GAAG,IAAI,CAAC,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;QAC1D,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAChD,CAAC;IAKD,KAAK,CAAC,oBAAoB,CAAC,EAAU,EAAE,0BAAmC,KAAK;QAC3E,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,gBAAgB,CAAC,OAAO,CAAC;YACjD,KAAK,EAAE,EAAE,EAAE,EAAE;SAChB,CAAC,CAAC;QAEH,IAAI,CAAC,QAAQ,EAAE,CAAC;YACZ,MAAM,IAAI,KAAK,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;QACjD,CAAC;QAGD,IAAI,QAAQ,CAAC,KAAK,KAAK,QAAQ,IAAI,CAAC,uBAAuB,EAAE,CAAC;YAC1D,MAAM,IAAI,2BAAkB,CAAC,gCAAgC,CAAC,CAAC;QACnE,CAAC;QAED,MAAM,IAAI,CAAC,gBAAgB,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IACjD,CAAC;CACJ,CAAA;AAjSY,sDAAqB;gCAArB,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAGJ,mBAAA,IAAA,0BAAgB,EAAC,kDAAyB,CAAC,CAAA;6CACT,oBAAU;QACZ,wDAA6B;GAJzD,qBAAqB,CAiSjC"}
|
|
@@ -10,8 +10,6 @@ const template_layout_entity_1 = require("./entities/template-layout.entity");
|
|
|
10
10
|
const template_service_1 = require("./services/template.service");
|
|
11
11
|
const template_layout_service_1 = require("./services/template-layout.service");
|
|
12
12
|
const template_engine_registry_1 = require("./services/template-engine.registry");
|
|
13
|
-
const template_layout_controller_1 = require("./controllers/template-layout.controller");
|
|
14
|
-
const template_controller_1 = require("./controllers/template.controller");
|
|
15
13
|
const constant_1 = require("./constant");
|
|
16
14
|
const deepmerge_1 = tslib_1.__importDefault(require("deepmerge"));
|
|
17
15
|
const template_types_1 = require("./interfaces/template.types");
|
|
@@ -34,7 +32,6 @@ let NestDynamicTemplatesModule = NestDynamicTemplatesModule_1 = class NestDynami
|
|
|
34
32
|
];
|
|
35
33
|
return {
|
|
36
34
|
module: NestDynamicTemplatesModule_1,
|
|
37
|
-
controllers: [template_controller_1.TemplateController, template_layout_controller_1.TemplateLayoutController],
|
|
38
35
|
imports: [
|
|
39
36
|
typeorm_1.TypeOrmModule.forFeature([template_entity_1.NestDynamicTemplate, template_layout_entity_1.NestDynamicTemplateLayout])
|
|
40
37
|
],
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"templates.module.js","sourceRoot":"","sources":["../../../../../packages/nest-dynamic-templates/src/lib/templates.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AACvD,6CAAgD;AAChD,gEAAiE;AACjE,8EAA8E;AAC9E,kEAA8D;AAC9D,gFAA2E;AAC3E,kFAAoF;
|
|
1
|
+
{"version":3,"file":"templates.module.js","sourceRoot":"","sources":["../../../../../packages/nest-dynamic-templates/src/lib/templates.module.ts"],"names":[],"mappings":";;;;;AAAA,2CAAuD;AACvD,6CAAgD;AAChD,gEAAiE;AACjE,8EAA8E;AAC9E,kEAA8D;AAC9D,gFAA2E;AAC3E,kFAAoF;AAEpF,yCAAkE;AAClE,kEAAkC;AAClC,gEAAuF;AAGvF,MAAM,aAAa,GAAqC;IACtD,OAAO,EAAE;QACP,QAAQ,EAAE,CAAC,mCAAkB,CAAC,QAAQ,CAAC;QACvC,QAAQ,EAAE,CAAC,qCAAoB,CAAC,IAAI,EAAE,qCAAoB,CAAC,IAAI,EAAE,qCAAoB,CAAC,IAAI,CAAC;KAC5F;CACF,CAAA;AAGM,IAAM,0BAA0B,kCAAhC,MAAM,0BAA0B;IAErC,MAAM,CAAC,OAAO,CAAC,MAAyC;QACtD,MAAM,SAAS,GAAG;YAChB,kCAAe;YACf,+CAAqB;YACrB,wDAA6B;YAC7B;gBACE,OAAO,EAAE,+CAAoC;gBAC7C,QAAQ,EAAE,IAAA,mBAAS,EAAC,aAAa,EAAE,MAAM,CAAC;aAC3C;SACF,CAAC;QAEF,OAAO;YACL,MAAM,EAAE,4BAA0B;YAClC,OAAO,EAAE;gBACP,uBAAa,CAAC,UAAU,CAAC,CAAC,qCAAmB,EAAE,kDAAyB,CAAC,CAAC;aAC3E;YACD,SAAS;YACT,OAAO,EAAE,CAAC,kCAAe,EAAE,+CAAqB,CAAC;SAClD,CAAC;IACJ,CAAC;CAEF,CAAA;AAvBY,gEAA0B;qCAA1B,0BAA0B;IADtC,IAAA,eAAM,EAAC,EAAE,CAAC;GACE,0BAA0B,CAuBtC"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.engineFilters = void 0;
|
|
4
|
+
exports.engineFilters = {
|
|
5
|
+
formatDate: (date, format) => {
|
|
6
|
+
const year = date.getFullYear();
|
|
7
|
+
const month = String(date.getMonth() + 1).padStart(2, '0');
|
|
8
|
+
const day = String(date.getDate()).padStart(2, '0');
|
|
9
|
+
switch (format) {
|
|
10
|
+
case 'YYYY-MM-DD':
|
|
11
|
+
return `${year}-${month}-${day}`;
|
|
12
|
+
case 'MM/DD/YY':
|
|
13
|
+
return `${month}/${day}/${String(year).slice(-2)}`;
|
|
14
|
+
case 'MMMM D, YYYY':
|
|
15
|
+
return date.toLocaleDateString('en-US', {
|
|
16
|
+
year: 'numeric',
|
|
17
|
+
month: 'long',
|
|
18
|
+
day: 'numeric'
|
|
19
|
+
});
|
|
20
|
+
default:
|
|
21
|
+
return `${year}-${month}-${day}`;
|
|
22
|
+
}
|
|
23
|
+
},
|
|
24
|
+
formatCurrency: (amount, currency) => {
|
|
25
|
+
const formatter = new Intl.NumberFormat('en-US', {
|
|
26
|
+
style: 'currency',
|
|
27
|
+
currency: currency,
|
|
28
|
+
minimumFractionDigits: 2,
|
|
29
|
+
maximumFractionDigits: 2
|
|
30
|
+
});
|
|
31
|
+
return formatter.format(amount);
|
|
32
|
+
}
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../../../../packages/nest-dynamic-templates/src/test/helpers.ts"],"names":[],"mappings":";;;AAAa,QAAA,aAAa,GAAG;IACzB,UAAU,EAAE,CAAC,IAAU,EAAE,MAAc,EAAE,EAAE;QACvC,MAAM,IAAI,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QAChC,MAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,QAAQ,EAAE,GAAG,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAC3D,MAAM,GAAG,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,EAAE,GAAG,CAAC,CAAC;QAEpD,QAAQ,MAAM,EAAE,CAAC;YACb,KAAK,YAAY;gBACb,OAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;YACrC,KAAK,UAAU;gBACX,OAAO,GAAG,KAAK,IAAI,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACvD,KAAK,cAAc;gBACf,OAAO,IAAI,CAAC,kBAAkB,CAAC,OAAO,EAAE;oBACpC,IAAI,EAAE,SAAS;oBACf,KAAK,EAAE,MAAM;oBACb,GAAG,EAAE,SAAS;iBACjB,CAAC,CAAC;YACP;gBACI,OAAO,GAAG,IAAI,IAAI,KAAK,IAAI,GAAG,EAAE,CAAC;QACzC,CAAC;IACL,CAAC;IACD,cAAc,EAAE,CAAC,MAAc,EAAE,QAAgB,EAAE,EAAE;QACjD,MAAM,SAAS,GAAG,IAAI,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE;YAC7C,KAAK,EAAE,UAAU;YACjB,QAAQ,EAAE,QAAQ;YAClB,qBAAqB,EAAE,CAAC;YACxB,qBAAqB,EAAE,CAAC;SAC3B,CAAC,CAAC;QACH,OAAO,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;IACpC,CAAC;CACJ,CAAA"}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { Repository } from 'typeorm';
|
|
2
|
-
import { NestDynamicTemplateLayout } from '../entities/template-layout.entity';
|
|
3
|
-
import { TemplateLayoutService } from '../services/template-layout.service';
|
|
4
|
-
import { CreateTemplateLayoutDto } from '../dto/create-template-layout.dto';
|
|
5
|
-
import { RenderTemplateLayoutDto } from '../dto/render-template-layout.dto';
|
|
6
|
-
export declare class TemplateLayoutController {
|
|
7
|
-
private readonly layoutRepository;
|
|
8
|
-
private readonly layoutService;
|
|
9
|
-
constructor(layoutRepository: Repository<NestDynamicTemplateLayout>, layoutService: TemplateLayoutService);
|
|
10
|
-
findAll(scope?: string, scopeId?: string): Promise<NestDynamicTemplateLayout[]>;
|
|
11
|
-
findOne(id: string): Promise<NestDynamicTemplateLayout>;
|
|
12
|
-
create(layout: CreateTemplateLayoutDto): Promise<NestDynamicTemplateLayout>;
|
|
13
|
-
update(id: string, layout: Partial<CreateTemplateLayoutDto>): Promise<NestDynamicTemplateLayout>;
|
|
14
|
-
remove(id: string): Promise<{
|
|
15
|
-
success: boolean;
|
|
16
|
-
}>;
|
|
17
|
-
render(data: RenderTemplateLayoutDto): Promise<import("../dto/render-template-layout.dto").RenderTemplateLayoutOutput>;
|
|
18
|
-
}
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TemplateLayoutController = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const typeorm_1 = require("@nestjs/typeorm");
|
|
7
|
-
const typeorm_2 = require("typeorm");
|
|
8
|
-
const template_layout_entity_1 = require("../entities/template-layout.entity");
|
|
9
|
-
const template_layout_service_1 = require("../services/template-layout.service");
|
|
10
|
-
const create_template_layout_dto_1 = require("../dto/create-template-layout.dto");
|
|
11
|
-
const render_template_layout_dto_1 = require("../dto/render-template-layout.dto");
|
|
12
|
-
let TemplateLayoutController = class TemplateLayoutController {
|
|
13
|
-
constructor(layoutRepository, layoutService) {
|
|
14
|
-
this.layoutRepository = layoutRepository;
|
|
15
|
-
this.layoutService = layoutService;
|
|
16
|
-
}
|
|
17
|
-
async findAll(scope, scopeId) {
|
|
18
|
-
const where = { isActive: true };
|
|
19
|
-
if (scope)
|
|
20
|
-
where.scope = scope;
|
|
21
|
-
if (scopeId)
|
|
22
|
-
where.scopeId = scopeId;
|
|
23
|
-
return this.layoutRepository.find({
|
|
24
|
-
where,
|
|
25
|
-
order: { createdAt: 'DESC' },
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
async findOne(id) {
|
|
29
|
-
return this.layoutRepository.findOneOrFail({ where: { id } });
|
|
30
|
-
}
|
|
31
|
-
async create(layout) {
|
|
32
|
-
return this.layoutService.createSystemTemplateLayout(layout);
|
|
33
|
-
}
|
|
34
|
-
async update(id, layout) {
|
|
35
|
-
return this.layoutService.updateSystemTemplateLayout(id, layout);
|
|
36
|
-
}
|
|
37
|
-
async remove(id) {
|
|
38
|
-
await this.layoutService.deleteTemplateLayout(id);
|
|
39
|
-
return { success: true };
|
|
40
|
-
}
|
|
41
|
-
async render(data) {
|
|
42
|
-
return this.layoutService.render(data);
|
|
43
|
-
}
|
|
44
|
-
};
|
|
45
|
-
exports.TemplateLayoutController = TemplateLayoutController;
|
|
46
|
-
tslib_1.__decorate([
|
|
47
|
-
(0, common_1.Get)(),
|
|
48
|
-
tslib_1.__param(0, (0, common_1.Query)('scope')),
|
|
49
|
-
tslib_1.__param(1, (0, common_1.Query)('scopeId')),
|
|
50
|
-
tslib_1.__metadata("design:type", Function),
|
|
51
|
-
tslib_1.__metadata("design:paramtypes", [String, String]),
|
|
52
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
53
|
-
], TemplateLayoutController.prototype, "findAll", null);
|
|
54
|
-
tslib_1.__decorate([
|
|
55
|
-
(0, common_1.Get)(':id'),
|
|
56
|
-
tslib_1.__param(0, (0, common_1.Param)('id')),
|
|
57
|
-
tslib_1.__metadata("design:type", Function),
|
|
58
|
-
tslib_1.__metadata("design:paramtypes", [String]),
|
|
59
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
60
|
-
], TemplateLayoutController.prototype, "findOne", null);
|
|
61
|
-
tslib_1.__decorate([
|
|
62
|
-
(0, common_1.Post)(),
|
|
63
|
-
tslib_1.__param(0, (0, common_1.Body)()),
|
|
64
|
-
tslib_1.__metadata("design:type", Function),
|
|
65
|
-
tslib_1.__metadata("design:paramtypes", [create_template_layout_dto_1.CreateTemplateLayoutDto]),
|
|
66
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
67
|
-
], TemplateLayoutController.prototype, "create", null);
|
|
68
|
-
tslib_1.__decorate([
|
|
69
|
-
(0, common_1.Put)(':id'),
|
|
70
|
-
tslib_1.__param(0, (0, common_1.Param)('id')),
|
|
71
|
-
tslib_1.__param(1, (0, common_1.Body)()),
|
|
72
|
-
tslib_1.__metadata("design:type", Function),
|
|
73
|
-
tslib_1.__metadata("design:paramtypes", [String, Object]),
|
|
74
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
75
|
-
], TemplateLayoutController.prototype, "update", null);
|
|
76
|
-
tslib_1.__decorate([
|
|
77
|
-
(0, common_1.Delete)(':id'),
|
|
78
|
-
tslib_1.__param(0, (0, common_1.Param)('id')),
|
|
79
|
-
tslib_1.__metadata("design:type", Function),
|
|
80
|
-
tslib_1.__metadata("design:paramtypes", [String]),
|
|
81
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
82
|
-
], TemplateLayoutController.prototype, "remove", null);
|
|
83
|
-
tslib_1.__decorate([
|
|
84
|
-
(0, common_1.Post)('render'),
|
|
85
|
-
tslib_1.__param(0, (0, common_1.Body)()),
|
|
86
|
-
tslib_1.__metadata("design:type", Function),
|
|
87
|
-
tslib_1.__metadata("design:paramtypes", [render_template_layout_dto_1.RenderTemplateLayoutDto]),
|
|
88
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
89
|
-
], TemplateLayoutController.prototype, "render", null);
|
|
90
|
-
exports.TemplateLayoutController = TemplateLayoutController = tslib_1.__decorate([
|
|
91
|
-
(0, common_1.Controller)('template-layouts'),
|
|
92
|
-
tslib_1.__param(0, (0, typeorm_1.InjectRepository)(template_layout_entity_1.NestDynamicTemplateLayout)),
|
|
93
|
-
tslib_1.__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
94
|
-
template_layout_service_1.TemplateLayoutService])
|
|
95
|
-
], TemplateLayoutController);
|
|
96
|
-
//# sourceMappingURL=template-layout.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template-layout.controller.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/controllers/template-layout.controller.ts"],"names":[],"mappings":";;;;AAAA,2CASwB;AACxB,6CAAmD;AACnD,qCAAqC;AACrC,+EAA+E;AAC/E,iFAA4E;AAC5E,kFAA4E;AAC5E,kFAA4E;AAGrE,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACjC,YAEqB,gBAAuD,EACvD,aAAoC;QADpC,qBAAgB,GAAhB,gBAAgB,CAAuC;QACvD,kBAAa,GAAb,aAAa,CAAuB;IACrD,CAAC;IAGC,AAAN,KAAK,CAAC,OAAO,CACO,KAAc,EACZ,OAAgB;QAElC,MAAM,KAAK,GAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACtC,IAAI,KAAK;YAAE,KAAK,CAAC,KAAK,GAAG,KAAK,CAAC;QAC/B,IAAI,OAAO;YAAE,KAAK,CAAC,OAAO,GAAG,OAAO,CAAC;QAErC,OAAO,IAAI,CAAC,gBAAgB,CAAC,IAA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BAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,mBAAA,IAAA,aAAI,GAAE,CAAA;;;;sDAGV;AAGK;IADL,IAAA,eAAM,EAAC,KAAK,CAAC;IACA,mBAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;sDAGxB;AAGK;IADL,IAAA,aAAI,EAAC,QAAQ,CAAC;IACD,mBAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,oDAAuB;;sDAEjD;mCAjDQ,wBAAwB;IADpC,IAAA,mBAAU,EAAC,kBAAkB,CAAC;IAGtB,mBAAA,IAAA,0BAAgB,EAAC,kDAAyB,CAAC,CAAA;6CACT,oBAAU;QACb,+CAAqB;GAJhD,wBAAwB,CAkDpC"}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { Repository } from 'typeorm';
|
|
2
|
-
import { NestDynamicTemplate } from '../entities/template.entity';
|
|
3
|
-
import { TemplateService } from '../services/template.service';
|
|
4
|
-
import { RenderTemplateDto, RenderTemplateOutputDTO } from '../dto/render-template.dto';
|
|
5
|
-
export declare class TemplateController {
|
|
6
|
-
private readonly templateRepository;
|
|
7
|
-
private readonly templateService;
|
|
8
|
-
constructor(templateRepository: Repository<NestDynamicTemplate>, templateService: TemplateService);
|
|
9
|
-
findAll(type?: string, scope?: string, scopeId?: string): Promise<NestDynamicTemplate[]>;
|
|
10
|
-
findOne(id: string): Promise<NestDynamicTemplate>;
|
|
11
|
-
create(template: NestDynamicTemplate): Promise<NestDynamicTemplate>;
|
|
12
|
-
update(id: string, template: NestDynamicTemplate): Promise<NestDynamicTemplate>;
|
|
13
|
-
remove(id: string): Promise<{
|
|
14
|
-
success: boolean;
|
|
15
|
-
}>;
|
|
16
|
-
render(data: RenderTemplateDto): Promise<RenderTemplateOutputDTO>;
|
|
17
|
-
}
|
|
@@ -1,100 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TemplateController = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const common_1 = require("@nestjs/common");
|
|
6
|
-
const typeorm_1 = require("@nestjs/typeorm");
|
|
7
|
-
const typeorm_2 = require("typeorm");
|
|
8
|
-
const template_entity_1 = require("../entities/template.entity");
|
|
9
|
-
const template_service_1 = require("../services/template.service");
|
|
10
|
-
const render_template_dto_1 = require("../dto/render-template.dto");
|
|
11
|
-
let TemplateController = class TemplateController {
|
|
12
|
-
constructor(templateRepository, templateService) {
|
|
13
|
-
this.templateRepository = templateRepository;
|
|
14
|
-
this.templateService = templateService;
|
|
15
|
-
}
|
|
16
|
-
async findAll(type, scope, scopeId) {
|
|
17
|
-
const where = { isActive: true };
|
|
18
|
-
if (type)
|
|
19
|
-
where.type = type;
|
|
20
|
-
if (scope)
|
|
21
|
-
where.scope = scope;
|
|
22
|
-
if (scopeId)
|
|
23
|
-
where.scopeId = scopeId;
|
|
24
|
-
return this.templateRepository.find({
|
|
25
|
-
where,
|
|
26
|
-
order: { createdAt: 'DESC' },
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
async findOne(id) {
|
|
30
|
-
return this.templateRepository.findOneOrFail({ where: { id } });
|
|
31
|
-
}
|
|
32
|
-
async create(template) {
|
|
33
|
-
const newTemplate = this.templateRepository.create(template);
|
|
34
|
-
return this.templateRepository.save(newTemplate);
|
|
35
|
-
}
|
|
36
|
-
async update(id, template) {
|
|
37
|
-
await this.templateRepository.update(id, template);
|
|
38
|
-
return this.templateRepository.findOneOrFail({ where: { id } });
|
|
39
|
-
}
|
|
40
|
-
async remove(id) {
|
|
41
|
-
await this.templateRepository.update(id, { isActive: false });
|
|
42
|
-
return { success: true };
|
|
43
|
-
}
|
|
44
|
-
async render(data) {
|
|
45
|
-
return this.templateService.render(data);
|
|
46
|
-
}
|
|
47
|
-
};
|
|
48
|
-
exports.TemplateController = TemplateController;
|
|
49
|
-
tslib_1.__decorate([
|
|
50
|
-
(0, common_1.Get)(),
|
|
51
|
-
tslib_1.__param(0, (0, common_1.Query)('type')),
|
|
52
|
-
tslib_1.__param(1, (0, common_1.Query)('scope')),
|
|
53
|
-
tslib_1.__param(2, (0, common_1.Query)('scopeId')),
|
|
54
|
-
tslib_1.__metadata("design:type", Function),
|
|
55
|
-
tslib_1.__metadata("design:paramtypes", [String, String, String]),
|
|
56
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
57
|
-
], TemplateController.prototype, "findAll", null);
|
|
58
|
-
tslib_1.__decorate([
|
|
59
|
-
(0, common_1.Get)(':id'),
|
|
60
|
-
tslib_1.__param(0, (0, common_1.Param)('id')),
|
|
61
|
-
tslib_1.__metadata("design:type", Function),
|
|
62
|
-
tslib_1.__metadata("design:paramtypes", [String]),
|
|
63
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
64
|
-
], TemplateController.prototype, "findOne", null);
|
|
65
|
-
tslib_1.__decorate([
|
|
66
|
-
(0, common_1.Post)(),
|
|
67
|
-
tslib_1.__param(0, (0, common_1.Body)()),
|
|
68
|
-
tslib_1.__metadata("design:type", Function),
|
|
69
|
-
tslib_1.__metadata("design:paramtypes", [template_entity_1.NestDynamicTemplate]),
|
|
70
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
71
|
-
], TemplateController.prototype, "create", null);
|
|
72
|
-
tslib_1.__decorate([
|
|
73
|
-
(0, common_1.Put)(':id'),
|
|
74
|
-
tslib_1.__param(0, (0, common_1.Param)('id')),
|
|
75
|
-
tslib_1.__param(1, (0, common_1.Body)()),
|
|
76
|
-
tslib_1.__metadata("design:type", Function),
|
|
77
|
-
tslib_1.__metadata("design:paramtypes", [String, template_entity_1.NestDynamicTemplate]),
|
|
78
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
79
|
-
], TemplateController.prototype, "update", null);
|
|
80
|
-
tslib_1.__decorate([
|
|
81
|
-
(0, common_1.Delete)(':id'),
|
|
82
|
-
tslib_1.__param(0, (0, common_1.Param)('id')),
|
|
83
|
-
tslib_1.__metadata("design:type", Function),
|
|
84
|
-
tslib_1.__metadata("design:paramtypes", [String]),
|
|
85
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
86
|
-
], TemplateController.prototype, "remove", null);
|
|
87
|
-
tslib_1.__decorate([
|
|
88
|
-
(0, common_1.Post)('render'),
|
|
89
|
-
tslib_1.__param(0, (0, common_1.Body)()),
|
|
90
|
-
tslib_1.__metadata("design:type", Function),
|
|
91
|
-
tslib_1.__metadata("design:paramtypes", [render_template_dto_1.RenderTemplateDto]),
|
|
92
|
-
tslib_1.__metadata("design:returntype", Promise)
|
|
93
|
-
], TemplateController.prototype, "render", null);
|
|
94
|
-
exports.TemplateController = TemplateController = tslib_1.__decorate([
|
|
95
|
-
(0, common_1.Controller)('templates'),
|
|
96
|
-
tslib_1.__param(0, (0, typeorm_1.InjectRepository)(template_entity_1.NestDynamicTemplate)),
|
|
97
|
-
tslib_1.__metadata("design:paramtypes", [typeorm_2.Repository,
|
|
98
|
-
template_service_1.TemplateService])
|
|
99
|
-
], TemplateController);
|
|
100
|
-
//# sourceMappingURL=template.controller.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"template.controller.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/controllers/template.controller.ts"],"names":[],"mappings":";;;;AAAA,2CAUwB;AACxB,6CAAmD;AACnD,qCAAqC;AACrC,iEAAkE;AAClE,mEAA+D;AAC/D,oEAAwF;AAGjF,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC3B,YAEqB,kBAAmD,EACnD,eAAgC;QADhC,uBAAkB,GAAlB,kBAAkB,CAAiC;QACnD,oBAAe,GAAf,eAAe,CAAiB;IACjD,CAAC;IAGC,AAAN,KAAK,CAAC,OAAO,CACM,IAAa,EACZ,KAAc,EACZ,OAAgB;QAElC,MAAM,KAAK,GAAQ,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;QACtC,IAAI,IAAI;YAAE,KAAK,CAAC,IAAI,GAA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