@novu/api 3.17.0 → 3.17.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.
- package/README.md +20 -14
- package/funcs/integrationsCreate.d.ts +1 -1
- package/funcs/integrationsCreate.js +1 -1
- package/funcs/integrationsCreateMobileLink.d.ts +19 -0
- package/funcs/integrationsCreateMobileLink.d.ts.map +1 -0
- package/funcs/integrationsCreateMobileLink.js +141 -0
- package/funcs/integrationsCreateMobileLink.js.map +1 -0
- package/funcs/integrationsDelete.d.ts +1 -1
- package/funcs/integrationsDelete.js +1 -1
- package/funcs/integrationsIntegrationsControllerAutoConfigureIntegration.d.ts +1 -1
- package/funcs/integrationsIntegrationsControllerAutoConfigureIntegration.js +1 -1
- package/funcs/integrationsIntegrationsControllerConfigureIntegrationWebhook.d.ts +18 -0
- package/funcs/integrationsIntegrationsControllerConfigureIntegrationWebhook.d.ts.map +1 -0
- package/funcs/integrationsIntegrationsControllerConfigureIntegrationWebhook.js +139 -0
- package/funcs/integrationsIntegrationsControllerConfigureIntegrationWebhook.js.map +1 -0
- package/funcs/integrationsLinkChannelEndpoint.d.ts +19 -0
- package/funcs/integrationsLinkChannelEndpoint.d.ts.map +1 -0
- package/funcs/integrationsLinkChannelEndpoint.js +138 -0
- package/funcs/integrationsLinkChannelEndpoint.js.map +1 -0
- package/funcs/integrationsList.d.ts +1 -1
- package/funcs/integrationsList.js +1 -1
- package/funcs/integrationsListActive.d.ts +1 -1
- package/funcs/integrationsListActive.js +1 -1
- package/funcs/integrationsSetAsPrimary.d.ts +1 -0
- package/funcs/integrationsSetAsPrimary.d.ts.map +1 -1
- package/funcs/integrationsSetAsPrimary.js +1 -0
- package/funcs/integrationsSetAsPrimary.js.map +1 -1
- package/funcs/integrationsUpdate.d.ts +1 -1
- package/funcs/integrationsUpdate.js +1 -1
- package/funcs/subscribersMessagesMarkAll.d.ts +3 -1
- package/funcs/subscribersMessagesMarkAll.d.ts.map +1 -1
- package/funcs/subscribersMessagesMarkAll.js +3 -1
- package/funcs/subscribersMessagesMarkAll.js.map +1 -1
- package/funcs/subscribersMessagesMarkAllAs.d.ts +4 -2
- package/funcs/subscribersMessagesMarkAllAs.d.ts.map +1 -1
- package/funcs/subscribersMessagesMarkAllAs.js +4 -2
- package/funcs/subscribersMessagesMarkAllAs.js.map +1 -1
- package/funcs/subscribersMessagesUpdateAsSeen.d.ts +3 -1
- package/funcs/subscribersMessagesUpdateAsSeen.d.ts.map +1 -1
- package/funcs/subscribersMessagesUpdateAsSeen.js +3 -1
- package/funcs/subscribersMessagesUpdateAsSeen.js.map +1 -1
- package/funcs/subscribersNotificationsFeed.d.ts +3 -1
- package/funcs/subscribersNotificationsFeed.d.ts.map +1 -1
- package/funcs/subscribersNotificationsFeed.js +3 -1
- package/funcs/subscribersNotificationsFeed.js.map +1 -1
- package/funcs/subscribersNotificationsUnseenCount.d.ts +3 -1
- package/funcs/subscribersNotificationsUnseenCount.d.ts.map +1 -1
- package/funcs/subscribersNotificationsUnseenCount.js +3 -1
- package/funcs/subscribersNotificationsUnseenCount.js.map +1 -1
- package/hooks/types.d.ts +1 -0
- package/hooks/types.d.ts.map +1 -1
- package/jsr.json +1 -1
- package/lib/config.d.ts +4 -4
- package/lib/config.js +4 -4
- package/lib/encodings.js +12 -12
- package/lib/encodings.js.map +1 -1
- package/lib/matchers.js +3 -3
- package/lib/matchers.js.map +1 -1
- package/lib/primitives.d.ts +1 -0
- package/lib/primitives.d.ts.map +1 -1
- package/lib/primitives.js +18 -0
- package/lib/primitives.js.map +1 -1
- package/lib/retries.js +7 -0
- package/lib/retries.js.map +1 -1
- package/lib/sdks.d.ts.map +1 -1
- package/lib/sdks.js +50 -16
- package/lib/sdks.js.map +1 -1
- package/models/components/configuretelegramwebhookresponsedto.d.ts +21 -0
- package/models/components/configuretelegramwebhookresponsedto.d.ts.map +1 -0
- package/models/components/configuretelegramwebhookresponsedto.js +52 -0
- package/models/components/configuretelegramwebhookresponsedto.js.map +1 -0
- package/models/components/credentialsdto.d.ts +2 -0
- package/models/components/credentialsdto.d.ts.map +1 -1
- package/models/components/credentialsdto.js +2 -0
- package/models/components/credentialsdto.js.map +1 -1
- package/models/components/index.d.ts +5 -0
- package/models/components/index.d.ts.map +1 -1
- package/models/components/index.js +5 -0
- package/models/components/index.js.map +1 -1
- package/models/components/issueintegrationmobilelinkrequestdto.d.ts +15 -0
- package/models/components/issueintegrationmobilelinkrequestdto.d.ts.map +1 -0
- package/models/components/issueintegrationmobilelinkrequestdto.js +49 -0
- package/models/components/issueintegrationmobilelinkrequestdto.js.map +1 -0
- package/models/components/issuetelegrammobilelinkresponsedto.d.ts +21 -0
- package/models/components/issuetelegrammobilelinkresponsedto.d.ts.map +1 -0
- package/models/components/issuetelegrammobilelinkresponsedto.js +52 -0
- package/models/components/issuetelegrammobilelinkresponsedto.js.map +1 -0
- package/models/components/linkchannelendpointrequestdto.d.ts +20 -0
- package/models/components/linkchannelendpointrequestdto.d.ts.map +1 -0
- package/models/components/linkchannelendpointrequestdto.js +50 -0
- package/models/components/linkchannelendpointrequestdto.js.map +1 -0
- package/models/components/linkchannelendpointresponsedto.d.ts +19 -0
- package/models/components/linkchannelendpointresponsedto.d.ts.map +1 -0
- package/models/components/linkchannelendpointresponsedto.js +51 -0
- package/models/components/linkchannelendpointresponsedto.js.map +1 -0
- package/models/components/previewpayloaddto.d.ts +5 -0
- package/models/components/previewpayloaddto.d.ts.map +1 -1
- package/models/components/previewpayloaddto.js +2 -0
- package/models/components/previewpayloaddto.js.map +1 -1
- package/models/components/updateworkflowdto.d.ts +5 -4
- package/models/components/updateworkflowdto.d.ts.map +1 -1
- package/models/components/updateworkflowdto.js +3 -0
- package/models/components/updateworkflowdto.js.map +1 -1
- package/models/operations/index.d.ts +3 -0
- package/models/operations/index.d.ts.map +1 -1
- package/models/operations/index.js +3 -0
- package/models/operations/index.js.map +1 -1
- package/models/operations/integrationscontrollerconfigureintegrationwebhook.d.ts +29 -0
- package/models/operations/integrationscontrollerconfigureintegrationwebhook.d.ts.map +1 -0
- package/models/operations/integrationscontrollerconfigureintegrationwebhook.js +73 -0
- package/models/operations/integrationscontrollerconfigureintegrationwebhook.js.map +1 -0
- package/models/operations/integrationscontrollercreateintegrationmobilelink.d.ts +31 -0
- package/models/operations/integrationscontrollercreateintegrationmobilelink.d.ts.map +1 -0
- package/models/operations/integrationscontrollercreateintegrationmobilelink.js +75 -0
- package/models/operations/integrationscontrollercreateintegrationmobilelink.js.map +1 -0
- package/models/operations/integrationscontrollerlinkchannelendpoint.d.ts +29 -0
- package/models/operations/integrationscontrollerlinkchannelendpoint.d.ts.map +1 -0
- package/models/operations/integrationscontrollerlinkchannelendpoint.js +72 -0
- package/models/operations/integrationscontrollerlinkchannelendpoint.js.map +1 -0
- package/package.json +1 -1
- package/sdk/integrations.d.ts +28 -6
- package/sdk/integrations.d.ts.map +1 -1
- package/sdk/integrations.js +37 -6
- package/sdk/integrations.js.map +1 -1
- package/sdk/novumessages.d.ts +10 -4
- package/sdk/novumessages.d.ts.map +1 -1
- package/sdk/novumessages.js +10 -4
- package/sdk/novumessages.js.map +1 -1
- package/sdk/novunotifications.d.ts +6 -2
- package/sdk/novunotifications.d.ts.map +1 -1
- package/sdk/novunotifications.js +6 -2
- package/sdk/novunotifications.js.map +1 -1
- package/src/funcs/integrationsCreate.ts +1 -1
- package/src/funcs/integrationsCreateMobileLink.ts +236 -0
- package/src/funcs/integrationsDelete.ts +1 -1
- package/src/funcs/integrationsIntegrationsControllerAutoConfigureIntegration.ts +1 -1
- package/src/funcs/integrationsIntegrationsControllerConfigureIntegrationWebhook.ts +223 -0
- package/src/funcs/integrationsLinkChannelEndpoint.ts +216 -0
- package/src/funcs/integrationsList.ts +1 -1
- package/src/funcs/integrationsListActive.ts +1 -1
- package/src/funcs/integrationsSetAsPrimary.ts +1 -0
- package/src/funcs/integrationsUpdate.ts +1 -1
- package/src/funcs/subscribersMessagesMarkAll.ts +3 -1
- package/src/funcs/subscribersMessagesMarkAllAs.ts +4 -2
- package/src/funcs/subscribersMessagesUpdateAsSeen.ts +3 -1
- package/src/funcs/subscribersNotificationsFeed.ts +3 -1
- package/src/funcs/subscribersNotificationsUnseenCount.ts +3 -1
- package/src/hooks/types.ts +1 -0
- package/src/lib/config.ts +4 -4
- package/src/lib/encodings.ts +1 -1
- package/src/lib/matchers.ts +1 -1
- package/src/lib/primitives.ts +16 -0
- package/src/lib/retries.ts +8 -0
- package/src/lib/sdks.ts +54 -17
- package/src/models/components/configuretelegramwebhookresponsedto.ts +45 -0
- package/src/models/components/credentialsdto.ts +4 -0
- package/src/models/components/index.ts +5 -0
- package/src/models/components/issueintegrationmobilelinkrequestdto.ts +36 -0
- package/src/models/components/issuetelegrammobilelinkresponsedto.ts +45 -0
- package/src/models/components/linkchannelendpointrequestdto.ts +42 -0
- package/src/models/components/linkchannelendpointresponsedto.ts +39 -0
- package/src/models/components/previewpayloaddto.ts +7 -0
- package/src/models/components/updateworkflowdto.ts +11 -0
- package/src/models/operations/index.ts +3 -0
- package/src/models/operations/integrationscontrollerconfigureintegrationwebhook.ts +86 -0
- package/src/models/operations/integrationscontrollercreateintegrationmobilelink.ts +94 -0
- package/src/models/operations/integrationscontrollerlinkchannelendpoint.ts +90 -0
- package/src/sdk/integrations.ts +76 -6
- package/src/sdk/novumessages.ts +10 -4
- package/src/sdk/novunotifications.ts +6 -2
- package/lib/dlv.d.ts +0 -14
- package/lib/dlv.d.ts.map +0 -1
- package/lib/dlv.js +0 -49
- package/lib/dlv.js.map +0 -1
- package/lib/is-plain-object.d.ts +0 -2
- package/lib/is-plain-object.d.ts.map +0 -1
- package/lib/is-plain-object.js +0 -41
- package/lib/is-plain-object.js.map +0 -1
- package/src/lib/dlv.ts +0 -53
- package/src/lib/is-plain-object.ts +0 -43
|
@@ -0,0 +1,223 @@
|
|
|
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 { matchStatusCode } from "../lib/http.js";
|
|
8
|
+
import * as M from "../lib/matchers.js";
|
|
9
|
+
import { compactMap } from "../lib/primitives.js";
|
|
10
|
+
import { safeParse } from "../lib/schemas.js";
|
|
11
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
12
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
13
|
+
import { pathToFunc } from "../lib/url.js";
|
|
14
|
+
import {
|
|
15
|
+
ConnectionError,
|
|
16
|
+
InvalidRequestError,
|
|
17
|
+
RequestAbortedError,
|
|
18
|
+
RequestTimeoutError,
|
|
19
|
+
UnexpectedClientError,
|
|
20
|
+
} from "../models/errors/httpclienterrors.js";
|
|
21
|
+
import * as errors from "../models/errors/index.js";
|
|
22
|
+
import { NovuError } from "../models/errors/novuerror.js";
|
|
23
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
24
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
25
|
+
import * as operations from "../models/operations/index.js";
|
|
26
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
27
|
+
import { Result } from "../types/fp.js";
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Configure a chat integration webhook
|
|
31
|
+
*
|
|
32
|
+
* @remarks
|
|
33
|
+
* Registers the Novu webhook URL with the chat provider for the specified integration. Telegram is the only supported provider initially.
|
|
34
|
+
*/
|
|
35
|
+
export function integrationsIntegrationsControllerConfigureIntegrationWebhook(
|
|
36
|
+
client: NovuCore,
|
|
37
|
+
integrationIdentifier: string,
|
|
38
|
+
idempotencyKey?: string | undefined,
|
|
39
|
+
options?: RequestOptions,
|
|
40
|
+
): APIPromise<
|
|
41
|
+
Result<
|
|
42
|
+
operations.IntegrationsControllerConfigureIntegrationWebhookResponse,
|
|
43
|
+
| errors.ErrorDto
|
|
44
|
+
| errors.ValidationErrorDto
|
|
45
|
+
| NovuError
|
|
46
|
+
| ResponseValidationError
|
|
47
|
+
| ConnectionError
|
|
48
|
+
| RequestAbortedError
|
|
49
|
+
| RequestTimeoutError
|
|
50
|
+
| InvalidRequestError
|
|
51
|
+
| UnexpectedClientError
|
|
52
|
+
| SDKValidationError
|
|
53
|
+
>
|
|
54
|
+
> {
|
|
55
|
+
return new APIPromise($do(
|
|
56
|
+
client,
|
|
57
|
+
integrationIdentifier,
|
|
58
|
+
idempotencyKey,
|
|
59
|
+
options,
|
|
60
|
+
));
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async function $do(
|
|
64
|
+
client: NovuCore,
|
|
65
|
+
integrationIdentifier: string,
|
|
66
|
+
idempotencyKey?: string | undefined,
|
|
67
|
+
options?: RequestOptions,
|
|
68
|
+
): Promise<
|
|
69
|
+
[
|
|
70
|
+
Result<
|
|
71
|
+
operations.IntegrationsControllerConfigureIntegrationWebhookResponse,
|
|
72
|
+
| errors.ErrorDto
|
|
73
|
+
| errors.ValidationErrorDto
|
|
74
|
+
| NovuError
|
|
75
|
+
| ResponseValidationError
|
|
76
|
+
| ConnectionError
|
|
77
|
+
| RequestAbortedError
|
|
78
|
+
| RequestTimeoutError
|
|
79
|
+
| InvalidRequestError
|
|
80
|
+
| UnexpectedClientError
|
|
81
|
+
| SDKValidationError
|
|
82
|
+
>,
|
|
83
|
+
APICall,
|
|
84
|
+
]
|
|
85
|
+
> {
|
|
86
|
+
const input:
|
|
87
|
+
operations.IntegrationsControllerConfigureIntegrationWebhookRequest = {
|
|
88
|
+
integrationIdentifier: integrationIdentifier,
|
|
89
|
+
idempotencyKey: idempotencyKey,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const parsed = safeParse(
|
|
93
|
+
input,
|
|
94
|
+
(value) =>
|
|
95
|
+
operations
|
|
96
|
+
.IntegrationsControllerConfigureIntegrationWebhookRequest$outboundSchema
|
|
97
|
+
.parse(value),
|
|
98
|
+
"Input validation failed",
|
|
99
|
+
);
|
|
100
|
+
if (!parsed.ok) {
|
|
101
|
+
return [parsed, { status: "invalid" }];
|
|
102
|
+
}
|
|
103
|
+
const payload = parsed.value;
|
|
104
|
+
const body = null;
|
|
105
|
+
|
|
106
|
+
const pathParams = {
|
|
107
|
+
integrationIdentifier: encodeSimple(
|
|
108
|
+
"integrationIdentifier",
|
|
109
|
+
payload.integrationIdentifier,
|
|
110
|
+
{ explode: false, charEncoding: "percent" },
|
|
111
|
+
),
|
|
112
|
+
};
|
|
113
|
+
const path = pathToFunc(
|
|
114
|
+
"/v1/integrations/{integrationIdentifier}/webhook/configure",
|
|
115
|
+
)(pathParams);
|
|
116
|
+
|
|
117
|
+
const headers = new Headers(compactMap({
|
|
118
|
+
Accept: "application/json",
|
|
119
|
+
"idempotency-key": encodeSimple(
|
|
120
|
+
"idempotency-key",
|
|
121
|
+
payload["idempotency-key"],
|
|
122
|
+
{ explode: false, charEncoding: "none" },
|
|
123
|
+
),
|
|
124
|
+
}));
|
|
125
|
+
|
|
126
|
+
const secConfig = await extractSecurity(client._options.secretKey);
|
|
127
|
+
const securityInput = secConfig == null ? {} : { secretKey: secConfig };
|
|
128
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
129
|
+
|
|
130
|
+
const context = {
|
|
131
|
+
options: client._options,
|
|
132
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
133
|
+
operationID: "IntegrationsController_configureIntegrationWebhook",
|
|
134
|
+
oAuth2Scopes: null,
|
|
135
|
+
|
|
136
|
+
resolvedSecurity: requestSecurity,
|
|
137
|
+
|
|
138
|
+
securitySource: client._options.secretKey,
|
|
139
|
+
retryConfig: options?.retries
|
|
140
|
+
|| client._options.retryConfig
|
|
141
|
+
|| {
|
|
142
|
+
strategy: "backoff",
|
|
143
|
+
backoff: {
|
|
144
|
+
initialInterval: 1000,
|
|
145
|
+
maxInterval: 30000,
|
|
146
|
+
exponent: 1.5,
|
|
147
|
+
maxElapsedTime: 3600000,
|
|
148
|
+
},
|
|
149
|
+
retryConnectionErrors: true,
|
|
150
|
+
}
|
|
151
|
+
|| { strategy: "none" },
|
|
152
|
+
retryCodes: options?.retryCodes || ["408", "409", "429", "5XX"],
|
|
153
|
+
};
|
|
154
|
+
|
|
155
|
+
const requestRes = client._createRequest(context, {
|
|
156
|
+
security: requestSecurity,
|
|
157
|
+
method: "POST",
|
|
158
|
+
baseURL: options?.serverURL,
|
|
159
|
+
path: path,
|
|
160
|
+
headers: headers,
|
|
161
|
+
body: body,
|
|
162
|
+
userAgent: client._options.userAgent,
|
|
163
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
164
|
+
}, options);
|
|
165
|
+
if (!requestRes.ok) {
|
|
166
|
+
return [requestRes, { status: "invalid" }];
|
|
167
|
+
}
|
|
168
|
+
const req = requestRes.value;
|
|
169
|
+
|
|
170
|
+
const doResult = await client._do(req, {
|
|
171
|
+
context,
|
|
172
|
+
isErrorStatusCode: (statusCode: number) =>
|
|
173
|
+
matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
|
|
174
|
+
retryConfig: context.retryConfig,
|
|
175
|
+
retryCodes: context.retryCodes,
|
|
176
|
+
});
|
|
177
|
+
if (!doResult.ok) {
|
|
178
|
+
return [doResult, { status: "request-error", request: req }];
|
|
179
|
+
}
|
|
180
|
+
const response = doResult.value;
|
|
181
|
+
|
|
182
|
+
const responseFields = {
|
|
183
|
+
HttpMeta: { Response: response, Request: req },
|
|
184
|
+
};
|
|
185
|
+
|
|
186
|
+
const [result] = await M.match<
|
|
187
|
+
operations.IntegrationsControllerConfigureIntegrationWebhookResponse,
|
|
188
|
+
| errors.ErrorDto
|
|
189
|
+
| errors.ValidationErrorDto
|
|
190
|
+
| NovuError
|
|
191
|
+
| ResponseValidationError
|
|
192
|
+
| ConnectionError
|
|
193
|
+
| RequestAbortedError
|
|
194
|
+
| RequestTimeoutError
|
|
195
|
+
| InvalidRequestError
|
|
196
|
+
| UnexpectedClientError
|
|
197
|
+
| SDKValidationError
|
|
198
|
+
>(
|
|
199
|
+
M.json(
|
|
200
|
+
200,
|
|
201
|
+
operations
|
|
202
|
+
.IntegrationsControllerConfigureIntegrationWebhookResponse$inboundSchema,
|
|
203
|
+
{ hdrs: true, key: "Result" },
|
|
204
|
+
),
|
|
205
|
+
M.jsonErr(414, errors.ErrorDto$inboundSchema),
|
|
206
|
+
M.jsonErr(
|
|
207
|
+
[400, 401, 403, 404, 405, 409, 413, 415],
|
|
208
|
+
errors.ErrorDto$inboundSchema,
|
|
209
|
+
{ hdrs: true },
|
|
210
|
+
),
|
|
211
|
+
M.jsonErr(422, errors.ValidationErrorDto$inboundSchema, { hdrs: true }),
|
|
212
|
+
M.fail(429),
|
|
213
|
+
M.jsonErr(500, errors.ErrorDto$inboundSchema, { hdrs: true }),
|
|
214
|
+
M.fail(503),
|
|
215
|
+
M.fail("4XX"),
|
|
216
|
+
M.fail("5XX"),
|
|
217
|
+
)(response, req, { extraFields: responseFields });
|
|
218
|
+
if (!result.ok) {
|
|
219
|
+
return [result, { status: "complete", request: req, response }];
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
return [result, { status: "complete", request: req, response }];
|
|
223
|
+
}
|
|
@@ -0,0 +1,216 @@
|
|
|
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 { matchStatusCode } from "../lib/http.js";
|
|
8
|
+
import * as M from "../lib/matchers.js";
|
|
9
|
+
import { compactMap } from "../lib/primitives.js";
|
|
10
|
+
import { safeParse } from "../lib/schemas.js";
|
|
11
|
+
import { RequestOptions } from "../lib/sdks.js";
|
|
12
|
+
import { extractSecurity, resolveGlobalSecurity } from "../lib/security.js";
|
|
13
|
+
import { pathToFunc } from "../lib/url.js";
|
|
14
|
+
import * as components from "../models/components/index.js";
|
|
15
|
+
import {
|
|
16
|
+
ConnectionError,
|
|
17
|
+
InvalidRequestError,
|
|
18
|
+
RequestAbortedError,
|
|
19
|
+
RequestTimeoutError,
|
|
20
|
+
UnexpectedClientError,
|
|
21
|
+
} from "../models/errors/httpclienterrors.js";
|
|
22
|
+
import * as errors from "../models/errors/index.js";
|
|
23
|
+
import { NovuError } from "../models/errors/novuerror.js";
|
|
24
|
+
import { ResponseValidationError } from "../models/errors/responsevalidationerror.js";
|
|
25
|
+
import { SDKValidationError } from "../models/errors/sdkvalidationerror.js";
|
|
26
|
+
import * as operations from "../models/operations/index.js";
|
|
27
|
+
import { APICall, APIPromise } from "../types/async.js";
|
|
28
|
+
import { Result } from "../types/fp.js";
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Issue a URL to link a subscriber chat identity
|
|
32
|
+
*
|
|
33
|
+
* @remarks
|
|
34
|
+
* Returns a provider-specific URL the subscriber opens to link their chat identity. The integration provider is resolved from integrationIdentifier; Telegram returns a deep link.
|
|
35
|
+
*/
|
|
36
|
+
export function integrationsLinkChannelEndpoint(
|
|
37
|
+
client: NovuCore,
|
|
38
|
+
linkChannelEndpointRequestDto: components.LinkChannelEndpointRequestDto,
|
|
39
|
+
idempotencyKey?: string | undefined,
|
|
40
|
+
options?: RequestOptions,
|
|
41
|
+
): APIPromise<
|
|
42
|
+
Result<
|
|
43
|
+
operations.IntegrationsControllerLinkChannelEndpointResponse,
|
|
44
|
+
| errors.ErrorDto
|
|
45
|
+
| errors.ValidationErrorDto
|
|
46
|
+
| NovuError
|
|
47
|
+
| ResponseValidationError
|
|
48
|
+
| ConnectionError
|
|
49
|
+
| RequestAbortedError
|
|
50
|
+
| RequestTimeoutError
|
|
51
|
+
| InvalidRequestError
|
|
52
|
+
| UnexpectedClientError
|
|
53
|
+
| SDKValidationError
|
|
54
|
+
>
|
|
55
|
+
> {
|
|
56
|
+
return new APIPromise($do(
|
|
57
|
+
client,
|
|
58
|
+
linkChannelEndpointRequestDto,
|
|
59
|
+
idempotencyKey,
|
|
60
|
+
options,
|
|
61
|
+
));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
async function $do(
|
|
65
|
+
client: NovuCore,
|
|
66
|
+
linkChannelEndpointRequestDto: components.LinkChannelEndpointRequestDto,
|
|
67
|
+
idempotencyKey?: string | undefined,
|
|
68
|
+
options?: RequestOptions,
|
|
69
|
+
): Promise<
|
|
70
|
+
[
|
|
71
|
+
Result<
|
|
72
|
+
operations.IntegrationsControllerLinkChannelEndpointResponse,
|
|
73
|
+
| errors.ErrorDto
|
|
74
|
+
| errors.ValidationErrorDto
|
|
75
|
+
| NovuError
|
|
76
|
+
| ResponseValidationError
|
|
77
|
+
| ConnectionError
|
|
78
|
+
| RequestAbortedError
|
|
79
|
+
| RequestTimeoutError
|
|
80
|
+
| InvalidRequestError
|
|
81
|
+
| UnexpectedClientError
|
|
82
|
+
| SDKValidationError
|
|
83
|
+
>,
|
|
84
|
+
APICall,
|
|
85
|
+
]
|
|
86
|
+
> {
|
|
87
|
+
const input: operations.IntegrationsControllerLinkChannelEndpointRequest = {
|
|
88
|
+
linkChannelEndpointRequestDto: linkChannelEndpointRequestDto,
|
|
89
|
+
idempotencyKey: idempotencyKey,
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const parsed = safeParse(
|
|
93
|
+
input,
|
|
94
|
+
(value) =>
|
|
95
|
+
operations.IntegrationsControllerLinkChannelEndpointRequest$outboundSchema
|
|
96
|
+
.parse(value),
|
|
97
|
+
"Input validation failed",
|
|
98
|
+
);
|
|
99
|
+
if (!parsed.ok) {
|
|
100
|
+
return [parsed, { status: "invalid" }];
|
|
101
|
+
}
|
|
102
|
+
const payload = parsed.value;
|
|
103
|
+
const body = encodeJSON("body", payload.LinkChannelEndpointRequestDto, {
|
|
104
|
+
explode: true,
|
|
105
|
+
});
|
|
106
|
+
|
|
107
|
+
const path = pathToFunc("/v1/integrations/channel-endpoints/link")();
|
|
108
|
+
|
|
109
|
+
const headers = new Headers(compactMap({
|
|
110
|
+
"Content-Type": "application/json",
|
|
111
|
+
Accept: "application/json",
|
|
112
|
+
"idempotency-key": encodeSimple(
|
|
113
|
+
"idempotency-key",
|
|
114
|
+
payload["idempotency-key"],
|
|
115
|
+
{ explode: false, charEncoding: "none" },
|
|
116
|
+
),
|
|
117
|
+
}));
|
|
118
|
+
|
|
119
|
+
const secConfig = await extractSecurity(client._options.secretKey);
|
|
120
|
+
const securityInput = secConfig == null ? {} : { secretKey: secConfig };
|
|
121
|
+
const requestSecurity = resolveGlobalSecurity(securityInput);
|
|
122
|
+
|
|
123
|
+
const context = {
|
|
124
|
+
options: client._options,
|
|
125
|
+
baseURL: options?.serverURL ?? client._baseURL ?? "",
|
|
126
|
+
operationID: "IntegrationsController_linkChannelEndpoint",
|
|
127
|
+
oAuth2Scopes: null,
|
|
128
|
+
|
|
129
|
+
resolvedSecurity: requestSecurity,
|
|
130
|
+
|
|
131
|
+
securitySource: client._options.secretKey,
|
|
132
|
+
retryConfig: options?.retries
|
|
133
|
+
|| client._options.retryConfig
|
|
134
|
+
|| {
|
|
135
|
+
strategy: "backoff",
|
|
136
|
+
backoff: {
|
|
137
|
+
initialInterval: 1000,
|
|
138
|
+
maxInterval: 30000,
|
|
139
|
+
exponent: 1.5,
|
|
140
|
+
maxElapsedTime: 3600000,
|
|
141
|
+
},
|
|
142
|
+
retryConnectionErrors: true,
|
|
143
|
+
}
|
|
144
|
+
|| { strategy: "none" },
|
|
145
|
+
retryCodes: options?.retryCodes || ["408", "409", "429", "5XX"],
|
|
146
|
+
};
|
|
147
|
+
|
|
148
|
+
const requestRes = client._createRequest(context, {
|
|
149
|
+
security: requestSecurity,
|
|
150
|
+
method: "POST",
|
|
151
|
+
baseURL: options?.serverURL,
|
|
152
|
+
path: path,
|
|
153
|
+
headers: headers,
|
|
154
|
+
body: body,
|
|
155
|
+
userAgent: client._options.userAgent,
|
|
156
|
+
timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1,
|
|
157
|
+
}, options);
|
|
158
|
+
if (!requestRes.ok) {
|
|
159
|
+
return [requestRes, { status: "invalid" }];
|
|
160
|
+
}
|
|
161
|
+
const req = requestRes.value;
|
|
162
|
+
|
|
163
|
+
const doResult = await client._do(req, {
|
|
164
|
+
context,
|
|
165
|
+
isErrorStatusCode: (statusCode: number) =>
|
|
166
|
+
matchStatusCode({ status: statusCode } as Response, ["4XX", "5XX"]),
|
|
167
|
+
retryConfig: context.retryConfig,
|
|
168
|
+
retryCodes: context.retryCodes,
|
|
169
|
+
});
|
|
170
|
+
if (!doResult.ok) {
|
|
171
|
+
return [doResult, { status: "request-error", request: req }];
|
|
172
|
+
}
|
|
173
|
+
const response = doResult.value;
|
|
174
|
+
|
|
175
|
+
const responseFields = {
|
|
176
|
+
HttpMeta: { Response: response, Request: req },
|
|
177
|
+
};
|
|
178
|
+
|
|
179
|
+
const [result] = await M.match<
|
|
180
|
+
operations.IntegrationsControllerLinkChannelEndpointResponse,
|
|
181
|
+
| errors.ErrorDto
|
|
182
|
+
| errors.ValidationErrorDto
|
|
183
|
+
| NovuError
|
|
184
|
+
| ResponseValidationError
|
|
185
|
+
| ConnectionError
|
|
186
|
+
| RequestAbortedError
|
|
187
|
+
| RequestTimeoutError
|
|
188
|
+
| InvalidRequestError
|
|
189
|
+
| UnexpectedClientError
|
|
190
|
+
| SDKValidationError
|
|
191
|
+
>(
|
|
192
|
+
M.json(
|
|
193
|
+
200,
|
|
194
|
+
operations
|
|
195
|
+
.IntegrationsControllerLinkChannelEndpointResponse$inboundSchema,
|
|
196
|
+
{ hdrs: true, key: "Result" },
|
|
197
|
+
),
|
|
198
|
+
M.jsonErr(414, errors.ErrorDto$inboundSchema),
|
|
199
|
+
M.jsonErr(
|
|
200
|
+
[400, 401, 403, 404, 405, 409, 413, 415],
|
|
201
|
+
errors.ErrorDto$inboundSchema,
|
|
202
|
+
{ hdrs: true },
|
|
203
|
+
),
|
|
204
|
+
M.jsonErr(422, errors.ValidationErrorDto$inboundSchema, { hdrs: true }),
|
|
205
|
+
M.fail(429),
|
|
206
|
+
M.jsonErr(500, errors.ErrorDto$inboundSchema, { hdrs: true }),
|
|
207
|
+
M.fail(503),
|
|
208
|
+
M.fail("4XX"),
|
|
209
|
+
M.fail("5XX"),
|
|
210
|
+
)(response, req, { extraFields: responseFields });
|
|
211
|
+
if (!result.ok) {
|
|
212
|
+
return [result, { status: "complete", request: req, response }];
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
return [result, { status: "complete", request: req, response }];
|
|
216
|
+
}
|
|
@@ -30,7 +30,7 @@ import { Result } from "../types/fp.js";
|
|
|
30
30
|
* List all integrations
|
|
31
31
|
*
|
|
32
32
|
* @remarks
|
|
33
|
-
* List all the channels integrations created in the organization
|
|
33
|
+
* List all the channels integrations created in the organization. Only integration metadata is returned, credentials field is returned as an empty object.
|
|
34
34
|
*/
|
|
35
35
|
export function integrationsList(
|
|
36
36
|
client: NovuCore,
|
|
@@ -30,7 +30,7 @@ import { Result } from "../types/fp.js";
|
|
|
30
30
|
* List active integrations
|
|
31
31
|
*
|
|
32
32
|
* @remarks
|
|
33
|
-
* List all the active integrations created in the organization
|
|
33
|
+
* List all the active integrations created in the organization. Only integration metadata is returned, credentials field is returned as an empty object.
|
|
34
34
|
*/
|
|
35
35
|
export function integrationsListActive(
|
|
36
36
|
client: NovuCore,
|
|
@@ -33,6 +33,7 @@ import { Result } from "../types/fp.js";
|
|
|
33
33
|
* Update an integration as **primary** by its unique key identifier **integrationId**.
|
|
34
34
|
* This API will set the integration as primary for that channel in the current environment.
|
|
35
35
|
* Primary integration is used to deliver notification for sms and email channels in the workflow.
|
|
36
|
+
* Only integration metadata is returned, credentials field is returned as an empty object.
|
|
36
37
|
*/
|
|
37
38
|
export function integrationsSetAsPrimary(
|
|
38
39
|
client: NovuCore,
|
|
@@ -32,7 +32,7 @@ import { Result } from "../types/fp.js";
|
|
|
32
32
|
*
|
|
33
33
|
* @remarks
|
|
34
34
|
* Update an integration by its unique key identifier **integrationId**.
|
|
35
|
-
* Each provider supports different credentials, check the provider documentation for more details.
|
|
35
|
+
* Each provider supports different credentials, check the provider documentation for more details. Only integration metadata is returned, credentials field is returned as an empty object.
|
|
36
36
|
*/
|
|
37
37
|
export function integrationsUpdate(
|
|
38
38
|
client: NovuCore,
|
|
@@ -31,7 +31,9 @@ import { Result } from "../types/fp.js";
|
|
|
31
31
|
* Update all notifications state
|
|
32
32
|
*
|
|
33
33
|
* @remarks
|
|
34
|
-
* Update all subscriber in-app
|
|
34
|
+
* This API is deprecated, use v2 API instead. Update all subscriber in-app notifications state such as read, unread, seen or unseen by **subscriberId**.
|
|
35
|
+
*
|
|
36
|
+
* @deprecated method: This will be removed in a future release, please migrate away from it as soon as possible.
|
|
35
37
|
*/
|
|
36
38
|
export function subscribersMessagesMarkAll(
|
|
37
39
|
client: NovuCore,
|
|
@@ -31,8 +31,10 @@ import { Result } from "../types/fp.js";
|
|
|
31
31
|
* Update notifications state
|
|
32
32
|
*
|
|
33
33
|
* @remarks
|
|
34
|
-
* Update subscriber's multiple in-app
|
|
35
|
-
* **messageId** is of type mongodbId of notifications
|
|
34
|
+
* This API is deprecated, use v2 API instead. Update subscriber's multiple in-app notifications state such as seen, read, unseen or unread by **subscriberId**.
|
|
35
|
+
* **messageId** is of type mongodbId of notifications.
|
|
36
|
+
*
|
|
37
|
+
* @deprecated method: This will be removed in a future release, please migrate away from it as soon as possible.
|
|
36
38
|
*/
|
|
37
39
|
export function subscribersMessagesMarkAllAs(
|
|
38
40
|
client: NovuCore,
|
|
@@ -30,8 +30,10 @@ import { Result } from "../types/fp.js";
|
|
|
30
30
|
* Update notification action status
|
|
31
31
|
*
|
|
32
32
|
* @remarks
|
|
33
|
-
* Update in-app
|
|
33
|
+
* This API is deprecated, use v2 API instead. Update in-app notification's action status by its unique key identifier **messageId** and type field **type**.
|
|
34
34
|
* **type** field can be **primary** or **secondary**
|
|
35
|
+
*
|
|
36
|
+
* @deprecated method: This will be removed in a future release, please migrate away from it as soon as possible.
|
|
35
37
|
*/
|
|
36
38
|
export function subscribersMessagesUpdateAsSeen(
|
|
37
39
|
client: NovuCore,
|
|
@@ -30,7 +30,9 @@ import { Result } from "../types/fp.js";
|
|
|
30
30
|
* Retrieve subscriber notifications
|
|
31
31
|
*
|
|
32
32
|
* @remarks
|
|
33
|
-
* Retrieve subscriber in-app
|
|
33
|
+
* This API is deprecated, use v2 API instead. Retrieve subscriber in-app notifications by its unique key identifier **subscriberId**.
|
|
34
|
+
*
|
|
35
|
+
* @deprecated method: This will be removed in a future release, please migrate away from it as soon as possible.
|
|
34
36
|
*/
|
|
35
37
|
export function subscribersNotificationsFeed(
|
|
36
38
|
client: NovuCore,
|
|
@@ -30,7 +30,9 @@ import { Result } from "../types/fp.js";
|
|
|
30
30
|
* Retrieve unseen notifications count
|
|
31
31
|
*
|
|
32
32
|
* @remarks
|
|
33
|
-
* Retrieve unseen in-app
|
|
33
|
+
* This API is deprecated, use v2 API instead. Retrieve unseen in-app notifications count for a subscriber by its unique key identifier **subscriberId**.
|
|
34
|
+
*
|
|
35
|
+
* @deprecated method: This will be removed in a future release, please migrate away from it as soon as possible.
|
|
34
36
|
*/
|
|
35
37
|
export function subscribersNotificationsUnseenCount(
|
|
36
38
|
client: NovuCore,
|
package/src/hooks/types.ts
CHANGED
package/src/lib/config.ts
CHANGED
|
@@ -58,8 +58,8 @@ export function serverURLFromOptions(options: SDKOptions): URL | null {
|
|
|
58
58
|
|
|
59
59
|
export const SDK_METADATA = {
|
|
60
60
|
language: "typescript",
|
|
61
|
-
openapiDocVersion: "3.
|
|
62
|
-
sdkVersion: "3.17.
|
|
63
|
-
genVersion: "2.
|
|
64
|
-
userAgent: "speakeasy-sdk/typescript 3.17.
|
|
61
|
+
openapiDocVersion: "3.17.1",
|
|
62
|
+
sdkVersion: "3.17.1",
|
|
63
|
+
genVersion: "2.916.2",
|
|
64
|
+
userAgent: "speakeasy-sdk/typescript 3.17.1 2.916.2 3.17.1 @novu/api",
|
|
65
65
|
} as const;
|
package/src/lib/encodings.ts
CHANGED
package/src/lib/matchers.ts
CHANGED
|
@@ -6,7 +6,7 @@ import { ResponseValidationError } from "../models/errors/responsevalidationerro
|
|
|
6
6
|
import { SDKError } from "../models/errors/sdkerror.js";
|
|
7
7
|
import { ERR, OK, Result } from "../types/fp.js";
|
|
8
8
|
import { matchResponse, matchStatusCode, StatusCodePredicate } from "./http.js";
|
|
9
|
-
import { isPlainObject } from "./
|
|
9
|
+
import { isPlainObject } from "./primitives.js";
|
|
10
10
|
|
|
11
11
|
export type Encoding =
|
|
12
12
|
| "jsonl"
|
package/src/lib/primitives.ts
CHANGED
|
@@ -148,3 +148,19 @@ export function allRequired<V extends Record<string, unknown>>(
|
|
|
148
148
|
|
|
149
149
|
return v as ReturnType<typeof allRequired<V>>;
|
|
150
150
|
}
|
|
151
|
+
|
|
152
|
+
export function isPlainObject(
|
|
153
|
+
value: unknown,
|
|
154
|
+
): value is Record<string, unknown> {
|
|
155
|
+
if (value === null || typeof value !== "object") return false;
|
|
156
|
+
if (Object.prototype.toString.call(value) !== "[object Object]") return false;
|
|
157
|
+
const proto = Object.getPrototypeOf(value);
|
|
158
|
+
if (proto === null || proto === Object.prototype) return true;
|
|
159
|
+
// cross-realm plain objects (vm contexts, iframes) inherit from a
|
|
160
|
+
// different realm's Object.prototype, which itself has a null prototype
|
|
161
|
+
try {
|
|
162
|
+
return Object.getPrototypeOf(proto) === null;
|
|
163
|
+
} catch {
|
|
164
|
+
return false;
|
|
165
|
+
}
|
|
166
|
+
}
|
package/src/lib/retries.ts
CHANGED
|
@@ -194,6 +194,14 @@ async function retryBackoff(
|
|
|
194
194
|
}
|
|
195
195
|
|
|
196
196
|
function retryIntervalFromResponse(res: Response): number {
|
|
197
|
+
const retryAfterMsVal = res.headers.get("retry-after-ms");
|
|
198
|
+
if (retryAfterMsVal) {
|
|
199
|
+
const parsedMs = Number(retryAfterMsVal);
|
|
200
|
+
if (Number.isFinite(parsedMs) && parsedMs >= 0) {
|
|
201
|
+
return parsedMs;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
197
205
|
const retryVal = res.headers.get("retry-after") || "";
|
|
198
206
|
if (!retryVal) {
|
|
199
207
|
return 0;
|