@ackplus/nest-dynamic-templates 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +173 -0
- package/package.json +62 -0
- package/src/index.d.ts +5 -0
- package/src/index.js +9 -0
- package/src/index.js.map +1 -0
- package/src/lib/constant.d.ts +1 -0
- package/src/lib/constant.js +5 -0
- package/src/lib/constant.js.map +1 -0
- package/src/lib/controllers/template-layout.controller.d.ts +18 -0
- package/src/lib/controllers/template-layout.controller.js +96 -0
- package/src/lib/controllers/template-layout.controller.js.map +1 -0
- package/src/lib/controllers/template.controller.d.ts +17 -0
- package/src/lib/controllers/template.controller.js +100 -0
- package/src/lib/controllers/template.controller.js.map +1 -0
- package/src/lib/dto/create-template-layout.dto.d.ts +15 -0
- package/src/lib/dto/create-template-layout.dto.js +86 -0
- package/src/lib/dto/create-template-layout.dto.js.map +1 -0
- package/src/lib/dto/create-template.dto.d.ts +16 -0
- package/src/lib/dto/create-template.dto.js +91 -0
- package/src/lib/dto/create-template.dto.js.map +1 -0
- package/src/lib/dto/render-template-layout.dto.d.ts +12 -0
- package/src/lib/dto/render-template-layout.dto.js +69 -0
- package/src/lib/dto/render-template-layout.dto.js.map +1 -0
- package/src/lib/dto/render-template.dto.d.ts +13 -0
- package/src/lib/dto/render-template.dto.js +82 -0
- package/src/lib/dto/render-template.dto.js.map +1 -0
- package/src/lib/dto/template-filter.dto.d.ts +8 -0
- package/src/lib/dto/template-filter.dto.js +62 -0
- package/src/lib/dto/template-filter.dto.js.map +1 -0
- package/src/lib/dto/template-layout-filter.dto.d.ts +8 -0
- package/src/lib/dto/template-layout-filter.dto.js +62 -0
- package/src/lib/dto/template-layout-filter.dto.js.map +1 -0
- package/src/lib/engines/language/html.engine.d.ts +9 -0
- package/src/lib/engines/language/html.engine.js +79 -0
- package/src/lib/engines/language/html.engine.js.map +1 -0
- package/src/lib/engines/language/index.d.ts +4 -0
- package/src/lib/engines/language/index.js +12 -0
- package/src/lib/engines/language/index.js.map +1 -0
- package/src/lib/engines/language/markdown.engine.d.ts +9 -0
- package/src/lib/engines/language/markdown.engine.js +39 -0
- package/src/lib/engines/language/markdown.engine.js.map +1 -0
- package/src/lib/engines/language/mjml.engine.d.ts +9 -0
- package/src/lib/engines/language/mjml.engine.js +77 -0
- package/src/lib/engines/language/mjml.engine.js.map +1 -0
- package/src/lib/engines/language/text.engine.d.ts +7 -0
- package/src/lib/engines/language/text.engine.js +16 -0
- package/src/lib/engines/language/text.engine.js.map +1 -0
- package/src/lib/engines/language-engine.d.ts +5 -0
- package/src/lib/engines/language-engine.js +7 -0
- package/src/lib/engines/language-engine.js.map +1 -0
- package/src/lib/engines/template/ejs.engine.d.ts +9 -0
- package/src/lib/engines/template/ejs.engine.js +66 -0
- package/src/lib/engines/template/ejs.engine.js.map +1 -0
- package/src/lib/engines/template/handlebars.engine.d.ts +9 -0
- package/src/lib/engines/template/handlebars.engine.js +67 -0
- package/src/lib/engines/template/handlebars.engine.js.map +1 -0
- package/src/lib/engines/template/index.d.ts +4 -0
- package/src/lib/engines/template/index.js +12 -0
- package/src/lib/engines/template/index.js.map +1 -0
- package/src/lib/engines/template/nunjucks.engine.d.ts +12 -0
- package/src/lib/engines/template/nunjucks.engine.js +82 -0
- package/src/lib/engines/template/nunjucks.engine.js.map +1 -0
- package/src/lib/engines/template/pug.engine.d.ts +10 -0
- package/src/lib/engines/template/pug.engine.js +67 -0
- package/src/lib/engines/template/pug.engine.js.map +1 -0
- package/src/lib/engines/template-engine.d.ts +5 -0
- package/src/lib/engines/template-engine.js +7 -0
- package/src/lib/engines/template-engine.js.map +1 -0
- package/src/lib/entities/template-layout.entity.d.ts +18 -0
- package/src/lib/entities/template-layout.entity.js +117 -0
- package/src/lib/entities/template-layout.entity.js.map +1 -0
- package/src/lib/entities/template.entity.d.ts +20 -0
- package/src/lib/entities/template.entity.js +127 -0
- package/src/lib/entities/template.entity.js.map +1 -0
- package/src/lib/interfaces/module-config.interface.d.ts +15 -0
- package/src/lib/interfaces/module-config.interface.js +3 -0
- package/src/lib/interfaces/module-config.interface.js.map +1 -0
- package/src/lib/interfaces/template.types.d.ts +22 -0
- package/src/lib/interfaces/template.types.js +25 -0
- package/src/lib/interfaces/template.types.js.map +1 -0
- package/src/lib/services/template-engine.registry.d.ts +22 -0
- package/src/lib/services/template-engine.registry.js +91 -0
- package/src/lib/services/template-engine.registry.js.map +1 -0
- package/src/lib/services/template-layout.service.d.ts +19 -0
- package/src/lib/services/template-layout.service.js +182 -0
- package/src/lib/services/template-layout.service.js.map +1 -0
- package/src/lib/services/template.service.d.ts +21 -0
- package/src/lib/services/template.service.js +231 -0
- package/src/lib/services/template.service.js.map +1 -0
- package/src/lib/templates.module.d.ts +5 -0
- package/src/lib/templates.module.js +50 -0
- package/src/lib/templates.module.js.map +1 -0
- package/src/test/test-database.config.d.ts +4 -0
- package/src/test/test-database.config.js +24 -0
- package/src/test/test-database.config.js.map +1 -0
- package/src/test/test.setup.d.ts +3 -0
- package/src/test/test.setup.js +29 -0
- package/src/test/test.setup.js.map +1 -0
- package/tsconfig.tsbuildinfo +1 -0
package/README.md
ADDED
|
@@ -0,0 +1,173 @@
|
|
|
1
|
+
# @nestjs/dynamic-templates
|
|
2
|
+
|
|
3
|
+
A dynamic template management system for NestJS applications. This package provides a flexible way to manage and render templates with support for multiple template engines and language formats.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- Support for multiple template engines (Nunjucks, Handlebars, EJS, Pug)
|
|
8
|
+
- Support for multiple language formats (MJML, HTML, Markdown, Text)
|
|
9
|
+
- Template layouts with inheritance
|
|
10
|
+
- Scoped templates with fallback to system templates
|
|
11
|
+
- Locale support with fallback
|
|
12
|
+
- Template validation
|
|
13
|
+
- TypeScript support
|
|
14
|
+
|
|
15
|
+
## Installation
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
npm install @nestjs/dynamic-templates
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
## Quick Start
|
|
22
|
+
|
|
23
|
+
1. Import the module in your `app.module.ts`:
|
|
24
|
+
|
|
25
|
+
```typescript
|
|
26
|
+
import { Module } from '@nestjs/common';
|
|
27
|
+
import { TypeOrmModule } from '@nestjs/typeorm';
|
|
28
|
+
import { NestDynamicTemplatesModule } from '@nestjs/dynamic-templates';
|
|
29
|
+
|
|
30
|
+
@Module({
|
|
31
|
+
imports: [
|
|
32
|
+
TypeOrmModule.forRoot({
|
|
33
|
+
// your database configuration
|
|
34
|
+
}),
|
|
35
|
+
NestDynamicTemplatesModule
|
|
36
|
+
]
|
|
37
|
+
})
|
|
38
|
+
export class AppModule {}
|
|
39
|
+
```
|
|
40
|
+
|
|
41
|
+
2. Use the services in your application:
|
|
42
|
+
|
|
43
|
+
```typescript
|
|
44
|
+
import { Injectable } from '@nestjs/common';
|
|
45
|
+
import { TemplateService } from '@nestjs/dynamic-templates';
|
|
46
|
+
import { TemplateTypeEnum } from '@nestjs/dynamic-templates';
|
|
47
|
+
|
|
48
|
+
@Injectable()
|
|
49
|
+
export class EmailService {
|
|
50
|
+
constructor(private readonly templateService: TemplateService) {}
|
|
51
|
+
|
|
52
|
+
async sendWelcomeEmail(user: any) {
|
|
53
|
+
const result = await this.templateService.renderTemplate({
|
|
54
|
+
type: TemplateTypeEnum.EMAIL,
|
|
55
|
+
name: 'welcome',
|
|
56
|
+
scope: 'user',
|
|
57
|
+
scopeId: user.id,
|
|
58
|
+
locale: user.locale,
|
|
59
|
+
context: {
|
|
60
|
+
user,
|
|
61
|
+
appName: 'My App'
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
// Send email using your email service
|
|
66
|
+
await this.emailService.send({
|
|
67
|
+
to: user.email,
|
|
68
|
+
subject: result.subject,
|
|
69
|
+
html: result.content
|
|
70
|
+
});
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
## Template Creation
|
|
76
|
+
|
|
77
|
+
Create a template using the `TemplateService`:
|
|
78
|
+
|
|
79
|
+
```typescript
|
|
80
|
+
await templateService.createTemplate({
|
|
81
|
+
name: 'welcome',
|
|
82
|
+
type: TemplateTypeEnum.EMAIL,
|
|
83
|
+
format: TemplateFormatEnum.NUNJUCKS,
|
|
84
|
+
languageFormat: LanguageFormatEnum.MJML,
|
|
85
|
+
content: `
|
|
86
|
+
<mjml>
|
|
87
|
+
<mj-body>
|
|
88
|
+
<mj-section>
|
|
89
|
+
<mj-column>
|
|
90
|
+
<mj-text>
|
|
91
|
+
Welcome to {{ appName }}, {{ user.name }}!
|
|
92
|
+
</mj-text>
|
|
93
|
+
</mj-column>
|
|
94
|
+
</mj-section>
|
|
95
|
+
</mj-body>
|
|
96
|
+
</mjml>
|
|
97
|
+
`,
|
|
98
|
+
subject: 'Welcome to {{ appName }}',
|
|
99
|
+
scope: 'user',
|
|
100
|
+
scopeId: '123',
|
|
101
|
+
locale: 'en'
|
|
102
|
+
});
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Template Layouts
|
|
106
|
+
|
|
107
|
+
Create a layout template:
|
|
108
|
+
|
|
109
|
+
```typescript
|
|
110
|
+
await templateLayoutService.createLayout({
|
|
111
|
+
name: 'email-base',
|
|
112
|
+
format: TemplateFormatEnum.NUNJUCKS,
|
|
113
|
+
languageFormat: LanguageFormatEnum.MJML,
|
|
114
|
+
content: `
|
|
115
|
+
<mjml>
|
|
116
|
+
<mj-head>
|
|
117
|
+
<mj-title>{{ title }}</mj-title>
|
|
118
|
+
</mj-head>
|
|
119
|
+
<mj-body>
|
|
120
|
+
<mj-section>
|
|
121
|
+
<mj-column>
|
|
122
|
+
<mj-text>
|
|
123
|
+
{{ content }}
|
|
124
|
+
</mj-text>
|
|
125
|
+
</mj-column>
|
|
126
|
+
</mj-section>
|
|
127
|
+
</mj-body>
|
|
128
|
+
</mjml>
|
|
129
|
+
`,
|
|
130
|
+
scope: 'system'
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
Use the layout in a template:
|
|
135
|
+
|
|
136
|
+
```typescript
|
|
137
|
+
await templateService.createTemplate({
|
|
138
|
+
name: 'welcome',
|
|
139
|
+
type: TemplateTypeEnum.EMAIL,
|
|
140
|
+
format: TemplateFormatEnum.NUNJUCKS,
|
|
141
|
+
languageFormat: LanguageFormatEnum.MJML,
|
|
142
|
+
content: 'Welcome to {{ appName }}, {{ user.name }}!',
|
|
143
|
+
subject: 'Welcome to {{ appName }}',
|
|
144
|
+
templateLayoutName: 'email-base',
|
|
145
|
+
scope: 'user',
|
|
146
|
+
scopeId: '123',
|
|
147
|
+
locale: 'en'
|
|
148
|
+
});
|
|
149
|
+
```
|
|
150
|
+
|
|
151
|
+
## API Reference
|
|
152
|
+
|
|
153
|
+
### TemplateService
|
|
154
|
+
|
|
155
|
+
- `renderTemplate(data: RenderTemplateDto): Promise<TemplateOutputDTO>`
|
|
156
|
+
- `createTemplate(data: CreateTemplateDto): Promise<NestDynamicTemplate>`
|
|
157
|
+
- `updateTemplate(data: UpdateTemplateDto): Promise<NestDynamicTemplate>`
|
|
158
|
+
- `deleteTemplate(id: string): Promise<void>`
|
|
159
|
+
- `findTemplate(id: string): Promise<NestDynamicTemplate>`
|
|
160
|
+
- `findTemplates(type?: TemplateTypeEnum, scope?: string, scopeId?: string, locale?: string): Promise<NestDynamicTemplate[]>`
|
|
161
|
+
|
|
162
|
+
### TemplateLayoutService
|
|
163
|
+
|
|
164
|
+
- `renderLayout(data: RenderTemplateLayoutDto): Promise<string>`
|
|
165
|
+
- `createLayout(data: CreateTemplateLayoutDto): Promise<TemplateLayout>`
|
|
166
|
+
- `updateLayout(data: UpdateTemplateLayoutDto): Promise<TemplateLayout>`
|
|
167
|
+
- `deleteLayout(id: string): Promise<void>`
|
|
168
|
+
- `findLayout(id: string): Promise<TemplateLayout>`
|
|
169
|
+
- `findLayouts(scope?: string, scopeId?: string, locale?: string): Promise<TemplateLayout[]>`
|
|
170
|
+
|
|
171
|
+
## License
|
|
172
|
+
|
|
173
|
+
MIT
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@ackplus/nest-dynamic-templates",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Dynamic template management for NestJS applications",
|
|
5
|
+
"author": "Chetan",
|
|
6
|
+
"dependencies": {
|
|
7
|
+
"@nestjs/common": "^10.0.0",
|
|
8
|
+
"@nestjs/core": "^10.0.0",
|
|
9
|
+
"@nestjs/platform-express": "^10.0.0",
|
|
10
|
+
"@nestjs/swagger": "^7.0.0",
|
|
11
|
+
"@nestjs/typeorm": "^10.0.0",
|
|
12
|
+
"class-transformer": "^0.5.1",
|
|
13
|
+
"class-validator": "^0.14.0",
|
|
14
|
+
"reflect-metadata": "^0.1.13",
|
|
15
|
+
"rxjs": "^7.8.1",
|
|
16
|
+
"typeorm": "^0.3.0"
|
|
17
|
+
},
|
|
18
|
+
"optionalDependencies": {
|
|
19
|
+
"nunjucks": "^3.2.4",
|
|
20
|
+
"handlebars": "^4.7.8",
|
|
21
|
+
"ejs": "^3.1.9",
|
|
22
|
+
"pug": "^3.0.2",
|
|
23
|
+
"mjml": "^4.14.1",
|
|
24
|
+
"marked": "^11.1.1",
|
|
25
|
+
"htmlparser2": "^9.0.0"
|
|
26
|
+
},
|
|
27
|
+
"devDependencies": {
|
|
28
|
+
"@types/jest": "^29.5.0",
|
|
29
|
+
"@types/node": "^20.0.0",
|
|
30
|
+
"@types/nunjucks": "^3.2.5",
|
|
31
|
+
"@types/handlebars": "^4.1.0",
|
|
32
|
+
"@types/ejs": "^3.1.5",
|
|
33
|
+
"@types/pug": "^2.0.6",
|
|
34
|
+
"@types/marked": "^5.0.2",
|
|
35
|
+
"@types/htmlparser2": "^3.10.7",
|
|
36
|
+
"eslint": "^8.0.0",
|
|
37
|
+
"jest": "^29.5.0",
|
|
38
|
+
"typescript": "^5.0.0"
|
|
39
|
+
},
|
|
40
|
+
"peerDependencies": {
|
|
41
|
+
"@nestjs/common": "^10.0.0",
|
|
42
|
+
"@nestjs/core": "^10.0.0",
|
|
43
|
+
"@nestjs/platform-express": "^10.0.0",
|
|
44
|
+
"@nestjs/typeorm": "^10.0.0",
|
|
45
|
+
"typeorm": "^0.3.0"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"nestjs",
|
|
49
|
+
"templates",
|
|
50
|
+
"dynamic",
|
|
51
|
+
"email",
|
|
52
|
+
"mjml",
|
|
53
|
+
"nunjucks",
|
|
54
|
+
"handlebars",
|
|
55
|
+
"ejs",
|
|
56
|
+
"pug"
|
|
57
|
+
],
|
|
58
|
+
"license": "MIT",
|
|
59
|
+
"types": "./src/index.d.ts",
|
|
60
|
+
"main": "./src/index.js",
|
|
61
|
+
"type": "commonjs"
|
|
62
|
+
}
|
package/src/index.d.ts
ADDED
package/src/index.js
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const tslib_1 = require("tslib");
|
|
4
|
+
tslib_1.__exportStar(require("./lib/templates.module"), exports);
|
|
5
|
+
tslib_1.__exportStar(require("./lib/services/template.service"), exports);
|
|
6
|
+
tslib_1.__exportStar(require("./lib/services/template-layout.service"), exports);
|
|
7
|
+
tslib_1.__exportStar(require("./lib/interfaces/module-config.interface"), exports);
|
|
8
|
+
tslib_1.__exportStar(require("./lib/interfaces/template.types"), exports);
|
|
9
|
+
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../packages/nest-dynamic-templates/src/index.ts"],"names":[],"mappings":";;;AAAA,iEAAuC;AAGvC,0EAAgD;AAChD,iFAAuD;AAGvD,mFAAyD;AACzD,0EAAgD"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const NEST_DYNAMIC_TEMPLATES_MODULE_CONFIG = "NEST_DYNAMIC_TEMPLATES_MODULE_CONFIG";
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constant.js","sourceRoot":"","sources":["../../../../../packages/nest-dynamic-templates/src/lib/constant.ts"],"names":[],"mappings":";;;AAAa,QAAA,oCAAoC,GAAG,sCAAsC,CAAC"}
|
|
@@ -0,0 +1,18 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,96 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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;QA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L,IAAA,YAAG,EAAC,KAAK,CAAC;IAEN,mBAAA,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"}
|
|
@@ -0,0 +1,17 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,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CAAC,IAAI,CAAC,CAAC;IAC7C,CAAC;CACJ,CAAA;AAvDY,gDAAkB;AAQrB;IADL,IAAA,YAAG,GAAE;IAED,mBAAA,IAAA,cAAK,EAAC,MAAM,CAAC,CAAA;IACb,mBAAA,IAAA,cAAK,EAAC,OAAO,CAAC,CAAA;IACd,mBAAA,IAAA,cAAK,EAAC,SAAS,CAAC,CAAA;;;;iDAWpB;AAGK;IADL,IAAA,YAAG,EAAC,KAAK,CAAC;IACI,mBAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;iDAEzB;AAGK;IADL,IAAA,aAAI,GAAE;IACO,mBAAA,IAAA,aAAI,GAAE,CAAA;;6CAAW,qCAAmB;;gDAGjD;AAGK;IADL,IAAA,YAAG,EAAC,KAAK,CAAC;IAEN,mBAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;IACX,mBAAA,IAAA,aAAI,GAAE,CAAA;;qDAAW,qCAAmB;;gDAIxC;AAGK;IADL,IAAA,eAAM,EAAC,KAAK,CAAC;IACA,mBAAA,IAAA,cAAK,EAAC,IAAI,CAAC,CAAA;;;;gDAIxB;AAGK;IADL,IAAA,aAAI,EAAC,QAAQ,CAAC;IACD,mBAAA,IAAA,aAAI,GAAE,CAAA;;6CAAO,uCAAiB;;gDAE3C;6BAtDQ,kBAAkB;IAD9B,IAAA,mBAAU,EAAC,WAAW,CAAC;IAGf,mBAAA,IAAA,0BAAgB,EAAC,qCAAmB,CAAC,CAAA;6CACD,oBAAU;QACb,kCAAe;GAJ5C,kBAAkB,CAuD9B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { TemplateEngineEnum, TemplateLanguageEnum, TemplateTypeEnum } from '../interfaces/template.types';
|
|
2
|
+
export declare class CreateTemplateLayoutDto {
|
|
3
|
+
name: string;
|
|
4
|
+
type: TemplateTypeEnum;
|
|
5
|
+
displayName: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
engine: TemplateEngineEnum;
|
|
8
|
+
language: TemplateLanguageEnum;
|
|
9
|
+
content: string;
|
|
10
|
+
scope: string;
|
|
11
|
+
scopeId?: string;
|
|
12
|
+
locale?: string;
|
|
13
|
+
previewContext?: Record<string, any>;
|
|
14
|
+
isActive?: boolean;
|
|
15
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CreateTemplateLayoutDto = void 0;
|
|
4
|
+
const tslib_1 = require("tslib");
|
|
5
|
+
const class_validator_1 = require("class-validator");
|
|
6
|
+
const template_types_1 = require("../interfaces/template.types");
|
|
7
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
8
|
+
class CreateTemplateLayoutDto {
|
|
9
|
+
constructor() {
|
|
10
|
+
this.engine = template_types_1.TemplateEngineEnum.NUNJUCKS;
|
|
11
|
+
this.scope = 'system';
|
|
12
|
+
this.locale = 'en';
|
|
13
|
+
this.isActive = true;
|
|
14
|
+
}
|
|
15
|
+
}
|
|
16
|
+
exports.CreateTemplateLayoutDto = CreateTemplateLayoutDto;
|
|
17
|
+
tslib_1.__decorate([
|
|
18
|
+
(0, swagger_1.ApiProperty)({ type: String }),
|
|
19
|
+
(0, class_validator_1.IsString)(),
|
|
20
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
21
|
+
(0, class_validator_1.Matches)(/^[a-z0-9\-_]+$/, { message: 'Invalid template name format' }),
|
|
22
|
+
tslib_1.__metadata("design:type", String)
|
|
23
|
+
], CreateTemplateLayoutDto.prototype, "name", void 0);
|
|
24
|
+
tslib_1.__decorate([
|
|
25
|
+
(0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateTypeEnum, type: String }),
|
|
26
|
+
(0, class_validator_1.IsEnum)(template_types_1.TemplateTypeEnum),
|
|
27
|
+
tslib_1.__metadata("design:type", String)
|
|
28
|
+
], CreateTemplateLayoutDto.prototype, "type", void 0);
|
|
29
|
+
tslib_1.__decorate([
|
|
30
|
+
(0, swagger_1.ApiPropertyOptional)({ type: String }),
|
|
31
|
+
(0, class_validator_1.IsString)(),
|
|
32
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
33
|
+
tslib_1.__metadata("design:type", String)
|
|
34
|
+
], CreateTemplateLayoutDto.prototype, "displayName", void 0);
|
|
35
|
+
tslib_1.__decorate([
|
|
36
|
+
(0, swagger_1.ApiProperty)({ type: String, nullable: true }),
|
|
37
|
+
(0, class_validator_1.IsString)(),
|
|
38
|
+
(0, class_validator_1.IsOptional)(),
|
|
39
|
+
tslib_1.__metadata("design:type", String)
|
|
40
|
+
], CreateTemplateLayoutDto.prototype, "description", void 0);
|
|
41
|
+
tslib_1.__decorate([
|
|
42
|
+
(0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateEngineEnum, type: String }),
|
|
43
|
+
(0, class_validator_1.IsEnum)(template_types_1.TemplateEngineEnum),
|
|
44
|
+
(0, class_validator_1.IsOptional)(),
|
|
45
|
+
tslib_1.__metadata("design:type", String)
|
|
46
|
+
], CreateTemplateLayoutDto.prototype, "engine", void 0);
|
|
47
|
+
tslib_1.__decorate([
|
|
48
|
+
(0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateLanguageEnum, type: String }),
|
|
49
|
+
(0, class_validator_1.IsEnum)(template_types_1.TemplateLanguageEnum),
|
|
50
|
+
(0, class_validator_1.IsNotEmpty)(),
|
|
51
|
+
tslib_1.__metadata("design:type", String)
|
|
52
|
+
], CreateTemplateLayoutDto.prototype, "language", void 0);
|
|
53
|
+
tslib_1.__decorate([
|
|
54
|
+
(0, swagger_1.ApiProperty)({ type: String, nullable: true }),
|
|
55
|
+
(0, class_validator_1.IsString)(),
|
|
56
|
+
tslib_1.__metadata("design:type", String)
|
|
57
|
+
], CreateTemplateLayoutDto.prototype, "content", void 0);
|
|
58
|
+
tslib_1.__decorate([
|
|
59
|
+
(0, swagger_1.ApiPropertyOptional)({ type: String, default: 'system' }),
|
|
60
|
+
(0, class_validator_1.IsString)(),
|
|
61
|
+
(0, class_validator_1.IsOptional)(),
|
|
62
|
+
tslib_1.__metadata("design:type", String)
|
|
63
|
+
], CreateTemplateLayoutDto.prototype, "scope", void 0);
|
|
64
|
+
tslib_1.__decorate([
|
|
65
|
+
(0, swagger_1.ApiPropertyOptional)({ type: String }),
|
|
66
|
+
(0, class_validator_1.IsString)(),
|
|
67
|
+
(0, class_validator_1.IsOptional)(),
|
|
68
|
+
tslib_1.__metadata("design:type", String)
|
|
69
|
+
], CreateTemplateLayoutDto.prototype, "scopeId", void 0);
|
|
70
|
+
tslib_1.__decorate([
|
|
71
|
+
(0, swagger_1.ApiPropertyOptional)({ type: String, nullable: true, default: 'en' }),
|
|
72
|
+
(0, class_validator_1.IsString)(),
|
|
73
|
+
(0, class_validator_1.IsOptional)(),
|
|
74
|
+
tslib_1.__metadata("design:type", String)
|
|
75
|
+
], CreateTemplateLayoutDto.prototype, "locale", void 0);
|
|
76
|
+
tslib_1.__decorate([
|
|
77
|
+
(0, swagger_1.ApiPropertyOptional)({ type: Object, nullable: true }),
|
|
78
|
+
(0, class_validator_1.IsOptional)(),
|
|
79
|
+
tslib_1.__metadata("design:type", Object)
|
|
80
|
+
], CreateTemplateLayoutDto.prototype, "previewContext", void 0);
|
|
81
|
+
tslib_1.__decorate([
|
|
82
|
+
(0, swagger_1.ApiPropertyOptional)({ type: Boolean, nullable: true }),
|
|
83
|
+
(0, class_validator_1.IsOptional)(),
|
|
84
|
+
tslib_1.__metadata("design:type", Boolean)
|
|
85
|
+
], CreateTemplateLayoutDto.prototype, "isActive", void 0);
|
|
86
|
+
//# sourceMappingURL=create-template-layout.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"create-template-layout.dto.js","sourceRoot":"","sources":["../../../../../../packages/nest-dynamic-templates/src/lib/dto/create-template-layout.dto.ts"],"names":[],"mappings":";;;;AAAA,qDAAoF;AACpF,iEAA0G;AAC1G,6CAAmE;AAGnE,MAAa,uBAAuB;IAApC;QAyBI,WAAM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C7C,IAAA,0BAAQ,GAAE;;wDACK;AAKhB;IAHC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC;IACxD,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;sDACY;AAKzB;IAHC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IACrC,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;;wDACI;AAKjB;IAHC,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;;uDACU;AAIvB;IAFC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACrD,IAAA,4BAAU,GAAE;;+DACwB;AAIrC;IAFC,IAAA,6BAAmB,EAAC,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IACtD,IAAA,4BAAU,GAAE;;yDACa"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { TemplateEngineEnum, TemplateLanguageEnum, TemplateTypeEnum } from '../interfaces/template.types';
|
|
2
|
+
export declare class CreateTemplateDto {
|
|
3
|
+
name: string;
|
|
4
|
+
type: TemplateTypeEnum;
|
|
5
|
+
displayName: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
engine: TemplateEngineEnum;
|
|
8
|
+
language: TemplateLanguageEnum;
|
|
9
|
+
content: string;
|
|
10
|
+
subject?: string;
|
|
11
|
+
scope: string;
|
|
12
|
+
scopeId?: string;
|
|
13
|
+
locale?: string;
|
|
14
|
+
previewContext?: Record<string, any>;
|
|
15
|
+
isActive?: boolean;
|
|
16
|
+
}
|