@knocklabs/node 1.33.0 → 1.35.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 (116) hide show
  1. package/CHANGELOG.md +59 -0
  2. package/client.d.mts +6 -6
  3. package/client.d.mts.map +1 -1
  4. package/client.d.ts +6 -6
  5. package/client.d.ts.map +1 -1
  6. package/client.js.map +1 -1
  7. package/client.mjs.map +1 -1
  8. package/package.json +2 -2
  9. package/resources/audiences.d.mts +19 -39
  10. package/resources/audiences.d.mts.map +1 -1
  11. package/resources/audiences.d.ts +19 -39
  12. package/resources/audiences.d.ts.map +1 -1
  13. package/resources/index.d.mts +3 -3
  14. package/resources/index.d.mts.map +1 -1
  15. package/resources/index.d.ts +3 -3
  16. package/resources/index.d.ts.map +1 -1
  17. package/resources/index.js.map +1 -1
  18. package/resources/index.mjs.map +1 -1
  19. package/resources/messages/batch.d.mts +15 -252
  20. package/resources/messages/batch.d.mts.map +1 -1
  21. package/resources/messages/batch.d.ts +15 -252
  22. package/resources/messages/batch.d.ts.map +1 -1
  23. package/resources/messages/batch.js +4 -3
  24. package/resources/messages/batch.js.map +1 -1
  25. package/resources/messages/batch.mjs +4 -3
  26. package/resources/messages/batch.mjs.map +1 -1
  27. package/resources/messages/index.d.mts +2 -2
  28. package/resources/messages/index.d.mts.map +1 -1
  29. package/resources/messages/index.d.ts +2 -2
  30. package/resources/messages/index.d.ts.map +1 -1
  31. package/resources/messages/index.js.map +1 -1
  32. package/resources/messages/index.mjs.map +1 -1
  33. package/resources/messages/messages.d.mts +215 -188
  34. package/resources/messages/messages.d.mts.map +1 -1
  35. package/resources/messages/messages.d.ts +215 -188
  36. package/resources/messages/messages.d.ts.map +1 -1
  37. package/resources/messages/messages.js +1 -1
  38. package/resources/messages/messages.js.map +1 -1
  39. package/resources/messages/messages.mjs +1 -1
  40. package/resources/messages/messages.mjs.map +1 -1
  41. package/resources/objects/objects.d.mts +5 -2
  42. package/resources/objects/objects.d.mts.map +1 -1
  43. package/resources/objects/objects.d.ts +5 -2
  44. package/resources/objects/objects.d.ts.map +1 -1
  45. package/resources/objects/objects.js.map +1 -1
  46. package/resources/objects/objects.mjs.map +1 -1
  47. package/resources/recipients/channel-data.d.mts +4 -0
  48. package/resources/recipients/channel-data.d.mts.map +1 -1
  49. package/resources/recipients/channel-data.d.ts +4 -0
  50. package/resources/recipients/channel-data.d.ts.map +1 -1
  51. package/resources/recipients/preferences.d.mts +9 -4
  52. package/resources/recipients/preferences.d.mts.map +1 -1
  53. package/resources/recipients/preferences.d.ts +9 -4
  54. package/resources/recipients/preferences.d.ts.map +1 -1
  55. package/resources/recipients/preferences.js.map +1 -1
  56. package/resources/recipients/preferences.mjs.map +1 -1
  57. package/resources/users/bulk.d.mts +4 -2
  58. package/resources/users/bulk.d.mts.map +1 -1
  59. package/resources/users/bulk.d.ts +4 -2
  60. package/resources/users/bulk.d.ts.map +1 -1
  61. package/resources/users/feeds.d.mts +1 -58
  62. package/resources/users/feeds.d.mts.map +1 -1
  63. package/resources/users/feeds.d.ts +1 -58
  64. package/resources/users/feeds.d.ts.map +1 -1
  65. package/resources/users/guides.d.mts +190 -108
  66. package/resources/users/guides.d.mts.map +1 -1
  67. package/resources/users/guides.d.ts +190 -108
  68. package/resources/users/guides.d.ts.map +1 -1
  69. package/resources/users/guides.js +55 -43
  70. package/resources/users/guides.js.map +1 -1
  71. package/resources/users/guides.mjs +55 -43
  72. package/resources/users/guides.mjs.map +1 -1
  73. package/resources/users/index.d.mts +3 -2
  74. package/resources/users/index.d.mts.map +1 -1
  75. package/resources/users/index.d.ts +3 -2
  76. package/resources/users/index.d.ts.map +1 -1
  77. package/resources/users/index.js +3 -1
  78. package/resources/users/index.js.map +1 -1
  79. package/resources/users/index.mjs +1 -0
  80. package/resources/users/index.mjs.map +1 -1
  81. package/resources/users/preference-center.d.mts +175 -0
  82. package/resources/users/preference-center.d.mts.map +1 -0
  83. package/resources/users/preference-center.d.ts +175 -0
  84. package/resources/users/preference-center.d.ts.map +1 -0
  85. package/resources/users/preference-center.js +41 -0
  86. package/resources/users/preference-center.js.map +1 -0
  87. package/resources/users/preference-center.mjs +37 -0
  88. package/resources/users/preference-center.mjs.map +1 -0
  89. package/resources/users/users.d.mts +47 -5
  90. package/resources/users/users.d.mts.map +1 -1
  91. package/resources/users/users.d.ts +47 -5
  92. package/resources/users/users.d.ts.map +1 -1
  93. package/resources/users/users.js +4 -0
  94. package/resources/users/users.js.map +1 -1
  95. package/resources/users/users.mjs +4 -0
  96. package/resources/users/users.mjs.map +1 -1
  97. package/src/client.ts +16 -2
  98. package/src/resources/audiences.ts +21 -42
  99. package/src/resources/index.ts +8 -1
  100. package/src/resources/messages/batch.ts +16 -294
  101. package/src/resources/messages/index.ts +5 -1
  102. package/src/resources/messages/messages.ts +252 -218
  103. package/src/resources/objects/objects.ts +5 -2
  104. package/src/resources/recipients/channel-data.ts +5 -0
  105. package/src/resources/recipients/preferences.ts +9 -4
  106. package/src/resources/users/bulk.ts +4 -2
  107. package/src/resources/users/feeds.ts +1 -70
  108. package/src/resources/users/guides.ts +228 -120
  109. package/src/resources/users/index.ts +15 -3
  110. package/src/resources/users/preference-center.ts +224 -0
  111. package/src/resources/users/users.ts +78 -8
  112. package/src/version.ts +1 -1
  113. package/version.d.mts +1 -1
  114. package/version.d.ts +1 -1
  115. package/version.js +1 -1
  116. package/version.mjs +1 -1
@@ -0,0 +1,224 @@
1
+ // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
2
+
3
+ import { APIResource } from '../../core/resource';
4
+ import * as PreferenceCenterAPI from './preference-center';
5
+ import { APIPromise } from '../../core/api-promise';
6
+ import { RequestOptions } from '../../internal/request-options';
7
+ import { path } from '../../internal/utils/path';
8
+
9
+ /**
10
+ * The preference center is a hosted page where users can manage their notification preferences.
11
+ */
12
+ export class PreferenceCenter extends APIResource {
13
+ /**
14
+ * Generates a signed preference center URL and token for the given user in the
15
+ * current environment.
16
+ *
17
+ * @example
18
+ * ```ts
19
+ * const response =
20
+ * await client.users.preferenceCenter.generateSignedURL(
21
+ * 'user_id',
22
+ * );
23
+ * ```
24
+ */
25
+ generateSignedURL(
26
+ userID: string,
27
+ options?: RequestOptions,
28
+ ): APIPromise<PreferenceCenterGenerateSignedURLResponse> {
29
+ return this._client.post(path`/v1/users/${userID}/preference_center/signed_url`, options);
30
+ }
31
+
32
+ /**
33
+ * Returns the preference center config with environment metadata for the given
34
+ * user.
35
+ *
36
+ * @example
37
+ * ```ts
38
+ * const response =
39
+ * await client.users.preferenceCenter.getConfig('user_id');
40
+ * ```
41
+ */
42
+ getConfig(userID: string, options?: RequestOptions): APIPromise<PreferenceCenterGetConfigResponse> {
43
+ return this._client.get(path`/v1/users/${userID}/preference_center/config`, options);
44
+ }
45
+ }
46
+
47
+ /**
48
+ * The branding for the preference center, sourced from public environment
49
+ * variables.
50
+ */
51
+ export interface PreferenceCenterBrandingConfig {
52
+ /**
53
+ * The icon URL for the preference center. Must point to a valid image with an
54
+ * image MIME type.
55
+ */
56
+ icon_url?: string | null;
57
+
58
+ /**
59
+ * The logo URL for the preference center. Must point to a valid image with an
60
+ * image MIME type.
61
+ */
62
+ logo_url?: string | null;
63
+
64
+ /**
65
+ * The primary color for the preference center, provided as a hex value.
66
+ */
67
+ primary_color?: string | null;
68
+
69
+ /**
70
+ * The primary color contrast for the preference center, provided as a hex value.
71
+ */
72
+ primary_color_contrast?: string | null;
73
+ }
74
+
75
+ /**
76
+ * A signed preference center URL and token for a user.
77
+ */
78
+ export interface PreferenceCenterGenerateSignedURLResponse {
79
+ /**
80
+ * The signed JWT token for the preference center, usable as the `/p/{token}` path
81
+ * segment.
82
+ */
83
+ token: string;
84
+
85
+ /**
86
+ * The full URL to the preference center for the user.
87
+ */
88
+ url: string;
89
+ }
90
+
91
+ /**
92
+ * The preference center configuration for an environment. Controls whether the
93
+ * preference center is enabled and defines the rows displayed in the UI.
94
+ */
95
+ export interface PreferenceCenterGetConfigResponse {
96
+ /**
97
+ * The name of the account that the preference center is associated with.
98
+ */
99
+ account_name: string | null;
100
+
101
+ /**
102
+ * The branding for the preference center, sourced from public environment
103
+ * variables.
104
+ */
105
+ branding: PreferenceCenterGetConfigResponse.Branding;
106
+
107
+ /**
108
+ * The preference center configuration data containing the rows to display.
109
+ */
110
+ config: PreferenceCenterGetConfigResponse.Config;
111
+
112
+ /**
113
+ * Whether the preference center is enabled for this environment.
114
+ */
115
+ enabled: boolean;
116
+
117
+ /**
118
+ * A display label for the user that the preference center is associated with,
119
+ * resolved as email, then user id.
120
+ */
121
+ user_email: string | null;
122
+
123
+ /**
124
+ * Whether Knock branding is required in the preference center.
125
+ */
126
+ knock_branding_required?: boolean;
127
+ }
128
+
129
+ export namespace PreferenceCenterGetConfigResponse {
130
+ /**
131
+ * The branding for the preference center, sourced from public environment
132
+ * variables.
133
+ */
134
+ export interface Branding extends PreferenceCenterAPI.PreferenceCenterBrandingConfig {
135
+ /**
136
+ * The branding for the preference center, sourced from public environment
137
+ * variables.
138
+ */
139
+ dark?: PreferenceCenterAPI.PreferenceCenterBrandingConfig;
140
+ }
141
+
142
+ /**
143
+ * The preference center configuration data containing the rows to display.
144
+ */
145
+ export interface Config {
146
+ /**
147
+ * The body text displayed below the title.
148
+ */
149
+ body: string;
150
+
151
+ /**
152
+ * An ordered list of rows to display in the preference center.
153
+ */
154
+ rows: Array<Config.Row>;
155
+
156
+ /**
157
+ * The title displayed at the top of the preference center.
158
+ */
159
+ title: string;
160
+
161
+ /**
162
+ * Whether the account name should be displayed in the preference center.
163
+ */
164
+ show_account_name?: boolean;
165
+ }
166
+
167
+ export namespace Config {
168
+ /**
169
+ * A preference row in the preference center configuration.
170
+ */
171
+ export interface Row {
172
+ /**
173
+ * The display name of the preference row.
174
+ */
175
+ name: string;
176
+
177
+ /**
178
+ * The type of this preference row. `workflow` targets a workflow, `channel`
179
+ * targets a specific channel, `category` targets a workflow category,
180
+ * `channel_types` controls per-channel-type opt-in/out, and
181
+ * `commercial_subscribed` is the commercial notification toggle.
182
+ */
183
+ type: 'workflow' | 'channel' | 'category' | 'channel_types' | 'commercial_subscribed';
184
+
185
+ /**
186
+ * The list of channel types this preference is scoped to. An empty list (or
187
+ * `null`) means the preference applies to all channel types. Present for
188
+ * `workflow`, `category`, and `channel_types` types.
189
+ */
190
+ channel_types?: Array<
191
+ | 'email'
192
+ | 'in_app'
193
+ | 'in_app_feed'
194
+ | 'in_app_guide'
195
+ | 'sms'
196
+ | 'push'
197
+ | 'chat'
198
+ | 'http'
199
+ | 'log'
200
+ | 'deferred_log'
201
+ > | null;
202
+
203
+ /**
204
+ * A description shown below the preference row name.
205
+ */
206
+ description?: string;
207
+
208
+ /**
209
+ * The category name, workflow key, or channel ID this row controls (e.g.
210
+ * `marketing`, `new-project-mentions`, or a channel UUID). Present for `workflow`,
211
+ * `channel`, and `category` types.
212
+ */
213
+ identifier?: string | null;
214
+ }
215
+ }
216
+ }
217
+
218
+ export declare namespace PreferenceCenter {
219
+ export {
220
+ type PreferenceCenterBrandingConfig as PreferenceCenterBrandingConfig,
221
+ type PreferenceCenterGenerateSignedURLResponse as PreferenceCenterGenerateSignedURLResponse,
222
+ type PreferenceCenterGetConfigResponse as PreferenceCenterGetConfigResponse,
223
+ };
224
+ }
@@ -23,16 +23,26 @@ import {
23
23
  } from './feeds';
24
24
  import * as GuidesAPI from './guides';
25
25
  import {
26
+ GuideActionResponse,
27
+ GuideArchivedRequest,
26
28
  GuideGetChannelParams,
27
29
  GuideGetChannelResponse,
30
+ GuideInteractedRequest,
28
31
  GuideMarkMessageAsArchivedParams,
29
- GuideMarkMessageAsArchivedResponse,
30
32
  GuideMarkMessageAsInteractedParams,
31
- GuideMarkMessageAsInteractedResponse,
32
33
  GuideMarkMessageAsSeenParams,
33
- GuideMarkMessageAsSeenResponse,
34
+ GuideResetGuideEngagementsParams,
35
+ GuideSeenRequest,
36
+ GuideUnarchiveGuideMessageParams,
34
37
  Guides,
35
38
  } from './guides';
39
+ import * as PreferenceCenterAPI from './preference-center';
40
+ import {
41
+ PreferenceCenter,
42
+ PreferenceCenterBrandingConfig,
43
+ PreferenceCenterGenerateSignedURLResponse,
44
+ PreferenceCenterGetConfigResponse,
45
+ } from './preference-center';
36
46
  import { APIPromise } from '../../core/api-promise';
37
47
  import {
38
48
  EntriesCursor,
@@ -52,6 +62,9 @@ export class Users extends APIResource {
52
62
  feeds: FeedsAPI.Feeds = new FeedsAPI.Feeds(this._client);
53
63
  guides: GuidesAPI.Guides = new GuidesAPI.Guides(this._client);
54
64
  bulk: BulkAPI.Bulk = new BulkAPI.Bulk(this._client);
65
+ preferenceCenter: PreferenceCenterAPI.PreferenceCenter = new PreferenceCenterAPI.PreferenceCenter(
66
+ this._client,
67
+ );
55
68
 
56
69
  /**
57
70
  * Create or update a user with the provided identification data. When you identify
@@ -512,6 +525,47 @@ export interface InlineIdentifyUserRequest {
512
525
  [k: string]: unknown;
513
526
  }
514
527
 
528
+ /**
529
+ * A response containing a list of schedules.
530
+ */
531
+ export interface ListSchedulesResponse {
532
+ /**
533
+ * A list of schedules.
534
+ */
535
+ entries: Array<SchedulesAPI.Schedule>;
536
+
537
+ /**
538
+ * Pagination information for a list of resources.
539
+ */
540
+ page_info: Shared.PageInfo;
541
+ }
542
+
543
+ /**
544
+ * A response containing a list of subscriptions.
545
+ */
546
+ export interface ListSubscriptionsResponse {
547
+ /**
548
+ * A list of subscriptions.
549
+ */
550
+ entries: Array<SubscriptionsAPI.Subscription>;
551
+
552
+ /**
553
+ * Pagination information for a list of resources.
554
+ */
555
+ page_info: Shared.PageInfo;
556
+ }
557
+
558
+ /**
559
+ * A set of settings for the commercial subscribed preference. Currently, this can
560
+ * only be a list of conditions to apply.
561
+ */
562
+ export interface PreferenceSetCommercialSubscribedSetting {
563
+ /**
564
+ * A list of conditions to apply to the commercial subscribed preference.
565
+ */
566
+ conditions: Array<Shared.Condition>;
567
+ }
568
+
515
569
  /**
516
570
  * A [User](/concepts/users) represents an individual in your system who can
517
571
  * receive notifications through Knock. Users are the most common recipients of
@@ -803,9 +857,11 @@ export interface UserSetPreferencesParams {
803
857
 
804
858
  /**
805
859
  * Whether the recipient is subscribed to commercial communications. When false,
806
- * the recipient will not receive commercial workflow notifications.
860
+ * the recipient will not receive commercial workflow notifications. Can also be
861
+ * set to a settings object with conditions that are evaluated at notification send
862
+ * time.
807
863
  */
808
- commercial_subscribed?: boolean | null;
864
+ commercial_subscribed?: boolean | PreferenceSetCommercialSubscribedSetting | null;
809
865
 
810
866
  /**
811
867
  * An object where the key is the workflow key and the values are the preference
@@ -863,11 +919,15 @@ export namespace UserSetPreferencesParams {
863
919
  Users.Feeds = Feeds;
864
920
  Users.Guides = Guides;
865
921
  Users.Bulk = Bulk;
922
+ Users.PreferenceCenter = PreferenceCenter;
866
923
 
867
924
  export declare namespace Users {
868
925
  export {
869
926
  type IdentifyUserRequest as IdentifyUserRequest,
870
927
  type InlineIdentifyUserRequest as InlineIdentifyUserRequest,
928
+ type ListSchedulesResponse as ListSchedulesResponse,
929
+ type ListSubscriptionsResponse as ListSubscriptionsResponse,
930
+ type PreferenceSetCommercialSubscribedSetting as PreferenceSetCommercialSubscribedSetting,
871
931
  type User as User,
872
932
  type UserListPreferencesResponse as UserListPreferencesResponse,
873
933
  type UsersEntriesCursor as UsersEntriesCursor,
@@ -892,14 +952,17 @@ export declare namespace Users {
892
952
 
893
953
  export {
894
954
  Guides as Guides,
955
+ type GuideActionResponse as GuideActionResponse,
956
+ type GuideArchivedRequest as GuideArchivedRequest,
957
+ type GuideInteractedRequest as GuideInteractedRequest,
958
+ type GuideSeenRequest as GuideSeenRequest,
895
959
  type GuideGetChannelResponse as GuideGetChannelResponse,
896
- type GuideMarkMessageAsArchivedResponse as GuideMarkMessageAsArchivedResponse,
897
- type GuideMarkMessageAsInteractedResponse as GuideMarkMessageAsInteractedResponse,
898
- type GuideMarkMessageAsSeenResponse as GuideMarkMessageAsSeenResponse,
899
960
  type GuideGetChannelParams as GuideGetChannelParams,
900
961
  type GuideMarkMessageAsArchivedParams as GuideMarkMessageAsArchivedParams,
901
962
  type GuideMarkMessageAsInteractedParams as GuideMarkMessageAsInteractedParams,
902
963
  type GuideMarkMessageAsSeenParams as GuideMarkMessageAsSeenParams,
964
+ type GuideResetGuideEngagementsParams as GuideResetGuideEngagementsParams,
965
+ type GuideUnarchiveGuideMessageParams as GuideUnarchiveGuideMessageParams,
903
966
  };
904
967
 
905
968
  export {
@@ -908,6 +971,13 @@ export declare namespace Users {
908
971
  type BulkIdentifyParams as BulkIdentifyParams,
909
972
  type BulkSetPreferencesParams as BulkSetPreferencesParams,
910
973
  };
974
+
975
+ export {
976
+ PreferenceCenter as PreferenceCenter,
977
+ type PreferenceCenterBrandingConfig as PreferenceCenterBrandingConfig,
978
+ type PreferenceCenterGenerateSignedURLResponse as PreferenceCenterGenerateSignedURLResponse,
979
+ type PreferenceCenterGetConfigResponse as PreferenceCenterGetConfigResponse,
980
+ };
911
981
  }
912
982
 
913
983
  export { type MessagesItemsCursor, type SchedulesEntriesCursor, type SubscriptionsEntriesCursor };
package/src/version.ts CHANGED
@@ -1 +1 @@
1
- export const VERSION = '1.33.0'; // x-release-please-version
1
+ export const VERSION = '1.35.0'; // x-release-please-version
package/version.d.mts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.33.0";
1
+ export declare const VERSION = "1.35.0";
2
2
  //# sourceMappingURL=version.d.mts.map
package/version.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- export declare const VERSION = "1.33.0";
1
+ export declare const VERSION = "1.35.0";
2
2
  //# sourceMappingURL=version.d.ts.map
package/version.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.VERSION = void 0;
4
- exports.VERSION = '1.33.0'; // x-release-please-version
4
+ exports.VERSION = '1.35.0'; // x-release-please-version
5
5
  //# sourceMappingURL=version.js.map
package/version.mjs CHANGED
@@ -1,2 +1,2 @@
1
- export const VERSION = '1.33.0'; // x-release-please-version
1
+ export const VERSION = '1.35.0'; // x-release-please-version
2
2
  //# sourceMappingURL=version.mjs.map