@postxl/generators 1.24.0 → 1.26.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 (51) hide show
  1. package/dist/backend-actions/actions.generator.d.ts +11 -0
  2. package/dist/backend-actions/actions.generator.js.map +1 -1
  3. package/dist/backend-actions/generators/actions-module.generator.js +11 -3
  4. package/dist/backend-actions/generators/actions-module.generator.js.map +1 -1
  5. package/dist/backend-actions/generators/dispatcher-service.generator.js +12 -4
  6. package/dist/backend-actions/generators/dispatcher-service.generator.js.map +1 -1
  7. package/dist/backend-core/backend.generator.js +72 -40
  8. package/dist/backend-core/backend.generator.js.map +1 -1
  9. package/dist/backend-mail/generators/conditional-files.d.ts +15 -0
  10. package/dist/backend-mail/generators/conditional-files.js +410 -0
  11. package/dist/backend-mail/generators/conditional-files.js.map +1 -0
  12. package/dist/backend-mail/generators/env-config.generator.d.ts +16 -0
  13. package/dist/backend-mail/generators/env-config.generator.js +167 -0
  14. package/dist/backend-mail/generators/env-config.generator.js.map +1 -0
  15. package/dist/backend-mail/generators/mail.service.generator.d.ts +11 -0
  16. package/dist/backend-mail/generators/mail.service.generator.js +243 -0
  17. package/dist/backend-mail/generators/mail.service.generator.js.map +1 -0
  18. package/dist/backend-mail/index.d.ts +5 -0
  19. package/dist/backend-mail/index.js +41 -0
  20. package/dist/backend-mail/index.js.map +1 -0
  21. package/dist/backend-mail/mail.generator.d.ts +78 -0
  22. package/dist/backend-mail/mail.generator.js +162 -0
  23. package/dist/backend-mail/mail.generator.js.map +1 -0
  24. package/dist/backend-mail/template/src/adapters/log.adapter.ts +14 -0
  25. package/dist/backend-mail/template/src/adapters/mail-adapter.interface.ts +27 -0
  26. package/dist/backend-mail/template/src/mail.config.ts +42 -0
  27. package/dist/backend-mail/template/src/mail.module.ts +37 -0
  28. package/dist/backend-mail/template/src/mail.service.test.ts +195 -0
  29. package/dist/backend-mail/template/src/mail.types.ts +67 -0
  30. package/dist/backend-mail/template/src/templates/simple.renderer.test.ts +155 -0
  31. package/dist/backend-mail/template/src/templates/simple.renderer.ts +171 -0
  32. package/dist/backend-mail/template/src/templates/template-renderer.interface.ts +5 -0
  33. package/dist/backend-mail/template/tsconfig.lib.json +10 -0
  34. package/dist/decoders/field-decoder.helper.js +7 -0
  35. package/dist/decoders/field-decoder.helper.js.map +1 -1
  36. package/dist/frontend-admin/generators/admin-overview-page.generator.js +24 -2
  37. package/dist/frontend-admin/generators/admin-overview-page.generator.js.map +1 -1
  38. package/dist/frontend-forms/generators/discriminated-union/fields.generator.js +6 -4
  39. package/dist/frontend-forms/generators/discriminated-union/fields.generator.js.map +1 -1
  40. package/dist/frontend-forms/generators/model/forms.generator.js +6 -4
  41. package/dist/frontend-forms/generators/model/forms.generator.js.map +1 -1
  42. package/dist/generators.js +2 -0
  43. package/dist/generators.js.map +1 -1
  44. package/dist/index.d.ts +2 -0
  45. package/dist/index.js +6 -2
  46. package/dist/index.js.map +1 -1
  47. package/dist/types/generators/model-type.generator.js +1 -1
  48. package/dist/types/generators/model-type.generator.js.map +1 -1
  49. package/dist/types/types.generator.js +3 -4
  50. package/dist/types/types.generator.js.map +1 -1
  51. package/package.json +4 -4
@@ -0,0 +1,195 @@
1
+ import { describe, expect, it, jest } from '@jest/globals'
2
+
3
+ import type { IMailAdapter, MailPayload, MailSendResult } from './adapters/mail-adapter.interface'
4
+ import { MailConfig, type MailConfigValues } from './mail.config'
5
+ import { createAdapter, MailService } from './mail.service'
6
+ import type { ITemplateRenderer } from './templates/template-renderer.interface'
7
+
8
+ type MinimalExecution = {
9
+ startTransformation: ReturnType<typeof jest.fn>
10
+ finishTransformation: ReturnType<typeof jest.fn>
11
+ errorActionOperation: ReturnType<typeof jest.fn>
12
+ }
13
+
14
+ function createExecution(): MinimalExecution {
15
+ return {
16
+ startTransformation: jest.fn(() => Promise.resolve('op-1' as unknown)),
17
+ finishTransformation: jest.fn(() => Promise.resolve(undefined)),
18
+ errorActionOperation: jest.fn(() => Promise.resolve(undefined)),
19
+ }
20
+ }
21
+
22
+ function createConfig(overrides: Partial<MailConfigValues> = {}): MailConfig {
23
+ const values: MailConfigValues = {
24
+ isEnabled: true,
25
+ adapter: 'log',
26
+ templateRenderer: 'simple',
27
+ from: 'noreply@example.com',
28
+ admins: ['admin@example.com'],
29
+ ses: { region: 'eu-central-1', useCredentials: false },
30
+ smtp: { host: '', port: 587, secure: false, user: '', password: '' },
31
+ ...overrides,
32
+ }
33
+ return new MailConfig(values)
34
+ }
35
+
36
+ class SpyAdapter implements IMailAdapter {
37
+ public readonly sent: MailPayload[] = []
38
+ constructor(private readonly result: MailSendResult = { success: true, status: 'sent' }) {}
39
+ send(payload: MailPayload): Promise<MailSendResult> {
40
+ this.sent.push(payload)
41
+ return Promise.resolve(this.result)
42
+ }
43
+ }
44
+
45
+ class FailingAdapter implements IMailAdapter {
46
+ send(): Promise<MailSendResult> {
47
+ return Promise.resolve({ success: false, status: 'errorRejected', details: 'nope' })
48
+ }
49
+ }
50
+
51
+ class SpyRenderer implements ITemplateRenderer {
52
+ public readonly calls: Array<{ source: string; data: Record<string, unknown> }> = []
53
+ render(source: string, data: Record<string, unknown>) {
54
+ this.calls.push({ source, data })
55
+ return { html: `rendered:${source}`, text: `text:${source}` }
56
+ }
57
+ }
58
+
59
+ describe('MailService', () => {
60
+ it('uses LogAdapter when mail is disabled', async () => {
61
+ const config = createConfig({ isEnabled: false })
62
+ const adapter = createAdapter(config.values)
63
+ expect(adapter.constructor.name).toBe('LogAdapter')
64
+
65
+ const service = new MailService(config, { adapter })
66
+ const execution = createExecution()
67
+
68
+ const result = await service.sendMail({
69
+ mail: { to: 'a@example.com', subject: 'hi', html: '<p>hi</p>', informAdmins: false },
70
+ execution: execution as never,
71
+ })
72
+
73
+ expect(result).toEqual({ success: true, status: 'disabled' })
74
+ expect(execution.startTransformation).toHaveBeenCalledTimes(1)
75
+ expect(execution.finishTransformation).toHaveBeenCalledTimes(1)
76
+ expect(execution.errorActionOperation).not.toHaveBeenCalled()
77
+ })
78
+
79
+ it('includes admins in bcc when informAdmins is true', async () => {
80
+ const adapter = new SpyAdapter()
81
+ const service = new MailService(createConfig(), { adapter })
82
+ const execution = createExecution()
83
+
84
+ await service.sendMail({
85
+ mail: { to: 'a@example.com', subject: 'hi', html: '<p>hi</p>', informAdmins: true },
86
+ execution: execution as never,
87
+ })
88
+
89
+ expect(adapter.sent).toHaveLength(1)
90
+ expect(adapter.sent[0]).toMatchObject({
91
+ from: 'noreply@example.com',
92
+ to: 'a@example.com',
93
+ bcc: ['admin@example.com'],
94
+ })
95
+ })
96
+
97
+ it('does not include admins in bcc when informAdmins is false', async () => {
98
+ const adapter = new SpyAdapter()
99
+ const service = new MailService(createConfig(), { adapter })
100
+ const execution = createExecution()
101
+
102
+ await service.sendMail({
103
+ mail: { to: 'a@example.com', subject: 'hi', html: '<p>hi</p>', informAdmins: false },
104
+ execution: execution as never,
105
+ })
106
+
107
+ expect(adapter.sent[0]?.bcc).toEqual([])
108
+ })
109
+
110
+ it('rejects empty user email in sendMailToUser, audits the failure, and bypasses the adapter', async () => {
111
+ const adapter = new SpyAdapter()
112
+ const service = new MailService(createConfig(), { adapter })
113
+ const execution = createExecution()
114
+
115
+ const result = await service.sendMailToUser({
116
+ payload: {
117
+ user: { id: 'user-1' as never, name: 'Ada', email: ' ' },
118
+ subject: 'hi',
119
+ html: '<p>hi</p>',
120
+ informAdmins: false,
121
+ },
122
+ execution: execution as never,
123
+ })
124
+
125
+ expect(result).toEqual({ success: false, status: 'errorInvalidEmail', details: 'Invalid user email' })
126
+ expect(adapter.sent).toHaveLength(0)
127
+ expect(execution.startTransformation).toHaveBeenCalledTimes(1)
128
+ expect(execution.errorActionOperation).toHaveBeenCalledTimes(1)
129
+ expect(execution.finishTransformation).not.toHaveBeenCalled()
130
+ })
131
+
132
+ it('dispatch calls startTransformation and finishTransformation on success', async () => {
133
+ const adapter = new SpyAdapter()
134
+ const service = new MailService(createConfig(), { adapter })
135
+ const execution = createExecution()
136
+
137
+ await service.dispatch({
138
+ action: {
139
+ scope: 'mail',
140
+ type: 'sendMail',
141
+ payload: { to: 'a@example.com', subject: 'hi', html: '<p>hi</p>', informAdmins: false },
142
+ },
143
+ execution: execution as never,
144
+ })
145
+
146
+ expect(execution.startTransformation).toHaveBeenCalledTimes(1)
147
+ expect(execution.finishTransformation).toHaveBeenCalledTimes(1)
148
+ expect(execution.errorActionOperation).not.toHaveBeenCalled()
149
+ })
150
+
151
+ it('dispatch calls errorActionOperation when the adapter fails', async () => {
152
+ const service = new MailService(createConfig(), { adapter: new FailingAdapter() })
153
+ const execution = createExecution()
154
+
155
+ const result = await service.dispatch({
156
+ action: {
157
+ scope: 'mail',
158
+ type: 'sendMail',
159
+ payload: { to: 'a@example.com', subject: 'hi', html: '<p>hi</p>', informAdmins: false },
160
+ },
161
+ execution: execution as never,
162
+ })
163
+
164
+ expect(result.success).toBe(false)
165
+ expect(execution.startTransformation).toHaveBeenCalledTimes(1)
166
+ expect(execution.finishTransformation).not.toHaveBeenCalled()
167
+ expect(execution.errorActionOperation).toHaveBeenCalledTimes(1)
168
+ })
169
+
170
+ it('renderAndSend runs the configured renderer before sending', async () => {
171
+ const adapter = new SpyAdapter()
172
+ const renderer = new SpyRenderer()
173
+ const service = new MailService(createConfig(), { adapter, renderer })
174
+ const execution = createExecution()
175
+
176
+ await service.renderAndSend({
177
+ template: '<p>Hi {{name}}</p>',
178
+ data: { name: 'Ada' },
179
+ subject: 'hi',
180
+ to: 'ada@example.com',
181
+ execution: execution as never,
182
+ })
183
+
184
+ expect(renderer.calls).toHaveLength(1)
185
+ expect(renderer.calls[0]).toEqual({
186
+ source: '<p>Hi {{name}}</p>',
187
+ data: { name: 'Ada' },
188
+ })
189
+ expect(adapter.sent[0]).toMatchObject({
190
+ to: 'ada@example.com',
191
+ html: 'rendered:<p>Hi {{name}}</p>',
192
+ text: 'text:<p>Hi {{name}}</p>',
193
+ })
194
+ })
195
+ })
@@ -0,0 +1,67 @@
1
+ import { zUserId } from '@types'
2
+
3
+ import { z } from 'zod'
4
+
5
+ export type Action_Mail = Action_Mail_SendMail | Action_Mail_SendMailToUser
6
+
7
+ export type ActionResult_Mail = {
8
+ sendMail: SendMailResult
9
+ sendMailToUser: SendMailResult
10
+ }
11
+
12
+ export type Action_Mail_SendMail = {
13
+ scope: 'mail'
14
+ type: 'sendMail'
15
+ payload: SendMailPayload
16
+ }
17
+
18
+ export const zSendMailDecoder = z.object({
19
+ to: z.string().email(),
20
+ subject: z.string().min(2),
21
+ html: z.string().min(2),
22
+ text: z.string().optional(),
23
+ informAdmins: z.boolean().default(false),
24
+ })
25
+
26
+ export type SendMailPayload = z.infer<typeof zSendMailDecoder>
27
+
28
+ export type SendMailStatus = 'sent' | 'disabled' | 'errorRejected' | 'errorInvalidEmail' | 'errorOther'
29
+
30
+ /**
31
+ * Action-level result returned by `MailService.sendMail` and
32
+ * `MailService.sendMailToUser`.
33
+ *
34
+ * Mirrors `MailSendResult` from the adapter interface: `details` is
35
+ * constrained to an opaque string so the value is safe to forward through
36
+ * tRPC or persist in the action-execution log without risking leakage of
37
+ * raw Error instances or SDK response objects.
38
+ */
39
+ export type SendMailResult = {
40
+ success: boolean
41
+ status: SendMailStatus
42
+ details?: string
43
+ }
44
+
45
+ export type Action_Mail_SendMailToUser = {
46
+ scope: 'mail'
47
+ type: 'sendMailToUser'
48
+ payload: SendMailToUserPayload
49
+ }
50
+
51
+ export const zMailUser = z.object({
52
+ id: zUserId,
53
+ name: z.string(),
54
+ email: z.string().email(),
55
+ })
56
+
57
+ export type MailUser = z.infer<typeof zMailUser>
58
+
59
+ export const zSendMailToUserDecoder = z.object({
60
+ user: zMailUser,
61
+ subject: z.string().min(2),
62
+ html: z.string().min(2),
63
+ text: z.string().optional(),
64
+ informAdmins: z.boolean().default(false),
65
+ })
66
+
67
+ export type SendMailToUserPayload = z.infer<typeof zSendMailToUserDecoder>
@@ -0,0 +1,155 @@
1
+ import { describe, expect, it } from '@jest/globals'
2
+
3
+ import { htmlEscape, SimpleRenderer, stripTags, substituteVariables, substituteVariablesRaw } from './simple.renderer'
4
+
5
+ describe('SimpleRenderer', () => {
6
+ const renderer = new SimpleRenderer()
7
+
8
+ describe('substituteVariables', () => {
9
+ it('substitutes a plain variable', () => {
10
+ expect(substituteVariables('Hello {{name}}', { name: 'Ada' })).toBe('Hello Ada')
11
+ })
12
+
13
+ it('resolves dotted paths', () => {
14
+ expect(substituteVariables('{{user.profile.first}}', { user: { profile: { first: 'Ada' } } })).toBe('Ada')
15
+ })
16
+
17
+ it('replaces missing values with empty string', () => {
18
+ expect(substituteVariables('Hi {{missing}}!', {})).toBe('Hi !')
19
+ expect(substituteVariables('{{user.nope}}', { user: {} })).toBe('')
20
+ })
21
+
22
+ it('tolerates whitespace inside the braces', () => {
23
+ expect(substituteVariables('Hello {{ name }}', { name: 'Ada' })).toBe('Hello Ada')
24
+ })
25
+
26
+ it('coerces number, boolean, and bigint values', () => {
27
+ expect(substituteVariables('{{n}} / {{b}} / {{big}}', { n: 42, b: true, big: 9007199254740993n })).toBe(
28
+ '42 / true / 9007199254740993',
29
+ )
30
+ })
31
+
32
+ it('treats null and undefined as empty', () => {
33
+ expect(substituteVariables('[{{a}}][{{b}}]', { a: null, b: undefined })).toBe('[][]')
34
+ })
35
+
36
+ it('formats Date values as ISO strings', () => {
37
+ const date = new Date('2026-04-14T08:00:00.000Z')
38
+ expect(substituteVariables('at {{when}}', { when: date })).toBe('at 2026-04-14T08:00:00.000Z')
39
+ })
40
+
41
+ it('serializes plain objects as JSON instead of the default [object Object]', () => {
42
+ expect(substituteVariables('{{obj}}', { obj: { a: 1, b: 'two' } })).toBe(
43
+ '{&quot;a&quot;:1,&quot;b&quot;:&quot;two&quot;}',
44
+ )
45
+ })
46
+
47
+ it('serializes arrays as JSON', () => {
48
+ expect(substituteVariablesRaw('{{arr}}', { arr: [1, 2, 3] })).toBe('[1,2,3]')
49
+ })
50
+
51
+ it('falls back to empty string for symbol and function values', () => {
52
+ expect(substituteVariables('[{{s}}][{{f}}]', { s: Symbol('x'), f: () => 1 })).toBe('[][]')
53
+ })
54
+
55
+ it('falls back to empty string on circular structures instead of throwing', () => {
56
+ const circular: Record<string, unknown> = {}
57
+ circular.self = circular
58
+ expect(substituteVariables('{{obj}}', { obj: circular })).toBe('')
59
+ })
60
+
61
+ it('escapes HTML-significant characters in substituted values', () => {
62
+ expect(substituteVariables('Hi {{name}}', { name: '<script>alert("x")</script>' })).toBe(
63
+ 'Hi &lt;script&gt;alert(&quot;x&quot;)&lt;/script&gt;',
64
+ )
65
+ expect(substituteVariables('{{x}}', { x: "O'Reilly & sons" })).toBe('O&#39;Reilly &amp; sons')
66
+ })
67
+
68
+ it('does not escape values substituted via the triple-brace form', () => {
69
+ expect(substituteVariables('<p>{{{trusted}}}</p>', { trusted: '<strong>hi</strong>' })).toBe(
70
+ '<p><strong>hi</strong></p>',
71
+ )
72
+ })
73
+
74
+ it('leaves the surrounding template HTML untouched', () => {
75
+ expect(substituteVariables('<p>Hello {{name}}</p>', { name: 'Ada' })).toBe('<p>Hello Ada</p>')
76
+ })
77
+
78
+ it('does not match placeholders whose identifier exceeds the length cap', () => {
79
+ const longName = 'a'.repeat(129)
80
+ const template = `{{${longName}}}`
81
+ expect(substituteVariables(template, { [longName]: 'x' })).toBe(template)
82
+ })
83
+
84
+ it('does not match placeholders with more than 16 spaces of padding', () => {
85
+ const template = `{{${' '.repeat(17)}name${' '.repeat(17)}}}`
86
+ expect(substituteVariables(template, { name: 'Ada' })).toBe(template)
87
+ })
88
+
89
+ // Loose ceiling on purpose: this test catches quadratic backtracking
90
+ // (which would measure in seconds), not absolute speed. See the
91
+ // stripTags timing tests below for the same rationale.
92
+ it('handles pathological no-closing-brace input in linear time', () => {
93
+ const hostile = `{{${' '.repeat(15)}${'a'.repeat(127)}`
94
+ const start = Date.now()
95
+ const result = substituteVariables(hostile, {})
96
+ const elapsed = Date.now() - start
97
+ expect(result).toBe(hostile)
98
+ expect(elapsed).toBeLessThan(2000)
99
+ })
100
+ })
101
+
102
+ describe('htmlEscape', () => {
103
+ it('escapes the five HTML-significant characters', () => {
104
+ expect(htmlEscape('<a href="x">&\'</a>')).toBe('&lt;a href=&quot;x&quot;&gt;&amp;&#39;&lt;/a&gt;')
105
+ })
106
+ })
107
+
108
+ describe('stripTags', () => {
109
+ it('strips HTML tags and collapses whitespace', () => {
110
+ expect(stripTags('<p>Hello <strong>world</strong></p>')).toBe('Hello world')
111
+ })
112
+
113
+ it('collapses mixed whitespace into a single space', () => {
114
+ expect(stripTags('a\t\n b \r\n c')).toBe('a b c')
115
+ })
116
+
117
+ it('trims leading and trailing whitespace', () => {
118
+ expect(stripTags(' hello ')).toBe('hello')
119
+ })
120
+
121
+ it('preserves an unmatched < with no closing > as a literal', () => {
122
+ expect(stripTags('Hello < world')).toBe('Hello < world')
123
+ })
124
+
125
+ // The timing ceilings are intentionally loose: these tests guard against
126
+ // quadratic/catastrophic blowup (which would be tens of seconds on 100k
127
+ // input), not against absolute wall-clock speed. Slower CI runners
128
+ // routinely take 100-300 ms on linear work, so tight bounds flake.
129
+ it('handles a pathological unclosed tag in linear time', () => {
130
+ const hostile = '<' + 'a'.repeat(100_000)
131
+ const start = Date.now()
132
+ const result = stripTags(hostile)
133
+ const elapsed = Date.now() - start
134
+ expect(result).toBe(hostile)
135
+ expect(elapsed).toBeLessThan(2000)
136
+ })
137
+
138
+ it('handles many adjacent tags in linear time', () => {
139
+ const tags = '<p></p>'.repeat(50_000)
140
+ const start = Date.now()
141
+ const result = stripTags(tags + 'ok')
142
+ const elapsed = Date.now() - start
143
+ expect(result).toBe('ok')
144
+ expect(elapsed).toBeLessThan(2000)
145
+ })
146
+ })
147
+
148
+ describe('render', () => {
149
+ it('returns html as-is and text with tags stripped', () => {
150
+ const { html, text } = renderer.render('<p>Hello {{name}}</p>', { name: 'Ada' })
151
+ expect(html).toBe('<p>Hello Ada</p>')
152
+ expect(text).toBe('Hello Ada')
153
+ })
154
+ })
155
+ })
@@ -0,0 +1,171 @@
1
+ import type { ITemplateRenderer, RenderedMail } from './template-renderer.interface'
2
+
3
+ /**
4
+ * Bounded-quantifier variants of the `{{var}}` / `{{{var}}}` patterns.
5
+ *
6
+ * The quantifiers on the whitespace padding and the identifier capture are
7
+ * all capped so a single match attempt is hard-bounded regardless of input
8
+ * size. `\w` and `\s` are disjoint so the regex is structurally safe (no
9
+ * two quantifiers can contest the same character), but the explicit upper
10
+ * bounds keep worst-case work constant per start position and stop
11
+ * static-analysis tools from flagging super-linear backtracking.
12
+ */
13
+ const MAX_WHITESPACE = 16
14
+ const MAX_IDENTIFIER = 128
15
+ const UNESCAPED_VARIABLE_PATTERN = new RegExp(
16
+ `\\{\\{\\{\\s{0,${MAX_WHITESPACE}}([\\w.]{1,${MAX_IDENTIFIER}})\\s{0,${MAX_WHITESPACE}}\\}\\}\\}`,
17
+ 'g',
18
+ )
19
+ const VARIABLE_PATTERN = new RegExp(
20
+ `\\{\\{\\s{0,${MAX_WHITESPACE}}([\\w.]{1,${MAX_IDENTIFIER}})\\s{0,${MAX_WHITESPACE}}\\}\\}`,
21
+ 'g',
22
+ )
23
+
24
+ const HTML_ENTITY_MAP: Record<string, string> = {
25
+ '&': '&amp;',
26
+ '<': '&lt;',
27
+ '>': '&gt;',
28
+ '"': '&quot;',
29
+ "'": '&#39;',
30
+ }
31
+
32
+ export function htmlEscape(value: string): string {
33
+ return value.replaceAll(/[&<>"']/g, (char) => HTML_ENTITY_MAP[char] ?? char)
34
+ }
35
+
36
+ /**
37
+ * Substitutes `{{var}}` (escaped) and `{{{var}}}` (raw) placeholders.
38
+ *
39
+ * Escaped is the default — callers should use the raw form only for values
40
+ * that are already trusted HTML.
41
+ */
42
+ export function substituteVariables(source: string, data: Record<string, unknown>): string {
43
+ const withRaw = source.replaceAll(UNESCAPED_VARIABLE_PATTERN, (_match, path: string) =>
44
+ coerce(resolvePath(data, path)),
45
+ )
46
+ return withRaw.replaceAll(VARIABLE_PATTERN, (_match, path: string) => htmlEscape(coerce(resolvePath(data, path))))
47
+ }
48
+
49
+ /**
50
+ * Substitutes `{{var}}` and `{{{var}}}` placeholders WITHOUT HTML escaping.
51
+ *
52
+ * Intended for building the plain-text MIME part of a mail, where the
53
+ * reader wants raw characters (e.g. `<script>`) rather than HTML entity
54
+ * codes (e.g. `&lt;script&gt;`). Never feed the result into an HTML body
55
+ * - use `substituteVariables` for that path.
56
+ */
57
+ export function substituteVariablesRaw(source: string, data: Record<string, unknown>): string {
58
+ return source
59
+ .replaceAll(UNESCAPED_VARIABLE_PATTERN, (_match, path: string) => coerce(resolvePath(data, path)))
60
+ .replaceAll(VARIABLE_PATTERN, (_match, path: string) => coerce(resolvePath(data, path)))
61
+ }
62
+
63
+ /**
64
+ * Converts a resolved template value to its string form for substitution.
65
+ *
66
+ * Handles the primitive cases directly and falls back to `JSON.stringify`
67
+ * for arrays / plain objects so template variables never surface as the
68
+ * useless `[object Object]` default from `String({})`. Dates get the ISO
69
+ * form (deterministic across locales), Symbols and Functions degrade to
70
+ * empty string (they have no meaningful text representation in a mail).
71
+ */
72
+ function coerce(value: unknown): string {
73
+ if (value === undefined || value === null) {
74
+ return ''
75
+ }
76
+ if (typeof value === 'string') {
77
+ return value
78
+ }
79
+ if (typeof value === 'number' || typeof value === 'boolean' || typeof value === 'bigint') {
80
+ return String(value)
81
+ }
82
+ if (value instanceof Date) {
83
+ return value.toISOString()
84
+ }
85
+ if (typeof value === 'symbol' || typeof value === 'function') {
86
+ return ''
87
+ }
88
+ try {
89
+ return JSON.stringify(value) ?? ''
90
+ } catch {
91
+ return ''
92
+ }
93
+ }
94
+
95
+ function resolvePath(data: Record<string, unknown>, path: string): unknown {
96
+ const parts = path.split('.')
97
+ let current: unknown = data
98
+ for (const part of parts) {
99
+ if (current === null || typeof current !== 'object') {
100
+ return undefined
101
+ }
102
+ current = (current as Record<string, unknown>)[part]
103
+ }
104
+ return current
105
+ }
106
+
107
+ /**
108
+ * Strips HTML tags and collapses whitespace into the plain-text body.
109
+ *
110
+ * Implemented as an explicit two-pass scanner rather than
111
+ * `/<[^>]*>/g` + `/\s+/g`. The natural regex form is linear on well-formed
112
+ * input (the `[^>]` negated class leaves no backtracking state), but
113
+ * static analyzers still flag the unbounded quantifier. A hand-written
114
+ * scanner makes the O(n) property obvious by construction, and lets us
115
+ * preserve the original behaviour for malformed input (an unmatched `<`
116
+ * with no closing `>` is kept as a literal).
117
+ */
118
+ export function stripTags(html: string): string {
119
+ const withoutTags = removeTags(html)
120
+ return collapseWhitespace(withoutTags)
121
+ }
122
+
123
+ function removeTags(html: string): string {
124
+ let out = ''
125
+ let i = 0
126
+ while (i < html.length) {
127
+ const ch = html[i]
128
+ if (ch !== '<') {
129
+ out += ch
130
+ i++
131
+ continue
132
+ }
133
+ const close = html.indexOf('>', i + 1)
134
+ if (close === -1) {
135
+ out += html.slice(i)
136
+ return out
137
+ }
138
+ i = close + 1
139
+ }
140
+ return out
141
+ }
142
+
143
+ const WHITESPACE = new Set([' ', '\t', '\n', '\r', '\f', '\v'])
144
+
145
+ function collapseWhitespace(input: string): string {
146
+ let out = ''
147
+ let pendingSpace = false
148
+ let hasContent = false
149
+ for (const ch of input) {
150
+ if (WHITESPACE.has(ch)) {
151
+ if (hasContent) {
152
+ pendingSpace = true
153
+ }
154
+ continue
155
+ }
156
+ if (pendingSpace) {
157
+ out += ' '
158
+ pendingSpace = false
159
+ }
160
+ out += ch
161
+ hasContent = true
162
+ }
163
+ return out
164
+ }
165
+
166
+ export class SimpleRenderer implements ITemplateRenderer {
167
+ public render(source: string, data: Record<string, unknown>): RenderedMail {
168
+ const html = substituteVariables(source, data)
169
+ return { html, text: stripTags(html) }
170
+ }
171
+ }
@@ -0,0 +1,5 @@
1
+ export type RenderedMail = { html: string; text: string }
2
+
3
+ export interface ITemplateRenderer {
4
+ render(source: string, data: Record<string, unknown>): RenderedMail
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "extends": "../../tsconfig.json",
3
+ "compilerOptions": {
4
+ "declaration": true,
5
+ "declarationMap": true,
6
+ "outDir": "../../dist/libs/mail"
7
+ },
8
+ "include": ["src/**/*"],
9
+ "exclude": ["node_modules", "dist", "test", "**/*spec.ts"]
10
+ }
@@ -48,6 +48,13 @@ function getFieldElementsForScalar(params) {
48
48
  if (!params.field.isRequired) {
49
49
  elements.modifiers.add('nullable()');
50
50
  }
51
+ if (params.field.defaultValue !== undefined) {
52
+ const defaultLiteral = typeof params.field.defaultValue === 'string'
53
+ ? JSON.stringify(params.field.defaultValue)
54
+ : String(params.field.defaultValue);
55
+ elements.modifiers.add(`optional()`);
56
+ elements.modifiers.add(`default(${defaultLiteral})`);
57
+ }
51
58
  return elements;
52
59
  }
53
60
  function getFieldElementsForScalar_Base(params) {
@@ -1 +1 @@
1
- {"version":3,"file":"field-decoder.helper.js","sourceRoot":"","sources":["../../src/decoders/field-decoder.helper.ts"],"names":[],"mappings":";;;AA6CA,0CAUC;AAuBD,4CAuBC;AAzFD,yCAAqD;AAiCrD,SAAgB,eAAe,CAAC,MAA0B;IACxD,MAAM,EAAE,UAAU,EAAE,SAAS,EAAE,WAAW,EAAE,GAAG,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACvE,IAAI,YAAY,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,KAAK,UAAU,EAAE,CAAA;IACxD,IAAI,SAAS,IAAI,SAAS,CAAC,IAAI,GAAG,CAAC,EAAE,CAAC;QACpC,YAAY,IAAI,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,CAAA;IACzD,CAAC;IACD,IAAI,WAAW,EAAE,CAAC;QAChB,YAAY,IAAI,qBAAqB,WAAW,CAAC,GAAG,CAAC,GAAG,CAAA;IAC1D,CAAC;IACD,OAAO,YAAY,CAAA;AACrB,CAAC;AAsBM,MAAM,kBAAkB,GAAG,CAAC,IAAY,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAA;AAAhD,QAAA,k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