@ackplus/nest-dynamic-templates 1.1.15 → 2.0.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +32 -0
  2. package/MIGRATION.md +97 -0
  3. package/README.md +201 -116
  4. package/dist/index.d.ts +2 -0
  5. package/dist/index.js +2 -0
  6. package/dist/index.js.map +1 -1
  7. package/dist/lib/config/resolve-config.d.ts +7 -0
  8. package/dist/lib/config/resolve-config.js +50 -0
  9. package/dist/lib/config/resolve-config.js.map +1 -0
  10. package/dist/lib/constant.d.ts +1 -0
  11. package/dist/lib/constant.js +2 -1
  12. package/dist/lib/constant.js.map +1 -1
  13. package/dist/lib/dto/create-template-layout.dto.js +49 -12
  14. package/dist/lib/dto/create-template-layout.dto.js.map +1 -1
  15. package/dist/lib/dto/create-template.dto.js +59 -14
  16. package/dist/lib/dto/create-template.dto.js.map +1 -1
  17. package/dist/lib/dto/render-template.dto.d.ts +3 -6
  18. package/dist/lib/dto/render-template.dto.js +17 -38
  19. package/dist/lib/dto/render-template.dto.js.map +1 -1
  20. package/dist/lib/engines/language/html.engine.d.ts +2 -3
  21. package/dist/lib/engines/language/html.engine.js +4 -34
  22. package/dist/lib/engines/language/html.engine.js.map +1 -1
  23. package/dist/lib/engines/language/markdown.engine.d.ts +4 -2
  24. package/dist/lib/engines/language/markdown.engine.js +20 -20
  25. package/dist/lib/engines/language/markdown.engine.js.map +1 -1
  26. package/dist/lib/engines/language/mjml.engine.d.ts +4 -2
  27. package/dist/lib/engines/language/mjml.engine.js +18 -20
  28. package/dist/lib/engines/language/mjml.engine.js.map +1 -1
  29. package/dist/lib/engines/language/text.engine.d.ts +2 -1
  30. package/dist/lib/engines/language/text.engine.js +2 -1
  31. package/dist/lib/engines/language/text.engine.js.map +1 -1
  32. package/dist/lib/engines/language-engine.d.ts +4 -1
  33. package/dist/lib/engines/language-engine.js +2 -0
  34. package/dist/lib/engines/language-engine.js.map +1 -1
  35. package/dist/lib/engines/load-peer.d.ts +1 -0
  36. package/dist/lib/engines/load-peer.js +21 -0
  37. package/dist/lib/engines/load-peer.js.map +1 -0
  38. package/dist/lib/engines/template/ejs.engine.d.ts +6 -3
  39. package/dist/lib/engines/template/ejs.engine.js +13 -12
  40. package/dist/lib/engines/template/ejs.engine.js.map +1 -1
  41. package/dist/lib/engines/template/handlebars.engine.d.ts +8 -3
  42. package/dist/lib/engines/template/handlebars.engine.js +26 -13
  43. package/dist/lib/engines/template/handlebars.engine.js.map +1 -1
  44. package/dist/lib/engines/template/nunjucks.engine.d.ts +8 -8
  45. package/dist/lib/engines/template/nunjucks.engine.js +26 -33
  46. package/dist/lib/engines/template/nunjucks.engine.js.map +1 -1
  47. package/dist/lib/engines/template/pug.engine.d.ts +7 -5
  48. package/dist/lib/engines/template/pug.engine.js +11 -20
  49. package/dist/lib/engines/template/pug.engine.js.map +1 -1
  50. package/dist/lib/engines/template-engine.d.ts +4 -1
  51. package/dist/lib/engines/template-engine.js +2 -0
  52. package/dist/lib/engines/template-engine.js.map +1 -1
  53. package/dist/lib/entities/template-layout.entity.js +51 -14
  54. package/dist/lib/entities/template-layout.entity.js.map +1 -1
  55. package/dist/lib/entities/template.entity.js +58 -15
  56. package/dist/lib/entities/template.entity.js.map +1 -1
  57. package/dist/lib/errors/diagnose.d.ts +11 -0
  58. package/dist/lib/errors/diagnose.js +162 -0
  59. package/dist/lib/errors/diagnose.js.map +1 -0
  60. package/dist/lib/errors/template.errors.d.ts +77 -13
  61. package/dist/lib/errors/template.errors.js +104 -59
  62. package/dist/lib/errors/template.errors.js.map +1 -1
  63. package/dist/lib/interfaces/module-config.interface.d.ts +29 -18
  64. package/dist/lib/nest-dynamic-templates.module.d.ts +1 -4
  65. package/dist/lib/nest-dynamic-templates.module.js +40 -96
  66. package/dist/lib/nest-dynamic-templates.module.js.map +1 -1
  67. package/dist/lib/services/template-config.service.d.ts +12 -15
  68. package/dist/lib/services/template-config.service.js +30 -45
  69. package/dist/lib/services/template-config.service.js.map +1 -1
  70. package/dist/lib/services/template-engine.registry.d.ts +6 -10
  71. package/dist/lib/services/template-engine.registry.js +42 -50
  72. package/dist/lib/services/template-engine.registry.js.map +1 -1
  73. package/dist/lib/services/template-layout.service.d.ts +1 -3
  74. package/dist/lib/services/template-layout.service.js +80 -152
  75. package/dist/lib/services/template-layout.service.js.map +1 -1
  76. package/dist/lib/services/template.service.d.ts +1 -3
  77. package/dist/lib/services/template.service.js +107 -209
  78. package/dist/lib/services/template.service.js.map +1 -1
  79. package/dist/tsconfig.build.tsbuildinfo +1 -1
  80. package/package.json +17 -20
@@ -34,12 +34,16 @@ let NestDynamicTemplateLayout = class NestDynamicTemplateLayout extends typeorm_
34
34
  };
35
35
  exports.NestDynamicTemplateLayout = NestDynamicTemplateLayout;
36
36
  __decorate([
37
- (0, swagger_1.ApiProperty)({ type: String, format: 'uuid', readOnly: true }),
37
+ (0, swagger_1.ApiProperty)({ type: String, format: 'uuid', readOnly: true, description: 'Primary key.' }),
38
38
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
39
39
  __metadata("design:type", String)
40
40
  ], NestDynamicTemplateLayout.prototype, "id", void 0);
41
41
  __decorate([
42
- (0, swagger_1.ApiProperty)({ type: String }),
42
+ (0, swagger_1.ApiProperty)({
43
+ type: String,
44
+ example: 'email-shell',
45
+ description: 'Stable identifier you reference by (lowercase letters, numbers, "-" and "_").',
46
+ }),
43
47
  (0, class_validator_1.IsString)(),
44
48
  (0, class_validator_1.IsNotEmpty)(),
45
49
  (0, class_validator_1.Matches)(/^[a-z0-9\-_]+$/, { message: 'Invalid template name format' }),
@@ -47,28 +51,32 @@ __decorate([
47
51
  __metadata("design:type", String)
48
52
  ], NestDynamicTemplateLayout.prototype, "name", void 0);
49
53
  __decorate([
50
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
54
+ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Human-friendly label for admin UIs.' }),
51
55
  (0, class_validator_1.IsString)(),
52
56
  (0, class_validator_1.IsOptional)(),
53
57
  (0, typeorm_1.Column)({ nullable: true }),
54
58
  __metadata("design:type", String)
55
59
  ], NestDynamicTemplateLayout.prototype, "displayName", void 0);
56
60
  __decorate([
57
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
61
+ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Free-text notes about what this layout is for.' }),
58
62
  (0, class_validator_1.IsString)(),
59
63
  (0, class_validator_1.IsOptional)(),
60
64
  (0, typeorm_1.Column)({ type: 'text', nullable: true }),
61
65
  __metadata("design:type", String)
62
66
  ], NestDynamicTemplateLayout.prototype, "description", void 0);
63
67
  __decorate([
64
- (0, swagger_1.ApiProperty)({ type: String }),
68
+ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Free category for grouping/filtering.' }),
65
69
  (0, class_validator_1.IsString)(),
66
70
  (0, class_validator_1.IsOptional)(),
67
71
  (0, typeorm_1.Column)({ type: 'text' }),
68
72
  __metadata("design:type", String)
69
73
  ], NestDynamicTemplateLayout.prototype, "type", void 0);
70
74
  __decorate([
71
- (0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateEngineEnum, type: String }),
75
+ (0, swagger_1.ApiProperty)({
76
+ enum: template_types_1.TemplateEngineEnum,
77
+ type: String,
78
+ description: 'Template engine that interpolates variables: njk (Nunjucks), hbs, ejs, pug.',
79
+ }),
72
80
  (0, class_validator_1.IsEnum)(template_types_1.TemplateEngineEnum),
73
81
  (0, typeorm_1.Column)({
74
82
  type: 'text',
@@ -78,52 +86,81 @@ __decorate([
78
86
  __metadata("design:type", String)
79
87
  ], NestDynamicTemplateLayout.prototype, "engine", void 0);
80
88
  __decorate([
81
- (0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateLanguageEnum, type: String, nullable: true }),
89
+ (0, swagger_1.ApiProperty)({
90
+ enum: template_types_1.TemplateLanguageEnum,
91
+ type: String,
92
+ nullable: true,
93
+ description: 'Output processor applied after interpolation: html, mjml, md, txt.',
94
+ }),
82
95
  (0, class_validator_1.IsEnum)(template_types_1.TemplateLanguageEnum),
83
96
  (0, class_validator_1.IsOptional)(),
84
97
  (0, typeorm_1.Column)({ type: 'text' }),
85
98
  __metadata("design:type", String)
86
99
  ], NestDynamicTemplateLayout.prototype, "language", void 0);
87
100
  __decorate([
88
- (0, swagger_1.ApiProperty)({ type: String }),
101
+ (0, swagger_1.ApiProperty)({
102
+ type: String,
103
+ description: 'The layout body. Use {{ content }} where the wrapped template should be injected.',
104
+ }),
89
105
  (0, class_validator_1.IsString)(),
90
106
  (0, class_validator_1.IsOptional)(),
91
107
  (0, typeorm_1.Column)('text'),
92
108
  __metadata("design:type", String)
93
109
  ], NestDynamicTemplateLayout.prototype, "content", void 0);
94
110
  __decorate([
95
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
111
+ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Name of another layout to nest this one in.' }),
96
112
  (0, class_validator_1.IsString)(),
97
113
  (0, class_validator_1.IsOptional)(),
98
114
  (0, typeorm_1.Column)({ nullable: true }),
99
115
  __metadata("design:type", String)
100
116
  ], NestDynamicTemplateLayout.prototype, "templateLayoutName", void 0);
101
117
  __decorate([
102
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
118
+ (0, swagger_1.ApiProperty)({
119
+ type: String,
120
+ nullable: true,
121
+ default: 'system',
122
+ description: 'Who owns this version: "system" (shared default) or a custom owner kind like "tenant"/"user". Overrides fall back to the system layout.',
123
+ }),
103
124
  (0, class_validator_1.IsString)(),
104
125
  (0, typeorm_1.Column)({ nullable: true, default: 'system' }),
105
126
  __metadata("design:type", String)
106
127
  ], NestDynamicTemplateLayout.prototype, "scope", void 0);
107
128
  __decorate([
108
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
129
+ (0, swagger_1.ApiProperty)({
130
+ type: String,
131
+ nullable: true,
132
+ description: 'Which owner inside the scope (e.g. the tenant id). Leave empty for system layouts.',
133
+ }),
109
134
  (0, class_validator_1.IsString)(),
110
135
  (0, typeorm_1.Column)({ nullable: true }),
111
136
  __metadata("design:type", String)
112
137
  ], NestDynamicTemplateLayout.prototype, "scopeId", void 0);
113
138
  __decorate([
114
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
139
+ (0, swagger_1.ApiProperty)({
140
+ type: String,
141
+ nullable: true,
142
+ default: 'en',
143
+ description: 'Language variant, e.g. en, fr, es. Missing locales fall back to "en".',
144
+ }),
115
145
  (0, class_validator_1.IsString)(),
116
146
  (0, typeorm_1.Column)({ nullable: true, default: 'en' }),
117
147
  __metadata("design:type", String)
118
148
  ], NestDynamicTemplateLayout.prototype, "locale", void 0);
119
149
  __decorate([
120
- (0, swagger_1.ApiProperty)({ type: Object, nullable: true }),
150
+ (0, swagger_1.ApiProperty)({
151
+ type: Object,
152
+ nullable: true,
153
+ description: 'Sample data used to preview the layout (not applied during render).',
154
+ }),
121
155
  (0, class_validator_1.IsOptional)(),
122
156
  (0, typeorm_1.Column)('simple-json', { nullable: true }),
123
157
  __metadata("design:type", Object)
124
158
  ], NestDynamicTemplateLayout.prototype, "previewContext", void 0);
125
159
  __decorate([
126
- (0, swagger_1.ApiProperty)({ type: Boolean }),
160
+ (0, swagger_1.ApiProperty)({
161
+ type: Boolean,
162
+ description: 'Set false to disable without deleting; inactive layouts are skipped during resolution.',
163
+ }),
127
164
  (0, class_validator_1.IsBoolean)(),
128
165
  (0, typeorm_1.Column)({ default: true }),
129
166
  __metadata("design:type", Boolean)
@@ -1 +1 @@
1
- {"version":3,"file":"template-layout.entity.js","sourceRoot":"","sources":["../../../src/lib/entities/template-layout.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAAwH;AACxH,qDAA+F;AAC/F,iEAA0G;AAC1G,6CAA8C;AAKvC,IAAM,yBAAyB,GAA/B,MAAM,yBAA0B,SAAQ,oBAAU;IAIrD,EAAE,CAAS;IAOX,IAAI,CAAS;IAMb,WAAW,CAAU;IAMrB,WAAW,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AAC;;iEACL;AAQrC;IANC,IAAA,qBAAW,EAAC;QACT,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,wFAAwF;KACxG,CAAC;IACD,IAAA,2BAAS,GAAE;IACX,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;2DACR;AAIlB;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,0BAAgB,GAAE;8BACR,IAAI;4DAAC;AAIhB;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,0BAAgB,GAAE;8BACR,IAAI;4DAAC;oCA/HP,yBAAyB;IAFrC,IAAA,gBAAM,EAAC,+BAA+B,CAAC;IACvC,IAAA,eAAK,EAAC,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACnD,yBAAyB,CAgIrC"}
@@ -35,12 +35,16 @@ let NestDynamicTemplate = class NestDynamicTemplate extends typeorm_1.BaseEntity
35
35
  };
36
36
  exports.NestDynamicTemplate = NestDynamicTemplate;
37
37
  __decorate([
38
- (0, swagger_1.ApiProperty)({ type: String, format: 'uuid', readOnly: true }),
38
+ (0, swagger_1.ApiProperty)({ type: String, format: 'uuid', readOnly: true, description: 'Primary key.' }),
39
39
  (0, typeorm_1.PrimaryGeneratedColumn)('uuid'),
40
40
  __metadata("design:type", String)
41
41
  ], NestDynamicTemplate.prototype, "id", void 0);
42
42
  __decorate([
43
- (0, swagger_1.ApiProperty)({ type: String }),
43
+ (0, swagger_1.ApiProperty)({
44
+ type: String,
45
+ example: 'welcome-email',
46
+ description: 'Stable identifier you render by (lowercase letters, numbers, "-" and "_"). Stays the same across scopes and locales.',
47
+ }),
44
48
  (0, class_validator_1.IsString)(),
45
49
  (0, class_validator_1.IsNotEmpty)(),
46
50
  (0, class_validator_1.Matches)(/^[a-z0-9\-_]+$/, { message: 'Invalid template name format' }),
@@ -48,28 +52,37 @@ __decorate([
48
52
  __metadata("design:type", String)
49
53
  ], NestDynamicTemplate.prototype, "name", void 0);
50
54
  __decorate([
51
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
55
+ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Human-friendly label for admin UIs, e.g. "Welcome email".' }),
52
56
  (0, class_validator_1.IsString)(),
53
57
  (0, class_validator_1.IsOptional)(),
54
58
  (0, typeorm_1.Column)({ nullable: true }),
55
59
  __metadata("design:type", String)
56
60
  ], NestDynamicTemplate.prototype, "displayName", void 0);
57
61
  __decorate([
58
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
62
+ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Free-text notes about what this template is for.' }),
59
63
  (0, class_validator_1.IsString)(),
60
64
  (0, class_validator_1.IsOptional)(),
61
65
  (0, typeorm_1.Column)({ type: 'text', nullable: true }),
62
66
  __metadata("design:type", String)
63
67
  ], NestDynamicTemplate.prototype, "description", void 0);
64
68
  __decorate([
65
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
69
+ (0, swagger_1.ApiProperty)({
70
+ type: String,
71
+ nullable: true,
72
+ example: 'email',
73
+ description: 'Free category for grouping/filtering, e.g. email, sms, push, pdf.',
74
+ }),
66
75
  (0, class_validator_1.IsString)(),
67
76
  (0, class_validator_1.IsOptional)(),
68
77
  (0, typeorm_1.Column)({ type: 'text', nullable: true }),
69
78
  __metadata("design:type", String)
70
79
  ], NestDynamicTemplate.prototype, "type", void 0);
71
80
  __decorate([
72
- (0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateEngineEnum, type: String }),
81
+ (0, swagger_1.ApiProperty)({
82
+ enum: template_types_1.TemplateEngineEnum,
83
+ type: String,
84
+ description: 'Template engine that interpolates variables: njk (Nunjucks), hbs, ejs, pug.',
85
+ }),
73
86
  (0, class_validator_1.IsEnum)(template_types_1.TemplateEngineEnum),
74
87
  (0, typeorm_1.Column)({
75
88
  type: 'text',
@@ -79,59 +92,89 @@ __decorate([
79
92
  __metadata("design:type", String)
80
93
  ], NestDynamicTemplate.prototype, "engine", void 0);
81
94
  __decorate([
82
- (0, swagger_1.ApiProperty)({ enum: template_types_1.TemplateLanguageEnum, type: String, nullable: true }),
95
+ (0, swagger_1.ApiProperty)({
96
+ enum: template_types_1.TemplateLanguageEnum,
97
+ type: String,
98
+ nullable: true,
99
+ description: 'Output processor applied after interpolation: html, mjml, md, txt. Omit to skip post-processing.',
100
+ }),
83
101
  (0, class_validator_1.IsEnum)(template_types_1.TemplateLanguageEnum),
84
102
  (0, class_validator_1.IsOptional)(),
85
103
  (0, typeorm_1.Column)({ type: 'text' }),
86
104
  __metadata("design:type", String)
87
105
  ], NestDynamicTemplate.prototype, "language", void 0);
88
106
  __decorate([
89
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
107
+ (0, swagger_1.ApiProperty)({
108
+ type: String,
109
+ nullable: true,
110
+ description: 'Optional subject line (emails). Rendered with the engine, so it can use variables.',
111
+ }),
90
112
  (0, class_validator_1.IsString)(),
91
113
  (0, class_validator_1.IsOptional)(),
92
114
  (0, typeorm_1.Column)({ nullable: true }),
93
115
  __metadata("design:type", String)
94
116
  ], NestDynamicTemplate.prototype, "subject", void 0);
95
117
  __decorate([
96
- (0, swagger_1.ApiProperty)({ type: String }),
118
+ (0, swagger_1.ApiProperty)({ type: String, description: "The template body, written in the chosen engine's syntax." }),
97
119
  (0, class_validator_1.IsString)(),
98
120
  (0, class_validator_1.IsOptional)(),
99
121
  (0, typeorm_1.Column)('text'),
100
122
  __metadata("design:type", String)
101
123
  ], NestDynamicTemplate.prototype, "content", void 0);
102
124
  __decorate([
103
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
125
+ (0, swagger_1.ApiProperty)({ type: String, nullable: true, description: 'Name of a layout to wrap this content in.' }),
104
126
  (0, class_validator_1.IsString)(),
105
127
  (0, class_validator_1.IsOptional)(),
106
128
  (0, typeorm_1.Column)({ nullable: true }),
107
129
  __metadata("design:type", String)
108
130
  ], NestDynamicTemplate.prototype, "templateLayoutName", void 0);
109
131
  __decorate([
110
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
132
+ (0, swagger_1.ApiProperty)({
133
+ type: String,
134
+ nullable: true,
135
+ default: 'system',
136
+ description: 'Who owns this version: "system" (shared default) or a custom owner kind like "tenant"/"user". Overrides fall back to the system template.',
137
+ }),
111
138
  (0, class_validator_1.IsString)(),
112
139
  (0, typeorm_1.Column)({ nullable: true, default: 'system' }),
113
140
  __metadata("design:type", String)
114
141
  ], NestDynamicTemplate.prototype, "scope", void 0);
115
142
  __decorate([
116
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
143
+ (0, swagger_1.ApiProperty)({
144
+ type: String,
145
+ nullable: true,
146
+ description: 'Which owner inside the scope (e.g. the tenant id). Leave empty for system templates.',
147
+ }),
117
148
  (0, class_validator_1.IsString)(),
118
149
  (0, typeorm_1.Column)({ nullable: true }),
119
150
  __metadata("design:type", String)
120
151
  ], NestDynamicTemplate.prototype, "scopeId", void 0);
121
152
  __decorate([
122
- (0, swagger_1.ApiProperty)({ type: String, nullable: true }),
153
+ (0, swagger_1.ApiProperty)({
154
+ type: String,
155
+ nullable: true,
156
+ default: 'en',
157
+ description: 'Language variant, e.g. en, fr, es. Missing locales fall back to "en".',
158
+ }),
123
159
  (0, class_validator_1.IsString)(),
124
160
  (0, typeorm_1.Column)({ nullable: true, default: 'en' }),
125
161
  __metadata("design:type", String)
126
162
  ], NestDynamicTemplate.prototype, "locale", void 0);
127
163
  __decorate([
128
- (0, swagger_1.ApiProperty)({ type: Object, nullable: true }),
164
+ (0, swagger_1.ApiProperty)({
165
+ type: Object,
166
+ nullable: true,
167
+ description: 'Sample data used to preview the template (not applied during render).',
168
+ }),
129
169
  (0, class_validator_1.IsOptional)(),
130
170
  (0, typeorm_1.Column)('simple-json', { nullable: true }),
131
171
  __metadata("design:type", Object)
132
172
  ], NestDynamicTemplate.prototype, "previewContext", void 0);
133
173
  __decorate([
134
- (0, swagger_1.ApiProperty)({ type: Boolean }),
174
+ (0, swagger_1.ApiProperty)({
175
+ type: Boolean,
176
+ description: 'Set false to disable without deleting; inactive templates are skipped during resolution.',
177
+ }),
135
178
  (0, class_validator_1.IsBoolean)(),
136
179
  (0, typeorm_1.Column)({ default: true }),
137
180
  __metadata("design:type", Boolean)
@@ -1 +1 @@
1
- {"version":3,"file":"template.entity.js","sourceRoot":"","sources":["../../../src/lib/entities/template.entity.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,qCAA2J;AAC3J,iEAA0G;AAC1G,qDAA+F;AAC/F,6CAA8C;AAKvC,IAAM,mBAAmB,GAAzB,MAAM,mBAAoB,SAAQ,oBAAU;IAI/C,EAAE,CAAS;IAOX,IAAI,CAAS;IAMb,WAAW,CAAU;IAMrB,WAAW,CAAU;IAMrB,IAAI,CAAU;IASd,MAAM,CAAqB;IAM3B,QAAQ,CAAwB;IAMhC,OAAO,CAAU;IAMjB,OAAO,CAAS;IAMhB,kBAAkB,CAAU;IAK5B,KAAK,CAAU;IAKf,OAAO,CAAU;IAKjB,MAAM,CAAU;IAKhB,cAAc,CAAuB;IAKrC,QAAQ,CAAU;IAIlB,SAAS,CAAO;IAIhB,SAAS,CAAO;CACnB,CAAA;AAhGY,kDAAmB;AAI5B;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC7D,IAAA,gCAAsB,EAAC,MAAM,CAAC;;+CACpB;AAOX;IALC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC;IAC7B,IAAA,0BAAQ,GAAE;IACV,IAAA,4BAAU,GAAE;IACZ,IAAA,yBAAO,EAAC,gBAAgB,EAAE,EAAE,OAAO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,EAAC;QACT,IAAI,EAAE,OAAO;QACb,WAAW,EAAE,0FAA0F;KAC1G,CAAC;IACD,IAAA,2BAAS,GAAE;IACX,IAAA,gBAAM,EAAC,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;;qDACR;AAIlB;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,0BAAgB,GAAE;8BACR,IAAI;sDAAC;AAIhB;IAFC,IAAA,qBAAW,EAAC,EAAE,IAAI,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,CAAC;IAC3C,IAAA,0BAAgB,GAAE;8BACR,IAAI;sDAAC;8BA5IP,mBAAmB;IAF/B,IAAA,gBAAM,EAAC,wBAAwB,CAAC;IAChC,IAAA,eAAK,EAAC,CAAC,MAAM,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;GACnD,mBAAmB,CA6I/B"}
@@ -0,0 +1,11 @@
1
+ import { RenderStage, TemplateRenderError } from './template.errors';
2
+ export interface RenderContextMeta {
3
+ stage: RenderStage;
4
+ engine?: string;
5
+ language?: string;
6
+ templateName?: string;
7
+ scope?: string;
8
+ scopeId?: string;
9
+ locale?: string;
10
+ }
11
+ export declare function diagnoseRenderError(cause: unknown, source: string, context: Record<string, any> | undefined, meta: RenderContextMeta): TemplateRenderError;
@@ -0,0 +1,162 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.diagnoseRenderError = diagnoseRenderError;
4
+ const template_errors_1 = require("./template.errors");
5
+ function diagnoseRenderError(cause, source, context, meta) {
6
+ const err = toError(cause);
7
+ const contextKeys = context ? Object.keys(context) : [];
8
+ const location = extractLocation(err.message, meta);
9
+ const missingVariable = extractMissingVariable(err.message, source, location);
10
+ const snippet = location ? lineAt(source, location.line) : undefined;
11
+ const reason = missingVariable
12
+ ? `variable "${missingVariable}" is undefined`
13
+ : cleanMessage(err.message);
14
+ const subject = meta.templateName ? `template "${meta.templateName}"` : 'inline content';
15
+ const tags = [
16
+ [meta.engine, meta.language].filter(Boolean).join(' → '),
17
+ meta.scope && `scope=${meta.scope}`,
18
+ meta.locale && `locale=${meta.locale}`,
19
+ ].filter(Boolean);
20
+ const where = tags.length ? ` [${tags.join(', ')}]` : '';
21
+ const message = `Failed to render ${subject}${where}: ${stripTrailingDot(reason)}.`;
22
+ const hint = missingVariable
23
+ ? buildMissingVarHint(missingVariable, contextKeys)
24
+ : stageHint(meta.stage, meta.engine, meta.language);
25
+ return new template_errors_1.TemplateRenderError({
26
+ message,
27
+ stage: meta.stage,
28
+ engine: meta.engine,
29
+ language: meta.language,
30
+ templateName: meta.templateName,
31
+ scope: meta.scope,
32
+ scopeId: meta.scopeId,
33
+ locale: meta.locale,
34
+ missingVariable,
35
+ contextKeys,
36
+ location,
37
+ snippet,
38
+ hint,
39
+ }, err);
40
+ }
41
+ function buildMissingVarHint(variable, contextKeys) {
42
+ const provided = contextKeys.length
43
+ ? `The render context has: [${contextKeys.join(', ')}].`
44
+ : `The render context was empty.`;
45
+ return `Pass "${variable}" in the render context. ${provided} To make it optional, guard it in the template, e.g. {{ ${variable} or "" }}.`;
46
+ }
47
+ function stageHint(stage, engine, language) {
48
+ switch (stage) {
49
+ case 'template-engine':
50
+ return `Check the ${engine ?? 'template'} syntax and that every referenced variable is provided.`;
51
+ case 'language-engine':
52
+ return `Check that the content is valid ${language ?? 'markup'} after variable interpolation.`;
53
+ case 'layout':
54
+ return `The error happened while rendering the layout wrapper around this template.`;
55
+ case 'subject':
56
+ return `The error happened while rendering the subject line.`;
57
+ default:
58
+ return undefined;
59
+ }
60
+ }
61
+ function toError(cause) {
62
+ if (cause instanceof Error)
63
+ return cause;
64
+ if (typeof cause === 'string')
65
+ return new Error(cause);
66
+ try {
67
+ return new Error(JSON.stringify(cause));
68
+ }
69
+ catch {
70
+ return new Error(String(cause));
71
+ }
72
+ }
73
+ function extractLocation(message, meta) {
74
+ const patterns = [
75
+ /\[Line (\d+),\s*Column (\d+)\]/i,
76
+ /Parse error on line (\d+)/i,
77
+ /(?:ejs|pug):(\d+)/i,
78
+ />>\s*(\d+)\s*\|/,
79
+ /\bon line (\d+)(?::(\d+))?/i,
80
+ /\bline (\d+)(?::(\d+))?/i,
81
+ ];
82
+ for (const re of patterns) {
83
+ const m = message.match(re);
84
+ if (m) {
85
+ const line = Number(m[1]);
86
+ const column = m[2] !== undefined ? Number(m[2]) : undefined;
87
+ if (Number.isFinite(line) && line > 0) {
88
+ return column !== undefined && Number.isFinite(column)
89
+ ? { line, column }
90
+ : { line };
91
+ }
92
+ }
93
+ }
94
+ return undefined;
95
+ }
96
+ function extractMissingVariable(message, source, location) {
97
+ const refError = message.match(/(\b[\w$][\w.$]*) is not defined/);
98
+ if (refError)
99
+ return refError[1];
100
+ const njkCall = message.match(/Unable to call `?([\w.$]+)`?, which is undefined/i);
101
+ if (njkCall)
102
+ return njkCall[1];
103
+ if (/attempted to output null or undefined value/i.test(message) && location) {
104
+ return expressionAt(source, location);
105
+ }
106
+ return undefined;
107
+ }
108
+ const TOKEN_RE = /\{\{-?\s*([\s\S]*?)\s*-?\}\}|<%[=\-_]?\s*([\s\S]*?)\s*[-_]?%>|#\{\s*([\s\S]*?)\s*\}/g;
109
+ function expressionAt(source, location) {
110
+ const lineText = rawLineAt(source, location.line);
111
+ if (!lineText)
112
+ return undefined;
113
+ const tokens = [];
114
+ TOKEN_RE.lastIndex = 0;
115
+ let m;
116
+ while ((m = TOKEN_RE.exec(lineText)) !== null) {
117
+ const expr = (m[1] ?? m[2] ?? m[3] ?? '').trim();
118
+ if (expr)
119
+ tokens.push({ start: m.index, expr });
120
+ }
121
+ if (tokens.length === 0)
122
+ return undefined;
123
+ let chosen = tokens[0];
124
+ if (location.column !== undefined) {
125
+ const col = location.column;
126
+ for (const t of tokens) {
127
+ if (t.start <= col)
128
+ chosen = t;
129
+ }
130
+ }
131
+ return leadingVariable(chosen.expr);
132
+ }
133
+ function leadingVariable(expr) {
134
+ const beforeFilter = expr.split('|')[0].trim();
135
+ const path = beforeFilter.match(/^[\w$][\w.$]*(?:\[[^\]]+\])*/);
136
+ return path ? path[0] : undefined;
137
+ }
138
+ function lineAt(source, line) {
139
+ const raw = rawLineAt(source, line);
140
+ if (raw === undefined)
141
+ return undefined;
142
+ const trimmed = raw.trim();
143
+ return trimmed.length > 200 ? `${trimmed.slice(0, 197)}...` : trimmed;
144
+ }
145
+ function rawLineAt(source, line) {
146
+ if (!source)
147
+ return undefined;
148
+ const lines = source.split(/\r?\n/);
149
+ return lines[line - 1];
150
+ }
151
+ function cleanMessage(message) {
152
+ return message
153
+ .replace(/^Error:\s*/i, '')
154
+ .replace(/\(unknown path\)\s*/gi, '')
155
+ .replace(/\[Line \d+,\s*Column \d+\]\s*/gi, '')
156
+ .replace(/\s+/g, ' ')
157
+ .trim();
158
+ }
159
+ function stripTrailingDot(s) {
160
+ return s.replace(/\.+$/, '');
161
+ }
162
+ //# sourceMappingURL=diagnose.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"diagnose.js","sourceRoot":"","sources":["../../../src/lib/errors/diagnose.ts"],"names":[],"mappings":";;AA0BA,kDAiDC;AA3ED,uDAAqE;AA0BrE,SAAgB,mBAAmB,CAC/B,KAAc,EACd,MAAc,EACd,OAAwC,EACxC,IAAuB;IAEvB,MAAM,GAAG,GAAG,OAAO,CAAC,KAAK,CAAC,CAAC;IAC3B,MAAM,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;IAExD,MAAM,QAAQ,GAAG,eAAe,CAAC,GAAG,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IACpD,MAAM,eAAe,GAAG,sBAAsB,CAAC,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,CAAC;IAC9E,MAAM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,EAAE,GAAG,CAAC;SACpB,IAAI,EAAE,CAAC;AAChB,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAS;IAC/B,OAAO,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACjC,CAAC"}
@@ -1,19 +1,83 @@
1
- import { BadRequestException, InternalServerErrorException } from '@nestjs/common';
2
- export declare class TemplateRenderError extends InternalServerErrorException {
3
- constructor(operation: string, originalError: Error, templateName?: string);
1
+ import { BadRequestException, ConflictException, ForbiddenException, InternalServerErrorException, NotFoundException, UnprocessableEntityException } from '@nestjs/common';
2
+ export declare enum TemplateErrorCode {
3
+ NOT_FOUND = "TEMPLATE_NOT_FOUND",
4
+ RENDER_FAILED = "TEMPLATE_RENDER_FAILED",
5
+ ENGINE_UNAVAILABLE = "TEMPLATE_ENGINE_UNAVAILABLE",
6
+ INVALID_INPUT = "TEMPLATE_INVALID_INPUT",
7
+ FORBIDDEN = "TEMPLATE_FORBIDDEN",
8
+ CONFLICT = "TEMPLATE_CONFLICT"
4
9
  }
5
- export declare class TemplateEngineError extends InternalServerErrorException {
6
- constructor(engine: string, originalError: Error);
10
+ export type RenderStage = 'subject' | 'template-engine' | 'language-engine' | 'layout';
11
+ export interface TemplateErrorDetails {
12
+ code: TemplateErrorCode;
13
+ message: string;
14
+ stage?: RenderStage;
15
+ engine?: string;
16
+ language?: string;
17
+ templateName?: string;
18
+ scope?: string;
19
+ scopeId?: string;
20
+ locale?: string;
21
+ missingVariable?: string;
22
+ contextKeys?: string[];
23
+ location?: {
24
+ line: number;
25
+ column?: number;
26
+ };
27
+ snippet?: string;
28
+ hint?: string;
7
29
  }
8
- export declare class TemplateLanguageError extends InternalServerErrorException {
9
- constructor(language: string, originalError: Error);
30
+ declare const TEMPLATE_ERROR: unique symbol;
31
+ export interface TemplateErrorLike {
32
+ code: TemplateErrorCode;
33
+ details: TemplateErrorDetails;
10
34
  }
11
- export declare class TemplateLayoutError extends InternalServerErrorException {
12
- constructor(layoutName: string, originalError: Error);
35
+ export declare function isTemplateError(e: unknown): e is TemplateErrorLike;
36
+ export declare class TemplateNotFoundError extends NotFoundException implements TemplateErrorLike {
37
+ readonly code = TemplateErrorCode.NOT_FOUND;
38
+ readonly details: TemplateErrorDetails;
39
+ readonly [TEMPLATE_ERROR] = true;
40
+ constructor(args: {
41
+ templateName: string;
42
+ scope?: string;
43
+ scopeId?: string;
44
+ locale?: string;
45
+ kind?: 'template' | 'layout';
46
+ });
13
47
  }
14
- export declare class TemplateContentError extends InternalServerErrorException {
15
- constructor(contentType: string, originalError: Error);
48
+ export declare class TemplateRenderError extends UnprocessableEntityException implements TemplateErrorLike {
49
+ readonly code = TemplateErrorCode.RENDER_FAILED;
50
+ readonly details: TemplateErrorDetails;
51
+ readonly [TEMPLATE_ERROR] = true;
52
+ constructor(details: Omit<TemplateErrorDetails, 'code'>, cause?: unknown);
16
53
  }
17
- export declare class TemplateValidationError extends BadRequestException {
18
- constructor(field: string, value: any, reason: string);
54
+ export declare class TemplateEngineUnavailableError extends InternalServerErrorException implements TemplateErrorLike {
55
+ readonly code = TemplateErrorCode.ENGINE_UNAVAILABLE;
56
+ readonly details: TemplateErrorDetails;
57
+ readonly [TEMPLATE_ERROR] = true;
58
+ constructor(args: {
59
+ engine: string;
60
+ kind: 'template' | 'language';
61
+ reason: 'not-enabled' | 'not-installed';
62
+ peerPackage?: string;
63
+ });
19
64
  }
65
+ export declare class TemplateInputError extends BadRequestException implements TemplateErrorLike {
66
+ readonly code = TemplateErrorCode.INVALID_INPUT;
67
+ readonly details: TemplateErrorDetails;
68
+ readonly [TEMPLATE_ERROR] = true;
69
+ constructor(message: string, hint?: string);
70
+ }
71
+ export declare class TemplateForbiddenError extends ForbiddenException implements TemplateErrorLike {
72
+ readonly code = TemplateErrorCode.FORBIDDEN;
73
+ readonly details: TemplateErrorDetails;
74
+ readonly [TEMPLATE_ERROR] = true;
75
+ constructor(message: string, hint?: string);
76
+ }
77
+ export declare class TemplateConflictError extends ConflictException implements TemplateErrorLike {
78
+ readonly code = TemplateErrorCode.CONFLICT;
79
+ readonly details: TemplateErrorDetails;
80
+ readonly [TEMPLATE_ERROR] = true;
81
+ constructor(message: string, hint?: string);
82
+ }
83
+ export {};