-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplates.ts
More file actions
840 lines (718 loc) · 18.6 KB
/
templates.ts
File metadata and controls
840 lines (718 loc) · 18.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
import { APIResource } from '../core/resource';
export class Templates extends APIResource {}
/**
* A chat template.
*/
export interface ChatTemplate {
/**
* The markdown body of the chat template.
*/
markdown_body: string;
/**
* A JSON template for the chat notification message payload. Only present if not
* using the markdown body.
*/
json_body?: string | null;
/**
* The summary of the chat template. Used by some chat apps in their push
* notifications.
*/
summary?: string;
}
/**
* An email message template.
*/
export interface EmailTemplate {
/**
* The [settings](https://docs.knock.app/integrations/email/settings) for the email
* template. Must be supplied with at least `layout_key`.
*/
settings: EmailTemplate.Settings;
/**
* The subject of the email. Supports Liquid templating with variables like
* `{{ recipient.name }}`, `{{ actor.name }}`, `{{ vars.app_name }}`,
* `{{ data.custom_field }}`, and `{{ tenant.name }}`. See the
* [template variables reference](https://docs.knock.app/designing-workflows/template-editor/variables)
* for available variables.
*/
subject: string;
/**
* An HTML or MJML template for the email body. **Required** if `visual_blocks` is
* not provided. Only one of `html_body` or `visual_blocks` should be set. When
* `is_mjml` is true, this must contain MJML components. Supports Liquid templating
* with variables like `{{ recipient.name }}`, `{{ actor.name }}`,
* `{{ vars.app_name }}`, `{{ data.custom_field }}`, and `{{ tenant.name }}`. See
* the
* [template variables reference](https://docs.knock.app/designing-workflows/template-editor/variables)
* for available variables.
*/
html_body?: string | null;
/**
* Whether this template uses MJML format. When true, the template content will be
* compiled from MJML to HTML. Only valid when the selected layout is also MJML or
* when no layout is selected.
*/
is_mjml?: boolean | null;
/**
* A text template for the email body. When omitted, the email template will be
* autogenerated from the `html_body` or `visual_blocks`.
*/
text_body?: string | null;
/**
* The visual blocks that make up the email template.
*/
visual_blocks?: Array<
| EmailTemplate.EmailButtonSetBlock
| EmailTemplate.EmailDividerBlock
| EmailTemplate.EmailHTMLBlock
| EmailTemplate.EmailImageBlock
| EmailTemplate.EmailMarkdownBlock
| EmailTemplate.EmailPartialBlock
> | null;
}
export namespace EmailTemplate {
/**
* The [settings](https://docs.knock.app/integrations/email/settings) for the email
* template. Must be supplied with at least `layout_key`.
*/
export interface Settings {
/**
* The object path in the workflow trigger's `data` payload to resolve
* attachments.Defaults to `attachments`.
*/
attachment_key?: string | null;
/**
* The `key` of the
* [email layout](https://docs.knock.app/integrations/email/layouts) that wraps the
* email template. When omitted, the email template will need to define the
* `<html>` structure.
*/
layout_key?: string | null;
/**
* A liquid template that will be injected into the email layout above the message
* template content. Useful for setting variables that should be available to the
* email layout.
*/
pre_content?: string | null;
}
/**
* A button set block in an email template.
*/
export interface EmailButtonSetBlock {
/**
* A list of buttons in the button set.
*/
buttons: Array<EmailButtonSetBlock.Button>;
/**
* The type of the block.
*/
type: 'button_set';
/**
* The ID of the block.
*/
id?: string;
/**
* The layout attributes of the block.
*/
layout_attrs?: EmailButtonSetBlock.LayoutAttrs;
/**
* The version of the block schema. This is automatically managed by Knock and
* should not be set manually. Currently all blocks are at version 1.
*/
version?: number;
}
export namespace EmailButtonSetBlock {
/**
* A button in a button set block.
*/
export interface Button {
/**
* The action of the button.
*/
action: string;
/**
* The label of the button.
*/
label: string;
/**
* The variant of the button.
*/
variant: 'solid' | 'outline';
/**
* The size attributes of the button.
*/
size_attrs?: Button.SizeAttrs;
/**
* The style attributes of the button.
*/
style_attrs?: Button.StyleAttrs;
}
export namespace Button {
/**
* The size attributes of the button.
*/
export interface SizeAttrs {
/**
* Whether the button is full width.
*/
is_fullwidth?: boolean;
/**
* The size of the button.
*/
size?: 'sm' | 'md' | 'lg';
}
/**
* The style attributes of the button.
*/
export interface StyleAttrs {
/**
* The background color of the button.
*/
background_color?: string;
/**
* The border color of the button.
*/
border_color?: string;
/**
* The border radius of the button.
*/
border_radius?: number;
/**
* The border width of the button.
*/
border_width?: number;
/**
* The text color of the button.
*/
text_color?: string;
}
}
/**
* The layout attributes of the block.
*/
export interface LayoutAttrs {
/**
* The column_gap layout attribute of the block.
*/
column_gap: number;
/**
* The horizontal alignment of the block.
*/
horizontal_align: 'left' | 'center' | 'right';
/**
* The padding_bottom layout attribute of the block.
*/
padding_bottom: number;
/**
* The padding_left layout attribute of the block.
*/
padding_left: number;
/**
* The padding_right layout attribute of the block.
*/
padding_right: number;
/**
* The padding_top layout attribute of the block.
*/
padding_top: number;
}
}
/**
* A divider block in an email template.
*/
export interface EmailDividerBlock {
/**
* The type of the block.
*/
type: 'divider';
/**
* The ID of the block.
*/
id?: string;
/**
* The layout attributes of the block.
*/
layout_attrs?: EmailDividerBlock.LayoutAttrs;
/**
* The version of the block schema. This is automatically managed by Knock and
* should not be set manually. Currently all blocks are at version 1.
*/
version?: number;
}
export namespace EmailDividerBlock {
/**
* The layout attributes of the block.
*/
export interface LayoutAttrs {
/**
* The padding_bottom layout attribute of the block.
*/
padding_bottom: number;
/**
* The padding_left layout attribute of the block.
*/
padding_left: number;
/**
* The padding_right layout attribute of the block.
*/
padding_right: number;
/**
* The padding_top layout attribute of the block.
*/
padding_top: number;
}
}
/**
* An HTML block in an email template.
*/
export interface EmailHTMLBlock {
/**
* The HTML content of the block. Supports Liquid templating with variables like
* `{{ recipient.name }}`, `{{ actor.name }}`, `{{ vars.app_name }}`,
* `{{ data.custom_field }}`, and `{{ tenant.name }}`. See the
* [template variables reference](https://docs.knock.app/designing-workflows/template-editor/variables)
* for available variables.
*/
content: string;
/**
* The type of the block.
*/
type: 'html';
/**
* The ID of the block.
*/
id?: string;
/**
* The layout attributes of the block.
*/
layout_attrs?: EmailHTMLBlock.LayoutAttrs;
/**
* The version of the block schema. This is automatically managed by Knock and
* should not be set manually. Currently all blocks are at version 1.
*/
version?: number;
}
export namespace EmailHTMLBlock {
/**
* The layout attributes of the block.
*/
export interface LayoutAttrs {
/**
* The padding_bottom layout attribute of the block.
*/
padding_bottom: number;
/**
* The padding_left layout attribute of the block.
*/
padding_left: number;
/**
* The padding_right layout attribute of the block.
*/
padding_right: number;
/**
* The padding_top layout attribute of the block.
*/
padding_top: number;
}
}
/**
* An image block in an email template.
*/
export interface EmailImageBlock {
/**
* The type of the block.
*/
type: 'image';
/**
* The URL of the image to display.
*/
url: string;
/**
* The ID of the block.
*/
id?: string;
/**
* Optional action URL for the image.
*/
action?: string | null;
/**
* Alt text for the image.
*/
alt?: string | null;
/**
* The layout attributes of the block.
*/
layout_attrs?: EmailImageBlock.LayoutAttrs;
/**
* The style attributes of the image.
*/
style_attrs?: EmailImageBlock.StyleAttrs;
/**
* The version of the block schema. This is automatically managed by Knock and
* should not be set manually. Currently all blocks are at version 1.
*/
version?: number;
}
export namespace EmailImageBlock {
/**
* The layout attributes of the block.
*/
export interface LayoutAttrs {
/**
* The horizontal alignment of the block.
*/
horizontal_align: 'left' | 'center' | 'right';
/**
* The padding_bottom layout attribute of the block.
*/
padding_bottom: number;
/**
* The padding_left layout attribute of the block.
*/
padding_left: number;
/**
* The padding_right layout attribute of the block.
*/
padding_right: number;
/**
* The padding_top layout attribute of the block.
*/
padding_top: number;
}
/**
* The style attributes of the image.
*/
export interface StyleAttrs {
/**
* The width of the image.
*/
width?: string;
}
}
/**
* A markdown block in an email template.
*/
export interface EmailMarkdownBlock {
/**
* The markdown content of the block. Supports Liquid templating with variables
* like `{{ recipient.name }}`, `{{ actor.name }}`, `{{ vars.app_name }}`,
* `{{ data.custom_field }}`, and `{{ tenant.name }}`. See the
* [template variables reference](https://docs.knock.app/designing-workflows/template-editor/variables)
* for available variables.
*/
content: string;
/**
* The type of the block.
*/
type: 'markdown';
/**
* The ID of the block.
*/
id?: string;
/**
* The layout attributes of the block.
*/
layout_attrs?: EmailMarkdownBlock.LayoutAttrs;
/**
* The flavor of markdown to use for the block.
*/
variant?: 'default';
/**
* The version of the block schema. This is automatically managed by Knock and
* should not be set manually. Currently all blocks are at version 1.
*/
version?: number;
}
export namespace EmailMarkdownBlock {
/**
* The layout attributes of the block.
*/
export interface LayoutAttrs {
/**
* The padding_bottom layout attribute of the block.
*/
padding_bottom: number;
/**
* The padding_left layout attribute of the block.
*/
padding_left: number;
/**
* The padding_right layout attribute of the block.
*/
padding_right: number;
/**
* The padding_top layout attribute of the block.
*/
padding_top: number;
}
}
/**
* A partial block in an email template, used to render a reusable partial
* component.
*/
export interface EmailPartialBlock {
/**
* The attributes to pass to the partial block.
*/
attrs: { [key: string]: unknown };
/**
* The key of the partial block to invoke.
*/
key: string;
/**
* The name of the partial block.
*/
name: string;
/**
* The type of the block.
*/
type: 'partial';
/**
* The ID of the block.
*/
id?: string;
/**
* The layout attributes of the block.
*/
layout_attrs?: EmailPartialBlock.LayoutAttrs;
/**
* The version of the block schema. This is automatically managed by Knock and
* should not be set manually. Currently all blocks are at version 1.
*/
version?: number;
}
export namespace EmailPartialBlock {
/**
* The layout attributes of the block.
*/
export interface LayoutAttrs {
/**
* The padding_bottom layout attribute of the block.
*/
padding_bottom: number;
/**
* The padding_left layout attribute of the block.
*/
padding_left: number;
/**
* The padding_right layout attribute of the block.
*/
padding_right: number;
/**
* The padding_top layout attribute of the block.
*/
padding_top: number;
}
}
}
/**
* An in-app feed template.
*/
export interface InAppFeedTemplate {
/**
* The markdown body of the in-app feed.
*/
markdown_body: string;
/**
* The action buttons of the in-app feed message.
*/
action_buttons?: Array<InAppFeedTemplate.ActionButton>;
/**
* The URL to navigate to when the in-app feed is tapped. Can be omitted for
* multi-action templates, where the action buttons will be used instead.
*/
action_url?: string | null;
}
export namespace InAppFeedTemplate {
/**
* A single-action button to be rendered in an in-app feed cell.
*/
export interface ActionButton {
/**
* The URI for this action.
*/
action: string;
/**
* The label of the action button.
*/
label: string;
}
}
/**
* A push notification template.
*/
export interface PushTemplate {
/**
* The [settings](https://docs.knock.app/integrations/sms/settings-and-overrides)
* for the push template.
*/
settings: PushTemplate.Settings;
/**
* The body of the push notification.
*/
text_body: string;
/**
* The title of the push notification.
*/
title: string;
}
export namespace PushTemplate {
/**
* The [settings](https://docs.knock.app/integrations/sms/settings-and-overrides)
* for the push template.
*/
export interface Settings {
/**
* The delivery type of the push notification. Set as silent to send a data-only
* notification. When set to `silent`, no body will be sent.
*/
delivery_type: 'silent' | 'content';
/**
* A JSON object that overrides the payload sent to the push provider.
*/
payload_overrides?: string;
}
}
/**
* A request template for a fetch function step.
*/
export interface RequestTemplate {
/**
* The HTTP method of the request.
*/
method: 'get' | 'post' | 'put' | 'delete' | 'patch';
/**
* The URL of the request.
*/
url: string;
/**
* The body of the request. Only used for POST or PUT requests.
*/
body?: string | null;
/**
* The headers of the request. Can be a template string or a list of key-value
* pairs.
*/
headers?: string | Array<RequestTemplate.RequestTemplateHeadersArray>;
/**
* The query params of the request. Can be a template string or a list of key-value
* pairs.
*/
query_params?: string | Array<RequestTemplate.RequestTemplateQueryParamsArray>;
}
export namespace RequestTemplate {
export interface RequestTemplateHeadersArray {
/**
* The key of the header.
*/
key: string;
/**
* The value of the header.
*/
value: string;
}
export interface RequestTemplateQueryParamsArray {
/**
* The key of the query param.
*/
key: string;
/**
* The value of the query param.
*/
value: string;
}
}
/**
* An SMS template.
*/
export interface SMSTemplate {
/**
* The message of the SMS.
*/
text_body: string;
/**
* The [settings](https://docs.knock.app/integrations/sms/settings-and-overrides)
* for the SMS template.
*/
settings?: SMSTemplate.Settings | null;
}
export namespace SMSTemplate {
/**
* The [settings](https://docs.knock.app/integrations/sms/settings-and-overrides)
* for the SMS template.
*/
export interface Settings {
/**
* A JSON object that overrides the payload sent to the SMS provider.
*/
payload_overrides?: string | null;
/**
* An override for the phone number to send the SMS to. When not set, defaults to
* `recipient.phone_number`.
*/
to_number?: string | null;
}
}
/**
* A webhook template. By default, a webhook step will use the request settings you
* configured in your webhook channel. You can override this as you see fit on a
* per-step basis.
*/
export interface WebhookTemplate {
/**
* The HTTP method of the webhook.
*/
method: 'get' | 'post' | 'put' | 'delete' | 'patch';
/**
* The URL of the webhook.
*/
url: string;
/**
* The body of the request. Only used for POST or PUT requests.
*/
body?: string | null;
/**
* A list of key-value pairs for the request headers. Each object should contain
* key and value fields with string values.
*/
headers?: Array<WebhookTemplate.Header>;
/**
* A list of key-value pairs for the request query params. Each object should
* contain key and value fields with string values.
*/
query_params?: Array<WebhookTemplate.QueryParam>;
}
export namespace WebhookTemplate {
export interface Header {
/**
* The key of the header.
*/
key: string;
/**
* The value of the header.
*/
value: string;
}
export interface QueryParam {
/**
* The key of the query param.
*/
key: string;
/**
* The value of the query param.
*/
value: string;
}
}
export declare namespace Templates {
export {
type ChatTemplate as ChatTemplate,
type EmailTemplate as EmailTemplate,
type InAppFeedTemplate as InAppFeedTemplate,
type PushTemplate as PushTemplate,
type RequestTemplate as RequestTemplate,
type SMSTemplate as SMSTemplate,
type WebhookTemplate as WebhookTemplate,
};
}