UNPKG

@ackplus/nest-dynamic-templates

Version:

A powerful and flexible dynamic template rendering library for NestJS applications with support for Nunjucks, Handlebars, EJS, Pug, MJML, Markdown, and more.

138 lines 5.91 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); 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; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.CreateTemplateLayoutDto = void 0; const class_validator_1 = require("class-validator"); const template_types_1 = require("../interfaces/template.types"); const swagger_1 = require("@nestjs/swagger"); class CreateTemplateLayoutDto { name; type; displayName; description; engine = template_types_1.TemplateEngineEnum.NUNJUCKS; language; content; scope = 'system'; scopeId; locale = 'en'; previewContext; isActive = true; } exports.CreateTemplateLayoutDto = CreateTemplateLayoutDto; __decorate([ (0, swagger_1.ApiProperty)({ type: String, example: 'email-shell', description: 'Stable identifier you reference by (lowercase letters, numbers, "-" and "_").', }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsNotEmpty)(), (0, class_validator_1.Matches)(/^[a-z0-9\-_]+$/, { message: 'Invalid template name format' }), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "name", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: String, description: 'Free category for grouping/filtering.' }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsOptional)(), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "type", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ type: String, description: 'Human-friendly label for admin UIs.' }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsNotEmpty)(), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "displayName", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Free-text notes about what this layout is for.' }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsOptional)(), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "description", void 0); __decorate([ (0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateEngineEnum, type: String, description: 'Template engine that interpolates variables: njk (Nunjucks), hbs, ejs, pug.', }), (0, class_validator_1.IsEnum)(template_types_1.TemplateEngineEnum), (0, class_validator_1.IsOptional)(), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "engine", void 0); __decorate([ (0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateLanguageEnum, type: String, description: 'Output processor applied after interpolation: html, mjml, md, txt.', }), (0, class_validator_1.IsEnum)(template_types_1.TemplateLanguageEnum), (0, class_validator_1.IsNotEmpty)(), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "language", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: String, nullable: true, example: '<html><body>{{ content }}</body></html>', description: 'The layout body. Use {{ content }} where the wrapped template should be injected.', }), (0, class_validator_1.IsString)(), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "content", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ type: String, default: 'system', description: 'Who owns this version: "system" (shared default) or a custom owner kind like "tenant"/"user".', }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsOptional)(), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "scope", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ type: String, description: 'Which owner inside the scope (e.g. the tenant id). Leave empty for system layouts.', }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsOptional)(), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "scopeId", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ type: String, nullable: true, default: 'en', description: 'Language variant, e.g. en, fr, es. Missing locales fall back to "en".', }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsOptional)(), __metadata("design:type", String) ], CreateTemplateLayoutDto.prototype, "locale", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ type: Object, nullable: true, description: 'Sample data used to preview the layout (not applied during render).', }), (0, class_validator_1.IsOptional)(), __metadata("design:type", Object) ], CreateTemplateLayoutDto.prototype, "previewContext", void 0); __decorate([ (0, swagger_1.ApiPropertyOptional)({ type: Boolean, nullable: true, description: 'Set false to disable without deleting.', }), (0, class_validator_1.IsOptional)(), __metadata("design:type", Boolean) ], CreateTemplateLayoutDto.prototype, "isActive", void 0); //# sourceMappingURL=create-template-layout.dto.js.map