diff --git a/.speakeasy/gen.lock b/.speakeasy/gen.lock index c9c29d22..339164ad 100644 --- a/.speakeasy/gen.lock +++ b/.speakeasy/gen.lock @@ -1,12 +1,12 @@ lockVersion: 2.0.0 id: 6bff3a53-3f0b-40b4-942f-ff70dc583ae5 management: - docChecksum: a3b9e1f5c5fd6328866eea116d03a7a6 + docChecksum: e581b83557f00a8a1f177ccc3d920d23 docVersion: "1.0" - speakeasyVersion: 1.490.0 - generationVersion: 2.512.0 - releaseVersion: 0.2.1 - configChecksum: f58cb0b941edc8bdebac2443dea15081 + speakeasyVersion: 1.494.0 + generationVersion: 2.515.0 + releaseVersion: 0.3.0 + configChecksum: 35683929341d803bc9d28ca5eb899567 repoURL: https://github.com/novuhq/novu-ts.git installationURL: https://github.com/novuhq/novu-ts published: true @@ -15,7 +15,7 @@ features: acceptHeaders: 2.81.2 additionalDependencies: 0.1.0 constsAndDefaults: 0.1.11 - core: 3.19.0 + core: 3.20.0 defaultEnabledRetries: 0.1.0 deprecations: 2.81.1 enumUnions: 0.1.0 @@ -80,7 +80,6 @@ generatedFiles: - docs/models/components/createintegrationrequestdto.md - docs/models/components/createintegrationrequestdtochannel.md - docs/models/components/createsubscriberrequestdto.md - - docs/models/components/createsubscriberrequestdtodata.md - docs/models/components/createtopicrequestdto.md - docs/models/components/createtopicresponsedto.md - docs/models/components/credentialsdto.md @@ -216,6 +215,7 @@ generatedFiles: - docs/models/components/weekdays.md - docs/models/components/workflowinfodto.md - docs/models/components/workflowintegrationstatus.md + - docs/models/components/workfloworiginenum.md - docs/models/components/workflowpreferencedto.md - docs/models/components/workflowresponse.md - docs/models/components/workflowresponsedata.md @@ -515,6 +515,7 @@ generatedFiles: - src/models/components/updatesubscriberchannelrequestdto.ts - src/models/components/updatesubscriberonlineflagrequestdto.ts - src/models/components/workflowinfodto.ts + - src/models/components/workfloworiginenum.ts - src/models/components/workflowpreferencedto.ts - src/models/components/workflowresponse.ts - src/models/errors/errordto.ts @@ -586,6 +587,7 @@ generatedFiles: - src/sdk/subscribers.ts - src/sdk/topics.ts - src/sdk/webhooks.ts + - src/types/async.ts - src/types/blobs.ts - src/types/constdatetime.ts - src/types/enums.ts @@ -674,6 +676,7 @@ examples: parameters: query: page: 0 + limit: 10 header: {} responses: "200": diff --git a/.speakeasy/gen.yaml b/.speakeasy/gen.yaml index bcab9f95..d84eda41 100755 --- a/.speakeasy/gen.yaml +++ b/.speakeasy/gen.yaml @@ -7,6 +7,7 @@ generation: useClassNamesForArrayFields: true fixes: nameResolutionDec2023: true + nameResolutionFeb2025: false parameterOrderingFeb2024: true requestResponseComponentNamesFeb2024: true securityFeb2025: false @@ -14,7 +15,7 @@ generation: oAuth2ClientCredentialsEnabled: false oAuth2PasswordEnabled: false typescript: - version: 0.2.1 + version: 0.3.0 additionalDependencies: dependencies: {} devDependencies: {} diff --git a/.speakeasy/workflow.lock b/.speakeasy/workflow.lock index 4b6996e9..976b7f9f 100644 --- a/.speakeasy/workflow.lock +++ b/.speakeasy/workflow.lock @@ -1,21 +1,21 @@ -speakeasyVersion: 1.490.0 +speakeasyVersion: 1.494.0 sources: json-development: sourceNamespace: json-development - sourceRevisionDigest: sha256:2e0c21308626b21c71d084379fa94efbd8f2a9f460b9767db02ab81cf314ab3f - sourceBlobDigest: sha256:07b6df397e8f8c7e1e1ba33ef2aa72bd74f9c14abc9962bf0b25ca4e761143ff + sourceRevisionDigest: sha256:5b534f729df60d25ae9a868905689010f8c0985a8efaeb9b54bf783e4cf64580 + sourceBlobDigest: sha256:3901a42e01b82ed5e37f76a1d5e38efd6c354a41d4a8e04b57cbde9f4649ed5f tags: - latest - - speakeasy-sdk-regen-1739439575 + - speakeasy-sdk-regen-1739492253 - "1.0" targets: my-first-target: source: json-development sourceNamespace: json-development - sourceRevisionDigest: sha256:2e0c21308626b21c71d084379fa94efbd8f2a9f460b9767db02ab81cf314ab3f - sourceBlobDigest: sha256:07b6df397e8f8c7e1e1ba33ef2aa72bd74f9c14abc9962bf0b25ca4e761143ff + sourceRevisionDigest: sha256:5b534f729df60d25ae9a868905689010f8c0985a8efaeb9b54bf783e4cf64580 + sourceBlobDigest: sha256:3901a42e01b82ed5e37f76a1d5e38efd6c354a41d4a8e04b57cbde9f4649ed5f codeSamplesNamespace: code-samples-typescript - codeSamplesRevisionDigest: sha256:1bdbb60d60c4cdcb79ff769cc7bcdded3265112307e8d9d5e81804388d72afe1 + codeSamplesRevisionDigest: sha256:0b78d306f2233cea5fc76344b40b2672232da2e23be91bd930799d216524c204 workflow: workflowVersion: 1.0.0 speakeasyVersion: latest diff --git a/README.md b/README.md index dde97d1b..bfc30cd4 100644 --- a/README.md +++ b/README.md @@ -560,10 +560,10 @@ In some rare cases, the SDK can fail to get a response from the server or even m You can override the default server globally by passing a server index to the `serverIdx: number` optional parameter when initializing the SDK client instance. The selected server will then be used as the default on the operations that use it. This table lists the indexes associated with the available servers: -| # | Server | -| --- | ------------------------ | -| 0 | `https://api.novu.co` | -| 1 | `https://eu.api.novu.co` | +| # | Server | Description | +| --- | ------------------------ | ----------- | +| 0 | `https://api.novu.co` | | +| 1 | `https://eu.api.novu.co` | | #### Example diff --git a/RELEASES.md b/RELEASES.md index 280077b9..015693c6 100644 --- a/RELEASES.md +++ b/RELEASES.md @@ -88,4 +88,14 @@ Based on: ### Generated - [typescript v0.2.1] . ### Releases -- [NPM v0.2.1] https://www.npmjs.com/package/@novu/api/v/0.2.1 - . \ No newline at end of file +- [NPM v0.2.1] https://www.npmjs.com/package/@novu/api/v/0.2.1 - . + +## 2025-02-19 00:17:17 +### Changes +Based on: +- OpenAPI Doc +- Speakeasy CLI 1.494.0 (2.515.0) https://github.com/speakeasy-api/speakeasy +### Generated +- [typescript v0.3.0] . +### Releases +- [NPM v0.3.0] https://www.npmjs.com/package/@novu/api/v/0.3.0 - . \ No newline at end of file diff --git a/docs/models/components/activitygraphstatesresponse.md b/docs/models/components/activitygraphstatesresponse.md index 2f849465..59a52ffc 100644 --- a/docs/models/components/activitygraphstatesresponse.md +++ b/docs/models/components/activitygraphstatesresponse.md @@ -7,7 +7,7 @@ import { ActivityGraphStatesResponse } from "@novu/api/models/components"; let value: ActivityGraphStatesResponse = { id: "", - count: 4358.65, + count: 8919.24, templates: [ "", ], diff --git a/docs/models/components/activitynotificationtemplateresponsedto.md b/docs/models/components/activitynotificationtemplateresponsedto.md index 252e24d9..57fea010 100644 --- a/docs/models/components/activitynotificationtemplateresponsedto.md +++ b/docs/models/components/activitynotificationtemplateresponsedto.md @@ -27,4 +27,5 @@ let value: ActivityNotificationTemplateResponseDto = { | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------- | | `id` | *string* | :heavy_minus_sign: | Unique identifier of the template | | `name` | *string* | :heavy_check_mark: | Name of the template | +| `origin` | [components.WorkflowOriginEnum](../../models/components/workfloworiginenum.md) | :heavy_minus_sign: | Origin of the workflow | | `triggers` | [components.NotificationTriggerDto](../../models/components/notificationtriggerdto.md)[] | :heavy_check_mark: | Triggers of the template | \ No newline at end of file diff --git a/docs/models/components/activitystatsresponsedto.md b/docs/models/components/activitystatsresponsedto.md index daa5d2ae..fc458826 100644 --- a/docs/models/components/activitystatsresponsedto.md +++ b/docs/models/components/activitystatsresponsedto.md @@ -6,8 +6,8 @@ import { ActivityStatsResponseDto } from "@novu/api/models/components"; let value: ActivityStatsResponseDto = { - weeklySent: 4314.18, - monthlySent: 8965.47, + weeklySent: 8965.47, + monthlySent: 3675.62, }; ``` diff --git a/docs/models/components/channel.md b/docs/models/components/channel.md index c4fbb153..fc76d0d4 100644 --- a/docs/models/components/channel.md +++ b/docs/models/components/channel.md @@ -7,7 +7,7 @@ The channel type for the integration, which defines how the integration communic ```typescript import { Channel } from "@novu/api/models/components"; -let value: Channel = "push"; +let value: Channel = "chat"; ``` ## Values diff --git a/docs/models/components/channels.md b/docs/models/components/channels.md index 6ae7eaf9..f6e5b156 100644 --- a/docs/models/components/channels.md +++ b/docs/models/components/channels.md @@ -5,7 +5,7 @@ ```typescript import { Channels } from "@novu/api/models/components"; -let value: Channels = "email"; +let value: Channels = "sms"; ``` ## Values diff --git a/docs/models/components/channelsettingsdto.md b/docs/models/components/channelsettingsdto.md index e044bd7d..2aba539d 100644 --- a/docs/models/components/channelsettingsdto.md +++ b/docs/models/components/channelsettingsdto.md @@ -6,7 +6,7 @@ import { ChannelSettingsDto } from "@novu/api/models/components"; let value: ChannelSettingsDto = { - providerId: "msteams", + providerId: "fcm", credentials: { webhookUrl: "https://example.com/webhook", channel: "general", diff --git a/docs/models/components/channelsettingsdtoproviderid.md b/docs/models/components/channelsettingsdtoproviderid.md index b50481b4..205fc4a9 100644 --- a/docs/models/components/channelsettingsdtoproviderid.md +++ b/docs/models/components/channelsettingsdtoproviderid.md @@ -7,7 +7,7 @@ The provider identifier for the credentials ```typescript import { ChannelSettingsDtoProviderId } from "@novu/api/models/components"; -let value: ChannelSettingsDtoProviderId = "pushpad"; +let value: ChannelSettingsDtoProviderId = "msteams"; ``` ## Values diff --git a/docs/models/components/channeltypeenum.md b/docs/models/components/channeltypeenum.md index e73c3082..f859f329 100644 --- a/docs/models/components/channeltypeenum.md +++ b/docs/models/components/channeltypeenum.md @@ -7,7 +7,7 @@ Channel type through which the message is sent ```typescript import { ChannelTypeEnum } from "@novu/api/models/components"; -let value: ChannelTypeEnum = "chat"; +let value: ChannelTypeEnum = "sms"; ``` ## Values diff --git a/docs/models/components/createintegrationrequestdto.md b/docs/models/components/createintegrationrequestdto.md index cf5a720b..8a32f099 100644 --- a/docs/models/components/createintegrationrequestdto.md +++ b/docs/models/components/createintegrationrequestdto.md @@ -7,7 +7,7 @@ import { CreateIntegrationRequestDto } from "@novu/api/models/components"; let value: CreateIntegrationRequestDto = { providerId: "", - channel: "push", + channel: "chat", }; ``` diff --git a/docs/models/components/createintegrationrequestdtochannel.md b/docs/models/components/createintegrationrequestdtochannel.md index 939fa732..1bcae17c 100644 --- a/docs/models/components/createintegrationrequestdtochannel.md +++ b/docs/models/components/createintegrationrequestdtochannel.md @@ -7,7 +7,7 @@ The channel type for the integration ```typescript import { CreateIntegrationRequestDtoChannel } from "@novu/api/models/components"; -let value: CreateIntegrationRequestDtoChannel = "in_app"; +let value: CreateIntegrationRequestDtoChannel = "push"; ``` ## Values diff --git a/docs/models/components/createsubscriberrequestdto.md b/docs/models/components/createsubscriberrequestdto.md index 6a32c0a9..0d503462 100644 --- a/docs/models/components/createsubscriberrequestdto.md +++ b/docs/models/components/createsubscriberrequestdto.md @@ -12,14 +12,14 @@ let value: CreateSubscriberRequestDto = { ## Fields -| Field | Type | Required | Description | -| ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------- | -| `subscriberId` | *string* | :heavy_check_mark: | The internal identifier you used to create this subscriber, usually correlates to the id the user in your systems | -| `email` | *string* | :heavy_minus_sign: | The email address of the subscriber. | -| `firstName` | *string* | :heavy_minus_sign: | The first name of the subscriber. | -| `lastName` | *string* | :heavy_minus_sign: | The last name of the subscriber. | -| `phone` | *string* | :heavy_minus_sign: | The phone number of the subscriber. | -| `avatar` | *string* | :heavy_minus_sign: | An HTTP URL to the profile image of your subscriber. | -| `locale` | *string* | :heavy_minus_sign: | The locale of the subscriber. | -| `data` | Record | :heavy_minus_sign: | An optional payload object that can contain any properties. | -| `channels` | [components.SubscriberChannelDto](../../models/components/subscriberchanneldto.md)[] | :heavy_minus_sign: | An optional array of subscriber channels. | \ No newline at end of file +| Field | Type | Required | Description | +| ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | ----------------------------------------- | +| `subscriberId` | *string* | :heavy_check_mark: | Unique identifier of the subscriber | +| `firstName` | *string* | :heavy_minus_sign: | First name of the subscriber | +| `lastName` | *string* | :heavy_minus_sign: | Last name of the subscriber | +| `email` | *string* | :heavy_minus_sign: | Email address of the subscriber | +| `phone` | *string* | :heavy_minus_sign: | Phone number of the subscriber | +| `avatar` | *string* | :heavy_minus_sign: | Avatar URL or identifier | +| `timezone` | *string* | :heavy_minus_sign: | Timezone of the subscriber | +| `locale` | *string* | :heavy_minus_sign: | Locale of the subscriber | +| `data` | Record | :heavy_minus_sign: | Additional custom data for the subscriber | \ No newline at end of file diff --git a/docs/models/components/createsubscriberrequestdtodata.md b/docs/models/components/createsubscriberrequestdtodata.md deleted file mode 100644 index 2c8a8729..00000000 --- a/docs/models/components/createsubscriberrequestdtodata.md +++ /dev/null @@ -1,31 +0,0 @@ -# CreateSubscriberRequestDtoData - - -## Supported Types - -### `string` - -```typescript -const value: string = ""; -``` - -### `string[]` - -```typescript -const value: string[] = [ - "", -]; -``` - -### `boolean` - -```typescript -const value: boolean = false; -``` - -### `number` - -```typescript -const value: number = 6155.6; -``` - diff --git a/docs/models/components/integrationresponsedto.md b/docs/models/components/integrationresponsedto.md index 4defdab4..34e00a87 100644 --- a/docs/models/components/integrationresponsedto.md +++ b/docs/models/components/integrationresponsedto.md @@ -11,7 +11,7 @@ let value: IntegrationResponseDto = { name: "", identifier: "", providerId: "", - channel: "chat", + channel: "in_app", credentials: {}, active: false, deleted: false, diff --git a/docs/models/components/listsubscribersresponsedto.md b/docs/models/components/listsubscribersresponsedto.md index 5f20c832..73f3e039 100644 --- a/docs/models/components/listsubscribersresponsedto.md +++ b/docs/models/components/listsubscribersresponsedto.md @@ -32,8 +32,8 @@ let value: ListSubscribersResponseDto = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1734646828003", - updatedAt: "1739423392882", + createdAt: "1735131063107", + updatedAt: "1739907627986", }, ], next: "", diff --git a/docs/models/components/messageresponsedto.md b/docs/models/components/messageresponsedto.md index 43ec6c6f..e0c82051 100644 --- a/docs/models/components/messageresponsedto.md +++ b/docs/models/components/messageresponsedto.md @@ -37,10 +37,10 @@ let value: MessageResponseDto = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1709617644175", - updatedAt: "1739370920929", + createdAt: "1710101879274", + updatedAt: "1739855156028", }, - createdAt: "1708488144722", + createdAt: "1708972379821", content: "", transactionId: "", channel: "email", diff --git a/docs/models/components/patchsubscriberrequestdto.md b/docs/models/components/patchsubscriberrequestdto.md index 3859ea4d..158e0cef 100644 --- a/docs/models/components/patchsubscriberrequestdto.md +++ b/docs/models/components/patchsubscriberrequestdto.md @@ -12,7 +12,6 @@ let value: PatchSubscriberRequestDto = {}; | Field | Type | Required | Description | | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- | -| `subscriberId` | *string* | :heavy_minus_sign: | Unique identifier of the subscriber | | `firstName` | *string* | :heavy_minus_sign: | First name of the subscriber | | `lastName` | *string* | :heavy_minus_sign: | Last name of the subscriber | | `email` | *string* | :heavy_minus_sign: | Email address of the subscriber | diff --git a/docs/models/components/status.md b/docs/models/components/status.md index b5482491..1c9e6b48 100644 --- a/docs/models/components/status.md +++ b/docs/models/components/status.md @@ -13,5 +13,5 @@ let value: Status = "processed"; ## Values ```typescript -"error" | "trigger_not_active" | "no_workflow_active_steps_defined" | "no_workflow_steps_defined" | "processed" | "no_tenant_found" +"error" | "trigger_not_active" | "no_workflow_active_steps_defined" | "no_workflow_steps_defined" | "processed" | "no_tenant_found" | "invalid_recipients" ``` \ No newline at end of file diff --git a/docs/models/components/subscriberpayloaddto.md b/docs/models/components/subscriberpayloaddto.md index e9f38255..7552eab7 100644 --- a/docs/models/components/subscriberpayloaddto.md +++ b/docs/models/components/subscriberpayloaddto.md @@ -22,4 +22,5 @@ let value: SubscriberPayloadDto = { | `avatar` | *string* | :heavy_minus_sign: | An HTTP URL to the profile image of your subscriber. | | `locale` | *string* | :heavy_minus_sign: | The locale of the subscriber. | | `data` | Record | :heavy_minus_sign: | An optional payload object that can contain any properties. | -| `channels` | [components.SubscriberChannelDto](../../models/components/subscriberchanneldto.md)[] | :heavy_minus_sign: | An optional array of subscriber channels. | \ No newline at end of file +| `channels` | [components.SubscriberChannelDto](../../models/components/subscriberchanneldto.md)[] | :heavy_minus_sign: | An optional array of subscriber channels. | +| `timezone` | *string* | :heavy_minus_sign: | The timezone of the subscriber. | \ No newline at end of file diff --git a/docs/models/components/subscriberresponsedto.md b/docs/models/components/subscriberresponsedto.md index 78a03738..1d8af252 100644 --- a/docs/models/components/subscriberresponsedto.md +++ b/docs/models/components/subscriberresponsedto.md @@ -9,7 +9,7 @@ let value: SubscriberResponseDto = { subscriberId: "", channels: [ { - providerId: "expo", + providerId: "pusher-beams", credentials: { webhookUrl: "https://example.com/webhook", channel: "general", @@ -30,8 +30,8 @@ let value: SubscriberResponseDto = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1739403679477", - updatedAt: "1739366553461", + createdAt: "1713101277984", + updatedAt: "1739912881622", }; ``` diff --git a/docs/models/components/workfloworiginenum.md b/docs/models/components/workfloworiginenum.md new file mode 100644 index 00000000..f31b9125 --- /dev/null +++ b/docs/models/components/workfloworiginenum.md @@ -0,0 +1,17 @@ +# WorkflowOriginEnum + +Origin of the workflow + +## Example Usage + +```typescript +import { WorkflowOriginEnum } from "@novu/api/models/components"; + +let value: WorkflowOriginEnum = "novu-cloud-v1"; +``` + +## Values + +```typescript +"novu-cloud" | "novu-cloud-v1" | "external" +``` \ No newline at end of file diff --git a/docs/models/operations/eventscontrollertriggerresponse.md b/docs/models/operations/eventscontrollertriggerresponse.md index 897375f2..49daaea5 100644 --- a/docs/models/operations/eventscontrollertriggerresponse.md +++ b/docs/models/operations/eventscontrollertriggerresponse.md @@ -13,7 +13,7 @@ let value: EventsControllerTriggerResponse = { }, result: { acknowledged: false, - status: "processed", + status: "no_tenant_found", }, }; ``` diff --git a/docs/models/operations/notificationscontrollerlistnotificationsrequest.md b/docs/models/operations/notificationscontrollerlistnotificationsrequest.md index 43bd1d8b..a27b7f63 100644 --- a/docs/models/operations/notificationscontrollerlistnotificationsrequest.md +++ b/docs/models/operations/notificationscontrollerlistnotificationsrequest.md @@ -18,6 +18,7 @@ let value: NotificationsControllerListNotificationsRequest = {}; | ~~`search`~~ | *string* | :heavy_minus_sign: | : warning: ** DEPRECATED **: This will be removed in a future release, please migrate away from it as soon as possible.

Search term (deprecated) | | `subscriberIds` | *string*[] | :heavy_minus_sign: | Array of subscriber IDs or a single subscriber ID | | `page` | *number* | :heavy_minus_sign: | Page number for pagination | +| `limit` | *number* | :heavy_minus_sign: | Limit for pagination | | `transactionId` | *string* | :heavy_minus_sign: | Transaction ID for filtering | | `after` | *string* | :heavy_minus_sign: | Date filter for records after this timestamp | | `before` | *string* | :heavy_minus_sign: | Date filter for records before this timestamp | diff --git a/docs/models/operations/subscriberscontrollercreatesubscriberresponse.md b/docs/models/operations/subscriberscontrollercreatesubscriberresponse.md index e4ca9108..7f8e8d3c 100644 --- a/docs/models/operations/subscriberscontrollercreatesubscriberresponse.md +++ b/docs/models/operations/subscriberscontrollercreatesubscriberresponse.md @@ -36,8 +36,8 @@ let value: SubscribersControllerCreateSubscriberResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1725830173138", - updatedAt: "1739355264114", + createdAt: "1726314408269", + updatedAt: "1739839499245", }, }; ``` diff --git a/docs/models/operations/subscriberscontrollergetsubscriberresponse.md b/docs/models/operations/subscriberscontrollergetsubscriberresponse.md index edf848a9..8fa58712 100644 --- a/docs/models/operations/subscriberscontrollergetsubscriberresponse.md +++ b/docs/models/operations/subscriberscontrollergetsubscriberresponse.md @@ -36,8 +36,8 @@ let value: SubscribersControllerGetSubscriberResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1727207090805", - updatedAt: "1739406943186", + createdAt: "1727691325935", + updatedAt: "1739891178316", }, }; ``` diff --git a/docs/models/operations/subscriberscontrollerpatchsubscriberresponse.md b/docs/models/operations/subscriberscontrollerpatchsubscriberresponse.md index 36b76087..4e9535e1 100644 --- a/docs/models/operations/subscriberscontrollerpatchsubscriberresponse.md +++ b/docs/models/operations/subscriberscontrollerpatchsubscriberresponse.md @@ -36,8 +36,8 @@ let value: SubscribersControllerPatchSubscriberResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1729405924986", - updatedAt: "1739384701838", + createdAt: "1729890160116", + updatedAt: "1739868936968", }, }; ``` diff --git a/docs/models/operations/subscriberscontrollersearchsubscribersresponse.md b/docs/models/operations/subscriberscontrollersearchsubscribersresponse.md index c986fb27..f32e695d 100644 --- a/docs/models/operations/subscriberscontrollersearchsubscribersresponse.md +++ b/docs/models/operations/subscriberscontrollersearchsubscribersresponse.md @@ -38,8 +38,8 @@ let value: SubscribersControllerSearchSubscribersResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1716247066203", - updatedAt: "1739420533702", + createdAt: "1716731301335", + updatedAt: "1739904768833", }, ], next: "", diff --git a/docs/models/operations/subscribersv1controllerlistsubscribersresponse.md b/docs/models/operations/subscribersv1controllerlistsubscribersresponse.md index 42a4ffa8..4fb81858 100644 --- a/docs/models/operations/subscribersv1controllerlistsubscribersresponse.md +++ b/docs/models/operations/subscribersv1controllerlistsubscribersresponse.md @@ -41,8 +41,8 @@ let value: SubscribersV1ControllerListSubscribersResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1712424829787", - updatedAt: "1739435259110", + createdAt: "1712909064923", + updatedAt: "1739919494245", }, ], }, diff --git a/docs/models/operations/subscribersv1controllerlistsubscribersresponsebody.md b/docs/models/operations/subscribersv1controllerlistsubscribersresponsebody.md index dd063255..b59cc444 100644 --- a/docs/models/operations/subscribersv1controllerlistsubscribersresponsebody.md +++ b/docs/models/operations/subscribersv1controllerlistsubscribersresponsebody.md @@ -35,8 +35,8 @@ let value: SubscribersV1ControllerListSubscribersResponseBody = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1733106304333", - updatedAt: "1739393512006", + createdAt: "1733590539470", + updatedAt: "1739877747143", }, ], }; diff --git a/docs/models/operations/subscribersv1controllermarkactionasseenresponse.md b/docs/models/operations/subscribersv1controllermarkactionasseenresponse.md index 5d31a61b..70d5f0f6 100644 --- a/docs/models/operations/subscribersv1controllermarkactionasseenresponse.md +++ b/docs/models/operations/subscribersv1controllermarkactionasseenresponse.md @@ -43,10 +43,10 @@ let value: SubscribersV1ControllerMarkActionAsSeenResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1710934600172", - updatedAt: "1739438005999", + createdAt: "1711418835299", + updatedAt: "1739922241126", }, - createdAt: "1722683424704", + createdAt: "1723167659831", content: "", transactionId: "", channel: "chat", diff --git a/docs/models/operations/subscribersv1controllermarkmessagesasresponse.md b/docs/models/operations/subscribersv1controllermarkmessagesasresponse.md index 45fec690..8dc533fc 100644 --- a/docs/models/operations/subscribersv1controllermarkmessagesasresponse.md +++ b/docs/models/operations/subscribersv1controllermarkmessagesasresponse.md @@ -44,10 +44,10 @@ let value: SubscribersV1ControllerMarkMessagesAsResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1722609616891", - updatedAt: "1739374758952", + createdAt: "1723093852042", + updatedAt: "1739858994102", }, - createdAt: "1712917305460", + createdAt: "1713401540608", content: { type: "text", content: "", diff --git a/docs/models/operations/subscribersv1controllermodifysubscriberchannelresponse.md b/docs/models/operations/subscribersv1controllermodifysubscriberchannelresponse.md index 2b92dee9..76724cfc 100644 --- a/docs/models/operations/subscribersv1controllermodifysubscriberchannelresponse.md +++ b/docs/models/operations/subscribersv1controllermodifysubscriberchannelresponse.md @@ -36,8 +36,8 @@ let value: SubscribersV1ControllerModifySubscriberChannelResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1711969860338", - updatedAt: "1739380893439", + createdAt: "1712454095467", + updatedAt: "1739865128567", }, }; ``` diff --git a/docs/models/operations/subscribersv1controllerupdatesubscriberchannelresponse.md b/docs/models/operations/subscribersv1controllerupdatesubscriberchannelresponse.md index 299416e8..9abe7e16 100644 --- a/docs/models/operations/subscribersv1controllerupdatesubscriberchannelresponse.md +++ b/docs/models/operations/subscribersv1controllerupdatesubscriberchannelresponse.md @@ -36,8 +36,8 @@ let value: SubscribersV1ControllerUpdateSubscriberChannelResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1709803311146", - updatedAt: "1739411248711", + createdAt: "1710287546275", + updatedAt: "1739895483840", }, }; ``` diff --git a/docs/models/operations/subscribersv1controllerupdatesubscriberonlineflagresponse.md b/docs/models/operations/subscribersv1controllerupdatesubscriberonlineflagresponse.md index ea9f6220..bf32d2ba 100644 --- a/docs/models/operations/subscribersv1controllerupdatesubscriberonlineflagresponse.md +++ b/docs/models/operations/subscribersv1controllerupdatesubscriberonlineflagresponse.md @@ -36,8 +36,8 @@ let value: SubscribersV1ControllerUpdateSubscriberOnlineFlagResponse = { organizationId: "", environmentId: "", deleted: false, - createdAt: "1725885765543", - updatedAt: "1739391535493", + createdAt: "1726370000695", + updatedAt: "1739875770646", }, }; ``` diff --git a/jsr.json b/jsr.json index c729b39c..143d9a99 100644 --- a/jsr.json +++ b/jsr.json @@ -2,7 +2,7 @@ { "name": "@novu/api", - "version": "0.2.1", + "version": "0.3.0", "exports": { ".": "./src/index.ts", "./models/errors": "./src/models/errors/index.ts", diff --git a/package-lock.json b/package-lock.json index c366fcf7..590854d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@novu/api", - "version": "0.2.1", + "version": "0.3.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@novu/api", - "version": "0.2.1", + "version": "0.3.0", "devDependencies": { "@eslint/js": "^9.19.0", "eslint": "^9.19.0", diff --git a/package.json b/package.json index 0e708644..9e3379ce 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@novu/api", - "version": "0.2.1", + "version": "0.3.0", "author": "Novu", "main": "./index.js", "sideEffects": false, diff --git a/sources/json-development.json b/sources/json-development.json index f042e009..18133230 100644 --- a/sources/json-development.json +++ b/sources/json-development.json @@ -2064,10 +2064,23 @@ "in": "query", "description": "Page number for pagination", "schema": { + "minimum": 0, "default": 0, "type": "number" } }, + { + "name": "limit", + "required": false, + "in": "query", + "description": "Limit for pagination", + "schema": { + "minimum": 1, + "maximum": 50, + "default": 10, + "type": "number" + } + }, { "name": "transactionId", "required": false, @@ -14519,8 +14532,8 @@ } }, "responses": { - "200": { - "description": "OK", + "201": { + "description": "Created", "headers": { "Content-Type": { "$ref": "#/components/headers/Content-Type" @@ -23185,7 +23198,8 @@ "no_workflow_active_steps_defined", "no_workflow_steps_defined", "processed", - "no_tenant_found" + "no_tenant_found", + "invalid_recipients" ], "type": "string", "description": "Status of the trigger" @@ -23327,6 +23341,10 @@ "items": { "$ref": "#/components/schemas/SubscriberChannelDto" } + }, + "timezone": { + "type": "string", + "description": "The timezone of the subscriber." } }, "required": [ @@ -23619,6 +23637,15 @@ "_id" ] }, + "WorkflowOriginEnum": { + "type": "string", + "description": "Origin of the workflow", + "enum": [ + "novu-cloud", + "novu-cloud-v1", + "external" + ] + }, "NotificationTriggerVariable": { "type": "object", "properties": { @@ -23677,6 +23704,9 @@ "type": "string", "description": "Name of the template" }, + "origin": { + "$ref": "#/components/schemas/WorkflowOriginEnum" + }, "triggers": { "description": "Triggers of the template", "type": "array", @@ -25024,61 +25054,48 @@ "properties": { "subscriberId": { "type": "string", - "description": "The internal identifier you used to create this subscriber, usually correlates to the id the user in your systems" - }, - "email": { - "type": "string", - "description": "The email address of the subscriber." + "description": "Unique identifier of the subscriber" }, "firstName": { "type": "string", - "description": "The first name of the subscriber." + "nullable": true, + "description": "First name of the subscriber" }, "lastName": { "type": "string", - "description": "The last name of the subscriber." + "nullable": true, + "description": "Last name of the subscriber" + }, + "email": { + "type": "string", + "nullable": true, + "description": "Email address of the subscriber" }, "phone": { "type": "string", - "description": "The phone number of the subscriber." + "nullable": true, + "description": "Phone number of the subscriber" }, "avatar": { "type": "string", - "description": "An HTTP URL to the profile image of your subscriber." + "nullable": true, + "description": "Avatar URL or identifier" + }, + "timezone": { + "type": "string", + "nullable": true, + "description": "Timezone of the subscriber" }, "locale": { "type": "string", - "description": "The locale of the subscriber." + "nullable": true, + "description": "Locale of the subscriber" }, "data": { "type": "object", - "description": "An optional payload object that can contain any properties.", - "additionalProperties": { - "oneOf": [ - { - "type": "string" - }, - { - "type": "array", - "items": { - "type": "string" - } - }, - { - "type": "boolean" - }, - { - "type": "number" - } - ] - } - }, - "channels": { - "description": "An optional array of subscriber channels.", - "type": "array", - "items": { - "$ref": "#/components/schemas/SubscriberChannelDto" - } + "nullable": true, + "description": "Additional custom data for the subscriber", + "additionalProperties": true } }, "required": [ @@ -26452,11 +26469,6 @@ "PatchSubscriberRequestDto": { "type": "object", "properties": { - "subscriberId": { - "type": "string", - "nullable": true, - "description": "Unique identifier of the subscriber" - }, "firstName": { "type": "string", "nullable": true, diff --git a/src/funcs/cancel.ts b/src/funcs/cancel.ts index 894a2a72..97fa3854 100644 --- a/src/funcs/cancel.ts +++ b/src/funcs/cancel.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -31,12 +32,12 @@ import { Result } from "../types/fp.js"; * Using a previously generated transactionId during the event trigger, * will cancel any active or pending workflows. This is useful to cancel active digests, delays etc... */ -export async function cancel( +export function cancel( client: NovuCore, transactionId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.EventsControllerCancelResponse, | errors.ErrorDto @@ -51,6 +52,38 @@ export async function cancel( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + transactionId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + transactionId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.EventsControllerCancelResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.EventsControllerCancelRequest = { transactionId: transactionId, @@ -64,7 +97,7 @@ export async function cancel( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -125,7 +158,7 @@ export async function cancel( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -152,7 +185,7 @@ export async function cancel( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -192,8 +225,8 @@ export async function cancel( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/integrationsCreate.ts b/src/funcs/integrationsCreate.ts index b0aea113..17f53be2 100644 --- a/src/funcs/integrationsCreate.ts +++ b/src/funcs/integrationsCreate.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,12 +31,12 @@ import { Result } from "../types/fp.js"; * @remarks * Create an integration for the current environment the user is based on the API key provided */ -export async function integrationsCreate( +export function integrationsCreate( client: NovuCore, createIntegrationRequestDto: components.CreateIntegrationRequestDto, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.IntegrationsControllerCreateIntegrationResponse, | errors.ErrorDto @@ -50,6 +51,38 @@ export async function integrationsCreate( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + createIntegrationRequestDto, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + createIntegrationRequestDto: components.CreateIntegrationRequestDto, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.IntegrationsControllerCreateIntegrationResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.IntegrationsControllerCreateIntegrationRequest = { createIntegrationRequestDto: createIntegrationRequestDto, @@ -64,7 +97,7 @@ export async function integrationsCreate( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.CreateIntegrationRequestDto, { @@ -121,7 +154,7 @@ export async function integrationsCreate( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -148,7 +181,7 @@ export async function integrationsCreate( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -189,8 +222,8 @@ export async function integrationsCreate( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/integrationsDelete.ts b/src/funcs/integrationsDelete.ts index 34ecac34..8df30960 100644 --- a/src/funcs/integrationsDelete.ts +++ b/src/funcs/integrationsDelete.ts @@ -21,17 +21,18 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Delete integration */ -export async function integrationsDelete( +export function integrationsDelete( client: NovuCore, integrationId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.IntegrationsControllerRemoveIntegrationResponse, | errors.ErrorDto @@ -46,6 +47,38 @@ export async function integrationsDelete( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + integrationId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + integrationId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.IntegrationsControllerRemoveIntegrationResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.IntegrationsControllerRemoveIntegrationRequest = { integrationId: integrationId, @@ -60,7 +93,7 @@ export async function integrationsDelete( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -121,7 +154,7 @@ export async function integrationsDelete( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -148,7 +181,7 @@ export async function integrationsDelete( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -189,8 +222,8 @@ export async function integrationsDelete( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/integrationsList.ts b/src/funcs/integrationsList.ts index f5d70b88..7c9c56fc 100644 --- a/src/funcs/integrationsList.ts +++ b/src/funcs/integrationsList.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,11 +30,11 @@ import { Result } from "../types/fp.js"; * @remarks * Return all the integrations the user has created for that organization. Review v.0.17.0 changelog for a breaking change */ -export async function integrationsList( +export function integrationsList( client: NovuCore, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.IntegrationsControllerListIntegrationsResponse, | errors.ErrorDto @@ -48,6 +49,36 @@ export async function integrationsList( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.IntegrationsControllerListIntegrationsResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.IntegrationsControllerListIntegrationsRequest = { idempotencyKey: idempotencyKey, @@ -61,7 +92,7 @@ export async function integrationsList( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -115,7 +146,7 @@ export async function integrationsList( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -142,7 +173,7 @@ export async function integrationsList( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -183,8 +214,8 @@ export async function integrationsList( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/integrationsListActive.ts b/src/funcs/integrationsListActive.ts index c9dc8cb7..78f99704 100644 --- a/src/funcs/integrationsListActive.ts +++ b/src/funcs/integrationsListActive.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,11 +30,11 @@ import { Result } from "../types/fp.js"; * @remarks * Return all the active integrations the user has created for that organization. Review v.0.17.0 changelog for a breaking change */ -export async function integrationsListActive( +export function integrationsListActive( client: NovuCore, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.IntegrationsControllerGetActiveIntegrationsResponse, | errors.ErrorDto @@ -48,6 +49,36 @@ export async function integrationsListActive( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.IntegrationsControllerGetActiveIntegrationsResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.IntegrationsControllerGetActiveIntegrationsRequest = { idempotencyKey: idempotencyKey, @@ -62,7 +93,7 @@ export async function integrationsListActive( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -116,7 +147,7 @@ export async function integrationsListActive( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -143,7 +174,7 @@ export async function integrationsListActive( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -185,8 +216,8 @@ export async function integrationsListActive( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/integrationsSetAsPrimary.ts b/src/funcs/integrationsSetAsPrimary.ts index d95971b7..0ac596b3 100644 --- a/src/funcs/integrationsSetAsPrimary.ts +++ b/src/funcs/integrationsSetAsPrimary.ts @@ -21,17 +21,18 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Set integration as primary */ -export async function integrationsSetAsPrimary( +export function integrationsSetAsPrimary( client: NovuCore, integrationId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.IntegrationsControllerSetIntegrationAsPrimaryResponse, | errors.ErrorDto @@ -46,6 +47,38 @@ export async function integrationsSetAsPrimary( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + integrationId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + integrationId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.IntegrationsControllerSetIntegrationAsPrimaryResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.IntegrationsControllerSetIntegrationAsPrimaryRequest = { @@ -62,7 +95,7 @@ export async function integrationsSetAsPrimary( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -125,7 +158,7 @@ export async function integrationsSetAsPrimary( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -152,7 +185,7 @@ export async function integrationsSetAsPrimary( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -194,8 +227,8 @@ export async function integrationsSetAsPrimary( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/integrationsUpdate.ts b/src/funcs/integrationsUpdate.ts index 1ae1a782..238c0268 100644 --- a/src/funcs/integrationsUpdate.ts +++ b/src/funcs/integrationsUpdate.ts @@ -22,18 +22,19 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Update integration */ -export async function integrationsUpdate( +export function integrationsUpdate( client: NovuCore, updateIntegrationRequestDto: components.UpdateIntegrationRequestDto, integrationId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.IntegrationsControllerUpdateIntegrationByIdResponse, | errors.ErrorDto @@ -48,6 +49,40 @@ export async function integrationsUpdate( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + updateIntegrationRequestDto, + integrationId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + updateIntegrationRequestDto: components.UpdateIntegrationRequestDto, + integrationId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.IntegrationsControllerUpdateIntegrationByIdResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.IntegrationsControllerUpdateIntegrationByIdRequest = { updateIntegrationRequestDto: updateIntegrationRequestDto, @@ -64,7 +99,7 @@ export async function integrationsUpdate( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.UpdateIntegrationRequestDto, { @@ -128,7 +163,7 @@ export async function integrationsUpdate( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -155,7 +190,7 @@ export async function integrationsUpdate( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -197,8 +232,8 @@ export async function integrationsUpdate( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/integrationsWebhooksRetrieve.ts b/src/funcs/integrationsWebhooksRetrieve.ts index d10ddd1b..375d31cd 100644 --- a/src/funcs/integrationsWebhooksRetrieve.ts +++ b/src/funcs/integrationsWebhooksRetrieve.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,12 +30,12 @@ import { Result } from "../types/fp.js"; * @remarks * Return the status of the webhook for this provider, if it is supported or if it is not based on a boolean value */ -export async function integrationsWebhooksRetrieve( +export function integrationsWebhooksRetrieve( client: NovuCore, providerOrIntegrationId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.IntegrationsControllerGetWebhookSupportStatusResponse, | errors.ErrorDto @@ -49,6 +50,38 @@ export async function integrationsWebhooksRetrieve( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + providerOrIntegrationId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + providerOrIntegrationId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.IntegrationsControllerGetWebhookSupportStatusResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.IntegrationsControllerGetWebhookSupportStatusRequest = { @@ -65,7 +98,7 @@ export async function integrationsWebhooksRetrieve( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -129,7 +162,7 @@ export async function integrationsWebhooksRetrieve( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -156,7 +189,7 @@ export async function integrationsWebhooksRetrieve( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -198,8 +231,8 @@ export async function integrationsWebhooksRetrieve( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/messagesDelete.ts b/src/funcs/messagesDelete.ts index 6a575e12..373041d1 100644 --- a/src/funcs/messagesDelete.ts +++ b/src/funcs/messagesDelete.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,12 +30,12 @@ import { Result } from "../types/fp.js"; * @remarks * Deletes a message entity from the Novu platform */ -export async function messagesDelete( +export function messagesDelete( client: NovuCore, messageId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.MessagesControllerDeleteMessageResponse, | errors.ErrorDto @@ -49,6 +50,38 @@ export async function messagesDelete( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + messageId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + messageId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.MessagesControllerDeleteMessageResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.MessagesControllerDeleteMessageRequest = { messageId: messageId, @@ -64,7 +97,7 @@ export async function messagesDelete( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -125,7 +158,7 @@ export async function messagesDelete( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -152,7 +185,7 @@ export async function messagesDelete( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -193,8 +226,8 @@ export async function messagesDelete( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/messagesDeleteByTransactionId.ts b/src/funcs/messagesDeleteByTransactionId.ts index 098e5c3c..c5ca4db3 100644 --- a/src/funcs/messagesDeleteByTransactionId.ts +++ b/src/funcs/messagesDeleteByTransactionId.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,13 +30,13 @@ import { Result } from "../types/fp.js"; * @remarks * Deletes messages entity from the Novu platform using TransactionId of message */ -export async function messagesDeleteByTransactionId( +export function messagesDeleteByTransactionId( client: NovuCore, transactionId: string, channel?: operations.Channel | undefined, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< | operations.MessagesControllerDeleteMessagesByTransactionIdResponse | undefined, @@ -51,6 +52,41 @@ export async function messagesDeleteByTransactionId( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + transactionId, + channel, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + transactionId: string, + channel?: operations.Channel | undefined, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + | operations.MessagesControllerDeleteMessagesByTransactionIdResponse + | undefined, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.MessagesControllerDeleteMessagesByTransactionIdRequest = { @@ -68,7 +104,7 @@ export async function messagesDeleteByTransactionId( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -136,7 +172,7 @@ export async function messagesDeleteByTransactionId( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -163,7 +199,7 @@ export async function messagesDeleteByTransactionId( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -207,8 +243,8 @@ export async function messagesDeleteByTransactionId( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/messagesRetrieve.ts b/src/funcs/messagesRetrieve.ts index 9bfdaccf..11db294e 100644 --- a/src/funcs/messagesRetrieve.ts +++ b/src/funcs/messagesRetrieve.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,11 +30,11 @@ import { Result } from "../types/fp.js"; * @remarks * Returns a list of messages, could paginate using the `page` query parameter */ -export async function messagesRetrieve( +export function messagesRetrieve( client: NovuCore, request: operations.MessagesControllerGetMessagesRequest, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.MessagesControllerGetMessagesResponse, | errors.ErrorDto @@ -48,6 +49,36 @@ export async function messagesRetrieve( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: NovuCore, + request: operations.MessagesControllerGetMessagesRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.MessagesControllerGetMessagesResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const parsed = safeParse( request, @@ -58,7 +89,7 @@ export async function messagesRetrieve( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -121,7 +152,7 @@ export async function messagesRetrieve( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -148,7 +179,7 @@ export async function messagesRetrieve( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -189,8 +220,8 @@ export async function messagesRetrieve( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/notificationsList.ts b/src/funcs/notificationsList.ts index 080b56dd..afaf1eb1 100644 --- a/src/funcs/notificationsList.ts +++ b/src/funcs/notificationsList.ts @@ -21,16 +21,17 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Get notifications */ -export async function notificationsList( +export function notificationsList( client: NovuCore, request: operations.NotificationsControllerListNotificationsRequest, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.NotificationsControllerListNotificationsResponse, | errors.ErrorDto @@ -45,6 +46,36 @@ export async function notificationsList( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: NovuCore, + request: operations.NotificationsControllerListNotificationsRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.NotificationsControllerListNotificationsResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const parsed = safeParse( request, @@ -54,7 +85,7 @@ export async function notificationsList( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -66,6 +97,7 @@ export async function notificationsList( "before": payload.before, "channels": payload.channels, "emails": payload.emails, + "limit": payload.limit, "page": payload.page, "search": payload.search, "subscriberIds": payload.subscriberIds, @@ -121,7 +153,7 @@ export async function notificationsList( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -148,7 +180,7 @@ export async function notificationsList( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -189,8 +221,8 @@ export async function notificationsList( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/notificationsRetrieve.ts b/src/funcs/notificationsRetrieve.ts index e7e05270..04114e94 100644 --- a/src/funcs/notificationsRetrieve.ts +++ b/src/funcs/notificationsRetrieve.ts @@ -21,17 +21,18 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Get notification */ -export async function notificationsRetrieve( +export function notificationsRetrieve( client: NovuCore, notificationId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.NotificationsControllerGetNotificationResponse, | errors.ErrorDto @@ -46,6 +47,38 @@ export async function notificationsRetrieve( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + notificationId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + notificationId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.NotificationsControllerGetNotificationResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.NotificationsControllerGetNotificationRequest = { notificationId: notificationId, @@ -60,7 +93,7 @@ export async function notificationsRetrieve( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -121,7 +154,7 @@ export async function notificationsRetrieve( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -148,7 +181,7 @@ export async function notificationsRetrieve( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -189,8 +222,8 @@ export async function notificationsRetrieve( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/notificationsStatsGraph.ts b/src/funcs/notificationsStatsGraph.ts index d219ff44..7576bb14 100644 --- a/src/funcs/notificationsStatsGraph.ts +++ b/src/funcs/notificationsStatsGraph.ts @@ -21,17 +21,18 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Get notification graph statistics */ -export async function notificationsStatsGraph( +export function notificationsStatsGraph( client: NovuCore, days?: number | undefined, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.NotificationsControllerGetActivityGraphStatsResponse, | errors.ErrorDto @@ -46,6 +47,38 @@ export async function notificationsStatsGraph( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + days, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + days?: number | undefined, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.NotificationsControllerGetActivityGraphStatsResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.NotificationsControllerGetActivityGraphStatsRequest = { @@ -62,7 +95,7 @@ export async function notificationsStatsGraph( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -121,7 +154,7 @@ export async function notificationsStatsGraph( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -148,7 +181,7 @@ export async function notificationsStatsGraph( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -190,8 +223,8 @@ export async function notificationsStatsGraph( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/notificationsStatsRetrieve.ts b/src/funcs/notificationsStatsRetrieve.ts index 64c7666e..7359e091 100644 --- a/src/funcs/notificationsStatsRetrieve.ts +++ b/src/funcs/notificationsStatsRetrieve.ts @@ -21,16 +21,17 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Get notification statistics */ -export async function notificationsStatsRetrieve( +export function notificationsStatsRetrieve( client: NovuCore, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.NotificationsControllerGetActivityStatsResponse, | errors.ErrorDto @@ -45,6 +46,36 @@ export async function notificationsStatsRetrieve( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.NotificationsControllerGetActivityStatsResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.NotificationsControllerGetActivityStatsRequest = { idempotencyKey: idempotencyKey, @@ -58,7 +89,7 @@ export async function notificationsStatsRetrieve( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -112,7 +143,7 @@ export async function notificationsStatsRetrieve( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -139,7 +170,7 @@ export async function notificationsStatsRetrieve( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -180,8 +211,8 @@ export async function notificationsStatsRetrieve( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersAuthenticationChatAccessOauth.ts b/src/funcs/subscribersAuthenticationChatAccessOauth.ts index 75722d1c..2633414a 100644 --- a/src/funcs/subscribersAuthenticationChatAccessOauth.ts +++ b/src/funcs/subscribersAuthenticationChatAccessOauth.ts @@ -21,16 +21,17 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Handle chat oauth */ -export async function subscribersAuthenticationChatAccessOauth( +export function subscribersAuthenticationChatAccessOauth( client: NovuCore, request: operations.SubscribersV1ControllerChatAccessOauthRequest, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerChatAccessOauthResponse | undefined, | errors.ErrorDto @@ -45,6 +46,36 @@ export async function subscribersAuthenticationChatAccessOauth( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: NovuCore, + request: operations.SubscribersV1ControllerChatAccessOauthRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerChatAccessOauthResponse | undefined, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const parsed = safeParse( request, @@ -54,7 +85,7 @@ export async function subscribersAuthenticationChatAccessOauth( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -128,7 +159,7 @@ export async function subscribersAuthenticationChatAccessOauth( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -155,7 +186,7 @@ export async function subscribersAuthenticationChatAccessOauth( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -196,8 +227,8 @@ export async function subscribersAuthenticationChatAccessOauth( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersAuthenticationChatAccessOauthCallBack.ts b/src/funcs/subscribersAuthenticationChatAccessOauthCallBack.ts index 937a18aa..61fd67b6 100644 --- a/src/funcs/subscribersAuthenticationChatAccessOauthCallBack.ts +++ b/src/funcs/subscribersAuthenticationChatAccessOauthCallBack.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; export enum ChatAccessOauthCallBackAcceptEnum { @@ -31,13 +32,13 @@ export enum ChatAccessOauthCallBackAcceptEnum { /** * Handle providers oauth redirect */ -export async function subscribersAuthenticationChatAccessOauthCallBack( +export function subscribersAuthenticationChatAccessOauthCallBack( client: NovuCore, request: operations.SubscribersV1ControllerChatOauthCallbackRequest, options?: RequestOptions & { acceptHeaderOverride?: ChatAccessOauthCallBackAcceptEnum; }, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerChatOauthCallbackResponse, | errors.ErrorDto @@ -52,6 +53,38 @@ export async function subscribersAuthenticationChatAccessOauthCallBack( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: NovuCore, + request: operations.SubscribersV1ControllerChatOauthCallbackRequest, + options?: RequestOptions & { + acceptHeaderOverride?: ChatAccessOauthCallBackAcceptEnum; + }, +): Promise< + [ + Result< + operations.SubscribersV1ControllerChatOauthCallbackResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const parsed = safeParse( request, @@ -61,7 +94,7 @@ export async function subscribersAuthenticationChatAccessOauthCallBack( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -137,7 +170,7 @@ export async function subscribersAuthenticationChatAccessOauthCallBack( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -164,7 +197,7 @@ export async function subscribersAuthenticationChatAccessOauthCallBack( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -210,8 +243,8 @@ export async function subscribersAuthenticationChatAccessOauthCallBack( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersCreate.ts b/src/funcs/subscribersCreate.ts index 638560a2..1b8d2872 100644 --- a/src/funcs/subscribersCreate.ts +++ b/src/funcs/subscribersCreate.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,12 +31,12 @@ import { Result } from "../types/fp.js"; * @remarks * Create subscriber with the given data */ -export async function subscribersCreate( +export function subscribersCreate( client: NovuCore, createSubscriberRequestDto: components.CreateSubscriberRequestDto, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersControllerCreateSubscriberResponse, | errors.ErrorDto @@ -50,6 +51,38 @@ export async function subscribersCreate( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + createSubscriberRequestDto, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + createSubscriberRequestDto: components.CreateSubscriberRequestDto, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersControllerCreateSubscriberResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersControllerCreateSubscriberRequest = { createSubscriberRequestDto: createSubscriberRequestDto, @@ -64,7 +97,7 @@ export async function subscribersCreate( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.CreateSubscriberRequestDto, { @@ -121,7 +154,7 @@ export async function subscribersCreate( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -148,7 +181,7 @@ export async function subscribersCreate( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -171,7 +204,7 @@ export async function subscribersCreate( | ConnectionError >( M.json( - 200, + 201, operations.SubscribersControllerCreateSubscriberResponse$inboundSchema, { hdrs: true, key: "Result" }, ), @@ -189,8 +222,8 @@ export async function subscribersCreate( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersCreateBulk.ts b/src/funcs/subscribersCreateBulk.ts index 914df125..05917a73 100644 --- a/src/funcs/subscribersCreateBulk.ts +++ b/src/funcs/subscribersCreateBulk.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -32,12 +33,12 @@ import { Result } from "../types/fp.js"; * Using this endpoint you can create multiple subscribers at once, to avoid multiple calls to the API. * The bulk API is limited to 500 subscribers per request. */ -export async function subscribersCreateBulk( +export function subscribersCreateBulk( client: NovuCore, bulkSubscriberCreateDto: components.BulkSubscriberCreateDto, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerBulkCreateSubscribersResponse, | errors.ErrorDto @@ -52,6 +53,38 @@ export async function subscribersCreateBulk( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + bulkSubscriberCreateDto, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + bulkSubscriberCreateDto: components.BulkSubscriberCreateDto, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerBulkCreateSubscribersResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersV1ControllerBulkCreateSubscribersRequest = { @@ -68,7 +101,7 @@ export async function subscribersCreateBulk( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.BulkSubscriberCreateDto, { @@ -125,7 +158,7 @@ export async function subscribersCreateBulk( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -152,7 +185,7 @@ export async function subscribersCreateBulk( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -194,8 +227,8 @@ export async function subscribersCreateBulk( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersCredentialsAppend.ts b/src/funcs/subscribersCredentialsAppend.ts index 0fa061d3..3b813a4c 100644 --- a/src/funcs/subscribersCredentialsAppend.ts +++ b/src/funcs/subscribersCredentialsAppend.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -31,14 +32,14 @@ import { Result } from "../types/fp.js"; * Subscriber credentials associated to the delivery methods such as slack and push tokens. * This endpoint appends provided credentials and deviceTokens to the existing ones. */ -export async function subscribersCredentialsAppend( +export function subscribersCredentialsAppend( client: NovuCore, updateSubscriberChannelRequestDto: components.UpdateSubscriberChannelRequestDto, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerModifySubscriberChannelResponse, | errors.ErrorDto @@ -53,6 +54,41 @@ export async function subscribersCredentialsAppend( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + updateSubscriberChannelRequestDto, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + updateSubscriberChannelRequestDto: + components.UpdateSubscriberChannelRequestDto, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerModifySubscriberChannelResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersV1ControllerModifySubscriberChannelRequest = { @@ -70,7 +106,7 @@ export async function subscribersCredentialsAppend( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.UpdateSubscriberChannelRequestDto, { @@ -136,7 +172,7 @@ export async function subscribersCredentialsAppend( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -163,7 +199,7 @@ export async function subscribersCredentialsAppend( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -205,8 +241,8 @@ export async function subscribersCredentialsAppend( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersCredentialsDelete.ts b/src/funcs/subscribersCredentialsDelete.ts index c115b756..90c79858 100644 --- a/src/funcs/subscribersCredentialsDelete.ts +++ b/src/funcs/subscribersCredentialsDelete.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,13 +30,13 @@ import { Result } from "../types/fp.js"; * @remarks * Delete subscriber credentials such as slack and expo tokens. */ -export async function subscribersCredentialsDelete( +export function subscribersCredentialsDelete( client: NovuCore, subscriberId: string, providerId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< | operations.SubscribersV1ControllerDeleteSubscriberCredentialsResponse | undefined, @@ -51,6 +52,41 @@ export async function subscribersCredentialsDelete( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + subscriberId, + providerId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + subscriberId: string, + providerId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + | operations.SubscribersV1ControllerDeleteSubscriberCredentialsResponse + | undefined, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersV1ControllerDeleteSubscriberCredentialsRequest = { @@ -68,7 +104,7 @@ export async function subscribersCredentialsDelete( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -135,7 +171,7 @@ export async function subscribersCredentialsDelete( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -162,7 +198,7 @@ export async function subscribersCredentialsDelete( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -206,8 +242,8 @@ export async function subscribersCredentialsDelete( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersCredentialsUpdate.ts b/src/funcs/subscribersCredentialsUpdate.ts index 328aec56..a4b8a2f7 100644 --- a/src/funcs/subscribersCredentialsUpdate.ts +++ b/src/funcs/subscribersCredentialsUpdate.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,14 +31,14 @@ import { Result } from "../types/fp.js"; * @remarks * Subscriber credentials associated to the delivery methods such as slack and push tokens. */ -export async function subscribersCredentialsUpdate( +export function subscribersCredentialsUpdate( client: NovuCore, updateSubscriberChannelRequestDto: components.UpdateSubscriberChannelRequestDto, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerUpdateSubscriberChannelResponse, | errors.ErrorDto @@ -52,6 +53,41 @@ export async function subscribersCredentialsUpdate( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + updateSubscriberChannelRequestDto, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + updateSubscriberChannelRequestDto: + components.UpdateSubscriberChannelRequestDto, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerUpdateSubscriberChannelResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersV1ControllerUpdateSubscriberChannelRequest = { @@ -69,7 +105,7 @@ export async function subscribersCredentialsUpdate( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.UpdateSubscriberChannelRequestDto, { @@ -135,7 +171,7 @@ export async function subscribersCredentialsUpdate( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -162,7 +198,7 @@ export async function subscribersCredentialsUpdate( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -204,8 +240,8 @@ export async function subscribersCredentialsUpdate( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersDelete.ts b/src/funcs/subscribersDelete.ts index df36e0fb..3d42c131 100644 --- a/src/funcs/subscribersDelete.ts +++ b/src/funcs/subscribersDelete.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,12 +30,12 @@ import { Result } from "../types/fp.js"; * @remarks * Deletes a subscriber entity from the Novu platform */ -export async function subscribersDelete( +export function subscribersDelete( client: NovuCore, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersControllerRemoveSubscriberResponse, | errors.ErrorDto @@ -49,6 +50,38 @@ export async function subscribersDelete( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersControllerRemoveSubscriberResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersControllerRemoveSubscriberRequest = { subscriberId: subscriberId, @@ -63,7 +96,7 @@ export async function subscribersDelete( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -124,7 +157,7 @@ export async function subscribersDelete( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -151,7 +184,7 @@ export async function subscribersDelete( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -192,8 +225,8 @@ export async function subscribersDelete( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersList.ts b/src/funcs/subscribersList.ts index 9e4d9b05..e5128702 100644 --- a/src/funcs/subscribersList.ts +++ b/src/funcs/subscribersList.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; import { createPageIterator, @@ -36,13 +37,13 @@ import { * @remarks * Returns a list of subscribers, could paginated using the `page` and `limit` query parameter */ -export async function subscribersList( +export function subscribersList( client: NovuCore, page?: number | undefined, limit?: number | undefined, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< PageIterator< Result< operations.SubscribersV1ControllerListSubscribersResponse, @@ -60,6 +61,43 @@ export async function subscribersList( >, { page: number } > +> { + return new APIPromise($do( + client, + page, + limit, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + page?: number | undefined, + limit?: number | undefined, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + PageIterator< + Result< + operations.SubscribersV1ControllerListSubscribersResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + { page: number } + >, + APICall, + ] > { const input: operations.SubscribersV1ControllerListSubscribersRequest = { page: page, @@ -75,7 +113,7 @@ export async function subscribersList( "Input validation failed", ); if (!parsed.ok) { - return haltIterator(parsed); + return [haltIterator(parsed), { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -135,7 +173,7 @@ export async function subscribersList( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return haltIterator(requestRes); + return [haltIterator(requestRes), { status: "invalid" }]; } const req = requestRes.value; @@ -162,7 +200,7 @@ export async function subscribersList( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return haltIterator(doResult); + return [haltIterator(doResult), { status: "request-error", request: req }]; } const response = doResult.value; @@ -203,7 +241,11 @@ export async function subscribersList( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return haltIterator(result); + return [haltIterator(result), { + status: "complete", + request: req, + response, + }]; } const nextFunc = ( @@ -255,5 +297,9 @@ export async function subscribersList( }; const page$ = { ...result, ...nextFunc(raw) }; - return { ...page$, ...createPageIterator(page$, (v) => !v.ok) }; + return [{ ...page$, ...createPageIterator(page$, (v) => !v.ok) }, { + status: "complete", + request: req, + response, + }]; } diff --git a/src/funcs/subscribersMessagesMarkAll.ts b/src/funcs/subscribersMessagesMarkAll.ts index a65277b3..b039a060 100644 --- a/src/funcs/subscribersMessagesMarkAll.ts +++ b/src/funcs/subscribersMessagesMarkAll.ts @@ -22,18 +22,19 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Marks all the subscriber messages as read, unread, seen or unseen. Optionally you can pass feed id (or array) to mark messages of a particular feed. */ -export async function subscribersMessagesMarkAll( +export function subscribersMessagesMarkAll( client: NovuCore, markAllMessageAsRequestDto: components.MarkAllMessageAsRequestDto, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerMarkAllUnreadAsReadResponse, | errors.ErrorDto @@ -48,6 +49,40 @@ export async function subscribersMessagesMarkAll( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + markAllMessageAsRequestDto, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + markAllMessageAsRequestDto: components.MarkAllMessageAsRequestDto, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerMarkAllUnreadAsReadResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersV1ControllerMarkAllUnreadAsReadRequest = { markAllMessageAsRequestDto: markAllMessageAsRequestDto, @@ -65,7 +100,7 @@ export async function subscribersMessagesMarkAll( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.MarkAllMessageAsRequestDto, { @@ -131,7 +166,7 @@ export async function subscribersMessagesMarkAll( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -158,7 +193,7 @@ export async function subscribersMessagesMarkAll( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -200,8 +235,8 @@ export async function subscribersMessagesMarkAll( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersMessagesMarkAllAs.ts b/src/funcs/subscribersMessagesMarkAllAs.ts index 96f024ac..aeea97e6 100644 --- a/src/funcs/subscribersMessagesMarkAllAs.ts +++ b/src/funcs/subscribersMessagesMarkAllAs.ts @@ -22,18 +22,19 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Mark a subscriber messages as seen, read, unseen or unread */ -export async function subscribersMessagesMarkAllAs( +export function subscribersMessagesMarkAllAs( client: NovuCore, messageMarkAsRequestDto: components.MessageMarkAsRequestDto, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerMarkMessagesAsResponse, | errors.ErrorDto @@ -48,6 +49,40 @@ export async function subscribersMessagesMarkAllAs( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + messageMarkAsRequestDto, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + messageMarkAsRequestDto: components.MessageMarkAsRequestDto, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerMarkMessagesAsResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersV1ControllerMarkMessagesAsRequest = { messageMarkAsRequestDto: messageMarkAsRequestDto, @@ -63,7 +98,7 @@ export async function subscribersMessagesMarkAllAs( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.MessageMarkAsRequestDto, { @@ -129,7 +164,7 @@ export async function subscribersMessagesMarkAllAs( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -156,7 +191,7 @@ export async function subscribersMessagesMarkAllAs( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -197,8 +232,8 @@ export async function subscribersMessagesMarkAllAs( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersMessagesUpdateAsSeen.ts b/src/funcs/subscribersMessagesUpdateAsSeen.ts index 7ef48830..35f05c46 100644 --- a/src/funcs/subscribersMessagesUpdateAsSeen.ts +++ b/src/funcs/subscribersMessagesUpdateAsSeen.ts @@ -21,16 +21,17 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Mark message action as seen */ -export async function subscribersMessagesUpdateAsSeen( +export function subscribersMessagesUpdateAsSeen( client: NovuCore, request: operations.SubscribersV1ControllerMarkActionAsSeenRequest, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerMarkActionAsSeenResponse, | errors.ErrorDto @@ -45,6 +46,36 @@ export async function subscribersMessagesUpdateAsSeen( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: NovuCore, + request: operations.SubscribersV1ControllerMarkActionAsSeenRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerMarkActionAsSeenResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const parsed = safeParse( request, @@ -54,7 +85,7 @@ export async function subscribersMessagesUpdateAsSeen( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.MarkMessageActionAsSeenDto, { @@ -128,7 +159,7 @@ export async function subscribersMessagesUpdateAsSeen( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -155,7 +186,7 @@ export async function subscribersMessagesUpdateAsSeen( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -196,8 +227,8 @@ export async function subscribersMessagesUpdateAsSeen( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersNotificationsFeed.ts b/src/funcs/subscribersNotificationsFeed.ts index 8fa1f516..2ff0f44d 100644 --- a/src/funcs/subscribersNotificationsFeed.ts +++ b/src/funcs/subscribersNotificationsFeed.ts @@ -21,16 +21,17 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Get in-app notification feed for a particular subscriber */ -export async function subscribersNotificationsFeed( +export function subscribersNotificationsFeed( client: NovuCore, request: operations.SubscribersV1ControllerGetNotificationsFeedRequest, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerGetNotificationsFeedResponse, | errors.ErrorDto @@ -45,6 +46,36 @@ export async function subscribersNotificationsFeed( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: NovuCore, + request: operations.SubscribersV1ControllerGetNotificationsFeedRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerGetNotificationsFeedResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const parsed = safeParse( request, @@ -55,7 +86,7 @@ export async function subscribersNotificationsFeed( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -127,7 +158,7 @@ export async function subscribersNotificationsFeed( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -154,7 +185,7 @@ export async function subscribersNotificationsFeed( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -196,8 +227,8 @@ export async function subscribersNotificationsFeed( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersNotificationsUnseenCount.ts b/src/funcs/subscribersNotificationsUnseenCount.ts index 43453201..568bdf58 100644 --- a/src/funcs/subscribersNotificationsUnseenCount.ts +++ b/src/funcs/subscribersNotificationsUnseenCount.ts @@ -21,16 +21,17 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Get the unseen in-app notifications count for subscribers feed */ -export async function subscribersNotificationsUnseenCount( +export function subscribersNotificationsUnseenCount( client: NovuCore, request: operations.SubscribersV1ControllerGetUnseenCountRequest, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerGetUnseenCountResponse, | errors.ErrorDto @@ -45,6 +46,36 @@ export async function subscribersNotificationsUnseenCount( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: NovuCore, + request: operations.SubscribersV1ControllerGetUnseenCountRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerGetUnseenCountResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const parsed = safeParse( request, @@ -54,7 +85,7 @@ export async function subscribersNotificationsUnseenCount( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -123,7 +154,7 @@ export async function subscribersNotificationsUnseenCount( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -150,7 +181,7 @@ export async function subscribersNotificationsUnseenCount( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -191,8 +222,8 @@ export async function subscribersNotificationsUnseenCount( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersPatch.ts b/src/funcs/subscribersPatch.ts index 49e06469..e0798531 100644 --- a/src/funcs/subscribersPatch.ts +++ b/src/funcs/subscribersPatch.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,13 +31,13 @@ import { Result } from "../types/fp.js"; * @remarks * Patch subscriber by your internal id used to identify the subscriber */ -export async function subscribersPatch( +export function subscribersPatch( client: NovuCore, patchSubscriberRequestDto: components.PatchSubscriberRequestDto, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersControllerPatchSubscriberResponse, | errors.ErrorDto @@ -51,6 +52,40 @@ export async function subscribersPatch( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + patchSubscriberRequestDto, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + patchSubscriberRequestDto: components.PatchSubscriberRequestDto, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersControllerPatchSubscriberResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersControllerPatchSubscriberRequest = { patchSubscriberRequestDto: patchSubscriberRequestDto, @@ -66,7 +101,7 @@ export async function subscribersPatch( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.PatchSubscriberRequestDto, { @@ -130,7 +165,7 @@ export async function subscribersPatch( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -157,7 +192,7 @@ export async function subscribersPatch( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -198,8 +233,8 @@ export async function subscribersPatch( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersPreferencesList.ts b/src/funcs/subscribersPreferencesList.ts index f4c28833..94097362 100644 --- a/src/funcs/subscribersPreferencesList.ts +++ b/src/funcs/subscribersPreferencesList.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,12 +30,12 @@ import { Result } from "../types/fp.js"; * @remarks * Get subscriber global and workflow specific preferences */ -export async function subscribersPreferencesList( +export function subscribersPreferencesList( client: NovuCore, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersControllerGetSubscriberPreferencesResponse, | errors.ErrorDto @@ -49,6 +50,38 @@ export async function subscribersPreferencesList( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersControllerGetSubscriberPreferencesResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersControllerGetSubscriberPreferencesRequest = { @@ -65,7 +98,7 @@ export async function subscribersPreferencesList( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -128,7 +161,7 @@ export async function subscribersPreferencesList( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -155,7 +188,7 @@ export async function subscribersPreferencesList( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -197,8 +230,8 @@ export async function subscribersPreferencesList( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersPreferencesUpdate.ts b/src/funcs/subscribersPreferencesUpdate.ts index 3986a93f..edb86841 100644 --- a/src/funcs/subscribersPreferencesUpdate.ts +++ b/src/funcs/subscribersPreferencesUpdate.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,13 +31,13 @@ import { Result } from "../types/fp.js"; * @remarks * Update subscriber global or workflow specific preferences */ -export async function subscribersPreferencesUpdate( +export function subscribersPreferencesUpdate( client: NovuCore, patchSubscriberPreferencesDto: components.PatchSubscriberPreferencesDto, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersControllerUpdateSubscriberPreferencesResponse, | errors.ErrorDto @@ -51,6 +52,40 @@ export async function subscribersPreferencesUpdate( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + patchSubscriberPreferencesDto, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + patchSubscriberPreferencesDto: components.PatchSubscriberPreferencesDto, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersControllerUpdateSubscriberPreferencesResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersControllerUpdateSubscriberPreferencesRequest = { @@ -68,7 +103,7 @@ export async function subscribersPreferencesUpdate( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.PatchSubscriberPreferencesDto, { @@ -134,7 +169,7 @@ export async function subscribersPreferencesUpdate( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -161,7 +196,7 @@ export async function subscribersPreferencesUpdate( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -203,8 +238,8 @@ export async function subscribersPreferencesUpdate( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersPropertiesUpdateOnlineFlag.ts b/src/funcs/subscribersPropertiesUpdateOnlineFlag.ts index 7dffc106..17b49ade 100644 --- a/src/funcs/subscribersPropertiesUpdateOnlineFlag.ts +++ b/src/funcs/subscribersPropertiesUpdateOnlineFlag.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,14 +31,14 @@ import { Result } from "../types/fp.js"; * @remarks * Used to update the subscriber isOnline flag. */ -export async function subscribersPropertiesUpdateOnlineFlag( +export function subscribersPropertiesUpdateOnlineFlag( client: NovuCore, updateSubscriberOnlineFlagRequestDto: components.UpdateSubscriberOnlineFlagRequestDto, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersV1ControllerUpdateSubscriberOnlineFlagResponse, | errors.ErrorDto @@ -52,6 +53,41 @@ export async function subscribersPropertiesUpdateOnlineFlag( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + updateSubscriberOnlineFlagRequestDto, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + updateSubscriberOnlineFlagRequestDto: + components.UpdateSubscriberOnlineFlagRequestDto, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersV1ControllerUpdateSubscriberOnlineFlagResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersV1ControllerUpdateSubscriberOnlineFlagRequest = { @@ -70,7 +106,7 @@ export async function subscribersPropertiesUpdateOnlineFlag( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON( @@ -138,7 +174,7 @@ export async function subscribersPropertiesUpdateOnlineFlag( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -165,7 +201,7 @@ export async function subscribersPropertiesUpdateOnlineFlag( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -207,8 +243,8 @@ export async function subscribersPropertiesUpdateOnlineFlag( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersRetrieve.ts b/src/funcs/subscribersRetrieve.ts index 01c6cd7c..85c72896 100644 --- a/src/funcs/subscribersRetrieve.ts +++ b/src/funcs/subscribersRetrieve.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,12 +30,12 @@ import { Result } from "../types/fp.js"; * @remarks * Get subscriber by your internal id used to identify the subscriber */ -export async function subscribersRetrieve( +export function subscribersRetrieve( client: NovuCore, subscriberId: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersControllerGetSubscriberResponse, | errors.ErrorDto @@ -49,6 +50,38 @@ export async function subscribersRetrieve( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + subscriberId, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + subscriberId: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersControllerGetSubscriberResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.SubscribersControllerGetSubscriberRequest = { subscriberId: subscriberId, @@ -64,7 +97,7 @@ export async function subscribersRetrieve( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -125,7 +158,7 @@ export async function subscribersRetrieve( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -152,7 +185,7 @@ export async function subscribersRetrieve( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -193,8 +226,8 @@ export async function subscribersRetrieve( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/subscribersSearch.ts b/src/funcs/subscribersSearch.ts index eb7897f8..a50b065e 100644 --- a/src/funcs/subscribersSearch.ts +++ b/src/funcs/subscribersSearch.ts @@ -21,16 +21,17 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** * Search for subscribers */ -export async function subscribersSearch( +export function subscribersSearch( client: NovuCore, request: operations.SubscribersControllerSearchSubscribersRequest, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.SubscribersControllerSearchSubscribersResponse, | errors.ErrorDto @@ -45,6 +46,36 @@ export async function subscribersSearch( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: NovuCore, + request: operations.SubscribersControllerSearchSubscribersRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.SubscribersControllerSearchSubscribersResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const parsed = safeParse( request, @@ -54,7 +85,7 @@ export async function subscribersSearch( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -121,7 +152,7 @@ export async function subscribersSearch( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -148,7 +179,7 @@ export async function subscribersSearch( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -189,8 +220,8 @@ export async function subscribersSearch( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/topicsCreate.ts b/src/funcs/topicsCreate.ts index 64ab0a81..440cd39c 100644 --- a/src/funcs/topicsCreate.ts +++ b/src/funcs/topicsCreate.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,12 +31,12 @@ import { Result } from "../types/fp.js"; * @remarks * Create a topic */ -export async function topicsCreate( +export function topicsCreate( client: NovuCore, createTopicRequestDto: components.CreateTopicRequestDto, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.TopicsControllerCreateTopicResponse, | errors.ErrorDto @@ -50,6 +51,38 @@ export async function topicsCreate( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + createTopicRequestDto, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + createTopicRequestDto: components.CreateTopicRequestDto, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.TopicsControllerCreateTopicResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.TopicsControllerCreateTopicRequest = { createTopicRequestDto: createTopicRequestDto, @@ -63,7 +96,7 @@ export async function topicsCreate( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.CreateTopicRequestDto, { @@ -120,7 +153,7 @@ export async function topicsCreate( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -147,7 +180,7 @@ export async function topicsCreate( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -187,8 +220,8 @@ export async function topicsCreate( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/topicsDelete.ts b/src/funcs/topicsDelete.ts index d02f79cb..02210b6e 100644 --- a/src/funcs/topicsDelete.ts +++ b/src/funcs/topicsDelete.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,12 +30,12 @@ import { Result } from "../types/fp.js"; * @remarks * Delete a topic by its topic key if it has no subscribers */ -export async function topicsDelete( +export function topicsDelete( client: NovuCore, topicKey: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.TopicsControllerDeleteTopicResponse | undefined, | errors.ErrorDto @@ -49,6 +50,38 @@ export async function topicsDelete( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + topicKey, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + topicKey: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.TopicsControllerDeleteTopicResponse | undefined, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.TopicsControllerDeleteTopicRequest = { topicKey: topicKey, @@ -62,7 +95,7 @@ export async function topicsDelete( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -123,7 +156,7 @@ export async function topicsDelete( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -150,7 +183,7 @@ export async function topicsDelete( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -191,8 +224,8 @@ export async function topicsDelete( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/topicsList.ts b/src/funcs/topicsList.ts index 6800e02c..f8340cde 100644 --- a/src/funcs/topicsList.ts +++ b/src/funcs/topicsList.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,11 +30,11 @@ import { Result } from "../types/fp.js"; * @remarks * Returns a list of topics that can be paginated using the `page` query parameter and filtered by the topic key with the `key` query parameter */ -export async function topicsList( +export function topicsList( client: NovuCore, request: operations.TopicsControllerListTopicsRequest, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.TopicsControllerListTopicsResponse, | errors.ErrorDto @@ -48,6 +49,36 @@ export async function topicsList( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + request, + options, + )); +} + +async function $do( + client: NovuCore, + request: operations.TopicsControllerListTopicsRequest, + options?: RequestOptions, +): Promise< + [ + Result< + operations.TopicsControllerListTopicsResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const parsed = safeParse( request, @@ -56,7 +87,7 @@ export async function topicsList( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -117,7 +148,7 @@ export async function topicsList( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -144,7 +175,7 @@ export async function topicsList( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -184,8 +215,8 @@ export async function topicsList( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/topicsRename.ts b/src/funcs/topicsRename.ts index 3a949f84..8ddab2ce 100644 --- a/src/funcs/topicsRename.ts +++ b/src/funcs/topicsRename.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,13 +31,13 @@ import { Result } from "../types/fp.js"; * @remarks * Rename a topic by providing a new name */ -export async function topicsRename( +export function topicsRename( client: NovuCore, renameTopicRequestDto: components.RenameTopicRequestDto, topicKey: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.TopicsControllerRenameTopicResponse, | errors.ErrorDto @@ -51,6 +52,40 @@ export async function topicsRename( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + renameTopicRequestDto, + topicKey, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + renameTopicRequestDto: components.RenameTopicRequestDto, + topicKey: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.TopicsControllerRenameTopicResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.TopicsControllerRenameTopicRequest = { renameTopicRequestDto: renameTopicRequestDto, @@ -65,7 +100,7 @@ export async function topicsRename( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.RenameTopicRequestDto, { @@ -129,7 +164,7 @@ export async function topicsRename( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -156,7 +191,7 @@ export async function topicsRename( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -196,8 +231,8 @@ export async function topicsRename( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/topicsRetrieve.ts b/src/funcs/topicsRetrieve.ts index 2b839e48..e1224aa8 100644 --- a/src/funcs/topicsRetrieve.ts +++ b/src/funcs/topicsRetrieve.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,12 +30,12 @@ import { Result } from "../types/fp.js"; * @remarks * Get a topic by its topic key */ -export async function topicsRetrieve( +export function topicsRetrieve( client: NovuCore, topicKey: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.TopicsControllerGetTopicResponse, | errors.ErrorDto @@ -49,6 +50,38 @@ export async function topicsRetrieve( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + topicKey, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + topicKey: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.TopicsControllerGetTopicResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.TopicsControllerGetTopicRequest = { topicKey: topicKey, @@ -62,7 +95,7 @@ export async function topicsRetrieve( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -123,7 +156,7 @@ export async function topicsRetrieve( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -150,7 +183,7 @@ export async function topicsRetrieve( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -190,8 +223,8 @@ export async function topicsRetrieve( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/topicsSubscribersAssign.ts b/src/funcs/topicsSubscribersAssign.ts index 7ef2aba2..54ac969a 100644 --- a/src/funcs/topicsSubscribersAssign.ts +++ b/src/funcs/topicsSubscribersAssign.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,13 +31,13 @@ import { Result } from "../types/fp.js"; * @remarks * Add subscribers to a topic by key */ -export async function topicsSubscribersAssign( +export function topicsSubscribersAssign( client: NovuCore, addSubscribersRequestDto: components.AddSubscribersRequestDto, topicKey: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.TopicsControllerAssignResponse, | errors.ErrorDto @@ -51,6 +52,40 @@ export async function topicsSubscribersAssign( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + addSubscribersRequestDto, + topicKey, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + addSubscribersRequestDto: components.AddSubscribersRequestDto, + topicKey: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.TopicsControllerAssignResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.TopicsControllerAssignRequest = { addSubscribersRequestDto: addSubscribersRequestDto, @@ -65,7 +100,7 @@ export async function topicsSubscribersAssign( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.AddSubscribersRequestDto, { @@ -129,7 +164,7 @@ export async function topicsSubscribersAssign( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -156,7 +191,7 @@ export async function topicsSubscribersAssign( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -196,8 +231,8 @@ export async function topicsSubscribersAssign( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/topicsSubscribersRemove.ts b/src/funcs/topicsSubscribersRemove.ts index 2bcdcbee..b15d6b5b 100644 --- a/src/funcs/topicsSubscribersRemove.ts +++ b/src/funcs/topicsSubscribersRemove.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -30,13 +31,13 @@ import { Result } from "../types/fp.js"; * @remarks * Remove subscribers from a topic */ -export async function topicsSubscribersRemove( +export function topicsSubscribersRemove( client: NovuCore, removeSubscribersRequestDto: components.RemoveSubscribersRequestDto, topicKey: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.TopicsControllerRemoveSubscribersResponse | undefined, | errors.ErrorDto @@ -51,6 +52,40 @@ export async function topicsSubscribersRemove( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + removeSubscribersRequestDto, + topicKey, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + removeSubscribersRequestDto: components.RemoveSubscribersRequestDto, + topicKey: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.TopicsControllerRemoveSubscribersResponse | undefined, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.TopicsControllerRemoveSubscribersRequest = { removeSubscribersRequestDto: removeSubscribersRequestDto, @@ -67,7 +102,7 @@ export async function topicsSubscribersRemove( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.RemoveSubscribersRequestDto, { @@ -133,7 +168,7 @@ export async function topicsSubscribersRemove( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -160,7 +195,7 @@ export async function topicsSubscribersRemove( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -202,8 +237,8 @@ export async function topicsSubscribersRemove( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/topicsSubscribersRetrieve.ts b/src/funcs/topicsSubscribersRetrieve.ts index 9c5c8c3d..542e2bdb 100644 --- a/src/funcs/topicsSubscribersRetrieve.ts +++ b/src/funcs/topicsSubscribersRetrieve.ts @@ -21,6 +21,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -29,13 +30,13 @@ import { Result } from "../types/fp.js"; * @remarks * Check if a subscriber belongs to a certain topic */ -export async function topicsSubscribersRetrieve( +export function topicsSubscribersRetrieve( client: NovuCore, externalSubscriberId: string, topicKey: string, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.TopicsControllerGetTopicSubscriberResponse, | errors.ErrorDto @@ -50,6 +51,40 @@ export async function topicsSubscribersRetrieve( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + externalSubscriberId, + topicKey, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + externalSubscriberId: string, + topicKey: string, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.TopicsControllerGetTopicSubscriberResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.TopicsControllerGetTopicSubscriberRequest = { externalSubscriberId: externalSubscriberId, @@ -66,7 +101,7 @@ export async function topicsSubscribersRetrieve( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = null; @@ -134,7 +169,7 @@ export async function topicsSubscribersRetrieve( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -161,7 +196,7 @@ export async function topicsSubscribersRetrieve( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -202,8 +237,8 @@ export async function topicsSubscribersRetrieve( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/trigger.ts b/src/funcs/trigger.ts index 68877bf4..56e188af 100644 --- a/src/funcs/trigger.ts +++ b/src/funcs/trigger.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -33,12 +34,12 @@ import { Result } from "../types/fp.js"; * The trigger identifier is used to match the particular workflow associated with it. * Additional information can be passed according the body interface below. */ -export async function trigger( +export function trigger( client: NovuCore, triggerEventRequestDto: components.TriggerEventRequestDto, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.EventsControllerTriggerResponse, | errors.ErrorDto @@ -53,6 +54,38 @@ export async function trigger( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + triggerEventRequestDto, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + triggerEventRequestDto: components.TriggerEventRequestDto, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.EventsControllerTriggerResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.EventsControllerTriggerRequest = { triggerEventRequestDto: triggerEventRequestDto, @@ -66,7 +99,7 @@ export async function trigger( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.TriggerEventRequestDto, { @@ -123,7 +156,7 @@ export async function trigger( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -150,7 +183,7 @@ export async function trigger( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -190,8 +223,8 @@ export async function trigger( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/triggerBroadcast.ts b/src/funcs/triggerBroadcast.ts index acc9963c..1a83700a 100644 --- a/src/funcs/triggerBroadcast.ts +++ b/src/funcs/triggerBroadcast.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -31,12 +32,12 @@ import { Result } from "../types/fp.js"; * Trigger a broadcast event to all existing subscribers, could be used to send announcements, etc. * In the future could be used to trigger events to a subset of subscribers based on defined filters. */ -export async function triggerBroadcast( +export function triggerBroadcast( client: NovuCore, triggerEventToAllRequestDto: components.TriggerEventToAllRequestDto, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.EventsControllerBroadcastEventToAllResponse, | errors.ErrorDto @@ -51,6 +52,38 @@ export async function triggerBroadcast( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + triggerEventToAllRequestDto, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + triggerEventToAllRequestDto: components.TriggerEventToAllRequestDto, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.EventsControllerBroadcastEventToAllResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.EventsControllerBroadcastEventToAllRequest = { triggerEventToAllRequestDto: triggerEventToAllRequestDto, @@ -65,7 +98,7 @@ export async function triggerBroadcast( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.TriggerEventToAllRequestDto, { @@ -122,7 +155,7 @@ export async function triggerBroadcast( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -149,7 +182,7 @@ export async function triggerBroadcast( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -190,8 +223,8 @@ export async function triggerBroadcast( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/funcs/triggerBulk.ts b/src/funcs/triggerBulk.ts index e5733632..b04d7bb6 100644 --- a/src/funcs/triggerBulk.ts +++ b/src/funcs/triggerBulk.ts @@ -22,6 +22,7 @@ import * as errors from "../models/errors/index.js"; import { SDKError } from "../models/errors/sdkerror.js"; import { SDKValidationError } from "../models/errors/sdkvalidationerror.js"; import * as operations from "../models/operations/index.js"; +import { APICall, APIPromise } from "../types/async.js"; import { Result } from "../types/fp.js"; /** @@ -32,12 +33,12 @@ import { Result } from "../types/fp.js"; * Using this endpoint you can trigger multiple events at once, to avoid multiple calls to the API. * The bulk API is limited to 100 events per request. */ -export async function triggerBulk( +export function triggerBulk( client: NovuCore, bulkTriggerEventDto: components.BulkTriggerEventDto, idempotencyKey?: string | undefined, options?: RequestOptions, -): Promise< +): APIPromise< Result< operations.EventsControllerTriggerBulkResponse, | errors.ErrorDto @@ -52,6 +53,38 @@ export async function triggerBulk( | RequestTimeoutError | ConnectionError > +> { + return new APIPromise($do( + client, + bulkTriggerEventDto, + idempotencyKey, + options, + )); +} + +async function $do( + client: NovuCore, + bulkTriggerEventDto: components.BulkTriggerEventDto, + idempotencyKey?: string | undefined, + options?: RequestOptions, +): Promise< + [ + Result< + operations.EventsControllerTriggerBulkResponse, + | errors.ErrorDto + | errors.ErrorDto + | errors.ValidationErrorDto + | errors.ErrorDto + | SDKError + | SDKValidationError + | UnexpectedClientError + | InvalidRequestError + | RequestAbortedError + | RequestTimeoutError + | ConnectionError + >, + APICall, + ] > { const input: operations.EventsControllerTriggerBulkRequest = { bulkTriggerEventDto: bulkTriggerEventDto, @@ -65,7 +98,7 @@ export async function triggerBulk( "Input validation failed", ); if (!parsed.ok) { - return parsed; + return [parsed, { status: "invalid" }]; } const payload = parsed.value; const body = encodeJSON("body", payload.BulkTriggerEventDto, { @@ -122,7 +155,7 @@ export async function triggerBulk( timeoutMs: options?.timeoutMs || client._options.timeoutMs || -1, }, options); if (!requestRes.ok) { - return requestRes; + return [requestRes, { status: "invalid" }]; } const req = requestRes.value; @@ -149,7 +182,7 @@ export async function triggerBulk( retryCodes: context.retryCodes, }); if (!doResult.ok) { - return doResult; + return [doResult, { status: "request-error", request: req }]; } const response = doResult.value; @@ -189,8 +222,8 @@ export async function triggerBulk( M.fail("5XX"), )(response, { extraFields: responseFields }); if (!result.ok) { - return result; + return [result, { status: "complete", request: req, response }]; } - return result; + return [result, { status: "complete", request: req, response }]; } diff --git a/src/lib/config.ts b/src/lib/config.ts index 05af29dd..cd6100f2 100644 --- a/src/lib/config.ts +++ b/src/lib/config.ts @@ -55,7 +55,7 @@ export function serverURLFromOptions(options: SDKOptions): URL | null { export const SDK_METADATA = { language: "typescript", openapiDocVersion: "1.0", - sdkVersion: "0.2.1", - genVersion: "2.512.0", - userAgent: "speakeasy-sdk/typescript 0.2.1 2.512.0 1.0 @novu/api", + sdkVersion: "0.3.0", + genVersion: "2.515.0", + userAgent: "speakeasy-sdk/typescript 0.3.0 2.515.0 1.0 @novu/api", } as const; diff --git a/src/models/components/activitynotificationtemplateresponsedto.ts b/src/models/components/activitynotificationtemplateresponsedto.ts index 0c736042..2f3259e5 100644 --- a/src/models/components/activitynotificationtemplateresponsedto.ts +++ b/src/models/components/activitynotificationtemplateresponsedto.ts @@ -13,6 +13,11 @@ import { NotificationTriggerDto$Outbound, NotificationTriggerDto$outboundSchema, } from "./notificationtriggerdto.js"; +import { + WorkflowOriginEnum, + WorkflowOriginEnum$inboundSchema, + WorkflowOriginEnum$outboundSchema, +} from "./workfloworiginenum.js"; export type ActivityNotificationTemplateResponseDto = { /** @@ -23,6 +28,10 @@ export type ActivityNotificationTemplateResponseDto = { * Name of the template */ name: string; + /** + * Origin of the workflow + */ + origin?: WorkflowOriginEnum | undefined; /** * Triggers of the template */ @@ -37,6 +46,7 @@ export const ActivityNotificationTemplateResponseDto$inboundSchema: z.ZodType< > = z.object({ _id: z.string().optional(), name: z.string(), + origin: WorkflowOriginEnum$inboundSchema.optional(), triggers: z.array(NotificationTriggerDto$inboundSchema), }).transform((v) => { return remap$(v, { @@ -48,6 +58,7 @@ export const ActivityNotificationTemplateResponseDto$inboundSchema: z.ZodType< export type ActivityNotificationTemplateResponseDto$Outbound = { _id?: string | undefined; name: string; + origin?: string | undefined; triggers: Array; }; @@ -59,6 +70,7 @@ export const ActivityNotificationTemplateResponseDto$outboundSchema: z.ZodType< > = z.object({ id: z.string().optional(), name: z.string(), + origin: WorkflowOriginEnum$outboundSchema.optional(), triggers: z.array(NotificationTriggerDto$outboundSchema), }).transform((v) => { return remap$(v, { diff --git a/src/models/components/createsubscriberrequestdto.ts b/src/models/components/createsubscriberrequestdto.ts index d3ab7fd9..a305adff 100644 --- a/src/models/components/createsubscriberrequestdto.ts +++ b/src/models/components/createsubscriberrequestdto.ts @@ -6,112 +6,46 @@ import * as z from "zod"; import { safeParse } from "../../lib/schemas.js"; import { Result as SafeParseResult } from "../../types/fp.js"; import { SDKValidationError } from "../errors/sdkvalidationerror.js"; -import { - SubscriberChannelDto, - SubscriberChannelDto$inboundSchema, - SubscriberChannelDto$Outbound, - SubscriberChannelDto$outboundSchema, -} from "./subscriberchanneldto.js"; - -export type CreateSubscriberRequestDtoData = - | string - | Array - | boolean - | number; export type CreateSubscriberRequestDto = { /** - * The internal identifier you used to create this subscriber, usually correlates to the id the user in your systems + * Unique identifier of the subscriber */ subscriberId: string; /** - * The email address of the subscriber. + * First name of the subscriber */ - email?: string | undefined; + firstName?: string | null | undefined; /** - * The first name of the subscriber. + * Last name of the subscriber */ - firstName?: string | undefined; + lastName?: string | null | undefined; /** - * The last name of the subscriber. + * Email address of the subscriber */ - lastName?: string | undefined; + email?: string | null | undefined; /** - * The phone number of the subscriber. + * Phone number of the subscriber */ - phone?: string | undefined; + phone?: string | null | undefined; /** - * An HTTP URL to the profile image of your subscriber. + * Avatar URL or identifier */ - avatar?: string | undefined; + avatar?: string | null | undefined; /** - * The locale of the subscriber. + * Timezone of the subscriber */ - locale?: string | undefined; + timezone?: string | null | undefined; /** - * An optional payload object that can contain any properties. + * Locale of the subscriber */ - data?: { [k: string]: string | Array | boolean | number } | undefined; + locale?: string | null | undefined; /** - * An optional array of subscriber channels. + * Additional custom data for the subscriber */ - channels?: Array | undefined; + data?: { [k: string]: any } | null | undefined; }; -/** @internal */ -export const CreateSubscriberRequestDtoData$inboundSchema: z.ZodType< - CreateSubscriberRequestDtoData, - z.ZodTypeDef, - unknown -> = z.union([z.string(), z.array(z.string()), z.boolean(), z.number()]); - -/** @internal */ -export type CreateSubscriberRequestDtoData$Outbound = - | string - | Array - | boolean - | number; - -/** @internal */ -export const CreateSubscriberRequestDtoData$outboundSchema: z.ZodType< - CreateSubscriberRequestDtoData$Outbound, - z.ZodTypeDef, - CreateSubscriberRequestDtoData -> = z.union([z.string(), z.array(z.string()), z.boolean(), z.number()]); - -/** - * @internal - * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. - */ -export namespace CreateSubscriberRequestDtoData$ { - /** @deprecated use `CreateSubscriberRequestDtoData$inboundSchema` instead. */ - export const inboundSchema = CreateSubscriberRequestDtoData$inboundSchema; - /** @deprecated use `CreateSubscriberRequestDtoData$outboundSchema` instead. */ - export const outboundSchema = CreateSubscriberRequestDtoData$outboundSchema; - /** @deprecated use `CreateSubscriberRequestDtoData$Outbound` instead. */ - export type Outbound = CreateSubscriberRequestDtoData$Outbound; -} - -export function createSubscriberRequestDtoDataToJSON( - createSubscriberRequestDtoData: CreateSubscriberRequestDtoData, -): string { - return JSON.stringify( - CreateSubscriberRequestDtoData$outboundSchema.parse( - createSubscriberRequestDtoData, - ), - ); -} - -export function createSubscriberRequestDtoDataFromJSON( - jsonString: string, -): SafeParseResult { - return safeParse( - jsonString, - (x) => CreateSubscriberRequestDtoData$inboundSchema.parse(JSON.parse(x)), - `Failed to parse 'CreateSubscriberRequestDtoData' from JSON`, - ); -} - /** @internal */ export const CreateSubscriberRequestDto$inboundSchema: z.ZodType< CreateSubscriberRequestDto, @@ -119,29 +53,27 @@ export const CreateSubscriberRequestDto$inboundSchema: z.ZodType< unknown > = z.object({ subscriberId: z.string(), - email: z.string().optional(), - firstName: z.string().optional(), - lastName: z.string().optional(), - phone: z.string().optional(), - avatar: z.string().optional(), - locale: z.string().optional(), - data: z.record( - z.union([z.string(), z.array(z.string()), z.boolean(), z.number()]), - ).optional(), - channels: z.array(SubscriberChannelDto$inboundSchema).optional(), + firstName: z.nullable(z.string()).optional(), + lastName: z.nullable(z.string()).optional(), + email: z.nullable(z.string()).optional(), + phone: z.nullable(z.string()).optional(), + avatar: z.nullable(z.string()).optional(), + timezone: z.nullable(z.string()).optional(), + locale: z.nullable(z.string()).optional(), + data: z.nullable(z.record(z.any())).optional(), }); /** @internal */ export type CreateSubscriberRequestDto$Outbound = { subscriberId: string; - email?: string | undefined; - firstName?: string | undefined; - lastName?: string | undefined; - phone?: string | undefined; - avatar?: string | undefined; - locale?: string | undefined; - data?: { [k: string]: string | Array | boolean | number } | undefined; - channels?: Array | undefined; + firstName?: string | null | undefined; + lastName?: string | null | undefined; + email?: string | null | undefined; + phone?: string | null | undefined; + avatar?: string | null | undefined; + timezone?: string | null | undefined; + locale?: string | null | undefined; + data?: { [k: string]: any } | null | undefined; }; /** @internal */ @@ -151,16 +83,14 @@ export const CreateSubscriberRequestDto$outboundSchema: z.ZodType< CreateSubscriberRequestDto > = z.object({ subscriberId: z.string(), - email: z.string().optional(), - firstName: z.string().optional(), - lastName: z.string().optional(), - phone: z.string().optional(), - avatar: z.string().optional(), - locale: z.string().optional(), - data: z.record( - z.union([z.string(), z.array(z.string()), z.boolean(), z.number()]), - ).optional(), - channels: z.array(SubscriberChannelDto$outboundSchema).optional(), + firstName: z.nullable(z.string()).optional(), + lastName: z.nullable(z.string()).optional(), + email: z.nullable(z.string()).optional(), + phone: z.nullable(z.string()).optional(), + avatar: z.nullable(z.string()).optional(), + timezone: z.nullable(z.string()).optional(), + locale: z.nullable(z.string()).optional(), + data: z.nullable(z.record(z.any())).optional(), }); /** diff --git a/src/models/components/index.ts b/src/models/components/index.ts index ad553ebe..ad3462a8 100644 --- a/src/models/components/index.ts +++ b/src/models/components/index.ts @@ -113,5 +113,6 @@ export * from "./updateintegrationrequestdto.js"; export * from "./updatesubscriberchannelrequestdto.js"; export * from "./updatesubscriberonlineflagrequestdto.js"; export * from "./workflowinfodto.js"; +export * from "./workfloworiginenum.js"; export * from "./workflowpreferencedto.js"; export * from "./workflowresponse.js"; diff --git a/src/models/components/patchsubscriberrequestdto.ts b/src/models/components/patchsubscriberrequestdto.ts index 2a0d135c..be79a664 100644 --- a/src/models/components/patchsubscriberrequestdto.ts +++ b/src/models/components/patchsubscriberrequestdto.ts @@ -13,10 +13,6 @@ import { SDKValidationError } from "../errors/sdkvalidationerror.js"; export type PatchSubscriberRequestDtoData = {}; export type PatchSubscriberRequestDto = { - /** - * Unique identifier of the subscriber - */ - subscriberId?: string | null | undefined; /** * First name of the subscriber */ @@ -107,7 +103,6 @@ export const PatchSubscriberRequestDto$inboundSchema: z.ZodType< z.ZodTypeDef, unknown > = z.object({ - subscriberId: z.nullable(z.string()).optional(), firstName: z.nullable(z.string()).optional(), lastName: z.nullable(z.string()).optional(), email: z.nullable(z.string()).optional(), @@ -121,7 +116,6 @@ export const PatchSubscriberRequestDto$inboundSchema: z.ZodType< /** @internal */ export type PatchSubscriberRequestDto$Outbound = { - subscriberId?: string | null | undefined; firstName?: string | null | undefined; lastName?: string | null | undefined; email?: string | null | undefined; @@ -138,7 +132,6 @@ export const PatchSubscriberRequestDto$outboundSchema: z.ZodType< z.ZodTypeDef, PatchSubscriberRequestDto > = z.object({ - subscriberId: z.nullable(z.string()).optional(), firstName: z.nullable(z.string()).optional(), lastName: z.nullable(z.string()).optional(), email: z.nullable(z.string()).optional(), diff --git a/src/models/components/subscriberpayloaddto.ts b/src/models/components/subscriberpayloaddto.ts index 9f48163e..d93133c6 100644 --- a/src/models/components/subscriberpayloaddto.ts +++ b/src/models/components/subscriberpayloaddto.ts @@ -52,6 +52,10 @@ export type SubscriberPayloadDto = { * An optional array of subscriber channels. */ channels?: Array | undefined; + /** + * The timezone of the subscriber. + */ + timezone?: string | undefined; }; /** @internal */ @@ -109,6 +113,7 @@ export const SubscriberPayloadDto$inboundSchema: z.ZodType< z.union([z.string(), z.array(z.string()), z.boolean(), z.number()]), ).optional(), channels: z.array(SubscriberChannelDto$inboundSchema).optional(), + timezone: z.string().optional(), }); /** @internal */ @@ -122,6 +127,7 @@ export type SubscriberPayloadDto$Outbound = { locale?: string | undefined; data?: { [k: string]: string | Array | boolean | number } | undefined; channels?: Array | undefined; + timezone?: string | undefined; }; /** @internal */ @@ -141,6 +147,7 @@ export const SubscriberPayloadDto$outboundSchema: z.ZodType< z.union([z.string(), z.array(z.string()), z.boolean(), z.number()]), ).optional(), channels: z.array(SubscriberChannelDto$outboundSchema).optional(), + timezone: z.string().optional(), }); /** diff --git a/src/models/components/triggereventresponsedto.ts b/src/models/components/triggereventresponsedto.ts index e084c6d5..17dac694 100644 --- a/src/models/components/triggereventresponsedto.ts +++ b/src/models/components/triggereventresponsedto.ts @@ -18,6 +18,7 @@ export const Status = { NoWorkflowStepsDefined: "no_workflow_steps_defined", Processed: "processed", NoTenantFound: "no_tenant_found", + InvalidRecipients: "invalid_recipients", } as const; /** * Status of the trigger diff --git a/src/models/components/workfloworiginenum.ts b/src/models/components/workfloworiginenum.ts new file mode 100644 index 00000000..a406ad14 --- /dev/null +++ b/src/models/components/workfloworiginenum.ts @@ -0,0 +1,40 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +import * as z from "zod"; +import { ClosedEnum } from "../../types/enums.js"; + +/** + * Origin of the workflow + */ +export const WorkflowOriginEnum = { + NovuCloud: "novu-cloud", + NovuCloudV1: "novu-cloud-v1", + External: "external", +} as const; +/** + * Origin of the workflow + */ +export type WorkflowOriginEnum = ClosedEnum; + +/** @internal */ +export const WorkflowOriginEnum$inboundSchema: z.ZodNativeEnum< + typeof WorkflowOriginEnum +> = z.nativeEnum(WorkflowOriginEnum); + +/** @internal */ +export const WorkflowOriginEnum$outboundSchema: z.ZodNativeEnum< + typeof WorkflowOriginEnum +> = WorkflowOriginEnum$inboundSchema; + +/** + * @internal + * @deprecated This namespace will be removed in future versions. Use schemas and types that are exported directly from this module. + */ +export namespace WorkflowOriginEnum$ { + /** @deprecated use `WorkflowOriginEnum$inboundSchema` instead. */ + export const inboundSchema = WorkflowOriginEnum$inboundSchema; + /** @deprecated use `WorkflowOriginEnum$outboundSchema` instead. */ + export const outboundSchema = WorkflowOriginEnum$outboundSchema; +} diff --git a/src/models/operations/notificationscontrollerlistnotifications.ts b/src/models/operations/notificationscontrollerlistnotifications.ts index a732bde0..ce2fdb34 100644 --- a/src/models/operations/notificationscontrollerlistnotifications.ts +++ b/src/models/operations/notificationscontrollerlistnotifications.ts @@ -36,6 +36,10 @@ export type NotificationsControllerListNotificationsRequest = { * Page number for pagination */ page?: number | undefined; + /** + * Limit for pagination + */ + limit?: number | undefined; /** * Transaction ID for filtering */ @@ -72,6 +76,7 @@ export const NotificationsControllerListNotificationsRequest$inboundSchema: search: z.string().optional(), subscriberIds: z.array(z.string()).optional(), page: z.number().default(0), + limit: z.number().default(10), transactionId: z.string().optional(), after: z.string().optional(), before: z.string().optional(), @@ -90,6 +95,7 @@ export type NotificationsControllerListNotificationsRequest$Outbound = { search?: string | undefined; subscriberIds?: Array | undefined; page: number; + limit: number; transactionId?: string | undefined; after?: string | undefined; before?: string | undefined; @@ -109,6 +115,7 @@ export const NotificationsControllerListNotificationsRequest$outboundSchema: search: z.string().optional(), subscriberIds: z.array(z.string()).optional(), page: z.number().default(0), + limit: z.number().default(10), transactionId: z.string().optional(), after: z.string().optional(), before: z.string().optional(), diff --git a/src/types/async.ts b/src/types/async.ts new file mode 100644 index 00000000..689dba5d --- /dev/null +++ b/src/types/async.ts @@ -0,0 +1,68 @@ +/* + * Code generated by Speakeasy (https://speakeasy.com). DO NOT EDIT. + */ + +export type APICall = + | { + status: "complete"; + request: Request; + response: Response; + } + | { + status: "request-error"; + request: Request; + response?: undefined; + } + | { + status: "invalid"; + request?: undefined; + response?: undefined; + }; + +export class APIPromise implements Promise { + readonly #promise: Promise<[T, APICall]>; + readonly #unwrapped: Promise; + + readonly [Symbol.toStringTag] = "APIPromise"; + + constructor(p: [T, APICall] | Promise<[T, APICall]>) { + this.#promise = p instanceof Promise ? p : Promise.resolve(p); + this.#unwrapped = + p instanceof Promise + ? this.#promise.then(([value]) => value) + : Promise.resolve(p[0]); + } + + then( + onfulfilled?: + | ((value: T) => TResult1 | PromiseLike) + | null + | undefined, + onrejected?: + | ((reason: any) => TResult2 | PromiseLike) + | null + | undefined, + ): Promise { + return this.#promise.then( + onfulfilled ? ([value]) => onfulfilled(value) : void 0, + onrejected, + ); + } + + catch( + onrejected?: + | ((reason: any) => TResult | PromiseLike) + | null + | undefined, + ): Promise { + return this.#unwrapped.catch(onrejected); + } + + finally(onfinally?: (() => void) | null | undefined): Promise { + return this.#unwrapped.finally(onfinally); + } + + $inspect(): Promise<[T, APICall]> { + return this.#promise; + } +}