@novu/api 0.1.2 → 0.1.6

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 (134) hide show
  1. package/README.md +18 -11
  2. package/docs/sdks/legacy/README.md +86 -0
  3. package/docs/sdks/messages/README.md +2 -8
  4. package/docs/sdks/notifications/README.md +2 -6
  5. package/docs/sdks/novunotifications/README.md +0 -6
  6. package/docs/sdks/preferences/README.md +123 -37
  7. package/docs/sdks/subscribers/README.md +7 -7
  8. package/docs/sdks/topics/README.md +0 -4
  9. package/funcs/subscribersPreferencesLegacyUpdateGlobal.d.ts +14 -0
  10. package/funcs/subscribersPreferencesLegacyUpdateGlobal.d.ts.map +1 -0
  11. package/funcs/{subscribersPreferencesUpdateGlobal.js → subscribersPreferencesLegacyUpdateGlobal.js} +4 -4
  12. package/funcs/subscribersPreferencesLegacyUpdateGlobal.js.map +1 -0
  13. package/funcs/{subscribersPreferencesUpdateGlobal.d.ts → subscribersPreferencesListLegacy.d.ts} +5 -4
  14. package/funcs/subscribersPreferencesListLegacy.d.ts.map +1 -0
  15. package/funcs/{subscribersPreferencesList.js → subscribersPreferencesListLegacy.js} +6 -4
  16. package/funcs/subscribersPreferencesListLegacy.js.map +1 -0
  17. package/funcs/subscribersPreferencesRetrieve.d.ts +16 -0
  18. package/funcs/subscribersPreferencesRetrieve.d.ts.map +1 -0
  19. package/funcs/subscribersPreferencesRetrieve.js +141 -0
  20. package/funcs/subscribersPreferencesRetrieve.js.map +1 -0
  21. package/funcs/subscribersPreferencesRetrieveByLevelLegacy.d.ts +15 -0
  22. package/funcs/subscribersPreferencesRetrieveByLevelLegacy.d.ts.map +1 -0
  23. package/funcs/{subscribersPreferencesRetrieveByLevel.js → subscribersPreferencesRetrieveByLevelLegacy.js} +6 -4
  24. package/funcs/subscribersPreferencesRetrieveByLevelLegacy.js.map +1 -0
  25. package/funcs/subscribersPreferencesUpdate.d.ts +6 -2
  26. package/funcs/subscribersPreferencesUpdate.d.ts.map +1 -1
  27. package/funcs/subscribersPreferencesUpdate.js +18 -12
  28. package/funcs/subscribersPreferencesUpdate.js.map +1 -1
  29. package/funcs/subscribersPreferencesUpdateLegacy.d.ts +13 -0
  30. package/funcs/subscribersPreferencesUpdateLegacy.d.ts.map +1 -0
  31. package/funcs/subscribersPreferencesUpdateLegacy.js +139 -0
  32. package/funcs/subscribersPreferencesUpdateLegacy.js.map +1 -0
  33. package/funcs/{subscribersUpdate.d.ts → subscribersUpdateLegacy.d.ts} +2 -2
  34. package/funcs/subscribersUpdateLegacy.d.ts.map +1 -0
  35. package/funcs/{subscribersUpdate.js → subscribersUpdateLegacy.js} +4 -4
  36. package/funcs/subscribersUpdateLegacy.js.map +1 -0
  37. package/jsr.json +1 -1
  38. package/lib/config.d.ts +3 -3
  39. package/lib/config.js +3 -3
  40. package/models/components/getsubscriberpreferencesdto.d.ts +39 -0
  41. package/models/components/getsubscriberpreferencesdto.d.ts.map +1 -0
  42. package/models/components/getsubscriberpreferencesdto.js +63 -0
  43. package/models/components/getsubscriberpreferencesdto.js.map +1 -0
  44. package/models/components/globalpreferencedto.d.ts +38 -0
  45. package/models/components/globalpreferencedto.d.ts.map +1 -0
  46. package/models/components/globalpreferencedto.js +62 -0
  47. package/models/components/globalpreferencedto.js.map +1 -0
  48. package/models/components/index.d.ts +7 -0
  49. package/models/components/index.d.ts.map +1 -1
  50. package/models/components/index.js +7 -0
  51. package/models/components/index.js.map +1 -1
  52. package/models/components/overrides.d.ts +112 -0
  53. package/models/components/overrides.d.ts.map +1 -0
  54. package/models/components/overrides.js +110 -0
  55. package/models/components/overrides.js.map +1 -0
  56. package/models/components/patchpreferencechannelsdto.d.ts +52 -0
  57. package/models/components/patchpreferencechannelsdto.d.ts.map +1 -0
  58. package/models/components/patchpreferencechannelsdto.js +76 -0
  59. package/models/components/patchpreferencechannelsdto.js.map +1 -0
  60. package/models/components/patchsubscriberpreferencesdto.d.ts +38 -0
  61. package/models/components/patchsubscriberpreferencesdto.d.ts.map +1 -0
  62. package/models/components/patchsubscriberpreferencesdto.js +62 -0
  63. package/models/components/patchsubscriberpreferencesdto.js.map +1 -0
  64. package/models/components/triggereventtoallrequestdto.d.ts +15 -15
  65. package/models/components/triggereventtoallrequestdto.d.ts.map +1 -1
  66. package/models/components/triggereventtoallrequestdto.js +20 -18
  67. package/models/components/triggereventtoallrequestdto.js.map +1 -1
  68. package/models/components/workflowinfodto.d.ts +42 -0
  69. package/models/components/workflowinfodto.d.ts.map +1 -0
  70. package/models/components/workflowinfodto.js +63 -0
  71. package/models/components/workflowinfodto.js.map +1 -0
  72. package/models/components/workflowpreferencedto.d.ts +50 -0
  73. package/models/components/workflowpreferencedto.d.ts.map +1 -0
  74. package/models/components/workflowpreferencedto.js +68 -0
  75. package/models/components/workflowpreferencedto.js.map +1 -0
  76. package/models/operations/index.d.ts +2 -0
  77. package/models/operations/index.d.ts.map +1 -1
  78. package/models/operations/index.js +2 -0
  79. package/models/operations/index.js.map +1 -1
  80. package/models/operations/subscriberscontrollergetsubscriberpreferences.d.ts +66 -0
  81. package/models/operations/subscriberscontrollergetsubscriberpreferences.d.ts.map +1 -0
  82. package/models/operations/subscriberscontrollergetsubscriberpreferences.js +110 -0
  83. package/models/operations/subscriberscontrollergetsubscriberpreferences.js.map +1 -0
  84. package/models/operations/subscriberscontrollerupdatesubscriberpreferences.d.ts +68 -0
  85. package/models/operations/subscriberscontrollerupdatesubscriberpreferences.d.ts.map +1 -0
  86. package/models/operations/subscriberscontrollerupdatesubscriberpreferences.js +118 -0
  87. package/models/operations/subscriberscontrollerupdatesubscriberpreferences.js.map +1 -0
  88. package/package.json +1 -1
  89. package/sdk/legacy.d.ts +10 -0
  90. package/sdk/legacy.d.ts.map +1 -0
  91. package/sdk/legacy.js +19 -0
  92. package/sdk/legacy.js.map +1 -0
  93. package/sdk/preferences.d.ts +24 -7
  94. package/sdk/preferences.d.ts.map +1 -1
  95. package/sdk/preferences.js +35 -14
  96. package/sdk/preferences.js.map +1 -1
  97. package/sdk/subscribers.d.ts +1 -1
  98. package/sdk/subscribers.d.ts.map +1 -1
  99. package/sdk/subscribers.js +3 -3
  100. package/sdk/subscribers.js.map +1 -1
  101. package/sources/json-development.json +1225 -57
  102. package/src/funcs/{subscribersPreferencesUpdateGlobal.ts → subscribersPreferencesLegacyUpdateGlobal.ts} +1 -1
  103. package/src/funcs/{subscribersPreferencesList.ts → subscribersPreferencesListLegacy.ts} +3 -1
  104. package/src/funcs/subscribersPreferencesRetrieve.ts +203 -0
  105. package/src/funcs/{subscribersPreferencesRetrieveByLevel.ts → subscribersPreferencesRetrieveByLevelLegacy.ts} +3 -1
  106. package/src/funcs/subscribersPreferencesUpdate.ts +27 -20
  107. package/src/funcs/subscribersPreferencesUpdateLegacy.ts +202 -0
  108. package/src/funcs/{subscribersUpdate.ts → subscribersUpdateLegacy.ts} +1 -1
  109. package/src/lib/config.ts +3 -3
  110. package/src/models/components/getsubscriberpreferencesdto.ts +90 -0
  111. package/src/models/components/globalpreferencedto.ts +82 -0
  112. package/src/models/components/index.ts +7 -0
  113. package/src/models/components/overrides.ts +141 -0
  114. package/src/models/components/patchpreferencechannelsdto.ts +106 -0
  115. package/src/models/components/patchsubscriberpreferencesdto.ts +84 -0
  116. package/src/models/components/triggereventtoallrequestdto.ts +35 -24
  117. package/src/models/components/workflowinfodto.ts +81 -0
  118. package/src/models/components/workflowpreferencedto.ts +108 -0
  119. package/src/models/operations/index.ts +2 -0
  120. package/src/models/operations/subscriberscontrollergetsubscriberpreferences.ts +183 -0
  121. package/src/models/operations/subscriberscontrollerupdatesubscriberpreferences.ts +189 -0
  122. package/src/sdk/legacy.ts +32 -0
  123. package/src/sdk/preferences.ts +58 -26
  124. package/src/sdk/subscribers.ts +3 -3
  125. package/funcs/subscribersPreferencesList.d.ts +0 -13
  126. package/funcs/subscribersPreferencesList.d.ts.map +0 -1
  127. package/funcs/subscribersPreferencesList.js.map +0 -1
  128. package/funcs/subscribersPreferencesRetrieveByLevel.d.ts +0 -13
  129. package/funcs/subscribersPreferencesRetrieveByLevel.d.ts.map +0 -1
  130. package/funcs/subscribersPreferencesRetrieveByLevel.js.map +0 -1
  131. package/funcs/subscribersPreferencesUpdateGlobal.d.ts.map +0 -1
  132. package/funcs/subscribersPreferencesUpdateGlobal.js.map +0 -1
  133. package/funcs/subscribersUpdate.d.ts.map +0 -1
  134. package/funcs/subscribersUpdate.js.map +0 -1
@@ -27,7 +27,7 @@ import { Result } from "../types/fp.js";
27
27
  /**
28
28
  * Update subscriber global preferences
29
29
  */
30
- export async function subscribersPreferencesUpdateGlobal(
30
+ export async function subscribersPreferencesLegacyUpdateGlobal(
31
31
  client: NovuCore,
32
32
  updateSubscriberGlobalPreferencesRequestDto:
33
33
  components.UpdateSubscriberGlobalPreferencesRequestDto,
@@ -25,8 +25,10 @@ import { Result } from "../types/fp.js";
25
25
 
26
26
  /**
27
27
  * Get subscriber preferences
28
+ *
29
+ * @deprecated method: This will be removed in a future release, please migrate away from it as soon as possible.
28
30
  */
29
- export async function subscribersPreferencesList(
31
+ export async function subscribersPreferencesListLegacy(
30
32
  client: NovuCore,
31
33
  subscriberId: string,
32
34
  includeInactiveChannels?: boolean | undefined,
@@ -0,0 +1,203 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { NovuCore } from "../core.js";
6
+ import { encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import {
14
+ ConnectionError,
15
+ InvalidRequestError,
16
+ RequestAbortedError,
17
+ RequestTimeoutError,
18
+ UnexpectedClientError,
19
+ } from "../models/errors/httpclienterrors.js";
20
+ import * as errors from "../models/errors/index.js";
21
+ import { SDKError } from "../models/errors/sdkerror.js";
22
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
23
+ import * as operations from "../models/operations/index.js";
24
+ import { Result } from "../types/fp.js";
25
+
26
+ /**
27
+ * Get subscriber preferences
28
+ *
29
+ * @remarks
30
+ * Get subscriber global and workflow specific preferences
31
+ */
32
+ export async function subscribersPreferencesRetrieve(
33
+ client: NovuCore,
34
+ subscriberId: string,
35
+ idempotencyKey?: string | undefined,
36
+ options?: RequestOptions,
37
+ ): Promise<
38
+ Result<
39
+ operations.SubscribersControllerGetSubscriberPreferencesResponse,
40
+ | errors.ErrorDto
41
+ | errors.ErrorDto
42
+ | errors.ValidationErrorDto
43
+ | errors.ErrorDto
44
+ | SDKError
45
+ | SDKValidationError
46
+ | UnexpectedClientError
47
+ | InvalidRequestError
48
+ | RequestAbortedError
49
+ | RequestTimeoutError
50
+ | ConnectionError
51
+ >
52
+ > {
53
+ const input: operations.SubscribersControllerGetSubscriberPreferencesRequest =
54
+ {
55
+ subscriberId: subscriberId,
56
+ idempotencyKey: idempotencyKey,
57
+ };
58
+
59
+ const parsed = safeParse(
60
+ input,
61
+ (value) =>
62
+ operations
63
+ .SubscribersControllerGetSubscriberPreferencesRequest$outboundSchema
64
+ .parse(value),
65
+ "Input validation failed",
66
+ );
67
+ if (!parsed.ok) {
68
+ return parsed;
69
+ }
70
+ const payload = parsed.value;
71
+ const body = null;
72
+
73
+ const pathParams = {
74
+ subscriberId: encodeSimple("subscriberId", payload.subscriberId, {
75
+ explode: false,
76
+ charEncoding: "percent",
77
+ }),
78
+ };
79
+
80
+ const path = pathToFunc("/v2/subscribers/{subscriberId}/preferences")(
81
+ pathParams,
82
+ );
83
+
84
+ const headers = new Headers(compactMap({
85
+ Accept: "application/json",
86
+ "idempotency-key": encodeSimple(
87
+ "idempotency-key",
88
+ payload["idempotency-key"],
89
+ { explode: false, charEncoding: "none" },
90
+ ),
91
+ }));
92
+
93
+ const secConfig = await extractSecurity(client._options.secretKey);
94
+ const securityInput = secConfig == null ? {} : { secretKey: secConfig };
95
+ const requestSecurity = resolveGlobalSecurity(securityInput);
96
+
97
+ const context = {
98
+ operationID: "SubscribersController_getSubscriberPreferences",
99
+ oAuth2Scopes: [],
100
+
101
+ resolvedSecurity: requestSecurity,
102
+
103
+ securitySource: client._options.secretKey,
104
+ retryConfig: options?.retries
105
+ || client._options.retryConfig
106
+ || {
107
+ strategy: "backoff",
108
+ backoff: {
109
+ initialInterval: 1000,
110
+ maxInterval: 30000,
111
+ exponent: 1.5,
112
+ maxElapsedTime: 3600000,
113
+ },
114
+ retryConnectionErrors: true,
115
+ }
116
+ || { strategy: "none" },
117
+ retryCodes: options?.retryCodes || ["408", "409", "429", "5XX"],
118
+ };
119
+
120
+ const requestRes = client._createRequest(context, {
121
+ security: requestSecurity,
122
+ method: "GET",
123
+ baseURL: options?.serverURL,
124
+ path: path,
125
+ headers: headers,
126
+ body: body,
127
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
128
+ }, options);
129
+ if (!requestRes.ok) {
130
+ return requestRes;
131
+ }
132
+ const req = requestRes.value;
133
+
134
+ const doResult = await client._do(req, {
135
+ context,
136
+ errorCodes: [
137
+ "400",
138
+ "401",
139
+ "403",
140
+ "404",
141
+ "405",
142
+ "409",
143
+ "413",
144
+ "414",
145
+ "415",
146
+ "422",
147
+ "429",
148
+ "4XX",
149
+ "500",
150
+ "503",
151
+ "5XX",
152
+ ],
153
+ retryConfig: context.retryConfig,
154
+ retryCodes: context.retryCodes,
155
+ });
156
+ if (!doResult.ok) {
157
+ return doResult;
158
+ }
159
+ const response = doResult.value;
160
+
161
+ const responseFields = {
162
+ HttpMeta: { Response: response, Request: req },
163
+ };
164
+
165
+ const [result] = await M.match<
166
+ operations.SubscribersControllerGetSubscriberPreferencesResponse,
167
+ | errors.ErrorDto
168
+ | errors.ErrorDto
169
+ | errors.ValidationErrorDto
170
+ | errors.ErrorDto
171
+ | SDKError
172
+ | SDKValidationError
173
+ | UnexpectedClientError
174
+ | InvalidRequestError
175
+ | RequestAbortedError
176
+ | RequestTimeoutError
177
+ | ConnectionError
178
+ >(
179
+ M.json(
180
+ 200,
181
+ operations
182
+ .SubscribersControllerGetSubscriberPreferencesResponse$inboundSchema,
183
+ { hdrs: true, key: "Result" },
184
+ ),
185
+ M.jsonErr(414, errors.ErrorDto$inboundSchema),
186
+ M.jsonErr(
187
+ [400, 401, 403, 404, 405, 409, 413, 415],
188
+ errors.ErrorDto$inboundSchema,
189
+ { hdrs: true },
190
+ ),
191
+ M.jsonErr(422, errors.ValidationErrorDto$inboundSchema, { hdrs: true }),
192
+ M.fail(429),
193
+ M.jsonErr(500, errors.ErrorDto$inboundSchema, { hdrs: true }),
194
+ M.fail(503),
195
+ M.fail("4XX"),
196
+ M.fail("5XX"),
197
+ )(response, { extraFields: responseFields });
198
+ if (!result.ok) {
199
+ return result;
200
+ }
201
+
202
+ return result;
203
+ }
@@ -25,8 +25,10 @@ import { Result } from "../types/fp.js";
25
25
 
26
26
  /**
27
27
  * Get subscriber preferences by level
28
+ *
29
+ * @deprecated method: This will be removed in a future release, please migrate away from it as soon as possible.
28
30
  */
29
- export async function subscribersPreferencesRetrieveByLevel(
31
+ export async function subscribersPreferencesRetrieveByLevelLegacy(
30
32
  client: NovuCore,
31
33
  request:
32
34
  operations.SubscribersV1ControllerGetSubscriberPreferenceByLevelRequest,
@@ -10,6 +10,7 @@ import { safeParse } from "../lib/schemas.js";
10
10
  import { RequestOptions } from "../lib/sdks.js";
11
11
  import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
12
  import { pathToFunc } from "../lib/url.js";
13
+ import * as components from "../models/components/index.js";
13
14
  import {
14
15
  ConnectionError,
15
16
  InvalidRequestError,
@@ -24,15 +25,20 @@ import * as operations from "../models/operations/index.js";
24
25
  import { Result } from "../types/fp.js";
25
26
 
26
27
  /**
27
- * Update subscriber preference
28
+ * Update subscriber global or workflow specific preferences
29
+ *
30
+ * @remarks
31
+ * Update subscriber global or workflow specific preferences
28
32
  */
29
33
  export async function subscribersPreferencesUpdate(
30
34
  client: NovuCore,
31
- request: operations.SubscribersV1ControllerUpdateSubscriberPreferenceRequest,
35
+ patchSubscriberPreferencesDto: components.PatchSubscriberPreferencesDto,
36
+ subscriberId: string,
37
+ idempotencyKey?: string | undefined,
32
38
  options?: RequestOptions,
33
39
  ): Promise<
34
40
  Result<
35
- operations.SubscribersV1ControllerUpdateSubscriberPreferenceResponse,
41
+ operations.SubscribersControllerUpdateSubscriberPreferencesResponse,
36
42
  | errors.ErrorDto
37
43
  | errors.ErrorDto
38
44
  | errors.ValidationErrorDto
@@ -46,11 +52,18 @@ export async function subscribersPreferencesUpdate(
46
52
  | ConnectionError
47
53
  >
48
54
  > {
55
+ const input:
56
+ operations.SubscribersControllerUpdateSubscriberPreferencesRequest = {
57
+ patchSubscriberPreferencesDto: patchSubscriberPreferencesDto,
58
+ subscriberId: subscriberId,
59
+ idempotencyKey: idempotencyKey,
60
+ };
61
+
49
62
  const parsed = safeParse(
50
- request,
63
+ input,
51
64
  (value) =>
52
65
  operations
53
- .SubscribersV1ControllerUpdateSubscriberPreferenceRequest$outboundSchema
66
+ .SubscribersControllerUpdateSubscriberPreferencesRequest$outboundSchema
54
67
  .parse(value),
55
68
  "Input validation failed",
56
69
  );
@@ -58,26 +71,20 @@ export async function subscribersPreferencesUpdate(
58
71
  return parsed;
59
72
  }
60
73
  const payload = parsed.value;
61
- const body = encodeJSON(
62
- "body",
63
- payload.UpdateSubscriberPreferenceRequestDto,
64
- { explode: true },
65
- );
74
+ const body = encodeJSON("body", payload.PatchSubscriberPreferencesDto, {
75
+ explode: true,
76
+ });
66
77
 
67
78
  const pathParams = {
68
79
  subscriberId: encodeSimple("subscriberId", payload.subscriberId, {
69
80
  explode: false,
70
81
  charEncoding: "percent",
71
82
  }),
72
- parameter: encodeSimple("parameter", payload.workflowId, {
73
- explode: false,
74
- charEncoding: "percent",
75
- }),
76
83
  };
77
84
 
78
- const path = pathToFunc(
79
- "/v1/subscribers/{subscriberId}/preferences/{parameter}",
80
- )(pathParams);
85
+ const path = pathToFunc("/v2/subscribers/{subscriberId}/preferences")(
86
+ pathParams,
87
+ );
81
88
 
82
89
  const headers = new Headers(compactMap({
83
90
  "Content-Type": "application/json",
@@ -94,7 +101,7 @@ export async function subscribersPreferencesUpdate(
94
101
  const requestSecurity = resolveGlobalSecurity(securityInput);
95
102
 
96
103
  const context = {
97
- operationID: "SubscribersV1Controller_updateSubscriberPreference",
104
+ operationID: "SubscribersController_updateSubscriberPreferences",
98
105
  oAuth2Scopes: [],
99
106
 
100
107
  resolvedSecurity: requestSecurity,
@@ -162,7 +169,7 @@ export async function subscribersPreferencesUpdate(
162
169
  };
163
170
 
164
171
  const [result] = await M.match<
165
- operations.SubscribersV1ControllerUpdateSubscriberPreferenceResponse,
172
+ operations.SubscribersControllerUpdateSubscriberPreferencesResponse,
166
173
  | errors.ErrorDto
167
174
  | errors.ErrorDto
168
175
  | errors.ValidationErrorDto
@@ -178,7 +185,7 @@ export async function subscribersPreferencesUpdate(
178
185
  M.json(
179
186
  200,
180
187
  operations
181
- .SubscribersV1ControllerUpdateSubscriberPreferenceResponse$inboundSchema,
188
+ .SubscribersControllerUpdateSubscriberPreferencesResponse$inboundSchema,
182
189
  { hdrs: true, key: "Result" },
183
190
  ),
184
191
  M.jsonErr(414, errors.ErrorDto$inboundSchema),
@@ -0,0 +1,202 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import { NovuCore } from "../core.js";
6
+ import { encodeJSON, encodeSimple } from "../lib/encodings.js";
7
+ import * as M from "../lib/matchers.js";
8
+ import { compactMap } from "../lib/primitives.js";
9
+ import { safeParse } from "../lib/schemas.js";
10
+ import { RequestOptions } from "../lib/sdks.js";
11
+ import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
12
+ import { pathToFunc } from "../lib/url.js";
13
+ import {
14
+ ConnectionError,
15
+ InvalidRequestError,
16
+ RequestAbortedError,
17
+ RequestTimeoutError,
18
+ UnexpectedClientError,
19
+ } from "../models/errors/httpclienterrors.js";
20
+ import * as errors from "../models/errors/index.js";
21
+ import { SDKError } from "../models/errors/sdkerror.js";
22
+ import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
23
+ import * as operations from "../models/operations/index.js";
24
+ import { Result } from "../types/fp.js";
25
+
26
+ /**
27
+ * Update subscriber preference
28
+ */
29
+ export async function subscribersPreferencesUpdateLegacy(
30
+ client: NovuCore,
31
+ request: operations.SubscribersV1ControllerUpdateSubscriberPreferenceRequest,
32
+ options?: RequestOptions,
33
+ ): Promise<
34
+ Result<
35
+ operations.SubscribersV1ControllerUpdateSubscriberPreferenceResponse,
36
+ | errors.ErrorDto
37
+ | errors.ErrorDto
38
+ | errors.ValidationErrorDto
39
+ | errors.ErrorDto
40
+ | SDKError
41
+ | SDKValidationError
42
+ | UnexpectedClientError
43
+ | InvalidRequestError
44
+ | RequestAbortedError
45
+ | RequestTimeoutError
46
+ | ConnectionError
47
+ >
48
+ > {
49
+ const parsed = safeParse(
50
+ request,
51
+ (value) =>
52
+ operations
53
+ .SubscribersV1ControllerUpdateSubscriberPreferenceRequest$outboundSchema
54
+ .parse(value),
55
+ "Input validation failed",
56
+ );
57
+ if (!parsed.ok) {
58
+ return parsed;
59
+ }
60
+ const payload = parsed.value;
61
+ const body = encodeJSON(
62
+ "body",
63
+ payload.UpdateSubscriberPreferenceRequestDto,
64
+ { explode: true },
65
+ );
66
+
67
+ const pathParams = {
68
+ subscriberId: encodeSimple("subscriberId", payload.subscriberId, {
69
+ explode: false,
70
+ charEncoding: "percent",
71
+ }),
72
+ parameter: encodeSimple("parameter", payload.workflowId, {
73
+ explode: false,
74
+ charEncoding: "percent",
75
+ }),
76
+ };
77
+
78
+ const path = pathToFunc(
79
+ "/v1/subscribers/{subscriberId}/preferences/{parameter}",
80
+ )(pathParams);
81
+
82
+ const headers = new Headers(compactMap({
83
+ "Content-Type": "application/json",
84
+ Accept: "application/json",
85
+ "idempotency-key": encodeSimple(
86
+ "idempotency-key",
87
+ payload["idempotency-key"],
88
+ { explode: false, charEncoding: "none" },
89
+ ),
90
+ }));
91
+
92
+ const secConfig = await extractSecurity(client._options.secretKey);
93
+ const securityInput = secConfig == null ? {} : { secretKey: secConfig };
94
+ const requestSecurity = resolveGlobalSecurity(securityInput);
95
+
96
+ const context = {
97
+ operationID: "SubscribersV1Controller_updateSubscriberPreference",
98
+ oAuth2Scopes: [],
99
+
100
+ resolvedSecurity: requestSecurity,
101
+
102
+ securitySource: client._options.secretKey,
103
+ retryConfig: options?.retries
104
+ || client._options.retryConfig
105
+ || {
106
+ strategy: "backoff",
107
+ backoff: {
108
+ initialInterval: 1000,
109
+ maxInterval: 30000,
110
+ exponent: 1.5,
111
+ maxElapsedTime: 3600000,
112
+ },
113
+ retryConnectionErrors: true,
114
+ }
115
+ || { strategy: "none" },
116
+ retryCodes: options?.retryCodes || ["408", "409", "429", "5XX"],
117
+ };
118
+
119
+ const requestRes = client._createRequest(context, {
120
+ security: requestSecurity,
121
+ method: "PATCH",
122
+ baseURL: options?.serverURL,
123
+ path: path,
124
+ headers: headers,
125
+ body: body,
126
+ timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
127
+ }, options);
128
+ if (!requestRes.ok) {
129
+ return requestRes;
130
+ }
131
+ const req = requestRes.value;
132
+
133
+ const doResult = await client._do(req, {
134
+ context,
135
+ errorCodes: [
136
+ "400",
137
+ "401",
138
+ "403",
139
+ "404",
140
+ "405",
141
+ "409",
142
+ "413",
143
+ "414",
144
+ "415",
145
+ "422",
146
+ "429",
147
+ "4XX",
148
+ "500",
149
+ "503",
150
+ "5XX",
151
+ ],
152
+ retryConfig: context.retryConfig,
153
+ retryCodes: context.retryCodes,
154
+ });
155
+ if (!doResult.ok) {
156
+ return doResult;
157
+ }
158
+ const response = doResult.value;
159
+
160
+ const responseFields = {
161
+ HttpMeta: { Response: response, Request: req },
162
+ };
163
+
164
+ const [result] = await M.match<
165
+ operations.SubscribersV1ControllerUpdateSubscriberPreferenceResponse,
166
+ | errors.ErrorDto
167
+ | errors.ErrorDto
168
+ | errors.ValidationErrorDto
169
+ | errors.ErrorDto
170
+ | SDKError
171
+ | SDKValidationError
172
+ | UnexpectedClientError
173
+ | InvalidRequestError
174
+ | RequestAbortedError
175
+ | RequestTimeoutError
176
+ | ConnectionError
177
+ >(
178
+ M.json(
179
+ 200,
180
+ operations
181
+ .SubscribersV1ControllerUpdateSubscriberPreferenceResponse$inboundSchema,
182
+ { hdrs: true, key: "Result" },
183
+ ),
184
+ M.jsonErr(414, errors.ErrorDto$inboundSchema),
185
+ M.jsonErr(
186
+ [400, 401, 403, 404, 405, 409, 413, 415],
187
+ errors.ErrorDto$inboundSchema,
188
+ { hdrs: true },
189
+ ),
190
+ M.jsonErr(422, errors.ValidationErrorDto$inboundSchema, { hdrs: true }),
191
+ M.fail(429),
192
+ M.jsonErr(500, errors.ErrorDto$inboundSchema, { hdrs: true }),
193
+ M.fail(503),
194
+ M.fail("4XX"),
195
+ M.fail("5XX"),
196
+ )(response, { extraFields: responseFields });
197
+ if (!result.ok) {
198
+ return result;
199
+ }
200
+
201
+ return result;
202
+ }
@@ -30,7 +30,7 @@ import { Result } from "../types/fp.js";
30
30
  * @remarks
31
31
  * Used to update the subscriber entity with new information
32
32
  */
33
- export async function subscribersUpdate(
33
+ export async function subscribersUpdateLegacy(
34
34
  client: NovuCore,
35
35
  updateSubscriberRequestDto: components.UpdateSubscriberRequestDto,
36
36
  subscriberId: string,
package/src/lib/config.ts CHANGED
@@ -55,7 +55,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
55
55
  export const SDK_METADATA = {
56
56
  language: "typescript",
57
57
  openapiDocVersion: "1.0",
58
- sdkVersion: "0.1.2",
59
- genVersion: "2.499.0",
60
- userAgent: "speakeasy-sdk/typescript 0.1.2 2.499.0 1.0 @novu/api",
58
+ sdkVersion: "0.1.6",
59
+ genVersion: "2.503.2",
60
+ userAgent: "speakeasy-sdk/typescript 0.1.6 2.503.2 1.0 @novu/api",
61
61
  } as const;
@@ -0,0 +1,90 @@
1
+ /*
2
+ * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT.
3
+ */
4
+
5
+ import * as z from "zod";
6
+ import { safeParse } from "../../lib/schemas.js";
7
+ import { Result as SafeParseResult } from "../../types/fp.js";
8
+ import { SDKValidationError } from "../errors/sdkvalidationerror.js";
9
+ import {
10
+ GlobalPreferenceDto,
11
+ GlobalPreferenceDto$inboundSchema,
12
+ GlobalPreferenceDto$Outbound,
13
+ GlobalPreferenceDto$outboundSchema,
14
+ } from "./globalpreferencedto.js";
15
+ import {
16
+ WorkflowPreferenceDto,
17
+ WorkflowPreferenceDto$inboundSchema,
18
+ WorkflowPreferenceDto$Outbound,
19
+ WorkflowPreferenceDto$outboundSchema,
20
+ } from "./workflowpreferencedto.js";
21
+
22
+ export type GetSubscriberPreferencesDto = {
23
+ /**
24
+ * Global preference settings
25
+ */
26
+ global: GlobalPreferenceDto;
27
+ /**
28
+ * Workflow-specific preference settings
29
+ */
30
+ workflows: Array<WorkflowPreferenceDto>;
31
+ };
32
+
33
+ /** @internal */
34
+ export const GetSubscriberPreferencesDto$inboundSchema: z.ZodType<
35
+ GetSubscriberPreferencesDto,
36
+ z.ZodTypeDef,
37
+ unknown
38
+ > = z.object({
39
+ global: GlobalPreferenceDto$inboundSchema,
40
+ workflows: z.array(WorkflowPreferenceDto$inboundSchema),
41
+ });
42
+
43
+ /** @internal */
44
+ export type GetSubscriberPreferencesDto$Outbound = {
45
+ global: GlobalPreferenceDto$Outbound;
46
+ workflows: Array<WorkflowPreferenceDto$Outbound>;
47
+ };
48
+
49
+ /** @internal */
50
+ export const GetSubscriberPreferencesDto$outboundSchema: z.ZodType<
51
+ GetSubscriberPreferencesDto$Outbound,
52
+ z.ZodTypeDef,
53
+ GetSubscriberPreferencesDto
54
+ > = z.object({
55
+ global: GlobalPreferenceDto$outboundSchema,
56
+ workflows: z.array(WorkflowPreferenceDto$outboundSchema),
57
+ });
58
+
59
+ /**
60
+ * @internal
61
+ * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module.
62
+ */
63
+ export namespace GetSubscriberPreferencesDto$ {
64
+ /** @deprecated use `GetSubscriberPreferencesDto$inboundSchema` instead. */
65
+ export const inboundSchema = GetSubscriberPreferencesDto$inboundSchema;
66
+ /** @deprecated use `GetSubscriberPreferencesDto$outboundSchema` instead. */
67
+ export const outboundSchema = GetSubscriberPreferencesDto$outboundSchema;
68
+ /** @deprecated use `GetSubscriberPreferencesDto$Outbound` instead. */
69
+ export type Outbound = GetSubscriberPreferencesDto$Outbound;
70
+ }
71
+
72
+ export function getSubscriberPreferencesDtoToJSON(
73
+ getSubscriberPreferencesDto: GetSubscriberPreferencesDto,
74
+ ): string {
75
+ return JSON.stringify(
76
+ GetSubscriberPreferencesDto$outboundSchema.parse(
77
+ getSubscriberPreferencesDto,
78
+ ),
79
+ );
80
+ }
81
+
82
+ export function getSubscriberPreferencesDtoFromJSON(
83
+ jsonString: string,
84
+ ): SafeParseResult<GetSubscriberPreferencesDto, SDKValidationError> {
85
+ return safeParse(
86
+ jsonString,
87
+ (x) => GetSubscriberPreferencesDto$inboundSchema.parse(JSON.parse(x)),
88
+ `Failed to parse 'GetSubscriberPreferencesDto' from JSON`,
89
+ );
90
+ }