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.

182 lines 7.98 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.NestDynamicTemplateLayout = void 0; const typeorm_1 = require("typeorm"); const class_validator_1 = require("class-validator"); const template_types_1 = require("../interfaces/template.types"); const swagger_1 = require("@nestjs/swagger"); let NestDynamicTemplateLayout = class NestDynamicTemplateLayout extends typeorm_1.BaseEntity { id; name; displayName; description; type; engine; language; content; templateLayoutName; scope; scopeId; locale; previewContext; isActive; createdAt; updatedAt; }; exports.NestDynamicTemplateLayout = NestDynamicTemplateLayout; __decorate([ (0, swagger_1.ApiProperty)({ type: String, format: 'uuid', readOnly: true, description: 'Primary key.' }), (0, typeorm_1.PrimaryGeneratedColumn)('uuid'), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "id", void 0); __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' }), (0, typeorm_1.Column)(), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "name", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Human-friendly label for admin UIs.' }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsOptional)(), (0, typeorm_1.Column)({ nullable: true }), __metadata("design:type", String) ], NestDynamicTemplateLayout.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)(), (0, typeorm_1.Column)({ type: 'text', nullable: true }), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "description", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Free category for grouping/filtering.' }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsOptional)(), (0, typeorm_1.Column)({ type: 'text' }), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "type", 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, typeorm_1.Column)({ type: 'text', enum: template_types_1.TemplateEngineEnum, default: template_types_1.TemplateEngineEnum.NUNJUCKS }), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "engine", void 0); __decorate([ (0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateLanguageEnum, type: String, nullable: true, description: 'Output processor applied after interpolation: html, mjml, md, txt.', }), (0, class_validator_1.IsEnum)(template_types_1.TemplateLanguageEnum), (0, class_validator_1.IsOptional)(), (0, typeorm_1.Column)({ type: 'text' }), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "language", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: String, description: 'The layout body. Use {{ content }} where the wrapped template should be injected.', }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsOptional)(), (0, typeorm_1.Column)('text'), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "content", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Name of another layout to nest this one in.' }), (0, class_validator_1.IsString)(), (0, class_validator_1.IsOptional)(), (0, typeorm_1.Column)({ nullable: true }), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "templateLayoutName", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: String, nullable: true, default: 'system', description: 'Who owns this version: "system" (shared default) or a custom owner kind like "tenant"/"user". Overrides fall back to the system layout.', }), (0, class_validator_1.IsString)(), (0, typeorm_1.Column)({ nullable: true, default: 'system' }), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "scope", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Which owner inside the scope (e.g. the tenant id). Leave empty for system layouts.', }), (0, class_validator_1.IsString)(), (0, typeorm_1.Column)({ nullable: true }), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "scopeId", void 0); __decorate([ (0, swagger_1.ApiProperty)({ 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, typeorm_1.Column)({ nullable: true, default: 'en' }), __metadata("design:type", String) ], NestDynamicTemplateLayout.prototype, "locale", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: Object, nullable: true, description: 'Sample data used to preview the layout (not applied during render).', }), (0, class_validator_1.IsOptional)(), (0, typeorm_1.Column)('simple-json', { nullable: true }), __metadata("design:type", Object) ], NestDynamicTemplateLayout.prototype, "previewContext", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: Boolean, description: 'Set false to disable without deleting; inactive layouts are skipped during resolution.', }), (0, class_validator_1.IsBoolean)(), (0, typeorm_1.Column)({ default: true }), __metadata("design:type", Boolean) ], NestDynamicTemplateLayout.prototype, "isActive", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: Date, readOnly: true }), (0, typeorm_1.CreateDateColumn)(), __metadata("design:type", Date) ], NestDynamicTemplateLayout.prototype, "createdAt", void 0); __decorate([ (0, swagger_1.ApiProperty)({ type: Date, readOnly: true }), (0, typeorm_1.UpdateDateColumn)(), __metadata("design:type", Date) ], NestDynamicTemplateLayout.prototype, "updatedAt", void 0); exports.NestDynamicTemplateLayout = NestDynamicTemplateLayout = __decorate([ (0, typeorm_1.Entity)('nest_dynamic_template_layouts'), (0, typeorm_1.Index)(['name', 'scope', 'scopeId', 'locale'], { unique: true }) ], NestDynamicTemplateLayout); //# sourceMappingURL=template-layout.entity.js.map