Skip to content

Commit 33ae1ce

Browse files
fix: remove unsupported types (#726)
1 parent 8a2cb30 commit 33ae1ce

File tree

4 files changed

+4
-158
lines changed

4 files changed

+4
-158
lines changed

src/common/interfaces/email-api-options.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,6 @@ export interface EmailApiOptions {
2525
attachments?: EmailApiAttachment[];
2626
template?: {
2727
id: string;
28-
variables?: Record<string, string | number | boolean>;
28+
variables?: Record<string, string | number>;
2929
};
3030
}

src/common/utils/parse-template-to-api-options.spec.ts

Lines changed: 0 additions & 147 deletions
Original file line numberDiff line numberDiff line change
@@ -38,11 +38,6 @@ describe('parseTemplateToApiOptions', () => {
3838
fallbackValue: 'Subscriber',
3939
type: 'string',
4040
},
41-
{
42-
key: 'isVip',
43-
fallbackValue: false,
44-
type: 'boolean',
45-
},
4641
],
4742
};
4843

@@ -62,11 +57,6 @@ describe('parseTemplateToApiOptions', () => {
6257
fallback_value: 'Subscriber',
6358
type: 'string',
6459
},
65-
{
66-
key: 'isVip',
67-
fallback_value: false,
68-
type: 'boolean',
69-
},
7060
],
7161
});
7262
});
@@ -158,11 +148,6 @@ describe('parseTemplateToApiOptions', () => {
158148
fallbackValue: 42,
159149
type: 'number',
160150
},
161-
{
162-
key: 'isEnabled',
163-
fallbackValue: true,
164-
type: 'boolean',
165-
},
166151
{
167152
key: 'optional',
168153
fallbackValue: null,
@@ -184,11 +169,6 @@ describe('parseTemplateToApiOptions', () => {
184169
fallback_value: 42,
185170
type: 'number',
186171
},
187-
{
188-
key: 'isEnabled',
189-
fallback_value: true,
190-
type: 'boolean',
191-
},
192172
{
193173
key: 'optional',
194174
fallback_value: null,
@@ -219,131 +199,4 @@ describe('parseTemplateToApiOptions', () => {
219199

220200
expect(apiOptions.variables).toEqual([]);
221201
});
222-
223-
it('handles object and list variable types for create template', () => {
224-
const templatePayload: CreateTemplateOptions = {
225-
name: 'Complex Variables Template',
226-
html: '<h1>Complex template</h1>',
227-
variables: [
228-
{
229-
key: 'userProfile',
230-
type: 'object',
231-
fallbackValue: { name: 'John', age: 30 },
232-
},
233-
{
234-
key: 'tags',
235-
type: 'list',
236-
fallbackValue: ['premium', 'vip'],
237-
},
238-
{
239-
key: 'scores',
240-
type: 'list',
241-
fallbackValue: [95, 87, 92],
242-
},
243-
{
244-
key: 'flags',
245-
type: 'list',
246-
fallbackValue: [true, false, true],
247-
},
248-
{
249-
key: 'items',
250-
type: 'list',
251-
fallbackValue: [{ id: 1 }, { id: 2 }],
252-
},
253-
],
254-
};
255-
256-
const apiOptions = parseTemplateToApiOptions(templatePayload);
257-
258-
expect(apiOptions.variables).toEqual([
259-
{
260-
key: 'userProfile',
261-
type: 'object',
262-
fallback_value: { name: 'John', age: 30 },
263-
},
264-
{
265-
key: 'tags',
266-
type: 'list',
267-
fallback_value: ['premium', 'vip'],
268-
},
269-
{
270-
key: 'scores',
271-
type: 'list',
272-
fallback_value: [95, 87, 92],
273-
},
274-
{
275-
key: 'flags',
276-
type: 'list',
277-
fallback_value: [true, false, true],
278-
},
279-
{
280-
key: 'items',
281-
type: 'list',
282-
fallback_value: [{ id: 1 }, { id: 2 }],
283-
},
284-
]);
285-
});
286-
287-
it('handles object and list variable types for update template', () => {
288-
const updatePayload: UpdateTemplateOptions = {
289-
subject: 'Updated Complex Template',
290-
variables: [
291-
{
292-
key: 'config',
293-
type: 'object',
294-
fallbackValue: { theme: 'dark', lang: 'en' },
295-
},
296-
{
297-
key: 'permissions',
298-
type: 'list',
299-
fallbackValue: ['read', 'write'],
300-
},
301-
{
302-
key: 'counts',
303-
type: 'list',
304-
fallbackValue: [10, 20, 30],
305-
},
306-
{
307-
key: 'enabled',
308-
type: 'list',
309-
fallbackValue: [true, false],
310-
},
311-
{
312-
key: 'metadata',
313-
type: 'list',
314-
fallbackValue: [{ key: 'a' }, { key: 'b' }],
315-
},
316-
],
317-
};
318-
319-
const apiOptions = parseTemplateToApiOptions(updatePayload);
320-
321-
expect(apiOptions.variables).toEqual([
322-
{
323-
key: 'config',
324-
type: 'object',
325-
fallback_value: { theme: 'dark', lang: 'en' },
326-
},
327-
{
328-
key: 'permissions',
329-
type: 'list',
330-
fallback_value: ['read', 'write'],
331-
},
332-
{
333-
key: 'counts',
334-
type: 'list',
335-
fallback_value: [10, 20, 30],
336-
},
337-
{
338-
key: 'enabled',
339-
type: 'list',
340-
fallback_value: [true, false],
341-
},
342-
{
343-
key: 'metadata',
344-
type: 'list',
345-
fallback_value: [{ key: 'a' }, { key: 'b' }],
346-
},
347-
]);
348-
});
349202
});

src/common/utils/parse-template-to-api-options.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import type { CreateTemplateOptions } from '../../templates/interfaces/create-template-options.interface';
2-
import type { TemplateVariableListFallbackType } from '../../templates/interfaces/template';
32
import type { UpdateTemplateOptions } from '../../templates/interfaces/update-template.interface';
43

54
interface TemplateVariableApiOptions {
65
key: string;
7-
type: 'string' | 'number' | 'boolean' | 'object' | 'list';
8-
fallback_value?:
9-
| string
10-
| number
11-
| boolean
12-
| Record<string, unknown>
13-
| TemplateVariableListFallbackType
14-
| null;
6+
type: 'string' | 'number';
7+
fallback_value?: string | number | null;
158
}
169

1710
interface TemplateApiOptions {

src/emails/interfaces/create-email-options.interface.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ interface EmailRenderOptions {
2828
interface EmailTemplateOptions {
2929
template: {
3030
id: string;
31-
variables?: Record<string, string | number | boolean>;
31+
variables?: Record<string, string | number>;
3232
};
3333
}
3434

0 commit comments

Comments
 (0)