@trycourier/courier 7.3.0 → 7.7.1

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 (175) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/LICENSE +1 -1
  3. package/README.md +34 -345
  4. package/client.d.mts +50 -8
  5. package/client.d.mts.map +1 -1
  6. package/client.d.ts +50 -8
  7. package/client.d.ts.map +1 -1
  8. package/client.js +17 -4
  9. package/client.js.map +1 -1
  10. package/client.mjs +18 -5
  11. package/client.mjs.map +1 -1
  12. package/internal/parse.d.mts.map +1 -1
  13. package/internal/parse.d.ts.map +1 -1
  14. package/internal/parse.js +5 -0
  15. package/internal/parse.js.map +1 -1
  16. package/internal/parse.mjs +5 -0
  17. package/internal/parse.mjs.map +1 -1
  18. package/internal/utils/query.d.mts +2 -0
  19. package/internal/utils/query.d.mts.map +1 -0
  20. package/internal/utils/query.d.ts +2 -0
  21. package/internal/utils/query.d.ts.map +1 -0
  22. package/internal/utils/query.js +10 -0
  23. package/internal/utils/query.js.map +1 -0
  24. package/internal/utils/query.mjs +6 -0
  25. package/internal/utils/query.mjs.map +1 -0
  26. package/internal/utils.d.mts +1 -0
  27. package/internal/utils.d.ts +1 -0
  28. package/internal/utils.js +1 -0
  29. package/internal/utils.js.map +1 -1
  30. package/internal/utils.mjs +1 -0
  31. package/package.json +1 -1
  32. package/resources/audiences.d.mts +11 -33
  33. package/resources/audiences.d.mts.map +1 -1
  34. package/resources/audiences.d.ts +11 -33
  35. package/resources/audiences.d.ts.map +1 -1
  36. package/resources/automations/automations.d.mts +54 -1
  37. package/resources/automations/automations.d.mts.map +1 -1
  38. package/resources/automations/automations.d.ts +54 -1
  39. package/resources/automations/automations.d.ts.map +1 -1
  40. package/resources/automations/automations.js +12 -0
  41. package/resources/automations/automations.js.map +1 -1
  42. package/resources/automations/automations.mjs +12 -0
  43. package/resources/automations/automations.mjs.map +1 -1
  44. package/resources/automations/index.d.mts +1 -1
  45. package/resources/automations/index.d.mts.map +1 -1
  46. package/resources/automations/index.d.ts +1 -1
  47. package/resources/automations/index.d.ts.map +1 -1
  48. package/resources/automations/index.js.map +1 -1
  49. package/resources/automations/index.mjs +1 -1
  50. package/resources/automations/index.mjs.map +1 -1
  51. package/resources/bulk.d.mts +80 -39
  52. package/resources/bulk.d.mts.map +1 -1
  53. package/resources/bulk.d.ts +80 -39
  54. package/resources/bulk.d.ts.map +1 -1
  55. package/resources/bulk.js +12 -2
  56. package/resources/bulk.js.map +1 -1
  57. package/resources/bulk.mjs +12 -2
  58. package/resources/bulk.mjs.map +1 -1
  59. package/resources/inbound.d.mts +1 -1
  60. package/resources/inbound.d.ts +1 -1
  61. package/resources/index.d.mts +3 -3
  62. package/resources/index.d.mts.map +1 -1
  63. package/resources/index.d.ts +3 -3
  64. package/resources/index.d.ts.map +1 -1
  65. package/resources/index.js.map +1 -1
  66. package/resources/index.mjs +1 -1
  67. package/resources/index.mjs.map +1 -1
  68. package/resources/lists/subscriptions.d.mts +1 -1
  69. package/resources/lists/subscriptions.d.ts +1 -1
  70. package/resources/notifications/checks.d.mts +2 -2
  71. package/resources/notifications/checks.d.ts +2 -2
  72. package/resources/send.d.mts +8 -2
  73. package/resources/send.d.mts.map +1 -1
  74. package/resources/send.d.ts +8 -2
  75. package/resources/send.d.ts.map +1 -1
  76. package/resources/send.js +1 -1
  77. package/resources/send.mjs +1 -1
  78. package/resources/shared.d.mts +290 -52
  79. package/resources/shared.d.mts.map +1 -1
  80. package/resources/shared.d.ts +290 -52
  81. package/resources/shared.d.ts.map +1 -1
  82. package/resources/tenants/index.d.mts +2 -2
  83. package/resources/tenants/index.d.mts.map +1 -1
  84. package/resources/tenants/index.d.ts +2 -2
  85. package/resources/tenants/index.d.ts.map +1 -1
  86. package/resources/tenants/index.js +2 -2
  87. package/resources/tenants/index.js.map +1 -1
  88. package/resources/tenants/index.mjs +1 -1
  89. package/resources/tenants/index.mjs.map +1 -1
  90. package/resources/tenants/preferences/items.d.mts +2 -2
  91. package/resources/tenants/preferences/items.d.ts +2 -2
  92. package/resources/tenants/templates/index.d.mts +3 -0
  93. package/resources/tenants/templates/index.d.mts.map +1 -0
  94. package/resources/tenants/templates/index.d.ts +3 -0
  95. package/resources/tenants/templates/index.d.ts.map +1 -0
  96. package/resources/tenants/templates/index.js +9 -0
  97. package/resources/tenants/templates/index.js.map +1 -0
  98. package/resources/tenants/templates/index.mjs +4 -0
  99. package/resources/tenants/templates/index.mjs.map +1 -0
  100. package/resources/tenants/templates/templates.d.mts +159 -0
  101. package/resources/tenants/templates/templates.d.mts.map +1 -0
  102. package/resources/tenants/templates/templates.d.ts +159 -0
  103. package/resources/tenants/templates/templates.d.ts.map +1 -0
  104. package/resources/tenants/templates/templates.js +91 -0
  105. package/resources/tenants/templates/templates.js.map +1 -0
  106. package/resources/tenants/templates/templates.mjs +86 -0
  107. package/resources/tenants/templates/templates.mjs.map +1 -0
  108. package/resources/tenants/templates/versions.d.mts +39 -0
  109. package/resources/tenants/templates/versions.d.mts.map +1 -0
  110. package/resources/tenants/templates/versions.d.ts +39 -0
  111. package/resources/tenants/templates/versions.d.ts.map +1 -0
  112. package/resources/tenants/templates/versions.js +32 -0
  113. package/resources/tenants/templates/versions.js.map +1 -0
  114. package/resources/tenants/templates/versions.mjs +28 -0
  115. package/resources/tenants/templates/versions.mjs.map +1 -0
  116. package/resources/tenants/templates.d.mts +1 -90
  117. package/resources/tenants/templates.d.mts.map +1 -1
  118. package/resources/tenants/templates.d.ts +1 -90
  119. package/resources/tenants/templates.d.ts.map +1 -1
  120. package/resources/tenants/templates.js +2 -34
  121. package/resources/tenants/templates.js.map +1 -1
  122. package/resources/tenants/templates.mjs +1 -32
  123. package/resources/tenants/templates.mjs.map +1 -1
  124. package/resources/tenants/tenants.d.mts +147 -5
  125. package/resources/tenants/tenants.d.mts.map +1 -1
  126. package/resources/tenants/tenants.d.ts +147 -5
  127. package/resources/tenants/tenants.d.ts.map +1 -1
  128. package/resources/tenants/tenants.js +2 -2
  129. package/resources/tenants/tenants.js.map +1 -1
  130. package/resources/tenants/tenants.mjs +2 -2
  131. package/resources/tenants/tenants.mjs.map +1 -1
  132. package/resources/translations.d.mts +1 -1
  133. package/resources/translations.d.ts +1 -1
  134. package/resources/users/preferences.d.mts +1 -1
  135. package/resources/users/preferences.d.ts +1 -1
  136. package/resources/users/tenants.d.mts +1 -1
  137. package/resources/users/tenants.d.ts +1 -1
  138. package/resources/users/tokens.d.mts +3 -8
  139. package/resources/users/tokens.d.mts.map +1 -1
  140. package/resources/users/tokens.d.ts +3 -8
  141. package/resources/users/tokens.d.ts.map +1 -1
  142. package/resources/users/tokens.js +2 -3
  143. package/resources/users/tokens.js.map +1 -1
  144. package/resources/users/tokens.mjs +2 -3
  145. package/resources/users/tokens.mjs.map +1 -1
  146. package/src/client.ts +88 -14
  147. package/src/internal/parse.ts +6 -0
  148. package/src/internal/utils/query.ts +7 -0
  149. package/src/internal/utils.ts +1 -0
  150. package/src/resources/audiences.ts +11 -69
  151. package/src/resources/automations/automations.ts +74 -1
  152. package/src/resources/automations/index.ts +7 -1
  153. package/src/resources/bulk.ts +71 -32
  154. package/src/resources/inbound.ts +1 -1
  155. package/src/resources/index.ts +12 -3
  156. package/src/resources/lists/subscriptions.ts +1 -1
  157. package/src/resources/notifications/checks.ts +2 -2
  158. package/src/resources/send.ts +28 -2
  159. package/src/resources/shared.ts +391 -49
  160. package/src/resources/tenants/index.ts +8 -1
  161. package/src/resources/tenants/preferences/items.ts +2 -2
  162. package/src/resources/tenants/templates/index.ts +11 -0
  163. package/src/resources/tenants/templates/templates.ts +222 -0
  164. package/src/resources/tenants/templates/versions.ts +55 -0
  165. package/src/resources/tenants/templates.ts +1 -122
  166. package/src/resources/tenants/tenants.ts +179 -3
  167. package/src/resources/translations.ts +1 -1
  168. package/src/resources/users/preferences.ts +1 -1
  169. package/src/resources/users/tenants.ts +1 -1
  170. package/src/resources/users/tokens.ts +4 -10
  171. package/src/version.ts +1 -1
  172. package/version.d.mts +1 -1
  173. package/version.d.ts +1 -1
  174. package/version.js +1 -1
  175. package/version.mjs +1 -1
package/src/client.ts CHANGED
@@ -11,7 +11,7 @@ import type { APIResponseProps } from './internal/parse';
11
11
  import { getPlatformHeaders } from './internal/detect-platform';
12
12
  import * as Shims from './internal/shims';
13
13
  import * as Opts from './internal/request-options';
14
- import * as qs from './internal/qs';
14
+ import { stringifyQuery } from './internal/utils/query';
15
15
  import { VERSION } from './version';
16
16
  import * as Errors from './core/error';
17
17
  import * as Uploads from './core/uploads';
@@ -26,8 +26,6 @@ import {
26
26
  AudienceUpdateParams,
27
27
  AudienceUpdateResponse,
28
28
  Audiences,
29
- Filter,
30
- FilterConfig,
31
29
  } from './resources/audiences';
32
30
  import {
33
31
  AuditEvent,
@@ -87,7 +85,13 @@ import {
87
85
  TranslationUpdateParams,
88
86
  Translations,
89
87
  } from './resources/translations';
90
- import { AutomationInvokeResponse, Automations } from './resources/automations/automations';
88
+ import {
89
+ AutomationInvokeResponse,
90
+ AutomationListParams,
91
+ AutomationTemplate,
92
+ AutomationTemplateListResponse,
93
+ Automations,
94
+ } from './resources/automations/automations';
91
95
  import {
92
96
  ListListParams,
93
97
  ListListResponse,
@@ -118,6 +122,10 @@ import {
118
122
  import {
119
123
  BaseTemplateTenantAssociation,
120
124
  DefaultPreferences,
125
+ PostTenantTemplatePublishRequest,
126
+ PostTenantTemplatePublishResponse,
127
+ PutTenantTemplateRequest,
128
+ PutTenantTemplateResponse,
121
129
  SubscriptionTopicNew,
122
130
  Tenant,
123
131
  TenantAssociation,
@@ -125,6 +133,7 @@ import {
125
133
  TenantListResponse,
126
134
  TenantListUsersParams,
127
135
  TenantListUsersResponse,
136
+ TenantTemplateInput,
128
137
  TenantUpdateParams,
129
138
  Tenants,
130
139
  } from './resources/tenants/tenants';
@@ -322,8 +331,8 @@ export class Courier {
322
331
  return buildHeaders([{ Authorization: `Bearer ${this.apiKey}` }]);
323
332
  }
324
333
 
325
- protected stringifyQuery(query: Record<string, unknown>): string {
326
- return qs.stringify(query, { arrayFormat: 'comma' });
334
+ protected stringifyQuery(query: object | Record<string, unknown>): string {
335
+ return stringifyQuery(query);
327
336
  }
328
337
 
329
338
  private getUserAgent(): string {
@@ -360,7 +369,7 @@ export class Courier {
360
369
  }
361
370
 
362
371
  if (typeof query === 'object' && query && !Array.isArray(query)) {
363
- url.search = this.stringifyQuery(query as Record<string, unknown>);
372
+ url.search = this.stringifyQuery(query);
364
373
  }
365
374
 
366
375
  return url.toString();
@@ -544,7 +553,7 @@ export class Courier {
544
553
  loggerFor(this).info(`${responseInfo} - ${retryMessage}`);
545
554
 
546
555
  const errText = await response.text().catch((err: any) => castToError(err).message);
547
- const errJSON = safeJSON(errText);
556
+ const errJSON = safeJSON(errText) as any;
548
557
  const errMessage = errJSON ? undefined : errText;
549
558
 
550
559
  loggerFor(this).debug(
@@ -585,9 +594,10 @@ export class Courier {
585
594
  controller: AbortController,
586
595
  ): Promise<Response> {
587
596
  const { signal, method, ...options } = init || {};
588
- if (signal) signal.addEventListener('abort', () => controller.abort());
597
+ const abort = this._makeAbort(controller);
598
+ if (signal) signal.addEventListener('abort', abort, { once: true });
589
599
 
590
- const timeout = setTimeout(() => controller.abort(), ms);
600
+ const timeout = setTimeout(abort, ms);
591
601
 
592
602
  const isReadableBody =
593
603
  ((globalThis as any).ReadableStream && options.body instanceof (globalThis as any).ReadableStream) ||
@@ -754,6 +764,12 @@ export class Courier {
754
764
  return headers.values;
755
765
  }
756
766
 
767
+ private _makeAbort(controller: AbortController) {
768
+ // note: we can't just inline this method inside `fetchWithTimeout()` because then the closure
769
+ // would capture all request options, and cause a memory leak.
770
+ return () => controller.abort();
771
+ }
772
+
757
773
  private buildBody({ options: { body, headers: rawHeaders } }: { options: FinalRequestOptions }): {
758
774
  bodyHeaders: HeadersLike;
759
775
  body: BodyInit | undefined;
@@ -786,6 +802,14 @@ export class Courier {
786
802
  (Symbol.iterator in body && 'next' in body && typeof body.next === 'function'))
787
803
  ) {
788
804
  return { bodyHeaders: undefined, body: Shims.ReadableStreamFrom(body as AsyncIterable<Uint8Array>) };
805
+ } else if (
806
+ typeof body === 'object' &&
807
+ headers.values.get('content-type') === 'application/x-www-form-urlencoded'
808
+ ) {
809
+ return {
810
+ bodyHeaders: { 'content-type': 'application/x-www-form-urlencoded' },
811
+ body: this.stringifyQuery(body),
812
+ };
789
813
  } else {
790
814
  return this.#encoder({ body, headers });
791
815
  }
@@ -857,8 +881,6 @@ export declare namespace Courier {
857
881
  export {
858
882
  Audiences as Audiences,
859
883
  type Audience as Audience,
860
- type Filter as Filter,
861
- type FilterConfig as FilterConfig,
862
884
  type AudienceUpdateResponse as AudienceUpdateResponse,
863
885
  type AudienceListResponse as AudienceListResponse,
864
886
  type AudienceListMembersResponse as AudienceListMembersResponse,
@@ -880,7 +902,13 @@ export declare namespace Courier {
880
902
  type AuthIssueTokenParams as AuthIssueTokenParams,
881
903
  };
882
904
 
883
- export { Automations as Automations, type AutomationInvokeResponse as AutomationInvokeResponse };
905
+ export {
906
+ Automations as Automations,
907
+ type AutomationInvokeResponse as AutomationInvokeResponse,
908
+ type AutomationTemplate as AutomationTemplate,
909
+ type AutomationTemplateListResponse as AutomationTemplateListResponse,
910
+ type AutomationListParams as AutomationListParams,
911
+ };
884
912
 
885
913
  export {
886
914
  Brands as Brands,
@@ -969,9 +997,14 @@ export declare namespace Courier {
969
997
  Tenants as Tenants,
970
998
  type BaseTemplateTenantAssociation as BaseTemplateTenantAssociation,
971
999
  type DefaultPreferences as DefaultPreferences,
1000
+ type PostTenantTemplatePublishRequest as PostTenantTemplatePublishRequest,
1001
+ type PostTenantTemplatePublishResponse as PostTenantTemplatePublishResponse,
1002
+ type PutTenantTemplateRequest as PutTenantTemplateRequest,
1003
+ type PutTenantTemplateResponse as PutTenantTemplateResponse,
972
1004
  type SubscriptionTopicNew as SubscriptionTopicNew,
973
1005
  type Tenant as Tenant,
974
1006
  type TenantAssociation as TenantAssociation,
1007
+ type TenantTemplateInput as TenantTemplateInput,
975
1008
  type TenantListResponse as TenantListResponse,
976
1009
  type TenantListUsersResponse as TenantListUsersResponse,
977
1010
  type TenantUpdateParams as TenantUpdateParams,
@@ -988,9 +1021,16 @@ export declare namespace Courier {
988
1021
 
989
1022
  export { Users as Users };
990
1023
 
1024
+ export type AirshipProfile = API.AirshipProfile;
1025
+ export type AirshipProfileAudience = API.AirshipProfileAudience;
991
1026
  export type Alignment = API.Alignment;
1027
+ export type AudienceFilter = API.AudienceFilter;
1028
+ export type AudienceFilterConfig = API.AudienceFilterConfig;
1029
+ export type AudienceRecipient = API.AudienceRecipient;
992
1030
  export type ChannelClassification = API.ChannelClassification;
993
1031
  export type ChannelPreference = API.ChannelPreference;
1032
+ export type DeviceType = API.DeviceType;
1033
+ export type Discord = API.Discord;
994
1034
  export type ElementalActionNodeWithType = API.ElementalActionNodeWithType;
995
1035
  export type ElementalBaseNode = API.ElementalBaseNode;
996
1036
  export type ElementalChannelNode = API.ElementalChannelNode;
@@ -1003,17 +1043,51 @@ export declare namespace Courier {
1003
1043
  export type ElementalNode = API.ElementalNode;
1004
1044
  export type ElementalQuoteNodeWithType = API.ElementalQuoteNodeWithType;
1005
1045
  export type ElementalTextNodeWithType = API.ElementalTextNodeWithType;
1046
+ export type Expo = API.Expo;
1047
+ export type FilterConfig = API.FilterConfig;
1048
+ export type Intercom = API.Intercom;
1049
+ export type IntercomRecipient = API.IntercomRecipient;
1050
+ export type ListFilter = API.ListFilter;
1051
+ export type ListPatternRecipient = API.ListPatternRecipient;
1052
+ export type ListRecipient = API.ListRecipient;
1006
1053
  export type MessageContext = API.MessageContext;
1007
1054
  export type MessageRouting = API.MessageRouting;
1008
1055
  export type MessageRoutingChannel = API.MessageRoutingChannel;
1056
+ export type MsTeams = API.MsTeams;
1057
+ export type MsTeamsBaseProperties = API.MsTeamsBaseProperties;
1058
+ export type MsTeamsRecipient = API.MsTeamsRecipient;
1059
+ export type MultipleTokens = API.MultipleTokens;
1009
1060
  export type NotificationPreferenceDetails = API.NotificationPreferenceDetails;
1061
+ export type Pagerduty = API.Pagerduty;
1062
+ export type PagerdutyRecipient = API.PagerdutyRecipient;
1010
1063
  export type Paging = API.Paging;
1011
1064
  export type Preference = API.Preference;
1012
1065
  export type PreferenceStatus = API.PreferenceStatus;
1013
- export type Recipient = API.Recipient;
1014
1066
  export type RecipientPreferences = API.RecipientPreferences;
1015
1067
  export type Rule = API.Rule;
1068
+ export type SendDirectMessage = API.SendDirectMessage;
1069
+ export type SendToChannel = API.SendToChannel;
1070
+ export type SendToMsTeamsChannelID = API.SendToMsTeamsChannelID;
1071
+ export type SendToMsTeamsChannelName = API.SendToMsTeamsChannelName;
1072
+ export type SendToMsTeamsConversationID = API.SendToMsTeamsConversationID;
1073
+ export type SendToMsTeamsEmail = API.SendToMsTeamsEmail;
1074
+ export type SendToMsTeamsUserID = API.SendToMsTeamsUserID;
1075
+ export type SendToSlackChannel = API.SendToSlackChannel;
1076
+ export type SendToSlackEmail = API.SendToSlackEmail;
1077
+ export type SendToSlackUserID = API.SendToSlackUserID;
1078
+ export type Slack = API.Slack;
1079
+ export type SlackBaseProperties = API.SlackBaseProperties;
1080
+ export type SlackRecipient = API.SlackRecipient;
1016
1081
  export type TextStyle = API.TextStyle;
1082
+ export type Token = API.Token;
1083
+ export type UserProfile = API.UserProfile;
1084
+ export type UserProfileFirebaseToken = API.UserProfileFirebaseToken;
1017
1085
  export type UserRecipient = API.UserRecipient;
1018
1086
  export type Utm = API.Utm;
1087
+ export type WebhookAuthMode = API.WebhookAuthMode;
1088
+ export type WebhookAuthentication = API.WebhookAuthentication;
1089
+ export type WebhookMethod = API.WebhookMethod;
1090
+ export type WebhookProfile = API.WebhookProfile;
1091
+ export type WebhookProfileType = API.WebhookProfileType;
1092
+ export type WebhookRecipient = API.WebhookRecipient;
1019
1093
  }
@@ -29,6 +29,12 @@ export async function defaultParseResponse<T>(client: Courier, props: APIRespons
29
29
  const mediaType = contentType?.split(';')[0]?.trim();
30
30
  const isJSON = mediaType?.includes('application/json') || mediaType?.endsWith('+json');
31
31
  if (isJSON) {
32
+ const contentLength = response.headers.get('content-length');
33
+ if (contentLength === '0') {
34
+ // if there is no content we can't do anything
35
+ return undefined as T;
36
+ }
37
+
32
38
  const json = await response.json();
33
39
  return json as T;
34
40
  }
@@ -0,0 +1,7 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import * as qs from '../qs/stringify';
4
+
5
+ export function stringifyQuery(query: object | Record<string, unknown>) {
6
+ return qs.stringify(query, { arrayFormat: 'comma' });
7
+ }
@@ -6,3 +6,4 @@ export * from './utils/env';
6
6
  export * from './utils/log';
7
7
  export * from './utils/uuid';
8
8
  export * from './utils/sleep';
9
+ export * from './utils/query';
@@ -71,83 +71,22 @@ export interface Audience {
71
71
  */
72
72
  description: string;
73
73
 
74
- /**
75
- * A single filter to use for filtering
76
- */
77
- filter: Filter;
78
-
79
74
  /**
80
75
  * The name of the audience
81
76
  */
82
77
  name: string;
83
78
 
84
79
  updated_at: string;
85
- }
86
-
87
- export interface Filter {
88
- /**
89
- * The operator to use for filtering
90
- */
91
- operator:
92
- | 'ENDS_WITH'
93
- | 'EQ'
94
- | 'EXISTS'
95
- | 'GT'
96
- | 'GTE'
97
- | 'INCLUDES'
98
- | 'IS_AFTER'
99
- | 'IS_BEFORE'
100
- | 'LT'
101
- | 'LTE'
102
- | 'NEQ'
103
- | 'OMIT'
104
- | 'STARTS_WITH'
105
- | 'AND'
106
- | 'OR';
107
-
108
- /**
109
- * The attribe name from profile whose value will be operated against the filter
110
- * value
111
- */
112
- path: string;
113
80
 
114
81
  /**
115
- * The value to use for filtering
82
+ * Filter configuration for audience membership containing an array of filter rules
116
83
  */
117
- value: string;
118
- }
119
-
120
- export interface FilterConfig {
121
- /**
122
- * The operator to use for filtering
123
- */
124
- operator:
125
- | 'ENDS_WITH'
126
- | 'EQ'
127
- | 'EXISTS'
128
- | 'GT'
129
- | 'GTE'
130
- | 'INCLUDES'
131
- | 'IS_AFTER'
132
- | 'IS_BEFORE'
133
- | 'LT'
134
- | 'LTE'
135
- | 'NEQ'
136
- | 'OMIT'
137
- | 'STARTS_WITH'
138
- | 'AND'
139
- | 'OR';
140
-
141
- /**
142
- * The attribe name from profile whose value will be operated against the filter
143
- * value
144
- */
145
- path: string;
84
+ filter?: Shared.AudienceFilterConfig | null;
146
85
 
147
86
  /**
148
- * The value to use for filtering
87
+ * The logical operator (AND/OR) for the top-level filter
149
88
  */
150
- value: string;
89
+ operator?: 'AND' | 'OR';
151
90
  }
152
91
 
153
92
  export interface AudienceUpdateResponse {
@@ -187,14 +126,19 @@ export interface AudienceUpdateParams {
187
126
  description?: string | null;
188
127
 
189
128
  /**
190
- * A single filter to use for filtering
129
+ * Filter configuration for audience membership containing an array of filter rules
191
130
  */
192
- filter?: Filter | null;
131
+ filter?: Shared.AudienceFilterConfig | null;
193
132
 
194
133
  /**
195
134
  * The name of the audience
196
135
  */
197
136
  name?: string | null;
137
+
138
+ /**
139
+ * The logical operator (AND/OR) for the top-level filter
140
+ */
141
+ operator?: 'AND' | 'OR' | null;
198
142
  }
199
143
 
200
144
  export interface AudienceListParams {
@@ -214,8 +158,6 @@ export interface AudienceListMembersParams {
214
158
  export declare namespace Audiences {
215
159
  export {
216
160
  type Audience as Audience,
217
- type Filter as Filter,
218
- type FilterConfig as FilterConfig,
219
161
  type AudienceUpdateResponse as AudienceUpdateResponse,
220
162
  type AudienceListResponse as AudienceListResponse,
221
163
  type AudienceListMembersResponse as AudienceListMembersResponse,
@@ -3,19 +3,92 @@
3
3
  import { APIResource } from '../../core/resource';
4
4
  import * as InvokeAPI from './invoke';
5
5
  import { Invoke, InvokeInvokeAdHocParams, InvokeInvokeByTemplateParams } from './invoke';
6
+ import { APIPromise } from '../../core/api-promise';
7
+ import { RequestOptions } from '../../internal/request-options';
6
8
 
7
9
  export class Automations extends APIResource {
8
10
  invoke: InvokeAPI.Invoke = new InvokeAPI.Invoke(this._client);
11
+
12
+ /**
13
+ * Get the list of automations.
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * const automationTemplateListResponse =
18
+ * await client.automations.list();
19
+ * ```
20
+ */
21
+ list(
22
+ query: AutomationListParams | null | undefined = {},
23
+ options?: RequestOptions,
24
+ ): APIPromise<AutomationTemplateListResponse> {
25
+ return this._client.get('/automations', { query, ...options });
26
+ }
9
27
  }
10
28
 
11
29
  export interface AutomationInvokeResponse {
12
30
  runId: string;
13
31
  }
14
32
 
33
+ export interface AutomationTemplate {
34
+ /**
35
+ * The unique identifier of the automation template.
36
+ */
37
+ id: string;
38
+
39
+ /**
40
+ * The name of the automation template.
41
+ */
42
+ name: string;
43
+
44
+ /**
45
+ * The version of the template published or drafted.
46
+ */
47
+ version: 'published' | 'draft';
48
+
49
+ /**
50
+ * ISO 8601 timestamp when the template was created.
51
+ */
52
+ createdAt?: string;
53
+
54
+ /**
55
+ * ISO 8601 timestamp when the template was last updated.
56
+ */
57
+ updatedAt?: string;
58
+ }
59
+
60
+ export interface AutomationTemplateListResponse {
61
+ /**
62
+ * A cursor token for pagination. Present when there are more results available.
63
+ */
64
+ cursor?: string;
65
+
66
+ templates?: Array<AutomationTemplate>;
67
+ }
68
+
69
+ export interface AutomationListParams {
70
+ /**
71
+ * A cursor token for pagination. Use the cursor from the previous response to
72
+ * fetch the next page of results.
73
+ */
74
+ cursor?: string;
75
+
76
+ /**
77
+ * The version of templates to retrieve. Accepted values are published (for
78
+ * published templates) or draft (for draft templates). Defaults to published.
79
+ */
80
+ version?: 'published' | 'draft';
81
+ }
82
+
15
83
  Automations.Invoke = Invoke;
16
84
 
17
85
  export declare namespace Automations {
18
- export { type AutomationInvokeResponse as AutomationInvokeResponse };
86
+ export {
87
+ type AutomationInvokeResponse as AutomationInvokeResponse,
88
+ type AutomationTemplate as AutomationTemplate,
89
+ type AutomationTemplateListResponse as AutomationTemplateListResponse,
90
+ type AutomationListParams as AutomationListParams,
91
+ };
19
92
 
20
93
  export {
21
94
  Invoke as Invoke,
@@ -1,4 +1,10 @@
1
1
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
2
 
3
- export { Automations, type AutomationInvokeResponse } from './automations';
3
+ export {
4
+ Automations,
5
+ type AutomationInvokeResponse,
6
+ type AutomationTemplate,
7
+ type AutomationTemplateListResponse,
8
+ type AutomationListParams,
9
+ } from './automations';
4
10
  export { Invoke, type InvokeInvokeAdHocParams, type InvokeInvokeByTemplateParams } from './invoke';
@@ -10,7 +10,11 @@ import { path } from '../internal/utils/path';
10
10
 
11
11
  export class Bulk extends APIResource {
12
12
  /**
13
- * Ingest user data into a Bulk Job
13
+ * Ingest user data into a Bulk Job.
14
+ *
15
+ * **Important**: For email-based bulk jobs, each user must include `profile.email`
16
+ * for provider routing to work correctly. The `to.email` field is not sufficient
17
+ * for email provider routing.
14
18
  */
15
19
  addUsers(jobID: string, body: BulkAddUsersParams, options?: RequestOptions): APIPromise<void> {
16
20
  return this._client.post(path`/bulk/${jobID}`, {
@@ -21,7 +25,13 @@ export class Bulk extends APIResource {
21
25
  }
22
26
 
23
27
  /**
24
- * Create a bulk job
28
+ * Creates a new bulk job for sending messages to multiple recipients.
29
+ *
30
+ * **Required**: `message.event` (event ID or notification ID)
31
+ *
32
+ * **Optional (V2 format)**: `message.template` (notification ID) or
33
+ * `message.content` (Elemental content) can be provided to override the
34
+ * notification associated with the event.
25
35
  */
26
36
  createJob(body: BulkCreateJobParams, options?: RequestOptions): APIPromise<BulkCreateJobResponse> {
27
37
  return this._client.post('/bulk', { body, ...options });
@@ -56,52 +66,67 @@ export class Bulk extends APIResource {
56
66
  }
57
67
  }
58
68
 
59
- export type InboundBulkMessage =
60
- | InboundBulkMessage.InboundBulkTemplateMessage
61
- | InboundBulkMessage.InboundBulkContentMessage;
62
-
63
- export namespace InboundBulkMessage {
64
- export interface InboundBulkTemplateMessage {
65
- template: string;
66
-
67
- brand?: string | null;
68
-
69
- data?: { [key: string]: unknown } | null;
70
-
71
- event?: string | null;
72
-
73
- locale?: { [key: string]: { [key: string]: unknown } } | null;
74
-
75
- override?: { [key: string]: unknown } | null;
76
- }
69
+ /**
70
+ * Bulk message definition. Supports two formats:
71
+ *
72
+ * - V1 format: Requires `event` field (event ID or notification ID)
73
+ * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental
74
+ * content) in addition to `event`
75
+ */
76
+ export interface InboundBulkMessage {
77
+ /**
78
+ * Event ID or Notification ID (required). Can be either a Notification ID (e.g.,
79
+ * "FRH3QXM9E34W4RKP7MRC8NZ1T8V8") or a custom Event ID (e.g., "welcome-email")
80
+ * mapped to a notification.
81
+ */
82
+ event: string;
77
83
 
78
- export interface InboundBulkContentMessage {
79
- /**
80
- * Syntactic sugar to provide a fast shorthand for Courier Elemental Blocks.
81
- */
82
- content: Shared.ElementalContentSugar | Shared.ElementalContent;
84
+ brand?: string | null;
83
85
 
84
- brand?: string | null;
86
+ /**
87
+ * Elemental content (optional, for V2 format). When provided, this will be used
88
+ * instead of the notification associated with the `event` field.
89
+ */
90
+ content?: Shared.ElementalContentSugar | Shared.ElementalContent | null;
85
91
 
86
- data?: { [key: string]: unknown } | null;
92
+ data?: { [key: string]: unknown } | null;
87
93
 
88
- event?: string | null;
94
+ locale?: { [key: string]: { [key: string]: unknown } } | null;
89
95
 
90
- locale?: { [key: string]: { [key: string]: unknown } } | null;
96
+ override?: { [key: string]: unknown } | null;
91
97
 
92
- override?: { [key: string]: unknown } | null;
93
- }
98
+ /**
99
+ * Notification ID or template ID (optional, for V2 format). When provided, this
100
+ * will be used instead of the notification associated with the `event` field.
101
+ */
102
+ template?: string | null;
94
103
  }
95
104
 
96
105
  export interface InboundBulkMessageUser {
106
+ /**
107
+ * User-specific data that will be merged with message.data
108
+ */
97
109
  data?: unknown;
98
110
 
99
111
  preferences?: Shared.RecipientPreferences | null;
100
112
 
101
- profile?: unknown;
113
+ /**
114
+ * User profile information. For email-based bulk jobs, `profile.email` is required
115
+ * for provider routing to determine if the message can be delivered. The email
116
+ * address should be provided here rather than in `to.email`.
117
+ */
118
+ profile?: { [key: string]: unknown } | null;
102
119
 
120
+ /**
121
+ * User ID (legacy field, use profile or to.user_id instead)
122
+ */
103
123
  recipient?: string | null;
104
124
 
125
+ /**
126
+ * Optional recipient information. Note: For email provider routing, use
127
+ * `profile.email` instead of `to.email`. The `to` field is primarily used for
128
+ * recipient identification and data merging.
129
+ */
105
130
  to?: Shared.UserRecipient | null;
106
131
  }
107
132
 
@@ -129,6 +154,13 @@ export interface BulkRetrieveJobResponse {
129
154
 
130
155
  export namespace BulkRetrieveJobResponse {
131
156
  export interface Job {
157
+ /**
158
+ * Bulk message definition. Supports two formats:
159
+ *
160
+ * - V1 format: Requires `event` field (event ID or notification ID)
161
+ * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental
162
+ * content) in addition to `event`
163
+ */
132
164
  definition: BulkAPI.InboundBulkMessage;
133
165
 
134
166
  enqueued: number;
@@ -146,6 +178,13 @@ export interface BulkAddUsersParams {
146
178
  }
147
179
 
148
180
  export interface BulkCreateJobParams {
181
+ /**
182
+ * Bulk message definition. Supports two formats:
183
+ *
184
+ * - V1 format: Requires `event` field (event ID or notification ID)
185
+ * - V2 format: Optionally use `template` (notification ID) or `content` (Elemental
186
+ * content) in addition to `event`
187
+ */
149
188
  message: InboundBulkMessage;
150
189
  }
151
190
 
@@ -54,7 +54,7 @@ export interface InboundTrackEventParams {
54
54
  type: 'track';
55
55
 
56
56
  /**
57
- * The user id associatiated with the track
57
+ * The user id associated with the track
58
58
  */
59
59
  userId?: string | null;
60
60
  }
@@ -4,8 +4,6 @@ export * from './shared';
4
4
  export {
5
5
  Audiences,
6
6
  type Audience,
7
- type Filter,
8
- type FilterConfig,
9
7
  type AudienceUpdateResponse,
10
8
  type AudienceListResponse,
11
9
  type AudienceListMembersResponse,
@@ -20,7 +18,13 @@ export {
20
18
  type AuditEventListParams,
21
19
  } from './audit-events';
22
20
  export { Auth, type AuthIssueTokenResponse, type AuthIssueTokenParams } from './auth';
23
- export { Automations, type AutomationInvokeResponse } from './automations/automations';
21
+ export {
22
+ Automations,
23
+ type AutomationInvokeResponse,
24
+ type AutomationTemplate,
25
+ type AutomationTemplateListResponse,
26
+ type AutomationListParams,
27
+ } from './automations/automations';
24
28
  export {
25
29
  Brands,
26
30
  type Brand,
@@ -97,9 +101,14 @@ export {
97
101
  Tenants,
98
102
  type BaseTemplateTenantAssociation,
99
103
  type DefaultPreferences,
104
+ type PostTenantTemplatePublishRequest,
105
+ type PostTenantTemplatePublishResponse,
106
+ type PutTenantTemplateRequest,
107
+ type PutTenantTemplateResponse,
100
108
  type SubscriptionTopicNew,
101
109
  type Tenant,
102
110
  type TenantAssociation,
111
+ type TenantTemplateInput,
103
112
  type TenantListResponse,
104
113
  type TenantListUsersResponse,
105
114
  type TenantUpdateParams,
@@ -115,7 +115,7 @@ export interface SubscriptionSubscribeUserParams {
115
115
  list_id: string;
116
116
 
117
117
  /**
118
- * Body param:
118
+ * Body param
119
119
  */
120
120
  preferences?: Shared.RecipientPreferences | null;
121
121
  }