diff --git a/.changeset/hip-dancers-move.md b/.changeset/hip-dancers-move.md new file mode 100644 index 00000000..cdb1c51f --- /dev/null +++ b/.changeset/hip-dancers-move.md @@ -0,0 +1,6 @@ +--- +'@magicbell/project-client': minor +'@magicbell/user-client': minor +--- + +use fetch as http client diff --git a/packages/project-client/README.md b/packages/project-client/README.md index e6d18be9..22e8a884 100644 --- a/packages/project-client/README.md +++ b/packages/project-client/README.md @@ -19,6 +19,7 @@ OpenAPI 3.1.0 Specification for MagicBell API. - [Authentication](#authentication) - [Access Token Authentication](#access-token-authentication) - [Setting a Custom Timeout](#setting-a-custom-timeout) +- [Sample Usage](#sample-usage) - [Services](#services) - [Models](#models) @@ -67,6 +68,24 @@ You can set a custom timeout for the SDK's HTTP requests as follows: const client = new Client({ timeout: 10000 }); ``` +# Sample Usage + +Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint: + +```ts +import { Client } from '@magicbell/project-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const { data } = await client.broadcasts.listBroadcasts(); + + console.log(data); +})(); +``` + ## Services The SDK provides various services to interact with the API. @@ -96,6 +115,8 @@ The SDK includes several models that represent the data structures used in API r | [Broadcast](documentation/models/Broadcast.md) | | | [ListIntegrationsResponse](documentation/models/ListIntegrationsResponse.md) | | | [ApnsConfig](documentation/models/ApnsConfig.md) | | +| [AwssnsConfig](documentation/models/AwssnsConfig.md) | | +| [ExpoConfig](documentation/models/ExpoConfig.md) | | | [FcmConfig](documentation/models/FcmConfig.md) | | | [GithubConfig](documentation/models/GithubConfig.md) | | | [InboxConfig](documentation/models/InboxConfig.md) | | @@ -112,11 +133,11 @@ The SDK includes several models that represent the data structures used in API r | [AccessToken](documentation/models/AccessToken.md) | | | [DiscardTokenResponse](documentation/models/DiscardTokenResponse.md) | | | [CreateUserTokenRequest](documentation/models/CreateUserTokenRequest.md) | | -| [ArrayWithMetadataOfInboxToken](documentation/models/ArrayWithMetadataOfInboxToken.md) | | -| [InboxTokenWithMetadata](documentation/models/InboxTokenWithMetadata.md) | | -| [DiscardResult](documentation/models/DiscardResult.md) | | | [ArrayWithMetadataOfApnsToken](documentation/models/ArrayWithMetadataOfApnsToken.md) | | | [ApnsTokenWithMetadata](documentation/models/ApnsTokenWithMetadata.md) | | +| [DiscardResult](documentation/models/DiscardResult.md) | | +| [ArrayWithMetadataOfExpoToken](documentation/models/ArrayWithMetadataOfExpoToken.md) | | +| [ExpoTokenWithMetadata](documentation/models/ExpoTokenWithMetadata.md) | | | [ArrayWithMetadataOfFcmToken](documentation/models/ArrayWithMetadataOfFcmToken.md) | | | [FcmTokenWithMetadata](documentation/models/FcmTokenWithMetadata.md) | | | [ArrayWithMetadataOfSlackToken](documentation/models/ArrayWithMetadataOfSlackToken.md) | | @@ -125,10 +146,11 @@ The SDK includes several models that represent the data structures used in API r | [TeamsTokenWithMetadata](documentation/models/TeamsTokenWithMetadata.md) | | | [ArrayWithMetadataOfWebPushToken](documentation/models/ArrayWithMetadataOfWebPushToken.md) | | | [WebPushTokenWithMetadata](documentation/models/WebPushTokenWithMetadata.md) | | -| [InboxToken](documentation/models/InboxToken.md) | | | [ApnsToken](documentation/models/ApnsToken.md) | | +| [ExpoToken](documentation/models/ExpoToken.md) | | | [FcmToken](documentation/models/FcmToken.md) | | | [SlackToken](documentation/models/SlackToken.md) | | +| [TeamsToken](documentation/models/TeamsToken.md) | | | [WebPushToken](documentation/models/WebPushToken.md) | | diff --git a/packages/project-client/docs/models/ArrayWithMetadataOfApnsToken.md b/packages/project-client/docs/models/ArrayWithMetadataOfApnsToken.md index 802e12a2..63f11103 100644 --- a/packages/project-client/docs/models/ArrayWithMetadataOfApnsToken.md +++ b/packages/project-client/docs/models/ArrayWithMetadataOfApnsToken.md @@ -13,9 +13,9 @@ | Name | Type | Required | Description | | :------- | :------------ | :------- | :---------- | | data | ApnsToken | ✅ | | -| metadata | DataMetadata2 | ✅ | | +| metadata | DataMetadata1 | ✅ | | -# DataMetadata2 +# DataMetadata1 **Properties** diff --git a/packages/project-client/docs/models/ArrayWithMetadataOfInboxToken.md b/packages/project-client/docs/models/ArrayWithMetadataOfExpoToken.md similarity index 53% rename from packages/project-client/docs/models/ArrayWithMetadataOfInboxToken.md rename to packages/project-client/docs/models/ArrayWithMetadataOfExpoToken.md index a3bd4dda..5ae9a1b5 100644 --- a/packages/project-client/docs/models/ArrayWithMetadataOfInboxToken.md +++ b/packages/project-client/docs/models/ArrayWithMetadataOfExpoToken.md @@ -1,21 +1,21 @@ -# ArrayWithMetadataOfInboxToken +# ArrayWithMetadataOfExpoToken **Properties** -| Name | Type | Required | Description | -| :--- | :---------------------------------- | :------- | :---------- | -| data | ArrayWithMetadataOfInboxTokenData[] | ✅ | | +| Name | Type | Required | Description | +| :--- | :--------------------------------- | :------- | :---------- | +| data | ArrayWithMetadataOfExpoTokenData[] | ✅ | | -# ArrayWithMetadataOfInboxTokenData +# ArrayWithMetadataOfExpoTokenData **Properties** | Name | Type | Required | Description | | :------- | :------------ | :------- | :---------- | -| data | InboxToken | ✅ | | -| metadata | DataMetadata1 | ✅ | | +| data | ExpoToken | ✅ | | +| metadata | DataMetadata2 | ✅ | | -# DataMetadata1 +# DataMetadata2 **Properties** diff --git a/packages/project-client/docs/models/ArrayWithMetadataOfTeamsToken.md b/packages/project-client/docs/models/ArrayWithMetadataOfTeamsToken.md index d3b3c426..b2ac9e7d 100644 --- a/packages/project-client/docs/models/ArrayWithMetadataOfTeamsToken.md +++ b/packages/project-client/docs/models/ArrayWithMetadataOfTeamsToken.md @@ -12,7 +12,7 @@ | Name | Type | Required | Description | | :------- | :------------ | :------- | :---------- | -| data | any | ✅ | | +| data | TeamsToken | ✅ | | | metadata | DataMetadata5 | ✅ | | # DataMetadata5 diff --git a/packages/project-client/docs/models/AwssnsConfig.md b/packages/project-client/docs/models/AwssnsConfig.md new file mode 100644 index 00000000..4b894014 --- /dev/null +++ b/packages/project-client/docs/models/AwssnsConfig.md @@ -0,0 +1,7 @@ +# AwssnsConfig + +**Properties** + +| Name | Type | Required | Description | +| :------------------- | :----- | :------- | :----------------------------------- | +| webhookSigningSecret | string | ✅ | The signing certificate from AWS SNS | diff --git a/packages/project-client/docs/models/Broadcast.md b/packages/project-client/docs/models/Broadcast.md index 551cd09c..6483dd31 100644 --- a/packages/project-client/docs/models/Broadcast.md +++ b/packages/project-client/docs/models/Broadcast.md @@ -7,11 +7,13 @@ | recipients | any[] | ✅ | | | title | string | ✅ | | | actionUrl | string | ❌ | | -| category | string | ❌ | | +| category | Category | ❌ | | | content | string | ❌ | | | customAttributes | any | ❌ | | | overrides | Overrides | ❌ | | -| topic | string | ❌ | | +| topic | Topic | ❌ | | + +# Category # Overrides @@ -108,3 +110,5 @@ | postmark | any | ❌ | | | sendgrid | any | ❌ | | | slack | any | ❌ | | + +# Topic diff --git a/packages/project-client/docs/models/ExpoConfig.md b/packages/project-client/docs/models/ExpoConfig.md new file mode 100644 index 00000000..9a46bc62 --- /dev/null +++ b/packages/project-client/docs/models/ExpoConfig.md @@ -0,0 +1,7 @@ +# ExpoConfig + +**Properties** + +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :---------- | +| accessToken | string | ✅ | | diff --git a/packages/project-client/docs/models/ExpoToken.md b/packages/project-client/docs/models/ExpoToken.md new file mode 100644 index 00000000..9dd82412 --- /dev/null +++ b/packages/project-client/docs/models/ExpoToken.md @@ -0,0 +1,7 @@ +# ExpoToken + +**Properties** + +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :---------- | +| deviceToken | string | ✅ | | diff --git a/packages/project-client/docs/models/ExpoTokenWithMetadata.md b/packages/project-client/docs/models/ExpoTokenWithMetadata.md new file mode 100644 index 00000000..5f6ca5cf --- /dev/null +++ b/packages/project-client/docs/models/ExpoTokenWithMetadata.md @@ -0,0 +1,19 @@ +# ExpoTokenWithMetadata + +**Properties** + +| Name | Type | Required | Description | +| :------- | :---------------------------- | :------- | :---------- | +| data | ExpoToken | ✅ | | +| metadata | ExpoTokenWithMetadataMetadata | ✅ | | + +# ExpoTokenWithMetadataMetadata + +**Properties** + +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :---------- | +| createdAt | string | ✅ | | +| id | string | ✅ | | +| discardedAt | string | ❌ | | +| updatedAt | string | ❌ | | diff --git a/packages/project-client/docs/models/GithubConfig.md b/packages/project-client/docs/models/GithubConfig.md index e884bcf7..7a25db58 100644 --- a/packages/project-client/docs/models/GithubConfig.md +++ b/packages/project-client/docs/models/GithubConfig.md @@ -4,4 +4,4 @@ | Name | Type | Required | Description | | :------------------- | :----- | :------- | :--------------------------------------------------------- | -| webhookSigningSecret | string | ✅ | The signing secret to verify incoming requests from Stripe | +| webhookSigningSecret | string | ✅ | The signing secret to verify incoming requests from Github | diff --git a/packages/project-client/docs/models/InboxConfig.md b/packages/project-client/docs/models/InboxConfig.md index 6d7cda95..db5fb9e5 100644 --- a/packages/project-client/docs/models/InboxConfig.md +++ b/packages/project-client/docs/models/InboxConfig.md @@ -4,6 +4,184 @@ | Name | Type | Required | Description | | :----- | :----- | :------- | :---------- | -| images | any | ✅ | | +| images | Images | ✅ | | | locale | string | ✅ | | -| theme | any | ✅ | | +| theme | Theme | ✅ | | + +# Images + +**Properties** + +| Name | Type | Required | Description | +| :------------ | :----- | :------- | :---------- | +| emptyInboxUrl | string | ✅ | | + +# Theme + +**Properties** + +| Name | Type | Required | Description | +| :----------- | :----------- | :------- | :---------- | +| banner | Banner | ❌ | | +| dialog | Dialog | ❌ | | +| footer | Footer | ❌ | | +| header | Header | ❌ | | +| icon | Icon | ❌ | | +| notification | Notification | ❌ | | +| unseenBadge | UnseenBadge | ❌ | | + +# Banner + +**Properties** + +| Name | Type | Required | Description | +| :---------------- | :----- | :------- | :---------- | +| backgroundColor | string | ✅ | | +| fontSize | string | ✅ | | +| textColor | string | ✅ | | +| backgroundOpacity | number | ❌ | | + +# Dialog + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------- | +| accentColor | string | ✅ | | +| backgroundColor | string | ✅ | | +| textColor | string | ✅ | | + +# Footer + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------- | +| backgroundColor | string | ✅ | | +| borderRadius | string | ✅ | | +| fontSize | string | ✅ | | +| textColor | string | ✅ | | + +# Header + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------- | +| backgroundColor | string | ✅ | | +| borderRadius | string | ✅ | | +| fontFamily | string | ✅ | | +| fontSize | string | ✅ | | +| textColor | string | ✅ | | + +# Icon + +**Properties** + +| Name | Type | Required | Description | +| :---------- | :----- | :------- | :---------- | +| borderColor | string | ✅ | | +| width | string | ✅ | | + +# Notification + +**Properties** + +| Name | Type | Required | Description | +| :------ | :-------- | :------- | :---------- | +| default | Default\_ | ✅ | | +| unread | Unread | ✅ | | +| unseen | Unseen | ✅ | | + +# Default\_ + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :----------- | :------- | :---------- | +| backgroundColor | string | ✅ | | +| borderRadius | string | ✅ | | +| fontFamily | string | ✅ | | +| fontSize | string | ✅ | | +| margin | string | ✅ | | +| textColor | string | ✅ | | +| hover | DefaultHover | ❌ | | +| state | DefaultState | ❌ | | + +# DefaultHover + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------- | +| backgroundColor | string | ✅ | | + +# DefaultState + +**Properties** + +| Name | Type | Required | Description | +| :---- | :----- | :------- | :---------- | +| color | string | ✅ | | + +# Unread + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :---------- | :------- | :---------- | +| backgroundColor | string | ✅ | | +| textColor | string | ✅ | | +| hover | UnreadHover | ❌ | | +| state | UnreadState | ❌ | | + +# UnreadHover + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------- | +| backgroundColor | string | ✅ | | + +# UnreadState + +**Properties** + +| Name | Type | Required | Description | +| :---- | :----- | :------- | :---------- | +| color | string | ✅ | | + +# Unseen + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :---------- | :------- | :---------- | +| backgroundColor | string | ✅ | | +| textColor | string | ✅ | | +| hover | UnseenHover | ❌ | | +| state | UnseenState | ❌ | | + +# UnseenHover + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------- | +| backgroundColor | string | ✅ | | + +# UnseenState + +**Properties** + +| Name | Type | Required | Description | +| :---- | :----- | :------- | :---------- | +| color | string | ✅ | | + +# UnseenBadge + +**Properties** + +| Name | Type | Required | Description | +| :-------------- | :----- | :------- | :---------- | +| backgroundColor | string | ✅ | | diff --git a/packages/project-client/docs/models/InboxToken.md b/packages/project-client/docs/models/InboxToken.md deleted file mode 100644 index b940caf6..00000000 --- a/packages/project-client/docs/models/InboxToken.md +++ /dev/null @@ -1,7 +0,0 @@ -# InboxToken - -**Properties** - -| Name | Type | Required | Description | -| :---- | :----- | :------- | :---------- | -| token | string | ✅ | | diff --git a/packages/project-client/docs/models/InboxTokenWithMetadata.md b/packages/project-client/docs/models/InboxTokenWithMetadata.md deleted file mode 100644 index 00839c8c..00000000 --- a/packages/project-client/docs/models/InboxTokenWithMetadata.md +++ /dev/null @@ -1,19 +0,0 @@ -# InboxTokenWithMetadata - -**Properties** - -| Name | Type | Required | Description | -| :------- | :----------------------------- | :------- | :---------- | -| data | InboxToken | ✅ | | -| metadata | InboxTokenWithMetadataMetadata | ✅ | | - -# InboxTokenWithMetadataMetadata - -**Properties** - -| Name | Type | Required | Description | -| :---------- | :----- | :------- | :---------- | -| createdAt | string | ✅ | | -| id | string | ✅ | | -| discardedAt | string | ❌ | | -| updatedAt | string | ❌ | | diff --git a/packages/project-client/docs/models/SlackConfig.md b/packages/project-client/docs/models/SlackConfig.md index 0366f21d..fe650c64 100644 --- a/packages/project-client/docs/models/SlackConfig.md +++ b/packages/project-client/docs/models/SlackConfig.md @@ -8,4 +8,3 @@ | clientId | string | ✅ | | | clientSecret | string | ✅ | | | signingSecret | string | ✅ | | -| id | string | ❌ | | diff --git a/packages/project-client/docs/models/SlackToken.md b/packages/project-client/docs/models/SlackToken.md index 03697085..58940692 100644 --- a/packages/project-client/docs/models/SlackToken.md +++ b/packages/project-client/docs/models/SlackToken.md @@ -2,10 +2,10 @@ **Properties** -| Name | Type | Required | Description | -| :------ | :------ | :------- | :---------- | -| oauth | Oauth | ❌ | | -| webhook | Webhook | ❌ | | +| Name | Type | Required | Description | +| :------ | :---------------- | :------- | :---------- | +| oauth | Oauth | ❌ | | +| webhook | SlackTokenWebhook | ❌ | | # Oauth @@ -17,7 +17,7 @@ | installationId | string | ✅ | | | scope | string | ❌ | | -# Webhook +# SlackTokenWebhook **Properties** diff --git a/packages/project-client/docs/models/TeamsToken.md b/packages/project-client/docs/models/TeamsToken.md new file mode 100644 index 00000000..fb141818 --- /dev/null +++ b/packages/project-client/docs/models/TeamsToken.md @@ -0,0 +1,15 @@ +# TeamsToken + +**Properties** + +| Name | Type | Required | Description | +| :------ | :---------------- | :------- | :---------- | +| webhook | TeamsTokenWebhook | ❌ | | + +# TeamsTokenWebhook + +**Properties** + +| Name | Type | Required | Description | +| :--- | :----- | :------- | :---------- | +| url | string | ❌ | | diff --git a/packages/project-client/docs/models/TeamsTokenWithMetadata.md b/packages/project-client/docs/models/TeamsTokenWithMetadata.md index 780c16ec..38e80dc8 100644 --- a/packages/project-client/docs/models/TeamsTokenWithMetadata.md +++ b/packages/project-client/docs/models/TeamsTokenWithMetadata.md @@ -4,7 +4,7 @@ | Name | Type | Required | Description | | :------- | :----------------------------- | :------- | :---------- | -| data | any | ✅ | | +| data | TeamsToken | ✅ | | | metadata | TeamsTokenWithMetadataMetadata | ✅ | | # TeamsTokenWithMetadataMetadata diff --git a/packages/project-client/docs/services/BroadcastsService.md b/packages/project-client/docs/services/BroadcastsService.md index 6144365d..ec6b3fdc 100644 --- a/packages/project-client/docs/services/BroadcastsService.md +++ b/packages/project-client/docs/services/BroadcastsService.md @@ -2,13 +2,13 @@ A list of all methods in the `BroadcastsService` service. Click on the method name to view detailed information about that method. -| Methods | Description | -| :------------------------------------ | :--------------------------------------- | -| [list_broadcasts](#list_broadcasts) | Returns a list of broadcasts | -| [create_broadcast](#create_broadcast) | Handles the create notification request. | -| [fetch_broadcast](#fetch_broadcast) | Returns a broadcast | +| Methods | Description | +| :---------------------------------- | :--------------------------------------- | +| [listBroadcasts](#listbroadcasts) | Returns a list of broadcasts | +| [createBroadcast](#createbroadcast) | Handles the create notification request. | +| [fetchBroadcast](#fetchbroadcast) | Returns a broadcast | -## list_broadcasts +## listBroadcasts Returns a list of broadcasts @@ -35,7 +35,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## create_broadcast +## createBroadcast Handles the create notification request. @@ -62,40 +62,42 @@ import { Broadcast, Client } from '@magicbell/project-client'; token: 'YOUR_TOKEN', }); + const category = 'Mx'; + const email: Email = { - actionUrl: 'ipsum esse', - content: 'sit veniam', - title: 'in id ex aliqua', + actionUrl: 'laborum commodo magna', + content: 'exdolore elit', + title: 'Excepteur occaecat eu ipsum', }; const inApp: InApp = { - actionUrl: 'ullamco labore voluptate', - content: 'consequat magna Excepteur dolor mollit', - title: 'irure', + actionUrl: 'inest ea elit exercitation dolore', + content: 'aute eiusmod ea', + title: 'nisi elit amet laboris tempor', }; const mobilePush: MobilePush = { - actionUrl: 'elitdolore adipisicing anim elit deserunt', - content: 'cupidatat elit', - title: 'ut', + actionUrl: 'nulla consequat do incididunt', + content: 'incididunt', + title: 'dolore labore', }; const slack: Slack = { - actionUrl: 'sit commodo consectetur Duis', - content: 'proident sed quis Lorem', - title: 'magna reprehenderit ut deserunt nisi', + actionUrl: 'sunt ullamco esse', + content: 'aliqua amet', + title: 'aliquip', }; const sms: Sms = { - actionUrl: 'irure Excepteur exercitation', - content: 'et adipisicing in elit', - title: 'sint voluptate ipsum cupidatat', + actionUrl: 'sit Excepteur', + content: 'incididunt laboris', + title: 'qui', }; const webPush: WebPush = { - actionUrl: 'dolor in elit id', - content: 'est ea elit exercitation dolore', - title: 'aute eiusmod ea', + actionUrl: 'Excepteur laboris est', + content: 'veniam sed ullamco', + title: 'volupta', }; const channels: Channels = { @@ -122,15 +124,17 @@ import { Broadcast, Client } from '@magicbell/project-client'; providers: providers, }; + const topic = 'sPebCt_M0'; + const broadcast: Broadcast = { - actionUrl: 'Ut aliquip est laboris', - category: 'sint in eu tempor magna', - content: 'aliqua ad dolor officia', + actionUrl: 'tempor enim', + category: category, + content: 'nostrud', customAttributes: {}, overrides: overrides, recipients: [{}], - title: 'nisi elit amet laboris tempor', - topic: 'nulla consequat do incididunt', + title: 'reprehenderit culpa aliqua ', + topic: topic, }; const { data } = await client.broadcasts.createBroadcast(input); @@ -139,7 +143,7 @@ import { Broadcast, Client } from '@magicbell/project-client'; })(); ``` -## fetch_broadcast +## fetchBroadcast Returns a broadcast diff --git a/packages/project-client/docs/services/ChannelsService.md b/packages/project-client/docs/services/ChannelsService.md index a3479444..091fbf6b 100644 --- a/packages/project-client/docs/services/ChannelsService.md +++ b/packages/project-client/docs/services/ChannelsService.md @@ -2,31 +2,31 @@ A list of all methods in the `ChannelsService` service. Click on the method name to view detailed information about that method. -| Methods | Description | -| :-------------------------------------------------------------------------- | :---------- | -| [get_in_app_user_tokens](#get_in_app_user_tokens) | | -| [get_in_app_user_token](#get_in_app_user_token) | | -| [discard_in_app_user_token](#discard_in_app_user_token) | | -| [get_mobile_push_apns_user_tokens](#get_mobile_push_apns_user_tokens) | | -| [get_mobile_push_apns_user_token](#get_mobile_push_apns_user_token) | | -| [discard_mobile_push_apns_user_token](#discard_mobile_push_apns_user_token) | | -| [get_mobile_push_fcm_user_tokens](#get_mobile_push_fcm_user_tokens) | | -| [get_mobile_push_fcm_user_token](#get_mobile_push_fcm_user_token) | | -| [discard_mobile_push_fcm_user_token](#discard_mobile_push_fcm_user_token) | | -| [get_slack_user_tokens](#get_slack_user_tokens) | | -| [get_slack_user_token](#get_slack_user_token) | | -| [discard_slack_user_token](#discard_slack_user_token) | | -| [get_teams_user_tokens](#get_teams_user_tokens) | | -| [get_teams_user_token](#get_teams_user_token) | | -| [discard_teams_user_token](#discard_teams_user_token) | | -| [get_web_push_user_tokens](#get_web_push_user_tokens) | | -| [get_web_push_user_token](#get_web_push_user_token) | | -| [discard_web_push_user_token](#discard_web_push_user_token) | | - -## get_in_app_user_tokens +| Methods | Description | +| :---------------------------------------------------------------- | :---------- | +| [getMobilePushApnsUserTokens](#getmobilepushapnsusertokens) | | +| [getMobilePushApnsUserToken](#getmobilepushapnsusertoken) | | +| [discardMobilePushApnsUserToken](#discardmobilepushapnsusertoken) | | +| [getMobilePushExpoUserTokens](#getmobilepushexpousertokens) | | +| [getMobilePushExpoUserToken](#getmobilepushexpousertoken) | | +| [discardMobilePushExpoUserToken](#discardmobilepushexpousertoken) | | +| [getMobilePushFcmUserTokens](#getmobilepushfcmusertokens) | | +| [getMobilePushFcmUserToken](#getmobilepushfcmusertoken) | | +| [discardMobilePushFcmUserToken](#discardmobilepushfcmusertoken) | | +| [getSlackUserTokens](#getslackusertokens) | | +| [getSlackUserToken](#getslackusertoken) | | +| [discardSlackUserToken](#discardslackusertoken) | | +| [getTeamsUserTokens](#getteamsusertokens) | | +| [getTeamsUserToken](#getteamsusertoken) | | +| [discardTeamsUserToken](#discardteamsusertoken) | | +| [getWebPushUserTokens](#getwebpushusertokens) | | +| [getWebPushUserToken](#getwebpushusertoken) | | +| [discardWebPushUserToken](#discardwebpushusertoken) | | + +## getMobilePushApnsUserTokens - HTTP Method: `GET` -- Endpoint: `/users/{user_id}/channels/in_app/tokens` +- Endpoint: `/users/{user_id}/channels/mobile_push/apns/tokens` **Parameters** @@ -36,7 +36,7 @@ A list of all methods in the `ChannelsService` service. Click on the method name **Return Type** -`ArrayWithMetadataOfInboxToken` +`ArrayWithMetadataOfApnsToken` **Example Usage Code Snippet** @@ -48,16 +48,16 @@ import { Client } from '@magicbell/project-client'; token: 'YOUR_TOKEN', }); - const { data } = await client.channels.getInAppUserTokens('user_id'); + const { data } = await client.channels.getMobilePushApnsUserTokens('user_id'); console.log(data); })(); ``` -## get_in_app_user_token +## getMobilePushApnsUserToken - HTTP Method: `GET` -- Endpoint: `/users/{user_id}/channels/in_app/tokens/{token_id}` +- Endpoint: `/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}` **Parameters** @@ -68,7 +68,7 @@ import { Client } from '@magicbell/project-client'; **Return Type** -`InboxTokenWithMetadata` +`ApnsTokenWithMetadata` **Example Usage Code Snippet** @@ -80,16 +80,16 @@ import { Client } from '@magicbell/project-client'; token: 'YOUR_TOKEN', }); - const { data } = await client.channels.getInAppUserToken('user_id', 'token_id'); + const { data } = await client.channels.getMobilePushApnsUserToken('user_id', 'token_id'); console.log(data); })(); ``` -## discard_in_app_user_token +## discardMobilePushApnsUserToken - HTTP Method: `DELETE` -- Endpoint: `/users/{user_id}/channels/in_app/tokens/{token_id}` +- Endpoint: `/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}` **Parameters** @@ -112,16 +112,16 @@ import { Client } from '@magicbell/project-client'; token: 'YOUR_TOKEN', }); - const { data } = await client.channels.discardInAppUserToken('user_id', 'token_id'); + const { data } = await client.channels.discardMobilePushApnsUserToken('user_id', 'token_id'); console.log(data); })(); ``` -## get_mobile_push_apns_user_tokens +## getMobilePushExpoUserTokens - HTTP Method: `GET` -- Endpoint: `/users/{user_id}/channels/mobile_push/apns/tokens` +- Endpoint: `/users/{user_id}/channels/mobile_push/expo/tokens` **Parameters** @@ -131,7 +131,7 @@ import { Client } from '@magicbell/project-client'; **Return Type** -`ArrayWithMetadataOfApnsToken` +`ArrayWithMetadataOfExpoToken` **Example Usage Code Snippet** @@ -143,16 +143,16 @@ import { Client } from '@magicbell/project-client'; token: 'YOUR_TOKEN', }); - const { data } = await client.channels.getMobilePushApnsUserTokens('user_id'); + const { data } = await client.channels.getMobilePushExpoUserTokens('user_id'); console.log(data); })(); ``` -## get_mobile_push_apns_user_token +## getMobilePushExpoUserToken - HTTP Method: `GET` -- Endpoint: `/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}` +- Endpoint: `/users/{user_id}/channels/mobile_push/expo/tokens/{token_id}` **Parameters** @@ -163,7 +163,7 @@ import { Client } from '@magicbell/project-client'; **Return Type** -`ApnsTokenWithMetadata` +`ExpoTokenWithMetadata` **Example Usage Code Snippet** @@ -175,16 +175,16 @@ import { Client } from '@magicbell/project-client'; token: 'YOUR_TOKEN', }); - const { data } = await client.channels.getMobilePushApnsUserToken('user_id', 'token_id'); + const { data } = await client.channels.getMobilePushExpoUserToken('user_id', 'token_id'); console.log(data); })(); ``` -## discard_mobile_push_apns_user_token +## discardMobilePushExpoUserToken - HTTP Method: `DELETE` -- Endpoint: `/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}` +- Endpoint: `/users/{user_id}/channels/mobile_push/expo/tokens/{token_id}` **Parameters** @@ -207,13 +207,13 @@ import { Client } from '@magicbell/project-client'; token: 'YOUR_TOKEN', }); - const { data } = await client.channels.discardMobilePushApnsUserToken('user_id', 'token_id'); + const { data } = await client.channels.discardMobilePushExpoUserToken('user_id', 'token_id'); console.log(data); })(); ``` -## get_mobile_push_fcm_user_tokens +## getMobilePushFcmUserTokens - HTTP Method: `GET` - Endpoint: `/users/{user_id}/channels/mobile_push/fcm/tokens` @@ -244,7 +244,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_mobile_push_fcm_user_token +## getMobilePushFcmUserToken - HTTP Method: `GET` - Endpoint: `/users/{user_id}/channels/mobile_push/fcm/tokens/{token_id}` @@ -276,7 +276,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## discard_mobile_push_fcm_user_token +## discardMobilePushFcmUserToken - HTTP Method: `DELETE` - Endpoint: `/users/{user_id}/channels/mobile_push/fcm/tokens/{token_id}` @@ -308,7 +308,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_slack_user_tokens +## getSlackUserTokens - HTTP Method: `GET` - Endpoint: `/users/{user_id}/channels/slack/tokens` @@ -339,7 +339,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_slack_user_token +## getSlackUserToken - HTTP Method: `GET` - Endpoint: `/users/{user_id}/channels/slack/tokens/{token_id}` @@ -371,7 +371,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## discard_slack_user_token +## discardSlackUserToken - HTTP Method: `DELETE` - Endpoint: `/users/{user_id}/channels/slack/tokens/{token_id}` @@ -403,7 +403,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_teams_user_tokens +## getTeamsUserTokens - HTTP Method: `GET` - Endpoint: `/users/{user_id}/channels/teams/tokens` @@ -434,7 +434,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_teams_user_token +## getTeamsUserToken - HTTP Method: `GET` - Endpoint: `/users/{user_id}/channels/teams/tokens/{token_id}` @@ -466,7 +466,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## discard_teams_user_token +## discardTeamsUserToken - HTTP Method: `DELETE` - Endpoint: `/users/{user_id}/channels/teams/tokens/{token_id}` @@ -498,7 +498,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_web_push_user_tokens +## getWebPushUserTokens - HTTP Method: `GET` - Endpoint: `/users/{user_id}/channels/web_push/tokens` @@ -529,7 +529,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_web_push_user_token +## getWebPushUserToken - HTTP Method: `GET` - Endpoint: `/users/{user_id}/channels/web_push/tokens/{token_id}` @@ -561,7 +561,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## discard_web_push_user_token +## discardWebPushUserToken - HTTP Method: `DELETE` - Endpoint: `/users/{user_id}/channels/web_push/tokens/{token_id}` diff --git a/packages/project-client/docs/services/IntegrationsService.md b/packages/project-client/docs/services/IntegrationsService.md index 628fdfb8..08307d5d 100644 --- a/packages/project-client/docs/services/IntegrationsService.md +++ b/packages/project-client/docs/services/IntegrationsService.md @@ -2,63 +2,71 @@ A list of all methods in the `IntegrationsService` service. Click on the method name to view detailed information about that method. -| Methods | Description | -| :-------------------------------------------------------------------------- | :---------- | -| [list_integrations](#list_integrations) | | -| [get_apns_integration](#get_apns_integration) | | -| [save_apns_integration](#save_apns_integration) | | -| [delete_apns_integration](#delete_apns_integration) | | -| [delete_apns_integration_by_id](#delete_apns_integration_by_id) | | -| [get_fcm_integration](#get_fcm_integration) | | -| [save_fcm_integration](#save_fcm_integration) | | -| [delete_fcm_integration](#delete_fcm_integration) | | -| [delete_fcm_integration_by_id](#delete_fcm_integration_by_id) | | -| [get_github_integration](#get_github_integration) | | -| [save_github_integration](#save_github_integration) | | -| [delete_github_integration](#delete_github_integration) | | -| [delete_github_integration_by_id](#delete_github_integration_by_id) | | -| [get_inbox_integration](#get_inbox_integration) | | -| [save_inbox_integration](#save_inbox_integration) | | -| [delete_inbox_integration](#delete_inbox_integration) | | -| [delete_inbox_integration_by_id](#delete_inbox_integration_by_id) | | -| [get_mailgun_integration](#get_mailgun_integration) | | -| [save_mailgun_integration](#save_mailgun_integration) | | -| [delete_mailgun_integration](#delete_mailgun_integration) | | -| [delete_mailgun_integration_by_id](#delete_mailgun_integration_by_id) | | -| [get_ping_email_integration](#get_ping_email_integration) | | -| [save_ping_email_integration](#save_ping_email_integration) | | -| [delete_ping_email_integration](#delete_ping_email_integration) | | -| [delete_ping_email_integration_by_id](#delete_ping_email_integration_by_id) | | -| [get_sendgrid_integration](#get_sendgrid_integration) | | -| [save_sendgrid_integration](#save_sendgrid_integration) | | -| [delete_sendgrid_integration](#delete_sendgrid_integration) | | -| [delete_sendgrid_integration_by_id](#delete_sendgrid_integration_by_id) | | -| [get_ses_integration](#get_ses_integration) | | -| [save_ses_integration](#save_ses_integration) | | -| [delete_ses_integration](#delete_ses_integration) | | -| [delete_ses_integration_by_id](#delete_ses_integration_by_id) | | -| [get_slack_integration](#get_slack_integration) | | -| [save_slack_integration](#save_slack_integration) | | -| [delete_slack_integration](#delete_slack_integration) | | -| [delete_slack_integration_by_id](#delete_slack_integration_by_id) | | -| [get_stripe_integration](#get_stripe_integration) | | -| [save_stripe_integration](#save_stripe_integration) | | -| [delete_stripe_integration](#delete_stripe_integration) | | -| [delete_stripe_integration_by_id](#delete_stripe_integration_by_id) | | -| [get_templates_integration](#get_templates_integration) | | -| [save_templates_integration](#save_templates_integration) | | -| [delete_templates_integration](#delete_templates_integration) | | -| [delete_templates_integration_by_id](#delete_templates_integration_by_id) | | -| [get_twilio_integration](#get_twilio_integration) | | -| [save_twilio_integration](#save_twilio_integration) | | -| [delete_twilio_integration](#delete_twilio_integration) | | -| [delete_twilio_integration_by_id](#delete_twilio_integration_by_id) | | -| [get_web_push_integration](#get_web_push_integration) | | -| [save_web_push_integration](#save_web_push_integration) | | -| [delete_web_push_integration](#delete_web_push_integration) | | -| [delete_web_push_integration_by_id](#delete_web_push_integration_by_id) | | - -## list_integrations +| Methods | Description | +| :---------------------------------------------------------------- | :---------- | +| [listIntegrations](#listintegrations) | | +| [getApnsIntegration](#getapnsintegration) | | +| [saveApnsIntegration](#saveapnsintegration) | | +| [deleteApnsIntegration](#deleteapnsintegration) | | +| [deleteApnsIntegrationById](#deleteapnsintegrationbyid) | | +| [getAwssnsIntegration](#getawssnsintegration) | | +| [saveAwssnsIntegration](#saveawssnsintegration) | | +| [deleteAwssnsIntegration](#deleteawssnsintegration) | | +| [deleteAwssnsIntegrationById](#deleteawssnsintegrationbyid) | | +| [getExpoIntegration](#getexpointegration) | | +| [saveExpoIntegration](#saveexpointegration) | | +| [deleteExpoIntegration](#deleteexpointegration) | | +| [deleteExpoIntegrationById](#deleteexpointegrationbyid) | | +| [getFcmIntegration](#getfcmintegration) | | +| [saveFcmIntegration](#savefcmintegration) | | +| [deleteFcmIntegration](#deletefcmintegration) | | +| [deleteFcmIntegrationById](#deletefcmintegrationbyid) | | +| [getGithubIntegration](#getgithubintegration) | | +| [saveGithubIntegration](#savegithubintegration) | | +| [deleteGithubIntegration](#deletegithubintegration) | | +| [deleteGithubIntegrationById](#deletegithubintegrationbyid) | | +| [getInboxIntegration](#getinboxintegration) | | +| [saveInboxIntegration](#saveinboxintegration) | | +| [deleteInboxIntegration](#deleteinboxintegration) | | +| [deleteInboxIntegrationById](#deleteinboxintegrationbyid) | | +| [getMailgunIntegration](#getmailgunintegration) | | +| [saveMailgunIntegration](#savemailgunintegration) | | +| [deleteMailgunIntegration](#deletemailgunintegration) | | +| [deleteMailgunIntegrationById](#deletemailgunintegrationbyid) | | +| [getPingEmailIntegration](#getpingemailintegration) | | +| [savePingEmailIntegration](#savepingemailintegration) | | +| [deletePingEmailIntegration](#deletepingemailintegration) | | +| [deletePingEmailIntegrationById](#deletepingemailintegrationbyid) | | +| [getSendgridIntegration](#getsendgridintegration) | | +| [saveSendgridIntegration](#savesendgridintegration) | | +| [deleteSendgridIntegration](#deletesendgridintegration) | | +| [deleteSendgridIntegrationById](#deletesendgridintegrationbyid) | | +| [getSesIntegration](#getsesintegration) | | +| [saveSesIntegration](#savesesintegration) | | +| [deleteSesIntegration](#deletesesintegration) | | +| [deleteSesIntegrationById](#deletesesintegrationbyid) | | +| [getSlackIntegration](#getslackintegration) | | +| [saveSlackIntegration](#saveslackintegration) | | +| [deleteSlackIntegration](#deleteslackintegration) | | +| [deleteSlackIntegrationById](#deleteslackintegrationbyid) | | +| [getStripeIntegration](#getstripeintegration) | | +| [saveStripeIntegration](#savestripeintegration) | | +| [deleteStripeIntegration](#deletestripeintegration) | | +| [deleteStripeIntegrationById](#deletestripeintegrationbyid) | | +| [getTemplatesIntegration](#gettemplatesintegration) | | +| [saveTemplatesIntegration](#savetemplatesintegration) | | +| [deleteTemplatesIntegration](#deletetemplatesintegration) | | +| [deleteTemplatesIntegrationById](#deletetemplatesintegrationbyid) | | +| [getTwilioIntegration](#gettwiliointegration) | | +| [saveTwilioIntegration](#savetwiliointegration) | | +| [deleteTwilioIntegration](#deletetwiliointegration) | | +| [deleteTwilioIntegrationById](#deletetwiliointegrationbyid) | | +| [getWebPushIntegration](#getwebpushintegration) | | +| [saveWebPushIntegration](#savewebpushintegration) | | +| [deleteWebPushIntegration](#deletewebpushintegration) | | +| [deleteWebPushIntegrationById](#deletewebpushintegrationbyid) | | + +## listIntegrations - HTTP Method: `GET` - Endpoint: `/integrations` @@ -83,7 +91,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_apns_integration +## getApnsIntegration - HTTP Method: `GET` - Endpoint: `/integrations/apns` @@ -108,7 +116,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_apns_integration +## saveApnsIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/apns` @@ -136,11 +144,11 @@ import { ApnsConfig, Client } from '@magicbell/project-client'; const badge = Badge.UNREAD; const apnsConfig: ApnsConfig = { - appId: 'iAYqMy12w9iGu7ff1EsX`Yd7Od!5pFmfIMNCPzvFgZiCEg+ihR0u2bAgXQlSqFd8hh', + appId: 'd9OR5CpLVzt', badge: badge, certificate: 'certificate', - keyId: 'nostrud ul', - teamId: 'ut reprehe', + keyId: 'Utpariatur', + teamId: 'in Excepte', }; const { data } = await client.integrations.saveApnsIntegration(input); @@ -149,7 +157,7 @@ import { ApnsConfig, Client } from '@magicbell/project-client'; })(); ``` -## delete_apns_integration +## deleteApnsIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/apns` @@ -170,7 +178,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_apns_integration_by_id +## deleteApnsIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/apns/{id}` @@ -197,7 +205,223 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_fcm_integration +## getAwssnsIntegration + +- HTTP Method: `GET` +- Endpoint: `/integrations/awssns` + +**Return Type** + +`ListIntegrationsResponse` + +**Example Usage Code Snippet** + +```typescript +import { Client } from '@magicbell/project-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const { data } = await client.integrations.getAwssnsIntegration(); + + console.log(data); +})(); +``` + +## saveAwssnsIntegration + +- HTTP Method: `PUT` +- Endpoint: `/integrations/awssns` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :---------------------------------------- | :------- | :---------------- | +| body | [AwssnsConfig](../models/AwssnsConfig.md) | ❌ | The request body. | + +**Return Type** + +`AwssnsConfig` + +**Example Usage Code Snippet** + +```typescript +import { AwssnsConfig, Client } from '@magicbell/project-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const awssnsConfig: AwssnsConfig = { + webhookSigningSecret: 'pariatur', + }; + + const { data } = await client.integrations.saveAwssnsIntegration(input); + + console.log(data); +})(); +``` + +## deleteAwssnsIntegration + +- HTTP Method: `DELETE` +- Endpoint: `/integrations/awssns` + +**Example Usage Code Snippet** + +```typescript +import { Client } from '@magicbell/project-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const { data } = await client.integrations.deleteAwssnsIntegration(); + + console.log(data); +})(); +``` + +## deleteAwssnsIntegrationById + +- HTTP Method: `DELETE` +- Endpoint: `/integrations/awssns/{id}` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :----- | :------- | :---------- | +| id | string | ✅ | | + +**Example Usage Code Snippet** + +```typescript +import { Client } from '@magicbell/project-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const { data } = await client.integrations.deleteAwssnsIntegrationById('id'); + + console.log(data); +})(); +``` + +## getExpoIntegration + +- HTTP Method: `GET` +- Endpoint: `/integrations/expo` + +**Return Type** + +`ListIntegrationsResponse` + +**Example Usage Code Snippet** + +```typescript +import { Client } from '@magicbell/project-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const { data } = await client.integrations.getExpoIntegration(); + + console.log(data); +})(); +``` + +## saveExpoIntegration + +- HTTP Method: `PUT` +- Endpoint: `/integrations/expo` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :------------------------------------ | :------- | :---------------- | +| body | [ExpoConfig](../models/ExpoConfig.md) | ❌ | The request body. | + +**Return Type** + +`ExpoConfig` + +**Example Usage Code Snippet** + +```typescript +import { Client, ExpoConfig } from '@magicbell/project-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const expoConfig: ExpoConfig = { + accessToken: 'dolore non mo', + }; + + const { data } = await client.integrations.saveExpoIntegration(input); + + console.log(data); +})(); +``` + +## deleteExpoIntegration + +- HTTP Method: `DELETE` +- Endpoint: `/integrations/expo` + +**Example Usage Code Snippet** + +```typescript +import { Client } from '@magicbell/project-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const { data } = await client.integrations.deleteExpoIntegration(); + + console.log(data); +})(); +``` + +## deleteExpoIntegrationById + +- HTTP Method: `DELETE` +- Endpoint: `/integrations/expo/{id}` + +**Parameters** + +| Name | Type | Required | Description | +| :--- | :----- | :------- | :---------- | +| id | string | ✅ | | + +**Example Usage Code Snippet** + +```typescript +import { Client } from '@magicbell/project-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const { data } = await client.integrations.deleteExpoIntegrationById('id'); + + console.log(data); +})(); +``` + +## getFcmIntegration - HTTP Method: `GET` - Endpoint: `/integrations/fcm` @@ -222,7 +446,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_fcm_integration +## saveFcmIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/fcm` @@ -269,7 +493,7 @@ import { Client, FcmConfig } from '@magicbell/project-client'; })(); ``` -## delete_fcm_integration +## deleteFcmIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/fcm` @@ -290,7 +514,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_fcm_integration_by_id +## deleteFcmIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/fcm/{id}` @@ -317,7 +541,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_github_integration +## getGithubIntegration - HTTP Method: `GET` - Endpoint: `/integrations/github` @@ -342,7 +566,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_github_integration +## saveGithubIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/github` @@ -368,7 +592,7 @@ import { Client, GithubConfig } from '@magicbell/project-client'; }); const githubConfig: GithubConfig = { - webhookSigningSecret: 'adipisicing', + webhookSigningSecret: 'id dol', }; const { data } = await client.integrations.saveGithubIntegration(input); @@ -377,7 +601,7 @@ import { Client, GithubConfig } from '@magicbell/project-client'; })(); ``` -## delete_github_integration +## deleteGithubIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/github` @@ -398,7 +622,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_github_integration_by_id +## deleteGithubIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/github/{id}` @@ -425,7 +649,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_inbox_integration +## getInboxIntegration - HTTP Method: `GET` - Endpoint: `/integrations/inbox` @@ -450,7 +674,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_inbox_integration +## saveInboxIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/inbox` @@ -475,10 +699,116 @@ import { Client, InboxConfig } from '@magicbell/project-client'; token: 'YOUR_TOKEN', }); + const images: Images = { + emptyInboxUrl: 'emptyInboxUrl', + }; + + const banner: Banner = { + backgroundColor: 'backgroundColor', + backgroundOpacity: 9.28, + fontSize: 'fontSize', + textColor: 'textColor', + }; + + const dialog: Dialog = { + accentColor: 'accentColor', + backgroundColor: 'backgroundColor', + textColor: 'textColor', + }; + + const footer: Footer = { + backgroundColor: 'backgroundColor', + borderRadius: 'borderRadius', + fontSize: 'fontSize', + textColor: 'textColor', + }; + + const header: Header = { + backgroundColor: 'backgroundColor', + borderRadius: 'borderRadius', + fontFamily: 'fontFamily', + fontSize: 'fontSize', + textColor: 'textColor', + }; + + const icon: Icon = { + borderColor: 'borderColor', + width: 'width', + }; + + const defaultHover: DefaultHover = { + backgroundColor: 'backgroundColor', + }; + + const defaultState: DefaultState = { + color: 'color', + }; + + const default_: Default_ = { + backgroundColor: 'backgroundColor', + borderRadius: 'borderRadius', + fontFamily: 'fontFamily', + fontSize: 'fontSize', + hover: defaultHover, + margin: 'margin', + state: defaultState, + textColor: 'textColor', + }; + + const unreadHover: UnreadHover = { + backgroundColor: 'backgroundColor', + }; + + const unreadState: UnreadState = { + color: 'color', + }; + + const unread: Unread = { + backgroundColor: 'backgroundColor', + hover: unreadHover, + state: unreadState, + textColor: 'textColor', + }; + + const unseenHover: UnseenHover = { + backgroundColor: 'backgroundColor', + }; + + const unseenState: UnseenState = { + color: 'color', + }; + + const unseen: Unseen = { + backgroundColor: 'backgroundColor', + hover: unseenHover, + state: unseenState, + textColor: 'textColor', + }; + + const notification: Notification = { + default: default_, + unread: unread, + unseen: unseen, + }; + + const unseenBadge: UnseenBadge = { + backgroundColor: 'backgroundColor', + }; + + const theme: Theme = { + banner: banner, + dialog: dialog, + footer: footer, + header: header, + icon: icon, + notification: notification, + unseenBadge: unseenBadge, + }; + const inboxConfig: InboxConfig = { - images: {}, - locale: 'dolore moll', - theme: {}, + images: images, + locale: 'ad consequat', + theme: theme, }; const { data } = await client.integrations.saveInboxIntegration(input); @@ -487,7 +817,7 @@ import { Client, InboxConfig } from '@magicbell/project-client'; })(); ``` -## delete_inbox_integration +## deleteInboxIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/inbox` @@ -508,7 +838,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_inbox_integration_by_id +## deleteInboxIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/inbox/{id}` @@ -535,7 +865,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_mailgun_integration +## getMailgunIntegration - HTTP Method: `GET` - Endpoint: `/integrations/mailgun` @@ -560,7 +890,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_mailgun_integration +## saveMailgunIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/mailgun` @@ -588,8 +918,8 @@ import { Client, MailgunConfig } from '@magicbell/project-client'; const mailgunConfigRegion = MailgunConfigRegion.US; const mailgunConfig: MailgunConfig = { - apiKey: 'molli', - domain: 'do ', + apiKey: 'voluptate ', + domain: 'magna a', region: mailgunConfigRegion, }; @@ -599,7 +929,7 @@ import { Client, MailgunConfig } from '@magicbell/project-client'; })(); ``` -## delete_mailgun_integration +## deleteMailgunIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/mailgun` @@ -620,7 +950,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_mailgun_integration_by_id +## deleteMailgunIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/mailgun/{id}` @@ -647,7 +977,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_ping_email_integration +## getPingEmailIntegration - HTTP Method: `GET` - Endpoint: `/integrations/ping_email` @@ -672,7 +1002,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_ping_email_integration +## savePingEmailIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/ping_email` @@ -698,7 +1028,7 @@ import { Client, PingConfig } from '@magicbell/project-client'; }); const pingConfig: PingConfig = { - url: 'laboris Duis', + url: 'et laborum pariatur esse consequat', }; const { data } = await client.integrations.savePingEmailIntegration(input); @@ -707,7 +1037,7 @@ import { Client, PingConfig } from '@magicbell/project-client'; })(); ``` -## delete_ping_email_integration +## deletePingEmailIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/ping_email` @@ -728,7 +1058,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_ping_email_integration_by_id +## deletePingEmailIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/ping_email/{id}` @@ -755,7 +1085,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_sendgrid_integration +## getSendgridIntegration - HTTP Method: `GET` - Endpoint: `/integrations/sendgrid` @@ -780,7 +1110,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_sendgrid_integration +## saveSendgridIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/sendgrid` @@ -827,7 +1157,7 @@ import { Client, SendgridConfig } from '@magicbell/project-client'; })(); ``` -## delete_sendgrid_integration +## deleteSendgridIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/sendgrid` @@ -848,7 +1178,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_sendgrid_integration_by_id +## deleteSendgridIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/sendgrid/{id}` @@ -875,7 +1205,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_ses_integration +## getSesIntegration - HTTP Method: `GET` - Endpoint: `/integrations/ses` @@ -900,7 +1230,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_ses_integration +## saveSesIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/ses` @@ -931,11 +1261,11 @@ import { Client, SesConfig } from '@magicbell/project-client'; }; const sesConfig: SesConfig = { - endpoint: 'dolor e', + endpoint: 'sed', from: sesConfigFrom, - keyId: 'cillum no', - region: 'dolor culpa co', - secretKey: 'pa', + keyId: 'pariat', + region: 'temp', + secretKey: 'c', }; const { data } = await client.integrations.saveSesIntegration(input); @@ -944,7 +1274,7 @@ import { Client, SesConfig } from '@magicbell/project-client'; })(); ``` -## delete_ses_integration +## deleteSesIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/ses` @@ -965,7 +1295,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_ses_integration_by_id +## deleteSesIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/ses/{id}` @@ -992,7 +1322,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_slack_integration +## getSlackIntegration - HTTP Method: `GET` - Endpoint: `/integrations/slack` @@ -1017,7 +1347,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_slack_integration +## saveSlackIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/slack` @@ -1043,11 +1373,10 @@ import { Client, SlackConfig } from '@magicbell/project-client'; }); const slackConfig: SlackConfig = { - appId: '6SX2ZNPXG8L', - clientId: '430411624.02717865207', - clientSecret: 'labore in ea fugiat magnainsed v', - id: 'CM0mBN', - signingSecret: 'exercitation Excepteur et euanim', + appId: 'LAUM', + clientId: '48902.5229056738', + clientSecret: 'esse inest cupidatat dolore offi', + signingSecret: 'deserunt quis ametnulla dolore a', }; const { data } = await client.integrations.saveSlackIntegration(input); @@ -1056,7 +1385,7 @@ import { Client, SlackConfig } from '@magicbell/project-client'; })(); ``` -## delete_slack_integration +## deleteSlackIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/slack` @@ -1077,7 +1406,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_slack_integration_by_id +## deleteSlackIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/slack/{id}` @@ -1104,7 +1433,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_stripe_integration +## getStripeIntegration - HTTP Method: `GET` - Endpoint: `/integrations/stripe` @@ -1129,7 +1458,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_stripe_integration +## saveStripeIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/stripe` @@ -1155,7 +1484,7 @@ import { Client, StripeConfig } from '@magicbell/project-client'; }); const stripeConfig: StripeConfig = { - webhookSigningSecret: 'et nisi', + webhookSigningSecret: 'mollit', }; const { data } = await client.integrations.saveStripeIntegration(input); @@ -1164,7 +1493,7 @@ import { Client, StripeConfig } from '@magicbell/project-client'; })(); ``` -## delete_stripe_integration +## deleteStripeIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/stripe` @@ -1185,7 +1514,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_stripe_integration_by_id +## deleteStripeIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/stripe/{id}` @@ -1212,7 +1541,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_templates_integration +## getTemplatesIntegration - HTTP Method: `GET` - Endpoint: `/integrations/templates` @@ -1237,7 +1566,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_templates_integration +## saveTemplatesIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/templates` @@ -1270,7 +1599,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_templates_integration +## deleteTemplatesIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/templates` @@ -1291,7 +1620,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_templates_integration_by_id +## deleteTemplatesIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/templates/{id}` @@ -1318,7 +1647,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_twilio_integration +## getTwilioIntegration - HTTP Method: `GET` - Endpoint: `/integrations/twilio` @@ -1343,7 +1672,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_twilio_integration +## saveTwilioIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/twilio` @@ -1371,10 +1700,10 @@ import { Client, TwilioConfig } from '@magicbell/project-client'; const twilioConfigRegion = TwilioConfigRegion.US1; const twilioConfig: TwilioConfig = { - accountSid: 'sunt', - apiKey: 'laboris non sunt fugiat', - apiSecret: 'aliqua sit laboris labore', - from: '+959', + accountSid: 'Ut fugiat culpa ex', + apiKey: 'sunt', + apiSecret: 'commodo dolo', + from: '+738', region: twilioConfigRegion, }; @@ -1384,7 +1713,7 @@ import { Client, TwilioConfig } from '@magicbell/project-client'; })(); ``` -## delete_twilio_integration +## deleteTwilioIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/twilio` @@ -1405,7 +1734,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_twilio_integration_by_id +## deleteTwilioIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/twilio/{id}` @@ -1432,7 +1761,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## get_web_push_integration +## getWebPushIntegration - HTTP Method: `GET` - Endpoint: `/integrations/web_push` @@ -1457,7 +1786,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## save_web_push_integration +## saveWebPushIntegration - HTTP Method: `PUT` - Endpoint: `/integrations/web_push` @@ -1483,8 +1812,8 @@ import { Client, WebpushConfig } from '@magicbell/project-client'; }); const webpushConfig: WebpushConfig = { - privateKey: 'pariatur occaecat magna', - publicKey: 'exercitati', + privateKey: 'Lorem minim', + publicKey: 'amet ullamco in', }; const { data } = await client.integrations.saveWebPushIntegration(input); @@ -1493,7 +1822,7 @@ import { Client, WebpushConfig } from '@magicbell/project-client'; })(); ``` -## delete_web_push_integration +## deleteWebPushIntegration - HTTP Method: `DELETE` - Endpoint: `/integrations/web_push` @@ -1514,7 +1843,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## delete_web_push_integration_by_id +## deleteWebPushIntegrationById - HTTP Method: `DELETE` - Endpoint: `/integrations/web_push/{id}` diff --git a/packages/project-client/docs/services/JwtService.md b/packages/project-client/docs/services/JwtService.md index adfd65e4..de728e05 100644 --- a/packages/project-client/docs/services/JwtService.md +++ b/packages/project-client/docs/services/JwtService.md @@ -2,16 +2,16 @@ A list of all methods in the `JwtService` service. Click on the method name to view detailed information about that method. -| Methods | Description | -| :-------------------------------------------- | :---------- | -| [fetch_project_tokens](#fetch_project_tokens) | | -| [create_project_jwt](#create_project_jwt) | | -| [discard_project_jwt](#discard_project_jwt) | | -| [create_user_jwt](#create_user_jwt) | | -| [discard_user_jwt](#discard_user_jwt) | | -| [fetch_user_tokens](#fetch_user_tokens) | | +| Methods | Description | +| :---------------------------------------- | :---------- | +| [fetchProjectTokens](#fetchprojecttokens) | | +| [createProjectJwt](#createprojectjwt) | | +| [discardProjectJwt](#discardprojectjwt) | | +| [createUserJwt](#createuserjwt) | | +| [discardUserJwt](#discarduserjwt) | | +| [fetchUserTokens](#fetchusertokens) | | -## fetch_project_tokens +## fetchProjectTokens - HTTP Method: `GET` - Endpoint: `/jwt/project` @@ -36,7 +36,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## create_project_jwt +## createProjectJwt - HTTP Method: `POST` - Endpoint: `/jwt/project` @@ -62,8 +62,8 @@ import { Client, CreateProjectTokenRequest } from '@magicbell/project-client'; }); const createProjectTokenRequest: CreateProjectTokenRequest = { - expiry: 1, - name: 'culpa', + expiry: 9, + name: 'ullamco ut', }; const { data } = await client.jwt.createProjectJwt(input); @@ -72,7 +72,7 @@ import { Client, CreateProjectTokenRequest } from '@magicbell/project-client'; })(); ``` -## discard_project_jwt +## discardProjectJwt - HTTP Method: `DELETE` - Endpoint: `/jwt/project/{token_id}` @@ -103,7 +103,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## create_user_jwt +## createUserJwt - HTTP Method: `POST` - Endpoint: `/jwt/user` @@ -129,10 +129,10 @@ import { Client, CreateUserTokenRequest } from '@magicbell/project-client'; }); const createUserTokenRequest: CreateUserTokenRequest = { - email: 'laborum esse do dolore ullamco', - expiry: 6, - externalId: 'ut officia', - name: 'exercitation esse', + email: 'deserunt sit nisi ut', + expiry: 10, + externalId: 'Duis amet magna', + name: 'veniam id adipisicing ea', }; const { data } = await client.jwt.createUserJwt(input); @@ -141,7 +141,7 @@ import { Client, CreateUserTokenRequest } from '@magicbell/project-client'; })(); ``` -## discard_user_jwt +## discardUserJwt - HTTP Method: `DELETE` - Endpoint: `/jwt/user/{token_id}` @@ -172,7 +172,7 @@ import { Client } from '@magicbell/project-client'; })(); ``` -## fetch_user_tokens +## fetchUserTokens - HTTP Method: `GET` - Endpoint: `/jwt/user/{user_id}` diff --git a/packages/project-client/liblab.config.json b/packages/project-client/liblab.config.json index 459fe175..017a426d 100644 --- a/packages/project-client/liblab.config.json +++ b/packages/project-client/liblab.config.json @@ -30,6 +30,7 @@ "languageOptions": { "typescript": { "bundle": false, + "httpClient": "fetch", "exportClassDefault": false, "npmName": "project-client", "npmOrg": "magicbell", diff --git a/packages/project-client/package.json b/packages/project-client/package.json index 0f89ec8c..3ae4d6ed 100644 --- a/packages/project-client/package.json +++ b/packages/project-client/package.json @@ -36,7 +36,6 @@ "start": "rm -rf dist/ && tsc -w" }, "dependencies": { - "axios": "^1.7.4", "zod": "3.23.8" }, "devDependencies": { diff --git a/packages/project-client/scripts/build.ts b/packages/project-client/scripts/build.ts index 04585d0c..a0d47110 100644 --- a/packages/project-client/scripts/build.ts +++ b/packages/project-client/scripts/build.ts @@ -158,7 +158,7 @@ async function build(specfile = 'https://public.magicbell.com/specs/openapi.v2.j pkgJson = sortPackageJson(pkgJson); await fs.writeFile('./package.json', JSON.stringify(pkgJson, null, 2) + '\n'); - execSync(`yarn --cwd ../.. eslint --fix .`, { stdio: 'inherit' }); + execSync(`yarn --cwd ../.. eslint --fix ./packages/project-client`, { stdio: 'inherit' }); execSync(`yarn --cwd ../.. manypkg fix`, { stdio: 'inherit' }); execSync(`yarn --cwd ../..`, { stdio: 'inherit' }); execSync(`yarn build`, { stdio: 'inherit' }); diff --git a/packages/project-client/src/http/handlers/terminating-handler.ts b/packages/project-client/src/http/handlers/terminating-handler.ts index 12f03fc7..0afd5a8c 100644 --- a/packages/project-client/src/http/handlers/terminating-handler.ts +++ b/packages/project-client/src/http/handlers/terminating-handler.ts @@ -1,9 +1,9 @@ import { Request } from '../transport/request'; -import { RequestAxiosAdapter } from '../transport/request-axios-adapter'; +import { RequestFetchAdapter } from '../transport/request-fetch-adapter'; import { HttpResponse, RequestHandler } from '../types'; export class TerminatingHandler implements RequestHandler { async handle(request: Request): Promise> { - return new RequestAxiosAdapter(request).send(); + return new RequestFetchAdapter(request).send(); } } diff --git a/packages/project-client/src/http/transport/request-axios-adapter.ts b/packages/project-client/src/http/transport/request-axios-adapter.ts deleted file mode 100644 index e7e14ff0..00000000 --- a/packages/project-client/src/http/transport/request-axios-adapter.ts +++ /dev/null @@ -1,98 +0,0 @@ -import axios, { AxiosRequestConfig, AxiosResponse, isAxiosError } from 'axios'; - -import { HttpError } from '../error'; -import { HttpMetadata, HttpResponse } from '../types'; -import { Request } from './request'; - -export interface HttpAdapter { - send(): Promise; -} - -export class RequestAxiosAdapter implements HttpAdapter { - private config: AxiosRequestConfig = { - responseType: 'arraybuffer', - }; - - constructor(private request: Request) { - this.setHeaders(); - this.setTimeout(); - } - - public async send(): Promise> { - const method = this.getMethod(); - const { body } = this.request; - let axiosResponse: AxiosResponse; - - try { - if (!!body) { - axiosResponse = await method(this.request.constructFullUrl(), body, this.config); - } else { - axiosResponse = await method(this.request.constructFullUrl(), this.config); - } - } catch (err) { - if (!isAxiosError(err)) { - throw err; - } - axiosResponse = err.response; - } - - const headerRecord: Record = {}; - Object.keys(axiosResponse.headers).forEach((key) => { - headerRecord[key] = axiosResponse.headers[key]; - }); - - const metadata: HttpMetadata = { - status: axiosResponse.status, - statusText: axiosResponse.statusText || '', - headers: headerRecord, - }; - - if (metadata.status >= 400) { - throw new HttpError(metadata); - } - - return { - metadata, - raw: axiosResponse.data.buffer.slice( - axiosResponse.data.byteOffset, - axiosResponse.data.byteOffset + axiosResponse.data.byteLength, - ), - }; - } - - private getMethod(): (url: string, data?: any, config?: AxiosRequestConfig) => Promise { - if (this.request.method === 'POST') { - return axios.post; - } else if (this.request.method === 'GET') { - return axios.get; - } else if (this.request.method === 'PUT') { - return axios.put; - } else if (this.request.method === 'DELETE') { - return axios.delete; - } - throw new Error('invalid method!!!!'); - } - - private setHeaders(): void { - if (!this.request.headers) { - return; - } - - const headersRecord: Record = {}; - new Headers(this.request.getHeaders()).forEach((value, key) => { - headersRecord[key] = value; - }); - - this.config = { - ...this.config, - headers: headersRecord, - }; - } - - private setTimeout(): void { - this.config = { - ...this.config, - timeout: this.request.config.timeout, - }; - } -} diff --git a/packages/project-client/src/http/transport/request-fetch-adapter.ts b/packages/project-client/src/http/transport/request-fetch-adapter.ts new file mode 100644 index 00000000..21d07846 --- /dev/null +++ b/packages/project-client/src/http/transport/request-fetch-adapter.ts @@ -0,0 +1,88 @@ +import { HttpError } from '../error'; +import { HttpMethod, HttpResponse } from '../types'; +import { Request } from './request'; + +interface HttpAdapter { + send(): Promise; +} + +export class RequestFetchAdapter implements HttpAdapter { + private requestInit: RequestInit = {}; + + constructor(private request: Request) { + this.setMethod(request.method); + this.setHeaders(request.getHeaders()); + this.setBody(request.body); + this.setTimeout(request.config.timeout); + } + + public async send(): Promise> { + const response = await fetch(this.request.constructFullUrl(), this.requestInit); + + const metadata = { + status: response.status, + statusText: response.statusText || '', + headers: this.getHeaders(response), + }; + + if (metadata.status >= 400) { + throw new HttpError(metadata); + } + + return { + metadata, + raw: await response.clone().arrayBuffer(), + }; + } + + private setMethod(method: HttpMethod) { + if (!method) { + return; + } + this.requestInit = { + ...this.requestInit, + method, + }; + } + + private setBody(body: ReadableStream | null) { + if (!body) { + return; + } + this.requestInit = { + ...this.requestInit, + body, + }; + } + + private setHeaders(headers: HeadersInit | undefined) { + if (!headers) { + return; + } + + this.requestInit = { + ...this.requestInit, + headers, + }; + } + + private setTimeout(timeout: number | undefined) { + if (!timeout) { + return; + } + + this.requestInit = { + ...this.requestInit, + signal: AbortSignal.timeout(timeout), + }; + } + + private getHeaders(response: Response): Record { + const headers: Record = {}; + response.headers.forEach((value: string, key: string) => { + headers[key] = value; + }); + + return headers; + } +} diff --git a/packages/project-client/src/services/broadcasts/models/broadcast.ts b/packages/project-client/src/services/broadcasts/models/broadcast.ts index 78bdf715..0385cebb 100644 --- a/packages/project-client/src/services/broadcasts/models/broadcast.ts +++ b/packages/project-client/src/services/broadcasts/models/broadcast.ts @@ -1,6 +1,8 @@ import { z } from 'zod'; +import { category, categoryRequest, categoryResponse } from './category'; import { overrides, overridesRequest, overridesResponse } from './overrides'; +import { topic, topicRequest, topicResponse } from './topic'; /** * The shape of the model inside the application code - what the users use @@ -8,13 +10,13 @@ import { overrides, overridesRequest, overridesResponse } from './overrides'; export const broadcast = z.lazy(() => { return z.object({ actionUrl: z.string().max(2048).optional().nullable(), - category: z.string().max(100).optional().nullable(), + category: category.optional(), content: z.string().max(10485760).optional().nullable(), customAttributes: z.any().optional().nullable(), overrides: overrides.optional().nullable(), recipients: z.array(z.any()).min(1).max(1000), title: z.string().min(1).max(255), - topic: z.string().max(100).optional().nullable(), + topic: topic.optional(), }); }); @@ -22,13 +24,13 @@ export const broadcast = z.lazy(() => { * * @typedef {Broadcast} broadcast * @property {string} - * @property {string} + * @property {Category} * @property {string} * @property {any} * @property {Overrides} * @property {any[]} * @property {string} - * @property {string} + * @property {Topic} */ export type Broadcast = z.infer; @@ -40,13 +42,13 @@ export const broadcastResponse = z.lazy(() => { return z .object({ action_url: z.string().max(2048).optional().nullable(), - category: z.string().max(100).optional().nullable(), + category: categoryResponse.optional(), content: z.string().max(10485760).optional().nullable(), custom_attributes: z.any().optional().nullable(), overrides: overridesResponse.optional().nullable(), recipients: z.array(z.any()).min(1).max(1000), title: z.string().min(1).max(255), - topic: z.string().max(100).optional().nullable(), + topic: topicResponse.optional(), }) .transform((data) => ({ actionUrl: data['action_url'], @@ -68,13 +70,13 @@ export const broadcastRequest = z.lazy(() => { return z .object({ actionUrl: z.string().nullish(), - category: z.string().nullish(), + category: categoryRequest.nullish(), content: z.string().nullish(), customAttributes: z.any().nullish(), overrides: overridesRequest.nullish(), recipients: z.array(z.any()).nullish(), title: z.string().nullish(), - topic: z.string().nullish(), + topic: topicRequest.nullish(), }) .transform((data) => ({ action_url: data['actionUrl'], diff --git a/packages/project-client/src/services/broadcasts/models/category.ts b/packages/project-client/src/services/broadcasts/models/category.ts new file mode 100644 index 00000000..6b2351b0 --- /dev/null +++ b/packages/project-client/src/services/broadcasts/models/category.ts @@ -0,0 +1,32 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const category = z.lazy(() => { + return z.union([z.string(), z.any()]); +}); + +/** + * + * @typedef {Category} category + * @property {string} + * @property {any} + */ +export type Category = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const categoryResponse = z.lazy(() => { + return z.union([z.string(), z.any()]); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const categoryRequest = z.lazy(() => { + return z.union([z.string(), z.any()]); +}); diff --git a/packages/project-client/src/services/broadcasts/models/index.ts b/packages/project-client/src/services/broadcasts/models/index.ts index 32846bda..b70fa8f9 100644 --- a/packages/project-client/src/services/broadcasts/models/index.ts +++ b/packages/project-client/src/services/broadcasts/models/index.ts @@ -1,5 +1,6 @@ export type { Broadcast } from './broadcast'; export type { BroadcastListResponse } from './broadcast-list-response'; +export type { Category } from './category'; export type { Channels } from './channels'; export type { Email } from './email'; export type { InApp } from './in-app'; @@ -8,4 +9,5 @@ export type { Overrides } from './overrides'; export type { Providers } from './providers'; export type { Slack } from './slack'; export type { Sms } from './sms'; +export type { Topic } from './topic'; export type { WebPush } from './web-push'; diff --git a/packages/project-client/src/services/broadcasts/models/topic.ts b/packages/project-client/src/services/broadcasts/models/topic.ts new file mode 100644 index 00000000..aad1e9bf --- /dev/null +++ b/packages/project-client/src/services/broadcasts/models/topic.ts @@ -0,0 +1,32 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const topic = z.lazy(() => { + return z.union([z.string(), z.any()]); +}); + +/** + * + * @typedef {Topic} topic + * @property {string} + * @property {any} + */ +export type Topic = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const topicResponse = z.lazy(() => { + return z.union([z.string(), z.any()]); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const topicRequest = z.lazy(() => { + return z.union([z.string(), z.any()]); +}); diff --git a/packages/project-client/src/services/channels/channels.ts b/packages/project-client/src/services/channels/channels.ts index 00572e0d..cb9906cd 100644 --- a/packages/project-client/src/services/channels/channels.ts +++ b/packages/project-client/src/services/channels/channels.ts @@ -1,6 +1,5 @@ import { z } from 'zod'; -import { SerializationStyle } from '../../http/serialization/base-serializer'; import { RequestBuilder } from '../../http/transport/request-builder'; import { ContentType, HttpResponse, RequestConfig } from '../../http/types'; import { BaseService } from '../base-service'; @@ -9,14 +8,14 @@ import { ArrayWithMetadataOfApnsToken, arrayWithMetadataOfApnsTokenResponse, } from './models/array-with-metadata-of-apns-token'; +import { + ArrayWithMetadataOfExpoToken, + arrayWithMetadataOfExpoTokenResponse, +} from './models/array-with-metadata-of-expo-token'; import { ArrayWithMetadataOfFcmToken, arrayWithMetadataOfFcmTokenResponse, } from './models/array-with-metadata-of-fcm-token'; -import { - ArrayWithMetadataOfInboxToken, - arrayWithMetadataOfInboxTokenResponse, -} from './models/array-with-metadata-of-inbox-token'; import { ArrayWithMetadataOfSlackToken, arrayWithMetadataOfSlackTokenResponse, @@ -30,8 +29,8 @@ import { arrayWithMetadataOfWebPushTokenResponse, } from './models/array-with-metadata-of-web-push-token'; import { DiscardResult, discardResultResponse } from './models/discard-result'; +import { ExpoTokenWithMetadata, expoTokenWithMetadataResponse } from './models/expo-token-with-metadata'; import { FcmTokenWithMetadata, fcmTokenWithMetadataResponse } from './models/fcm-token-with-metadata'; -import { InboxTokenWithMetadata, inboxTokenWithMetadataResponse } from './models/inbox-token-with-metadata'; import { SlackTokenWithMetadata, slackTokenWithMetadataResponse } from './models/slack-token-with-metadata'; import { TeamsTokenWithMetadata, teamsTokenWithMetadataResponse } from './models/teams-token-with-metadata'; import { WebPushTokenWithMetadata, webPushTokenWithMetadataResponse } from './models/web-push-token-with-metadata'; @@ -40,19 +39,19 @@ export class ChannelsService extends BaseService { /** * * @param {string} userId - - * @returns {Promise>} OK + * @returns {Promise>} OK */ - async getInAppUserTokens( + async getMobilePushApnsUserTokens( userId: string, requestConfig?: RequestConfig, - ): Promise> { - const request = new RequestBuilder() + ): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('GET') - .setPath('/users/{user_id}/channels/in_app/tokens') + .setPath('/users/{user_id}/channels/mobile_push/apns/tokens') .setRequestSchema(z.any()) - .setResponseSchema(arrayWithMetadataOfInboxTokenResponse) + .setResponseSchema(arrayWithMetadataOfApnsTokenResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -63,27 +62,27 @@ export class ChannelsService extends BaseService { value: userId, }) .build(); - return this.client.call(request); + return this.client.call(request); } /** * * @param {string} userId - * @param {string} tokenId - - * @returns {Promise>} OK + * @returns {Promise>} OK */ - async getInAppUserToken( + async getMobilePushApnsUserToken( userId: string, tokenId: string, requestConfig?: RequestConfig, - ): Promise> { - const request = new RequestBuilder() + ): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('GET') - .setPath('/users/{user_id}/channels/in_app/tokens/{token_id}') + .setPath('/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}') .setRequestSchema(z.any()) - .setResponseSchema(inboxTokenWithMetadataResponse) + .setResponseSchema(apnsTokenWithMetadataResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -98,7 +97,7 @@ export class ChannelsService extends BaseService { value: tokenId, }) .build(); - return this.client.call(request); + return this.client.call(request); } /** @@ -107,7 +106,7 @@ export class ChannelsService extends BaseService { * @param {string} tokenId - * @returns {Promise>} OK */ - async discardInAppUserToken( + async discardMobilePushApnsUserToken( userId: string, tokenId: string, requestConfig?: RequestConfig, @@ -116,7 +115,7 @@ export class ChannelsService extends BaseService { .setConfig(this.config) .setBaseUrl(this.config) .setMethod('DELETE') - .setPath('/users/{user_id}/channels/in_app/tokens/{token_id}') + .setPath('/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}') .setRequestSchema(z.any()) .setResponseSchema(discardResultResponse) .setRequestContentType(ContentType.Json) @@ -139,19 +138,19 @@ export class ChannelsService extends BaseService { /** * * @param {string} userId - - * @returns {Promise>} OK + * @returns {Promise>} OK */ - async getMobilePushApnsUserTokens( + async getMobilePushExpoUserTokens( userId: string, requestConfig?: RequestConfig, - ): Promise> { - const request = new RequestBuilder() + ): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('GET') - .setPath('/users/{user_id}/channels/mobile_push/apns/tokens') + .setPath('/users/{user_id}/channels/mobile_push/expo/tokens') .setRequestSchema(z.any()) - .setResponseSchema(arrayWithMetadataOfApnsTokenResponse) + .setResponseSchema(arrayWithMetadataOfExpoTokenResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -162,27 +161,27 @@ export class ChannelsService extends BaseService { value: userId, }) .build(); - return this.client.call(request); + return this.client.call(request); } /** * * @param {string} userId - * @param {string} tokenId - - * @returns {Promise>} OK + * @returns {Promise>} OK */ - async getMobilePushApnsUserToken( + async getMobilePushExpoUserToken( userId: string, tokenId: string, requestConfig?: RequestConfig, - ): Promise> { - const request = new RequestBuilder() + ): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('GET') - .setPath('/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}') + .setPath('/users/{user_id}/channels/mobile_push/expo/tokens/{token_id}') .setRequestSchema(z.any()) - .setResponseSchema(apnsTokenWithMetadataResponse) + .setResponseSchema(expoTokenWithMetadataResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -197,7 +196,7 @@ export class ChannelsService extends BaseService { value: tokenId, }) .build(); - return this.client.call(request); + return this.client.call(request); } /** @@ -206,7 +205,7 @@ export class ChannelsService extends BaseService { * @param {string} tokenId - * @returns {Promise>} OK */ - async discardMobilePushApnsUserToken( + async discardMobilePushExpoUserToken( userId: string, tokenId: string, requestConfig?: RequestConfig, @@ -215,7 +214,7 @@ export class ChannelsService extends BaseService { .setConfig(this.config) .setBaseUrl(this.config) .setMethod('DELETE') - .setPath('/users/{user_id}/channels/mobile_push/apns/tokens/{token_id}') + .setPath('/users/{user_id}/channels/mobile_push/expo/tokens/{token_id}') .setRequestSchema(z.any()) .setResponseSchema(discardResultResponse) .setRequestContentType(ContentType.Json) diff --git a/packages/project-client/src/services/channels/models/array-with-metadata-of-apns-token-data.ts b/packages/project-client/src/services/channels/models/array-with-metadata-of-apns-token-data.ts index bdbed050..be409755 100644 --- a/packages/project-client/src/services/channels/models/array-with-metadata-of-apns-token-data.ts +++ b/packages/project-client/src/services/channels/models/array-with-metadata-of-apns-token-data.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { apnsToken, apnsTokenRequest, apnsTokenResponse } from './apns-token'; -import { dataMetadata2, dataMetadata2Request, dataMetadata2Response } from './data-metadata-2'; +import { dataMetadata1, dataMetadata1Request, dataMetadata1Response } from './data-metadata-1'; /** * The shape of the model inside the application code - what the users use @@ -9,7 +9,7 @@ import { dataMetadata2, dataMetadata2Request, dataMetadata2Response } from './da export const arrayWithMetadataOfApnsTokenData = z.lazy(() => { return z.object({ data: apnsToken, - metadata: dataMetadata2, + metadata: dataMetadata1, }); }); @@ -17,7 +17,7 @@ export const arrayWithMetadataOfApnsTokenData = z.lazy(() => { * * @typedef {ArrayWithMetadataOfApnsTokenData} arrayWithMetadataOfApnsTokenData * @property {ApnsToken} - * @property {DataMetadata2} + * @property {DataMetadata1} */ export type ArrayWithMetadataOfApnsTokenData = z.infer; @@ -29,7 +29,7 @@ export const arrayWithMetadataOfApnsTokenDataResponse = z.lazy(() => { return z .object({ data: apnsTokenResponse, - metadata: dataMetadata2Response, + metadata: dataMetadata1Response, }) .transform((data) => ({ data: data['data'], @@ -42,7 +42,7 @@ export const arrayWithMetadataOfApnsTokenDataResponse = z.lazy(() => { * Is equal to application shape if all property names match the api schema */ export const arrayWithMetadataOfApnsTokenDataRequest = z.lazy(() => { - return z.object({ data: apnsTokenRequest.nullish(), metadata: dataMetadata2Request.nullish() }).transform((data) => ({ + return z.object({ data: apnsTokenRequest.nullish(), metadata: dataMetadata1Request.nullish() }).transform((data) => ({ data: data['data'], metadata: data['metadata'], })); diff --git a/packages/project-client/src/services/channels/models/array-with-metadata-of-expo-token-data.ts b/packages/project-client/src/services/channels/models/array-with-metadata-of-expo-token-data.ts new file mode 100644 index 00000000..cbc68219 --- /dev/null +++ b/packages/project-client/src/services/channels/models/array-with-metadata-of-expo-token-data.ts @@ -0,0 +1,49 @@ +import { z } from 'zod'; + +import { dataMetadata2, dataMetadata2Request, dataMetadata2Response } from './data-metadata-2'; +import { expoToken, expoTokenRequest, expoTokenResponse } from './expo-token'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const arrayWithMetadataOfExpoTokenData = z.lazy(() => { + return z.object({ + data: expoToken, + metadata: dataMetadata2, + }); +}); + +/** + * + * @typedef {ArrayWithMetadataOfExpoTokenData} arrayWithMetadataOfExpoTokenData + * @property {ExpoToken} + * @property {DataMetadata2} + */ +export type ArrayWithMetadataOfExpoTokenData = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const arrayWithMetadataOfExpoTokenDataResponse = z.lazy(() => { + return z + .object({ + data: expoTokenResponse, + metadata: dataMetadata2Response, + }) + .transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const arrayWithMetadataOfExpoTokenDataRequest = z.lazy(() => { + return z.object({ data: expoTokenRequest.nullish(), metadata: dataMetadata2Request.nullish() }).transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); +}); diff --git a/packages/project-client/src/services/channels/models/array-with-metadata-of-expo-token.ts b/packages/project-client/src/services/channels/models/array-with-metadata-of-expo-token.ts new file mode 100644 index 00000000..2dbc0bf5 --- /dev/null +++ b/packages/project-client/src/services/channels/models/array-with-metadata-of-expo-token.ts @@ -0,0 +1,47 @@ +import { z } from 'zod'; + +import { + arrayWithMetadataOfExpoTokenData, + arrayWithMetadataOfExpoTokenDataRequest, + arrayWithMetadataOfExpoTokenDataResponse, +} from './array-with-metadata-of-expo-token-data'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const arrayWithMetadataOfExpoToken = z.lazy(() => { + return z.object({ + data: z.array(arrayWithMetadataOfExpoTokenData), + }); +}); + +/** + * + * @typedef {ArrayWithMetadataOfExpoToken} arrayWithMetadataOfExpoToken + * @property {ArrayWithMetadataOfExpoTokenData[]} + */ +export type ArrayWithMetadataOfExpoToken = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const arrayWithMetadataOfExpoTokenResponse = z.lazy(() => { + return z + .object({ + data: z.array(arrayWithMetadataOfExpoTokenDataResponse), + }) + .transform((data) => ({ + data: data['data'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const arrayWithMetadataOfExpoTokenRequest = z.lazy(() => { + return z.object({ data: z.array(arrayWithMetadataOfExpoTokenDataRequest).nullish() }).transform((data) => ({ + data: data['data'], + })); +}); diff --git a/packages/project-client/src/services/channels/models/array-with-metadata-of-inbox-token-data.ts b/packages/project-client/src/services/channels/models/array-with-metadata-of-inbox-token-data.ts deleted file mode 100644 index 72cef23f..00000000 --- a/packages/project-client/src/services/channels/models/array-with-metadata-of-inbox-token-data.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { z } from 'zod'; - -import { dataMetadata1, dataMetadata1Request, dataMetadata1Response } from './data-metadata-1'; -import { inboxToken, inboxTokenRequest, inboxTokenResponse } from './inbox-token'; - -/** - * The shape of the model inside the application code - what the users use - */ -export const arrayWithMetadataOfInboxTokenData = z.lazy(() => { - return z.object({ - data: inboxToken, - metadata: dataMetadata1, - }); -}); - -/** - * - * @typedef {ArrayWithMetadataOfInboxTokenData} arrayWithMetadataOfInboxTokenData - * @property {InboxToken} - * @property {DataMetadata1} - */ -export type ArrayWithMetadataOfInboxTokenData = z.infer; - -/** - * The shape of the model mapping from the api schema into the application shape. - * Is equal to application shape if all property names match the api schema - */ -export const arrayWithMetadataOfInboxTokenDataResponse = z.lazy(() => { - return z - .object({ - data: inboxTokenResponse, - metadata: dataMetadata1Response, - }) - .transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); -}); - -/** - * The shape of the model mapping from the application shape into the api schema. - * Is equal to application shape if all property names match the api schema - */ -export const arrayWithMetadataOfInboxTokenDataRequest = z.lazy(() => { - return z - .object({ data: inboxTokenRequest.nullish(), metadata: dataMetadata1Request.nullish() }) - .transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); -}); diff --git a/packages/project-client/src/services/channels/models/array-with-metadata-of-inbox-token.ts b/packages/project-client/src/services/channels/models/array-with-metadata-of-inbox-token.ts deleted file mode 100644 index 02f34cdb..00000000 --- a/packages/project-client/src/services/channels/models/array-with-metadata-of-inbox-token.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { z } from 'zod'; - -import { - arrayWithMetadataOfInboxTokenData, - arrayWithMetadataOfInboxTokenDataRequest, - arrayWithMetadataOfInboxTokenDataResponse, -} from './array-with-metadata-of-inbox-token-data'; - -/** - * The shape of the model inside the application code - what the users use - */ -export const arrayWithMetadataOfInboxToken = z.lazy(() => { - return z.object({ - data: z.array(arrayWithMetadataOfInboxTokenData), - }); -}); - -/** - * - * @typedef {ArrayWithMetadataOfInboxToken} arrayWithMetadataOfInboxToken - * @property {ArrayWithMetadataOfInboxTokenData[]} - */ -export type ArrayWithMetadataOfInboxToken = z.infer; - -/** - * The shape of the model mapping from the api schema into the application shape. - * Is equal to application shape if all property names match the api schema - */ -export const arrayWithMetadataOfInboxTokenResponse = z.lazy(() => { - return z - .object({ - data: z.array(arrayWithMetadataOfInboxTokenDataResponse), - }) - .transform((data) => ({ - data: data['data'], - })); -}); - -/** - * The shape of the model mapping from the application shape into the api schema. - * Is equal to application shape if all property names match the api schema - */ -export const arrayWithMetadataOfInboxTokenRequest = z.lazy(() => { - return z.object({ data: z.array(arrayWithMetadataOfInboxTokenDataRequest).nullish() }).transform((data) => ({ - data: data['data'], - })); -}); diff --git a/packages/project-client/src/services/channels/models/array-with-metadata-of-teams-token-data.ts b/packages/project-client/src/services/channels/models/array-with-metadata-of-teams-token-data.ts index db76fcf1..80d59854 100644 --- a/packages/project-client/src/services/channels/models/array-with-metadata-of-teams-token-data.ts +++ b/packages/project-client/src/services/channels/models/array-with-metadata-of-teams-token-data.ts @@ -1,13 +1,14 @@ import { z } from 'zod'; import { dataMetadata5, dataMetadata5Request, dataMetadata5Response } from './data-metadata-5'; +import { teamsToken, teamsTokenRequest, teamsTokenResponse } from './teams-token'; /** * The shape of the model inside the application code - what the users use */ export const arrayWithMetadataOfTeamsTokenData = z.lazy(() => { return z.object({ - data: z.any(), + data: teamsToken, metadata: dataMetadata5, }); }); @@ -15,7 +16,7 @@ export const arrayWithMetadataOfTeamsTokenData = z.lazy(() => { /** * * @typedef {ArrayWithMetadataOfTeamsTokenData} arrayWithMetadataOfTeamsTokenData - * @property {any} + * @property {TeamsToken} * @property {DataMetadata5} */ export type ArrayWithMetadataOfTeamsTokenData = z.infer; @@ -27,7 +28,7 @@ export type ArrayWithMetadataOfTeamsTokenData = z.infer { return z .object({ - data: z.any(), + data: teamsTokenResponse, metadata: dataMetadata5Response, }) .transform((data) => ({ @@ -41,8 +42,10 @@ export const arrayWithMetadataOfTeamsTokenDataResponse = z.lazy(() => { * Is equal to application shape if all property names match the api schema */ export const arrayWithMetadataOfTeamsTokenDataRequest = z.lazy(() => { - return z.object({ data: z.any().nullish(), metadata: dataMetadata5Request.nullish() }).transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); + return z + .object({ data: teamsTokenRequest.nullish(), metadata: dataMetadata5Request.nullish() }) + .transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); }); diff --git a/packages/user-client/src/services/channels/models/inbox-token-with-metadata-metadata.ts b/packages/project-client/src/services/channels/models/expo-token-with-metadata-metadata.ts similarity index 79% rename from packages/user-client/src/services/channels/models/inbox-token-with-metadata-metadata.ts rename to packages/project-client/src/services/channels/models/expo-token-with-metadata-metadata.ts index 47a99e2c..0f93e7bd 100644 --- a/packages/user-client/src/services/channels/models/inbox-token-with-metadata-metadata.ts +++ b/packages/project-client/src/services/channels/models/expo-token-with-metadata-metadata.ts @@ -3,7 +3,7 @@ import { z } from 'zod'; /** * The shape of the model inside the application code - what the users use */ -export const inboxTokenWithMetadataMetadata = z.lazy(() => { +export const expoTokenWithMetadataMetadata = z.lazy(() => { return z.object({ createdAt: z.string(), discardedAt: z.string().optional(), @@ -14,19 +14,19 @@ export const inboxTokenWithMetadataMetadata = z.lazy(() => { /** * - * @typedef {InboxTokenWithMetadataMetadata} inboxTokenWithMetadataMetadata + * @typedef {ExpoTokenWithMetadataMetadata} expoTokenWithMetadataMetadata * @property {string} * @property {string} * @property {string} * @property {string} */ -export type InboxTokenWithMetadataMetadata = z.infer; +export type ExpoTokenWithMetadataMetadata = z.infer; /** * The shape of the model mapping from the api schema into the application shape. * Is equal to application shape if all property names match the api schema */ -export const inboxTokenWithMetadataMetadataResponse = z.lazy(() => { +export const expoTokenWithMetadataMetadataResponse = z.lazy(() => { return z .object({ created_at: z.string(), @@ -46,7 +46,7 @@ export const inboxTokenWithMetadataMetadataResponse = z.lazy(() => { * The shape of the model mapping from the application shape into the api schema. * Is equal to application shape if all property names match the api schema */ -export const inboxTokenWithMetadataMetadataRequest = z.lazy(() => { +export const expoTokenWithMetadataMetadataRequest = z.lazy(() => { return z .object({ createdAt: z.string().nullish(), diff --git a/packages/project-client/src/services/channels/models/expo-token-with-metadata.ts b/packages/project-client/src/services/channels/models/expo-token-with-metadata.ts new file mode 100644 index 00000000..e1423654 --- /dev/null +++ b/packages/project-client/src/services/channels/models/expo-token-with-metadata.ts @@ -0,0 +1,55 @@ +import { z } from 'zod'; + +import { expoToken, expoTokenRequest, expoTokenResponse } from './expo-token'; +import { + expoTokenWithMetadataMetadata, + expoTokenWithMetadataMetadataRequest, + expoTokenWithMetadataMetadataResponse, +} from './expo-token-with-metadata-metadata'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const expoTokenWithMetadata = z.lazy(() => { + return z.object({ + data: expoToken, + metadata: expoTokenWithMetadataMetadata, + }); +}); + +/** + * + * @typedef {ExpoTokenWithMetadata} expoTokenWithMetadata + * @property {ExpoToken} + * @property {ExpoTokenWithMetadataMetadata} + */ +export type ExpoTokenWithMetadata = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const expoTokenWithMetadataResponse = z.lazy(() => { + return z + .object({ + data: expoTokenResponse, + metadata: expoTokenWithMetadataMetadataResponse, + }) + .transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const expoTokenWithMetadataRequest = z.lazy(() => { + return z + .object({ data: expoTokenRequest.nullish(), metadata: expoTokenWithMetadataMetadataRequest.nullish() }) + .transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); +}); diff --git a/packages/project-client/src/services/channels/models/expo-token.ts b/packages/project-client/src/services/channels/models/expo-token.ts new file mode 100644 index 00000000..56d74a95 --- /dev/null +++ b/packages/project-client/src/services/channels/models/expo-token.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const expoToken = z.lazy(() => { + return z.object({ + deviceToken: z.string().min(1), + }); +}); + +/** + * + * @typedef {ExpoToken} expoToken + * @property {string} + */ +export type ExpoToken = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const expoTokenResponse = z.lazy(() => { + return z + .object({ + device_token: z.string().min(1), + }) + .transform((data) => ({ + deviceToken: data['device_token'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const expoTokenRequest = z.lazy(() => { + return z.object({ deviceToken: z.string().nullish() }).transform((data) => ({ + device_token: data['deviceToken'], + })); +}); diff --git a/packages/project-client/src/services/channels/models/inbox-token-with-metadata.ts b/packages/project-client/src/services/channels/models/inbox-token-with-metadata.ts deleted file mode 100644 index 14cb0bd2..00000000 --- a/packages/project-client/src/services/channels/models/inbox-token-with-metadata.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { z } from 'zod'; - -import { inboxToken, inboxTokenRequest, inboxTokenResponse } from './inbox-token'; -import { - inboxTokenWithMetadataMetadata, - inboxTokenWithMetadataMetadataRequest, - inboxTokenWithMetadataMetadataResponse, -} from './inbox-token-with-metadata-metadata'; - -/** - * The shape of the model inside the application code - what the users use - */ -export const inboxTokenWithMetadata = z.lazy(() => { - return z.object({ - data: inboxToken, - metadata: inboxTokenWithMetadataMetadata, - }); -}); - -/** - * - * @typedef {InboxTokenWithMetadata} inboxTokenWithMetadata - * @property {InboxToken} - * @property {InboxTokenWithMetadataMetadata} - */ -export type InboxTokenWithMetadata = z.infer; - -/** - * The shape of the model mapping from the api schema into the application shape. - * Is equal to application shape if all property names match the api schema - */ -export const inboxTokenWithMetadataResponse = z.lazy(() => { - return z - .object({ - data: inboxTokenResponse, - metadata: inboxTokenWithMetadataMetadataResponse, - }) - .transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); -}); - -/** - * The shape of the model mapping from the application shape into the api schema. - * Is equal to application shape if all property names match the api schema - */ -export const inboxTokenWithMetadataRequest = z.lazy(() => { - return z - .object({ data: inboxTokenRequest.nullish(), metadata: inboxTokenWithMetadataMetadataRequest.nullish() }) - .transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); -}); diff --git a/packages/project-client/src/services/channels/models/index.ts b/packages/project-client/src/services/channels/models/index.ts index 15a326e2..64a77eda 100644 --- a/packages/project-client/src/services/channels/models/index.ts +++ b/packages/project-client/src/services/channels/models/index.ts @@ -4,10 +4,10 @@ export type { ApnsTokenWithMetadata } from './apns-token-with-metadata'; export type { ApnsTokenWithMetadataMetadata } from './apns-token-with-metadata-metadata'; export type { ArrayWithMetadataOfApnsToken } from './array-with-metadata-of-apns-token'; export type { ArrayWithMetadataOfApnsTokenData } from './array-with-metadata-of-apns-token-data'; +export type { ArrayWithMetadataOfExpoToken } from './array-with-metadata-of-expo-token'; +export type { ArrayWithMetadataOfExpoTokenData } from './array-with-metadata-of-expo-token-data'; export type { ArrayWithMetadataOfFcmToken } from './array-with-metadata-of-fcm-token'; export type { ArrayWithMetadataOfFcmTokenData } from './array-with-metadata-of-fcm-token-data'; -export type { ArrayWithMetadataOfInboxToken } from './array-with-metadata-of-inbox-token'; -export type { ArrayWithMetadataOfInboxTokenData } from './array-with-metadata-of-inbox-token-data'; export type { ArrayWithMetadataOfSlackToken } from './array-with-metadata-of-slack-token'; export type { ArrayWithMetadataOfSlackTokenData } from './array-with-metadata-of-slack-token-data'; export type { ArrayWithMetadataOfTeamsToken } from './array-with-metadata-of-teams-token'; @@ -21,21 +21,23 @@ export type { DataMetadata4 } from './data-metadata-4'; export type { DataMetadata5 } from './data-metadata-5'; export type { DataMetadata6 } from './data-metadata-6'; export type { DiscardResult } from './discard-result'; +export type { ExpoToken } from './expo-token'; +export type { ExpoTokenWithMetadata } from './expo-token-with-metadata'; +export type { ExpoTokenWithMetadataMetadata } from './expo-token-with-metadata-metadata'; export type { FcmToken } from './fcm-token'; export { FcmTokenInstallationId } from './fcm-token-installation-id'; export type { FcmTokenWithMetadata } from './fcm-token-with-metadata'; export type { FcmTokenWithMetadataMetadata } from './fcm-token-with-metadata-metadata'; -export type { InboxToken } from './inbox-token'; -export type { InboxTokenWithMetadata } from './inbox-token-with-metadata'; -export type { InboxTokenWithMetadataMetadata } from './inbox-token-with-metadata-metadata'; export type { Keys } from './keys'; export type { Oauth } from './oauth'; export type { SlackToken } from './slack-token'; +export type { SlackTokenWebhook } from './slack-token-webhook'; export type { SlackTokenWithMetadata } from './slack-token-with-metadata'; export type { SlackTokenWithMetadataMetadata } from './slack-token-with-metadata-metadata'; +export type { TeamsToken } from './teams-token'; +export type { TeamsTokenWebhook } from './teams-token-webhook'; export type { TeamsTokenWithMetadata } from './teams-token-with-metadata'; export type { TeamsTokenWithMetadataMetadata } from './teams-token-with-metadata-metadata'; export type { WebPushToken } from './web-push-token'; export type { WebPushTokenWithMetadata } from './web-push-token-with-metadata'; export type { WebPushTokenWithMetadataMetadata } from './web-push-token-with-metadata-metadata'; -export type { Webhook } from './webhook'; diff --git a/packages/project-client/src/services/channels/models/webhook.ts b/packages/project-client/src/services/channels/models/slack-token-webhook.ts similarity index 73% rename from packages/project-client/src/services/channels/models/webhook.ts rename to packages/project-client/src/services/channels/models/slack-token-webhook.ts index 80d30b9f..66d4af3b 100644 --- a/packages/project-client/src/services/channels/models/webhook.ts +++ b/packages/project-client/src/services/channels/models/slack-token-webhook.ts @@ -3,7 +3,7 @@ import { z } from 'zod'; /** * The shape of the model inside the application code - what the users use */ -export const webhook = z.lazy(() => { +export const slackTokenWebhook = z.lazy(() => { return z.object({ url: z.string(), }); @@ -11,16 +11,16 @@ export const webhook = z.lazy(() => { /** * - * @typedef {Webhook} webhook + * @typedef {SlackTokenWebhook} slackTokenWebhook * @property {string} */ -export type Webhook = z.infer; +export type SlackTokenWebhook = z.infer; /** * The shape of the model mapping from the api schema into the application shape. * Is equal to application shape if all property names match the api schema */ -export const webhookResponse = z.lazy(() => { +export const slackTokenWebhookResponse = z.lazy(() => { return z .object({ url: z.string(), @@ -34,7 +34,7 @@ export const webhookResponse = z.lazy(() => { * The shape of the model mapping from the application shape into the api schema. * Is equal to application shape if all property names match the api schema */ -export const webhookRequest = z.lazy(() => { +export const slackTokenWebhookRequest = z.lazy(() => { return z.object({ url: z.string().nullish() }).transform((data) => ({ url: data['url'], })); diff --git a/packages/project-client/src/services/channels/models/slack-token.ts b/packages/project-client/src/services/channels/models/slack-token.ts index c8087f81..e985889f 100644 --- a/packages/project-client/src/services/channels/models/slack-token.ts +++ b/packages/project-client/src/services/channels/models/slack-token.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { oauth, oauthRequest, oauthResponse } from './oauth'; -import { webhook, webhookRequest, webhookResponse } from './webhook'; +import { slackTokenWebhook, slackTokenWebhookRequest, slackTokenWebhookResponse } from './slack-token-webhook'; /** * The shape of the model inside the application code - what the users use @@ -9,7 +9,7 @@ import { webhook, webhookRequest, webhookResponse } from './webhook'; export const slackToken = z.lazy(() => { return z.object({ oauth: oauth.optional(), - webhook: webhook.optional(), + webhook: slackTokenWebhook.optional(), }); }); @@ -17,7 +17,7 @@ export const slackToken = z.lazy(() => { * * @typedef {SlackToken} slackToken * @property {Oauth} - * @property {Webhook} + * @property {SlackTokenWebhook} */ export type SlackToken = z.infer; @@ -29,7 +29,7 @@ export const slackTokenResponse = z.lazy(() => { return z .object({ oauth: oauthResponse.optional(), - webhook: webhookResponse.optional(), + webhook: slackTokenWebhookResponse.optional(), }) .transform((data) => ({ oauth: data['oauth'], @@ -42,7 +42,7 @@ export const slackTokenResponse = z.lazy(() => { * Is equal to application shape if all property names match the api schema */ export const slackTokenRequest = z.lazy(() => { - return z.object({ oauth: oauthRequest.nullish(), webhook: webhookRequest.nullish() }).transform((data) => ({ + return z.object({ oauth: oauthRequest.nullish(), webhook: slackTokenWebhookRequest.nullish() }).transform((data) => ({ oauth: data['oauth'], webhook: data['webhook'], })); diff --git a/packages/project-client/src/services/channels/models/teams-token-webhook.ts b/packages/project-client/src/services/channels/models/teams-token-webhook.ts new file mode 100644 index 00000000..95121613 --- /dev/null +++ b/packages/project-client/src/services/channels/models/teams-token-webhook.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const teamsTokenWebhook = z.lazy(() => { + return z.object({ + url: z.string().optional(), + }); +}); + +/** + * + * @typedef {TeamsTokenWebhook} teamsTokenWebhook + * @property {string} + */ +export type TeamsTokenWebhook = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const teamsTokenWebhookResponse = z.lazy(() => { + return z + .object({ + url: z.string().optional(), + }) + .transform((data) => ({ + url: data['url'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const teamsTokenWebhookRequest = z.lazy(() => { + return z.object({ url: z.string().nullish() }).transform((data) => ({ + url: data['url'], + })); +}); diff --git a/packages/project-client/src/services/channels/models/teams-token-with-metadata.ts b/packages/project-client/src/services/channels/models/teams-token-with-metadata.ts index d64c03b6..fa95bc84 100644 --- a/packages/project-client/src/services/channels/models/teams-token-with-metadata.ts +++ b/packages/project-client/src/services/channels/models/teams-token-with-metadata.ts @@ -1,5 +1,6 @@ import { z } from 'zod'; +import { teamsToken, teamsTokenRequest, teamsTokenResponse } from './teams-token'; import { teamsTokenWithMetadataMetadata, teamsTokenWithMetadataMetadataRequest, @@ -11,7 +12,7 @@ import { */ export const teamsTokenWithMetadata = z.lazy(() => { return z.object({ - data: z.any(), + data: teamsToken, metadata: teamsTokenWithMetadataMetadata, }); }); @@ -19,7 +20,7 @@ export const teamsTokenWithMetadata = z.lazy(() => { /** * * @typedef {TeamsTokenWithMetadata} teamsTokenWithMetadata - * @property {any} + * @property {TeamsToken} * @property {TeamsTokenWithMetadataMetadata} */ export type TeamsTokenWithMetadata = z.infer; @@ -31,7 +32,7 @@ export type TeamsTokenWithMetadata = z.infer; export const teamsTokenWithMetadataResponse = z.lazy(() => { return z .object({ - data: z.any(), + data: teamsTokenResponse, metadata: teamsTokenWithMetadataMetadataResponse, }) .transform((data) => ({ @@ -46,7 +47,7 @@ export const teamsTokenWithMetadataResponse = z.lazy(() => { */ export const teamsTokenWithMetadataRequest = z.lazy(() => { return z - .object({ data: z.any().nullish(), metadata: teamsTokenWithMetadataMetadataRequest.nullish() }) + .object({ data: teamsTokenRequest.nullish(), metadata: teamsTokenWithMetadataMetadataRequest.nullish() }) .transform((data) => ({ data: data['data'], metadata: data['metadata'], diff --git a/packages/project-client/src/services/channels/models/teams-token.ts b/packages/project-client/src/services/channels/models/teams-token.ts new file mode 100644 index 00000000..992c6323 --- /dev/null +++ b/packages/project-client/src/services/channels/models/teams-token.ts @@ -0,0 +1,43 @@ +import { z } from 'zod'; + +import { teamsTokenWebhook, teamsTokenWebhookRequest, teamsTokenWebhookResponse } from './teams-token-webhook'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const teamsToken = z.lazy(() => { + return z.object({ + webhook: teamsTokenWebhook.optional(), + }); +}); + +/** + * + * @typedef {TeamsToken} teamsToken + * @property {TeamsTokenWebhook} + */ +export type TeamsToken = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const teamsTokenResponse = z.lazy(() => { + return z + .object({ + webhook: teamsTokenWebhookResponse.optional(), + }) + .transform((data) => ({ + webhook: data['webhook'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const teamsTokenRequest = z.lazy(() => { + return z.object({ webhook: teamsTokenWebhookRequest.nullish() }).transform((data) => ({ + webhook: data['webhook'], + })); +}); diff --git a/packages/project-client/src/services/integrations/integrations.ts b/packages/project-client/src/services/integrations/integrations.ts index 5a130596..efc5355c 100644 --- a/packages/project-client/src/services/integrations/integrations.ts +++ b/packages/project-client/src/services/integrations/integrations.ts @@ -1,10 +1,11 @@ import { z } from 'zod'; -import { SerializationStyle } from '../../http/serialization/base-serializer'; import { RequestBuilder } from '../../http/transport/request-builder'; import { ContentType, HttpResponse, RequestConfig } from '../../http/types'; import { BaseService } from '../base-service'; import { ApnsConfig, apnsConfigRequest, apnsConfigResponse } from './models/apns-config'; +import { AwssnsConfig, awssnsConfigRequest, awssnsConfigResponse } from './models/awssns-config'; +import { ExpoConfig, expoConfigRequest, expoConfigResponse } from './models/expo-config'; import { FcmConfig, fcmConfigRequest, fcmConfigResponse } from './models/fcm-config'; import { GithubConfig, githubConfigRequest, githubConfigResponse } from './models/github-config'; import { InboxConfig, inboxConfigRequest, inboxConfigResponse } from './models/inbox-config'; @@ -131,6 +132,188 @@ export class IntegrationsService extends BaseService { return this.client.call(request); } + /** + * + * @returns {Promise>} OK + */ + async getAwssnsIntegration(requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('GET') + .setPath('/integrations/awssns') + .setRequestSchema(z.any()) + .setResponseSchema(listIntegrationsResponseResponse) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .build(); + return this.client.call(request); + } + + /** + * + * @returns {Promise>} OK + */ + async saveAwssnsIntegration(body: AwssnsConfig, requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('PUT') + .setPath('/integrations/awssns') + .setRequestSchema(awssnsConfigRequest) + .setResponseSchema(awssnsConfigResponse) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) + .addBody(body) + .build(); + return this.client.call(request); + } + + /** + * + * @returns {Promise>} No Content + */ + async deleteAwssnsIntegration(requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('DELETE') + .setPath('/integrations/awssns') + .setRequestSchema(z.any()) + .setResponseSchema(z.undefined()) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .build(); + return this.client.call(request); + } + + /** + * + * @param {string} id - + * @returns {Promise>} No Content + */ + async deleteAwssnsIntegrationById(id: string, requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('DELETE') + .setPath('/integrations/awssns/{id}') + .setRequestSchema(z.any()) + .setResponseSchema(z.undefined()) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .addPathParam({ + key: 'id', + value: id, + }) + .build(); + return this.client.call(request); + } + + /** + * + * @returns {Promise>} OK + */ + async getExpoIntegration(requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('GET') + .setPath('/integrations/expo') + .setRequestSchema(z.any()) + .setResponseSchema(listIntegrationsResponseResponse) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .build(); + return this.client.call(request); + } + + /** + * + * @returns {Promise>} OK + */ + async saveExpoIntegration(body: ExpoConfig, requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('PUT') + .setPath('/integrations/expo') + .setRequestSchema(expoConfigRequest) + .setResponseSchema(expoConfigResponse) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) + .addBody(body) + .build(); + return this.client.call(request); + } + + /** + * + * @returns {Promise>} No Content + */ + async deleteExpoIntegration(requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('DELETE') + .setPath('/integrations/expo') + .setRequestSchema(z.any()) + .setResponseSchema(z.undefined()) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .build(); + return this.client.call(request); + } + + /** + * + * @param {string} id - + * @returns {Promise>} No Content + */ + async deleteExpoIntegrationById(id: string, requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('DELETE') + .setPath('/integrations/expo/{id}') + .setRequestSchema(z.any()) + .setResponseSchema(z.undefined()) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .addPathParam({ + key: 'id', + value: id, + }) + .build(); + return this.client.call(request); + } + /** * * @returns {Promise>} OK diff --git a/packages/project-client/src/services/integrations/models/awssns-config.ts b/packages/project-client/src/services/integrations/models/awssns-config.ts new file mode 100644 index 00000000..025957bb --- /dev/null +++ b/packages/project-client/src/services/integrations/models/awssns-config.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const awssnsConfig = z.lazy(() => { + return z.object({ + webhookSigningSecret: z.string().min(1), + }); +}); + +/** + * + * @typedef {AwssnsConfig} awssnsConfig + * @property {string} - The signing certificate from AWS SNS + */ +export type AwssnsConfig = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const awssnsConfigResponse = z.lazy(() => { + return z + .object({ + webhook_signing_secret: z.string().min(1), + }) + .transform((data) => ({ + webhookSigningSecret: data['webhook_signing_secret'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const awssnsConfigRequest = z.lazy(() => { + return z.object({ webhookSigningSecret: z.string().nullish() }).transform((data) => ({ + webhook_signing_secret: data['webhookSigningSecret'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/banner.ts b/packages/project-client/src/services/integrations/models/banner.ts new file mode 100644 index 00000000..ba226518 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/banner.ts @@ -0,0 +1,63 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const banner = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + backgroundOpacity: z.number().optional(), + fontSize: z.string(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Banner} banner + * @property {string} + * @property {number} + * @property {string} + * @property {string} + */ +export type Banner = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const bannerResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + backgroundOpacity: z.number().optional(), + fontSize: z.string(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + backgroundOpacity: data['backgroundOpacity'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const bannerRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + backgroundOpacity: z.number().nullish(), + fontSize: z.string().nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + backgroundOpacity: data['backgroundOpacity'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/default-hover.ts b/packages/project-client/src/services/integrations/models/default-hover.ts new file mode 100644 index 00000000..11a20f49 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/default-hover.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const defaultHover = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + }); +}); + +/** + * + * @typedef {DefaultHover} defaultHover + * @property {string} + */ +export type DefaultHover = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const defaultHoverResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const defaultHoverRequest = z.lazy(() => { + return z.object({ backgroundColor: z.string().nullish() }).transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/default-state.ts b/packages/project-client/src/services/integrations/models/default-state.ts new file mode 100644 index 00000000..236276a9 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/default-state.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const defaultState = z.lazy(() => { + return z.object({ + color: z.string(), + }); +}); + +/** + * + * @typedef {DefaultState} defaultState + * @property {string} + */ +export type DefaultState = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const defaultStateResponse = z.lazy(() => { + return z + .object({ + color: z.string(), + }) + .transform((data) => ({ + color: data['color'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const defaultStateRequest = z.lazy(() => { + return z.object({ color: z.string().nullish() }).transform((data) => ({ + color: data['color'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/default_.ts b/packages/project-client/src/services/integrations/models/default_.ts new file mode 100644 index 00000000..19689028 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/default_.ts @@ -0,0 +1,90 @@ +import { z } from 'zod'; + +import { defaultHover, defaultHoverRequest, defaultHoverResponse } from './default-hover'; +import { defaultState, defaultStateRequest, defaultStateResponse } from './default-state'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const default_ = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontFamily: z.string(), + fontSize: z.string(), + hover: defaultHover.optional(), + margin: z.string(), + state: defaultState.optional(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Default_} default_ + * @property {string} + * @property {string} + * @property {string} + * @property {string} + * @property {DefaultHover} + * @property {string} + * @property {DefaultState} + * @property {string} + */ +export type Default_ = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const defaultResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontFamily: z.string(), + fontSize: z.string(), + hover: defaultHoverResponse.optional(), + margin: z.string(), + state: defaultStateResponse.optional(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontFamily: data['fontFamily'], + fontSize: data['fontSize'], + hover: data['hover'], + margin: data['margin'], + state: data['state'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const defaultRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + borderRadius: z.string().nullish(), + fontFamily: z.string().nullish(), + fontSize: z.string().nullish(), + hover: defaultHoverRequest.nullish(), + margin: z.string().nullish(), + state: defaultStateRequest.nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontFamily: data['fontFamily'], + fontSize: data['fontSize'], + hover: data['hover'], + margin: data['margin'], + state: data['state'], + textColor: data['textColor'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/dialog.ts b/packages/project-client/src/services/integrations/models/dialog.ts new file mode 100644 index 00000000..258bcee9 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/dialog.ts @@ -0,0 +1,57 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const dialog = z.lazy(() => { + return z.object({ + accentColor: z.string(), + backgroundColor: z.string(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Dialog} dialog + * @property {string} + * @property {string} + * @property {string} + */ +export type Dialog = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const dialogResponse = z.lazy(() => { + return z + .object({ + accentColor: z.string(), + backgroundColor: z.string(), + textColor: z.string(), + }) + .transform((data) => ({ + accentColor: data['accentColor'], + backgroundColor: data['backgroundColor'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const dialogRequest = z.lazy(() => { + return z + .object({ + accentColor: z.string().nullish(), + backgroundColor: z.string().nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + accentColor: data['accentColor'], + backgroundColor: data['backgroundColor'], + textColor: data['textColor'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/expo-config.ts b/packages/project-client/src/services/integrations/models/expo-config.ts new file mode 100644 index 00000000..90198143 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/expo-config.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const expoConfig = z.lazy(() => { + return z.object({ + accessToken: z.string().min(1), + }); +}); + +/** + * + * @typedef {ExpoConfig} expoConfig + * @property {string} + */ +export type ExpoConfig = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const expoConfigResponse = z.lazy(() => { + return z + .object({ + access_token: z.string().min(1), + }) + .transform((data) => ({ + accessToken: data['access_token'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const expoConfigRequest = z.lazy(() => { + return z.object({ accessToken: z.string().nullish() }).transform((data) => ({ + access_token: data['accessToken'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/footer.ts b/packages/project-client/src/services/integrations/models/footer.ts new file mode 100644 index 00000000..8e7b8717 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/footer.ts @@ -0,0 +1,63 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const footer = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontSize: z.string(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Footer} footer + * @property {string} + * @property {string} + * @property {string} + * @property {string} + */ +export type Footer = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const footerResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontSize: z.string(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const footerRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + borderRadius: z.string().nullish(), + fontSize: z.string().nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/github-config.ts b/packages/project-client/src/services/integrations/models/github-config.ts index 945bb249..cd8a1e15 100644 --- a/packages/project-client/src/services/integrations/models/github-config.ts +++ b/packages/project-client/src/services/integrations/models/github-config.ts @@ -12,7 +12,7 @@ export const githubConfig = z.lazy(() => { /** * * @typedef {GithubConfig} githubConfig - * @property {string} - The signing secret to verify incoming requests from Stripe + * @property {string} - The signing secret to verify incoming requests from Github */ export type GithubConfig = z.infer; diff --git a/packages/project-client/src/services/integrations/models/header.ts b/packages/project-client/src/services/integrations/models/header.ts new file mode 100644 index 00000000..5d42dacf --- /dev/null +++ b/packages/project-client/src/services/integrations/models/header.ts @@ -0,0 +1,69 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const header = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontFamily: z.string(), + fontSize: z.string(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Header} header + * @property {string} + * @property {string} + * @property {string} + * @property {string} + * @property {string} + */ +export type Header = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const headerResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontFamily: z.string(), + fontSize: z.string(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontFamily: data['fontFamily'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const headerRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + borderRadius: z.string().nullish(), + fontFamily: z.string().nullish(), + fontSize: z.string().nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontFamily: data['fontFamily'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/icon.ts b/packages/project-client/src/services/integrations/models/icon.ts new file mode 100644 index 00000000..c118c4bb --- /dev/null +++ b/packages/project-client/src/services/integrations/models/icon.ts @@ -0,0 +1,46 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const icon = z.lazy(() => { + return z.object({ + borderColor: z.string(), + width: z.string(), + }); +}); + +/** + * + * @typedef {Icon} icon + * @property {string} + * @property {string} + */ +export type Icon = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const iconResponse = z.lazy(() => { + return z + .object({ + borderColor: z.string(), + width: z.string(), + }) + .transform((data) => ({ + borderColor: data['borderColor'], + width: data['width'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const iconRequest = z.lazy(() => { + return z.object({ borderColor: z.string().nullish(), width: z.string().nullish() }).transform((data) => ({ + borderColor: data['borderColor'], + width: data['width'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/images.ts b/packages/project-client/src/services/integrations/models/images.ts new file mode 100644 index 00000000..ae21479e --- /dev/null +++ b/packages/project-client/src/services/integrations/models/images.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const images = z.lazy(() => { + return z.object({ + emptyInboxUrl: z.string(), + }); +}); + +/** + * + * @typedef {Images} images + * @property {string} + */ +export type Images = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const imagesResponse = z.lazy(() => { + return z + .object({ + emptyInboxUrl: z.string(), + }) + .transform((data) => ({ + emptyInboxUrl: data['emptyInboxUrl'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const imagesRequest = z.lazy(() => { + return z.object({ emptyInboxUrl: z.string().nullish() }).transform((data) => ({ + emptyInboxUrl: data['emptyInboxUrl'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/inbox-config.ts b/packages/project-client/src/services/integrations/models/inbox-config.ts index 8513a4ef..2daa02a7 100644 --- a/packages/project-client/src/services/integrations/models/inbox-config.ts +++ b/packages/project-client/src/services/integrations/models/inbox-config.ts @@ -1,22 +1,25 @@ import { z } from 'zod'; +import { images, imagesRequest, imagesResponse } from './images'; +import { theme, themeRequest, themeResponse } from './theme'; + /** * The shape of the model inside the application code - what the users use */ export const inboxConfig = z.lazy(() => { return z.object({ - images: z.any().nullable(), + images: images.nullable(), locale: z.string().min(2).nullable(), - theme: z.any().nullable(), + theme: theme.nullable(), }); }); /** * * @typedef {InboxConfig} inboxConfig - * @property {any} + * @property {Images} * @property {string} - * @property {any} + * @property {Theme} */ export type InboxConfig = z.infer; @@ -27,9 +30,9 @@ export type InboxConfig = z.infer; export const inboxConfigResponse = z.lazy(() => { return z .object({ - images: z.any().nullable(), + images: imagesResponse.nullable(), locale: z.string().min(2).nullable(), - theme: z.any().nullable(), + theme: themeResponse.nullable(), }) .transform((data) => ({ images: data['images'], @@ -44,7 +47,7 @@ export const inboxConfigResponse = z.lazy(() => { */ export const inboxConfigRequest = z.lazy(() => { return z - .object({ images: z.any().nullish(), locale: z.string().nullish(), theme: z.any().nullish() }) + .object({ images: imagesRequest.nullish(), locale: z.string().nullish(), theme: themeRequest.nullish() }) .transform((data) => ({ images: data['images'], locale: data['locale'], diff --git a/packages/project-client/src/services/integrations/models/index.ts b/packages/project-client/src/services/integrations/models/index.ts index 36d6482c..86f72d56 100644 --- a/packages/project-client/src/services/integrations/models/index.ts +++ b/packages/project-client/src/services/integrations/models/index.ts @@ -1,12 +1,24 @@ export type { ApnsConfig } from './apns-config'; +export type { AwssnsConfig } from './awssns-config'; export { Badge } from './badge'; +export type { Banner } from './banner'; +export type { Default_ } from './default_'; +export type { DefaultHover } from './default-hover'; +export type { DefaultState } from './default-state'; +export type { Dialog } from './dialog'; +export type { ExpoConfig } from './expo-config'; export type { FcmConfig } from './fcm-config'; +export type { Footer } from './footer'; export type { GithubConfig } from './github-config'; +export type { Header } from './header'; +export type { Icon } from './icon'; +export type { Images } from './images'; export type { InboxConfig } from './inbox-config'; export type { Integrations } from './integrations'; export type { ListIntegrationsResponse } from './list-integrations-response'; export type { MailgunConfig } from './mailgun-config'; export { MailgunConfigRegion } from './mailgun-config-region'; +export type { Notification } from './notification'; export type { PingConfig } from './ping-config'; export type { ReplyTo } from './reply-to'; export type { SendgridConfig } from './sendgrid-config'; @@ -15,7 +27,15 @@ export type { SesConfig } from './ses-config'; export type { SesConfigFrom } from './ses-config-from'; export type { SlackConfig } from './slack-config'; export type { StripeConfig } from './stripe-config'; +export type { Theme } from './theme'; export type { TwilioConfig } from './twilio-config'; export { TwilioConfigRegion } from './twilio-config-region'; export { Type_ } from './type_'; +export type { Unread } from './unread'; +export type { UnreadHover } from './unread-hover'; +export type { UnreadState } from './unread-state'; +export type { Unseen } from './unseen'; +export type { UnseenBadge } from './unseen-badge'; +export type { UnseenHover } from './unseen-hover'; +export type { UnseenState } from './unseen-state'; export type { WebpushConfig } from './webpush-config'; diff --git a/packages/project-client/src/services/integrations/models/notification.ts b/packages/project-client/src/services/integrations/models/notification.ts new file mode 100644 index 00000000..e7c6b693 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/notification.ts @@ -0,0 +1,57 @@ +import { z } from 'zod'; + +import { default_, defaultRequest, defaultResponse } from './default_'; +import { unread, unreadRequest, unreadResponse } from './unread'; +import { unseen, unseenRequest, unseenResponse } from './unseen'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const notification = z.lazy(() => { + return z.object({ + default: default_, + unread: unread, + unseen: unseen, + }); +}); + +/** + * + * @typedef {Notification} notification + * @property {Default_} + * @property {Unread} + * @property {Unseen} + */ +export type Notification = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const notificationResponse = z.lazy(() => { + return z + .object({ + default: defaultResponse, + unread: unreadResponse, + unseen: unseenResponse, + }) + .transform((data) => ({ + default: data['default'], + unread: data['unread'], + unseen: data['unseen'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const notificationRequest = z.lazy(() => { + return z + .object({ default: defaultRequest.nullish(), unread: unreadRequest.nullish(), unseen: unseenRequest.nullish() }) + .transform((data) => ({ + default: data['default'], + unread: data['unread'], + unseen: data['unseen'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/slack-config.ts b/packages/project-client/src/services/integrations/models/slack-config.ts index 45eface9..1cee92af 100644 --- a/packages/project-client/src/services/integrations/models/slack-config.ts +++ b/packages/project-client/src/services/integrations/models/slack-config.ts @@ -8,11 +8,6 @@ export const slackConfig = z.lazy(() => { appId: z.string().regex(/^[0-9A-Z]+$/), clientId: z.string().regex(/^[0-9]+\.[0-9]+$/), clientSecret: z.string().min(32).max(32), - id: z - .string() - .min(1) - .regex(/^[\w]*/) - .optional(), signingSecret: z.string().min(32).max(32), }); }); @@ -24,7 +19,6 @@ export const slackConfig = z.lazy(() => { * @property {string} * @property {string} * @property {string} - * @property {string} */ export type SlackConfig = z.infer; @@ -38,18 +32,12 @@ export const slackConfigResponse = z.lazy(() => { app_id: z.string().regex(/^[0-9A-Z]+$/), client_id: z.string().regex(/^[0-9]+\.[0-9]+$/), client_secret: z.string().min(32).max(32), - id: z - .string() - .min(1) - .regex(/^[\w]*/) - .optional(), signing_secret: z.string().min(32).max(32), }) .transform((data) => ({ appId: data['app_id'], clientId: data['client_id'], clientSecret: data['client_secret'], - id: data['id'], signingSecret: data['signing_secret'], })); }); @@ -64,14 +52,12 @@ export const slackConfigRequest = z.lazy(() => { appId: z.string().nullish(), clientId: z.string().nullish(), clientSecret: z.string().nullish(), - id: z.string().nullish(), signingSecret: z.string().nullish(), }) .transform((data) => ({ app_id: data['appId'], client_id: data['clientId'], client_secret: data['clientSecret'], - id: data['id'], signing_secret: data['signingSecret'], })); }); diff --git a/packages/project-client/src/services/integrations/models/theme.ts b/packages/project-client/src/services/integrations/models/theme.ts new file mode 100644 index 00000000..694558dc --- /dev/null +++ b/packages/project-client/src/services/integrations/models/theme.ts @@ -0,0 +1,89 @@ +import { z } from 'zod'; + +import { banner, bannerRequest, bannerResponse } from './banner'; +import { dialog, dialogRequest, dialogResponse } from './dialog'; +import { footer, footerRequest, footerResponse } from './footer'; +import { header, headerRequest, headerResponse } from './header'; +import { icon, iconRequest, iconResponse } from './icon'; +import { notification, notificationRequest, notificationResponse } from './notification'; +import { unseenBadge, unseenBadgeRequest, unseenBadgeResponse } from './unseen-badge'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const theme = z.lazy(() => { + return z.object({ + banner: banner.optional(), + dialog: dialog.optional(), + footer: footer.optional(), + header: header.optional(), + icon: icon.optional(), + notification: notification.optional(), + unseenBadge: unseenBadge.optional(), + }); +}); + +/** + * + * @typedef {Theme} theme + * @property {Banner} + * @property {Dialog} + * @property {Footer} + * @property {Header} + * @property {Icon} + * @property {Notification} + * @property {UnseenBadge} + */ +export type Theme = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const themeResponse = z.lazy(() => { + return z + .object({ + banner: bannerResponse.optional(), + dialog: dialogResponse.optional(), + footer: footerResponse.optional(), + header: headerResponse.optional(), + icon: iconResponse.optional(), + notification: notificationResponse.optional(), + unseenBadge: unseenBadgeResponse.optional(), + }) + .transform((data) => ({ + banner: data['banner'], + dialog: data['dialog'], + footer: data['footer'], + header: data['header'], + icon: data['icon'], + notification: data['notification'], + unseenBadge: data['unseenBadge'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const themeRequest = z.lazy(() => { + return z + .object({ + banner: bannerRequest.nullish(), + dialog: dialogRequest.nullish(), + footer: footerRequest.nullish(), + header: headerRequest.nullish(), + icon: iconRequest.nullish(), + notification: notificationRequest.nullish(), + unseenBadge: unseenBadgeRequest.nullish(), + }) + .transform((data) => ({ + banner: data['banner'], + dialog: data['dialog'], + footer: data['footer'], + header: data['header'], + icon: data['icon'], + notification: data['notification'], + unseenBadge: data['unseenBadge'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/unread-hover.ts b/packages/project-client/src/services/integrations/models/unread-hover.ts new file mode 100644 index 00000000..091e0886 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/unread-hover.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unreadHover = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + }); +}); + +/** + * + * @typedef {UnreadHover} unreadHover + * @property {string} + */ +export type UnreadHover = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unreadHoverResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unreadHoverRequest = z.lazy(() => { + return z.object({ backgroundColor: z.string().nullish() }).transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); diff --git a/packages/project-client/src/services/channels/models/inbox-token.ts b/packages/project-client/src/services/integrations/models/unread-state.ts similarity index 59% rename from packages/project-client/src/services/channels/models/inbox-token.ts rename to packages/project-client/src/services/integrations/models/unread-state.ts index cf8432cd..50a1388d 100644 --- a/packages/project-client/src/services/channels/models/inbox-token.ts +++ b/packages/project-client/src/services/integrations/models/unread-state.ts @@ -3,30 +3,30 @@ import { z } from 'zod'; /** * The shape of the model inside the application code - what the users use */ -export const inboxToken = z.lazy(() => { +export const unreadState = z.lazy(() => { return z.object({ - token: z.string(), + color: z.string(), }); }); /** * - * @typedef {InboxToken} inboxToken + * @typedef {UnreadState} unreadState * @property {string} */ -export type InboxToken = z.infer; +export type UnreadState = z.infer; /** * The shape of the model mapping from the api schema into the application shape. * Is equal to application shape if all property names match the api schema */ -export const inboxTokenResponse = z.lazy(() => { +export const unreadStateResponse = z.lazy(() => { return z .object({ - token: z.string(), + color: z.string(), }) .transform((data) => ({ - token: data['token'], + color: data['color'], })); }); @@ -34,8 +34,8 @@ export const inboxTokenResponse = z.lazy(() => { * The shape of the model mapping from the application shape into the api schema. * Is equal to application shape if all property names match the api schema */ -export const inboxTokenRequest = z.lazy(() => { - return z.object({ token: z.string().nullish() }).transform((data) => ({ - token: data['token'], +export const unreadStateRequest = z.lazy(() => { + return z.object({ color: z.string().nullish() }).transform((data) => ({ + color: data['color'], })); }); diff --git a/packages/project-client/src/services/integrations/models/unread.ts b/packages/project-client/src/services/integrations/models/unread.ts new file mode 100644 index 00000000..5f522156 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/unread.ts @@ -0,0 +1,66 @@ +import { z } from 'zod'; + +import { unreadHover, unreadHoverRequest, unreadHoverResponse } from './unread-hover'; +import { unreadState, unreadStateRequest, unreadStateResponse } from './unread-state'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unread = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + hover: unreadHover.optional(), + state: unreadState.optional(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Unread} unread + * @property {string} + * @property {UnreadHover} + * @property {UnreadState} + * @property {string} + */ +export type Unread = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unreadResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + hover: unreadHoverResponse.optional(), + state: unreadStateResponse.optional(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + hover: data['hover'], + state: data['state'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unreadRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + hover: unreadHoverRequest.nullish(), + state: unreadStateRequest.nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + hover: data['hover'], + state: data['state'], + textColor: data['textColor'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/unseen-badge.ts b/packages/project-client/src/services/integrations/models/unseen-badge.ts new file mode 100644 index 00000000..7f370808 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/unseen-badge.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unseenBadge = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + }); +}); + +/** + * + * @typedef {UnseenBadge} unseenBadge + * @property {string} + */ +export type UnseenBadge = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unseenBadgeResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unseenBadgeRequest = z.lazy(() => { + return z.object({ backgroundColor: z.string().nullish() }).transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); diff --git a/packages/project-client/src/services/integrations/models/unseen-hover.ts b/packages/project-client/src/services/integrations/models/unseen-hover.ts new file mode 100644 index 00000000..32cc7e07 --- /dev/null +++ b/packages/project-client/src/services/integrations/models/unseen-hover.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unseenHover = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + }); +}); + +/** + * + * @typedef {UnseenHover} unseenHover + * @property {string} + */ +export type UnseenHover = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unseenHoverResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unseenHoverRequest = z.lazy(() => { + return z.object({ backgroundColor: z.string().nullish() }).transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); diff --git a/packages/user-client/src/services/channels/models/inbox-token.ts b/packages/project-client/src/services/integrations/models/unseen-state.ts similarity index 59% rename from packages/user-client/src/services/channels/models/inbox-token.ts rename to packages/project-client/src/services/integrations/models/unseen-state.ts index cf8432cd..7a447d6c 100644 --- a/packages/user-client/src/services/channels/models/inbox-token.ts +++ b/packages/project-client/src/services/integrations/models/unseen-state.ts @@ -3,30 +3,30 @@ import { z } from 'zod'; /** * The shape of the model inside the application code - what the users use */ -export const inboxToken = z.lazy(() => { +export const unseenState = z.lazy(() => { return z.object({ - token: z.string(), + color: z.string(), }); }); /** * - * @typedef {InboxToken} inboxToken + * @typedef {UnseenState} unseenState * @property {string} */ -export type InboxToken = z.infer; +export type UnseenState = z.infer; /** * The shape of the model mapping from the api schema into the application shape. * Is equal to application shape if all property names match the api schema */ -export const inboxTokenResponse = z.lazy(() => { +export const unseenStateResponse = z.lazy(() => { return z .object({ - token: z.string(), + color: z.string(), }) .transform((data) => ({ - token: data['token'], + color: data['color'], })); }); @@ -34,8 +34,8 @@ export const inboxTokenResponse = z.lazy(() => { * The shape of the model mapping from the application shape into the api schema. * Is equal to application shape if all property names match the api schema */ -export const inboxTokenRequest = z.lazy(() => { - return z.object({ token: z.string().nullish() }).transform((data) => ({ - token: data['token'], +export const unseenStateRequest = z.lazy(() => { + return z.object({ color: z.string().nullish() }).transform((data) => ({ + color: data['color'], })); }); diff --git a/packages/project-client/src/services/integrations/models/unseen.ts b/packages/project-client/src/services/integrations/models/unseen.ts new file mode 100644 index 00000000..ddb66e2f --- /dev/null +++ b/packages/project-client/src/services/integrations/models/unseen.ts @@ -0,0 +1,66 @@ +import { z } from 'zod'; + +import { unseenHover, unseenHoverRequest, unseenHoverResponse } from './unseen-hover'; +import { unseenState, unseenStateRequest, unseenStateResponse } from './unseen-state'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unseen = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + hover: unseenHover.optional(), + state: unseenState.optional(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Unseen} unseen + * @property {string} + * @property {UnseenHover} + * @property {UnseenState} + * @property {string} + */ +export type Unseen = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unseenResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + hover: unseenHoverResponse.optional(), + state: unseenStateResponse.optional(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + hover: data['hover'], + state: data['state'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unseenRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + hover: unseenHoverRequest.nullish(), + state: unseenStateRequest.nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + hover: data['hover'], + state: data['state'], + textColor: data['textColor'], + })); +}); diff --git a/packages/user-client/README.md b/packages/user-client/README.md index 460fef21..613489b7 100644 --- a/packages/user-client/README.md +++ b/packages/user-client/README.md @@ -19,6 +19,7 @@ OpenAPI 3.1.0 Specification for MagicBell API. - [Authentication](#authentication) - [Access Token Authentication](#access-token-authentication) - [Setting a Custom Timeout](#setting-a-custom-timeout) +- [Sample Usage](#sample-usage) - [Services](#services) - [Models](#models) @@ -67,6 +68,24 @@ You can set a custom timeout for the SDK's HTTP requests as follows: const client = new Client({ timeout: 10000 }); ``` +# Sample Usage + +Below is a comprehensive example demonstrating how to authenticate and call a simple endpoint: + +```ts +import { Client } from '@magicbell/user-client'; + +(async () => { + const client = new Client({ + token: 'YOUR_TOKEN', + }); + + const { data } = await client.channels.getMobilePushApnsTokens(); + + console.log(data); +})(); +``` + ## Services The SDK provides various services to interact with the API. @@ -90,13 +109,13 @@ The SDK includes several models that represent the data structures used in API r | Name | Description | | :------------------------------------------------------------------------------------------- | :---------- | -| [ArrayWithMetadataOfInboxToken](documentation/models/ArrayWithMetadataOfInboxToken.md) | | -| [InboxToken](documentation/models/InboxToken.md) | | -| [InboxTokenWithMetadata](documentation/models/InboxTokenWithMetadata.md) | | -| [DiscardResult](documentation/models/DiscardResult.md) | | | [ArrayWithMetadataOfApnsToken](documentation/models/ArrayWithMetadataOfApnsToken.md) | | | [ApnsToken](documentation/models/ApnsToken.md) | | | [ApnsTokenWithMetadata](documentation/models/ApnsTokenWithMetadata.md) | | +| [DiscardResult](documentation/models/DiscardResult.md) | | +| [ArrayWithMetadataOfExpoToken](documentation/models/ArrayWithMetadataOfExpoToken.md) | | +| [ExpoToken](documentation/models/ExpoToken.md) | | +| [ExpoTokenWithMetadata](documentation/models/ExpoTokenWithMetadata.md) | | | [ArrayWithMetadataOfFcmToken](documentation/models/ArrayWithMetadataOfFcmToken.md) | | | [FcmToken](documentation/models/FcmToken.md) | | | [FcmTokenWithMetadata](documentation/models/FcmTokenWithMetadata.md) | | @@ -104,6 +123,7 @@ The SDK includes several models that represent the data structures used in API r | [SlackToken](documentation/models/SlackToken.md) | | | [SlackTokenWithMetadata](documentation/models/SlackTokenWithMetadata.md) | | | [ArrayWithMetadataOfTeamsToken](documentation/models/ArrayWithMetadataOfTeamsToken.md) | | +| [TeamsToken](documentation/models/TeamsToken.md) | | | [TeamsTokenWithMetadata](documentation/models/TeamsTokenWithMetadata.md) | | | [ArrayWithMetadataOfWebPushToken](documentation/models/ArrayWithMetadataOfWebPushToken.md) | | | [WebPushToken](documentation/models/WebPushToken.md) | | @@ -112,6 +132,7 @@ The SDK includes several models that represent the data structures used in API r | [SlackInstallation](documentation/models/SlackInstallation.md) | | | [SlackFinishInstallResponse](documentation/models/SlackFinishInstallResponse.md) | | | [SlackStartInstall](documentation/models/SlackStartInstall.md) | | +| [SlackStartInstallResponseContent](documentation/models/SlackStartInstallResponseContent.md) | | | [TemplatesInstallation](documentation/models/TemplatesInstallation.md) | | | [WebPushStartInstallationResponse](documentation/models/WebPushStartInstallationResponse.md) | | diff --git a/packages/user-client/liblab.config.json b/packages/user-client/liblab.config.json index ff275058..4ad88e0c 100644 --- a/packages/user-client/liblab.config.json +++ b/packages/user-client/liblab.config.json @@ -30,6 +30,7 @@ "languageOptions": { "typescript": { "bundle": false, + "httpClient": "fetch", "exportClassDefault": false, "npmName": "user-client", "npmOrg": "magicbell", diff --git a/packages/user-client/package.json b/packages/user-client/package.json index 87b28ada..ca78ff5b 100644 --- a/packages/user-client/package.json +++ b/packages/user-client/package.json @@ -33,10 +33,10 @@ "build:cjs": "tsc --project tsconfig.build.json --module commonjs --outDir dist/commonjs", "build:esm": "tsc --project tsconfig.build.json --module esnext --outDir dist/esm", "codegen": "tsx scripts/build.ts", - "start": "rm -rf dist/ && tsc -w" + "start": "rm -rf dist/ && tsc -w", + "test": "tsc --noEmit" }, "dependencies": { - "axios": "^1.7.4", "zod": "3.23.8" }, "devDependencies": { diff --git a/packages/user-client/scripts/build.ts b/packages/user-client/scripts/build.ts index eed1b181..fb4b8cd3 100644 --- a/packages/user-client/scripts/build.ts +++ b/packages/user-client/scripts/build.ts @@ -156,7 +156,7 @@ async function build(specfile = 'https://public.magicbell.com/specs/openapi.v2.j pkgJson = sortPackageJson(pkgJson); await fs.writeFile('./package.json', JSON.stringify(pkgJson, null, 2) + '\n'); - execSync(`yarn --cwd ../.. eslint --fix .`, { stdio: 'inherit' }); + execSync(`yarn --cwd ../.. eslint --fix ./packages/user-client`, { stdio: 'inherit' }); execSync(`yarn --cwd ../.. manypkg fix`, { stdio: 'inherit' }); execSync(`yarn --cwd ../..`, { stdio: 'inherit' }); execSync(`yarn build`, { stdio: 'inherit' }); diff --git a/packages/user-client/src/http/handlers/terminating-handler.ts b/packages/user-client/src/http/handlers/terminating-handler.ts index 12f03fc7..0afd5a8c 100644 --- a/packages/user-client/src/http/handlers/terminating-handler.ts +++ b/packages/user-client/src/http/handlers/terminating-handler.ts @@ -1,9 +1,9 @@ import { Request } from '../transport/request'; -import { RequestAxiosAdapter } from '../transport/request-axios-adapter'; +import { RequestFetchAdapter } from '../transport/request-fetch-adapter'; import { HttpResponse, RequestHandler } from '../types'; export class TerminatingHandler implements RequestHandler { async handle(request: Request): Promise> { - return new RequestAxiosAdapter(request).send(); + return new RequestFetchAdapter(request).send(); } } diff --git a/packages/user-client/src/http/transport/request-axios-adapter.ts b/packages/user-client/src/http/transport/request-axios-adapter.ts deleted file mode 100644 index e7e14ff0..00000000 --- a/packages/user-client/src/http/transport/request-axios-adapter.ts +++ /dev/null @@ -1,98 +0,0 @@ -import axios, { AxiosRequestConfig, AxiosResponse, isAxiosError } from 'axios'; - -import { HttpError } from '../error'; -import { HttpMetadata, HttpResponse } from '../types'; -import { Request } from './request'; - -export interface HttpAdapter { - send(): Promise; -} - -export class RequestAxiosAdapter implements HttpAdapter { - private config: AxiosRequestConfig = { - responseType: 'arraybuffer', - }; - - constructor(private request: Request) { - this.setHeaders(); - this.setTimeout(); - } - - public async send(): Promise> { - const method = this.getMethod(); - const { body } = this.request; - let axiosResponse: AxiosResponse; - - try { - if (!!body) { - axiosResponse = await method(this.request.constructFullUrl(), body, this.config); - } else { - axiosResponse = await method(this.request.constructFullUrl(), this.config); - } - } catch (err) { - if (!isAxiosError(err)) { - throw err; - } - axiosResponse = err.response; - } - - const headerRecord: Record = {}; - Object.keys(axiosResponse.headers).forEach((key) => { - headerRecord[key] = axiosResponse.headers[key]; - }); - - const metadata: HttpMetadata = { - status: axiosResponse.status, - statusText: axiosResponse.statusText || '', - headers: headerRecord, - }; - - if (metadata.status >= 400) { - throw new HttpError(metadata); - } - - return { - metadata, - raw: axiosResponse.data.buffer.slice( - axiosResponse.data.byteOffset, - axiosResponse.data.byteOffset + axiosResponse.data.byteLength, - ), - }; - } - - private getMethod(): (url: string, data?: any, config?: AxiosRequestConfig) => Promise { - if (this.request.method === 'POST') { - return axios.post; - } else if (this.request.method === 'GET') { - return axios.get; - } else if (this.request.method === 'PUT') { - return axios.put; - } else if (this.request.method === 'DELETE') { - return axios.delete; - } - throw new Error('invalid method!!!!'); - } - - private setHeaders(): void { - if (!this.request.headers) { - return; - } - - const headersRecord: Record = {}; - new Headers(this.request.getHeaders()).forEach((value, key) => { - headersRecord[key] = value; - }); - - this.config = { - ...this.config, - headers: headersRecord, - }; - } - - private setTimeout(): void { - this.config = { - ...this.config, - timeout: this.request.config.timeout, - }; - } -} diff --git a/packages/user-client/src/http/transport/request-fetch-adapter.ts b/packages/user-client/src/http/transport/request-fetch-adapter.ts new file mode 100644 index 00000000..21d07846 --- /dev/null +++ b/packages/user-client/src/http/transport/request-fetch-adapter.ts @@ -0,0 +1,88 @@ +import { HttpError } from '../error'; +import { HttpMethod, HttpResponse } from '../types'; +import { Request } from './request'; + +interface HttpAdapter { + send(): Promise; +} + +export class RequestFetchAdapter implements HttpAdapter { + private requestInit: RequestInit = {}; + + constructor(private request: Request) { + this.setMethod(request.method); + this.setHeaders(request.getHeaders()); + this.setBody(request.body); + this.setTimeout(request.config.timeout); + } + + public async send(): Promise> { + const response = await fetch(this.request.constructFullUrl(), this.requestInit); + + const metadata = { + status: response.status, + statusText: response.statusText || '', + headers: this.getHeaders(response), + }; + + if (metadata.status >= 400) { + throw new HttpError(metadata); + } + + return { + metadata, + raw: await response.clone().arrayBuffer(), + }; + } + + private setMethod(method: HttpMethod) { + if (!method) { + return; + } + this.requestInit = { + ...this.requestInit, + method, + }; + } + + private setBody(body: ReadableStream | null) { + if (!body) { + return; + } + this.requestInit = { + ...this.requestInit, + body, + }; + } + + private setHeaders(headers: HeadersInit | undefined) { + if (!headers) { + return; + } + + this.requestInit = { + ...this.requestInit, + headers, + }; + } + + private setTimeout(timeout: number | undefined) { + if (!timeout) { + return; + } + + this.requestInit = { + ...this.requestInit, + signal: AbortSignal.timeout(timeout), + }; + } + + private getHeaders(response: Response): Record { + const headers: Record = {}; + response.headers.forEach((value: string, key: string) => { + headers[key] = value; + }); + + return headers; + } +} diff --git a/packages/user-client/src/services/channels/channels.ts b/packages/user-client/src/services/channels/channels.ts index 41f01925..91dc2d51 100644 --- a/packages/user-client/src/services/channels/channels.ts +++ b/packages/user-client/src/services/channels/channels.ts @@ -3,20 +3,21 @@ import { z } from 'zod'; import { RequestBuilder } from '../../http/transport/request-builder'; import { ContentType, HttpResponse, RequestConfig } from '../../http/types'; import { BaseService } from '../base-service'; +import { WebPushToken, webPushTokenRequest, webPushTokenResponse } from '../common/web-push-token'; import { ApnsToken, apnsTokenRequest, apnsTokenResponse } from './models/apns-token'; import { ApnsTokenWithMetadata, apnsTokenWithMetadataResponse } from './models/apns-token-with-metadata'; import { ArrayWithMetadataOfApnsToken, arrayWithMetadataOfApnsTokenResponse, } from './models/array-with-metadata-of-apns-token'; +import { + ArrayWithMetadataOfExpoToken, + arrayWithMetadataOfExpoTokenResponse, +} from './models/array-with-metadata-of-expo-token'; import { ArrayWithMetadataOfFcmToken, arrayWithMetadataOfFcmTokenResponse, } from './models/array-with-metadata-of-fcm-token'; -import { - ArrayWithMetadataOfInboxToken, - arrayWithMetadataOfInboxTokenResponse, -} from './models/array-with-metadata-of-inbox-token'; import { ArrayWithMetadataOfSlackToken, arrayWithMetadataOfSlackTokenResponse, @@ -30,50 +31,50 @@ import { arrayWithMetadataOfWebPushTokenResponse, } from './models/array-with-metadata-of-web-push-token'; import { DiscardResult, discardResultResponse } from './models/discard-result'; +import { ExpoToken, expoTokenRequest, expoTokenResponse } from './models/expo-token'; +import { ExpoTokenWithMetadata, expoTokenWithMetadataResponse } from './models/expo-token-with-metadata'; import { FcmToken, fcmTokenRequest, fcmTokenResponse } from './models/fcm-token'; import { FcmTokenWithMetadata, fcmTokenWithMetadataResponse } from './models/fcm-token-with-metadata'; -import { InboxToken, inboxTokenRequest, inboxTokenResponse } from './models/inbox-token'; -import { InboxTokenWithMetadata, inboxTokenWithMetadataResponse } from './models/inbox-token-with-metadata'; import { SlackToken, slackTokenRequest, slackTokenResponse } from './models/slack-token'; import { SlackTokenWithMetadata, slackTokenWithMetadataResponse } from './models/slack-token-with-metadata'; +import { TeamsToken, teamsTokenRequest, teamsTokenResponse } from './models/teams-token'; import { TeamsTokenWithMetadata, teamsTokenWithMetadataResponse } from './models/teams-token-with-metadata'; -import { WebPushToken, webPushTokenRequest, webPushTokenResponse } from './models/web-push-token'; import { WebPushTokenWithMetadata, webPushTokenWithMetadataResponse } from './models/web-push-token-with-metadata'; export class ChannelsService extends BaseService { /** * - * @returns {Promise>} OK + * @returns {Promise>} OK */ - async getInAppTokens(requestConfig?: RequestConfig): Promise> { - const request = new RequestBuilder() + async getMobilePushApnsTokens(requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('GET') - .setPath('/channels/in_app/tokens') + .setPath('/channels/mobile_push/apns/tokens') .setRequestSchema(z.any()) - .setResponseSchema(arrayWithMetadataOfInboxTokenResponse) + .setResponseSchema(arrayWithMetadataOfApnsTokenResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .build(); - return this.client.call(request); + return this.client.call(request); } /** * - * @returns {Promise>} Created + * @returns {Promise>} Created */ - async saveInAppToken(body: InboxToken, requestConfig?: RequestConfig): Promise> { - const request = new RequestBuilder() + async saveMobilePushApnsToken(body: ApnsToken, requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('POST') - .setPath('/channels/in_app/tokens') - .setRequestSchema(inboxTokenRequest) - .setResponseSchema(inboxTokenResponse) + .setPath('/channels/mobile_push/apns/tokens') + .setRequestSchema(apnsTokenRequest) + .setResponseSchema(apnsTokenResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -82,22 +83,25 @@ export class ChannelsService extends BaseService { .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); - return this.client.call(request); + return this.client.call(request); } /** * * @param {string} tokenId - - * @returns {Promise>} OK + * @returns {Promise>} OK */ - async getInAppToken(tokenId: string, requestConfig?: RequestConfig): Promise> { - const request = new RequestBuilder() + async getMobilePushApnsToken( + tokenId: string, + requestConfig?: RequestConfig, + ): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('GET') - .setPath('/channels/in_app/tokens/{token_id}') + .setPath('/channels/mobile_push/apns/tokens/{token_id}') .setRequestSchema(z.any()) - .setResponseSchema(inboxTokenWithMetadataResponse) + .setResponseSchema(apnsTokenWithMetadataResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -108,7 +112,7 @@ export class ChannelsService extends BaseService { value: tokenId, }) .build(); - return this.client.call(request); + return this.client.call(request); } /** @@ -116,12 +120,15 @@ export class ChannelsService extends BaseService { * @param {string} tokenId - * @returns {Promise>} OK */ - async discardInAppToken(tokenId: string, requestConfig?: RequestConfig): Promise> { + async discardMobilePushApnsToken( + tokenId: string, + requestConfig?: RequestConfig, + ): Promise> { const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('DELETE') - .setPath('/channels/in_app/tokens/{token_id}') + .setPath('/channels/mobile_push/apns/tokens/{token_id}') .setRequestSchema(z.any()) .setResponseSchema(discardResultResponse) .setRequestContentType(ContentType.Json) @@ -139,37 +146,37 @@ export class ChannelsService extends BaseService { /** * - * @returns {Promise>} OK + * @returns {Promise>} OK */ - async getMobilePushApnsTokens(requestConfig?: RequestConfig): Promise> { - const request = new RequestBuilder() + async getMobilePushExpoTokens(requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('GET') - .setPath('/channels/mobile_push/apns/tokens') + .setPath('/channels/mobile_push/expo/tokens') .setRequestSchema(z.any()) - .setResponseSchema(arrayWithMetadataOfApnsTokenResponse) + .setResponseSchema(arrayWithMetadataOfExpoTokenResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) .setRetryDelayMs(this.config, requestConfig) .setResponseValidation(this.config, requestConfig) .build(); - return this.client.call(request); + return this.client.call(request); } /** * - * @returns {Promise>} Created + * @returns {Promise>} Created */ - async saveMobilePushApnsToken(body: ApnsToken, requestConfig?: RequestConfig): Promise> { - const request = new RequestBuilder() + async saveMobilePushExpoToken(body: ExpoToken, requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('POST') - .setPath('/channels/mobile_push/apns/tokens') - .setRequestSchema(apnsTokenRequest) - .setResponseSchema(apnsTokenResponse) + .setPath('/channels/mobile_push/expo/tokens') + .setRequestSchema(expoTokenRequest) + .setResponseSchema(expoTokenResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -178,25 +185,25 @@ export class ChannelsService extends BaseService { .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); - return this.client.call(request); + return this.client.call(request); } /** * * @param {string} tokenId - - * @returns {Promise>} OK + * @returns {Promise>} OK */ - async getMobilePushApnsToken( + async getMobilePushExpoToken( tokenId: string, requestConfig?: RequestConfig, - ): Promise> { - const request = new RequestBuilder() + ): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('GET') - .setPath('/channels/mobile_push/apns/tokens/{token_id}') + .setPath('/channels/mobile_push/expo/tokens/{token_id}') .setRequestSchema(z.any()) - .setResponseSchema(apnsTokenWithMetadataResponse) + .setResponseSchema(expoTokenWithMetadataResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -207,7 +214,7 @@ export class ChannelsService extends BaseService { value: tokenId, }) .build(); - return this.client.call(request); + return this.client.call(request); } /** @@ -215,7 +222,7 @@ export class ChannelsService extends BaseService { * @param {string} tokenId - * @returns {Promise>} OK */ - async discardMobilePushApnsToken( + async discardMobilePushExpoToken( tokenId: string, requestConfig?: RequestConfig, ): Promise> { @@ -223,7 +230,7 @@ export class ChannelsService extends BaseService { .setConfig(this.config) .setBaseUrl(this.config) .setMethod('DELETE') - .setPath('/channels/mobile_push/apns/tokens/{token_id}') + .setPath('/channels/mobile_push/expo/tokens/{token_id}') .setRequestSchema(z.any()) .setResponseSchema(discardResultResponse) .setRequestContentType(ContentType.Json) @@ -460,16 +467,16 @@ export class ChannelsService extends BaseService { /** * - * @returns {Promise>} Created + * @returns {Promise>} Created */ - async saveTeamsToken(body: any, requestConfig?: RequestConfig): Promise> { - const request = new RequestBuilder() + async saveTeamsToken(body: TeamsToken, requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('POST') .setPath('/channels/teams/tokens') - .setRequestSchema(z.any()) - .setResponseSchema(z.undefined()) + .setRequestSchema(teamsTokenRequest) + .setResponseSchema(teamsTokenResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -478,7 +485,7 @@ export class ChannelsService extends BaseService { .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); - return this.client.call(request); + return this.client.call(request); } /** diff --git a/packages/user-client/src/services/channels/models/array-with-metadata-of-apns-token-data.ts b/packages/user-client/src/services/channels/models/array-with-metadata-of-apns-token-data.ts index bdbed050..be409755 100644 --- a/packages/user-client/src/services/channels/models/array-with-metadata-of-apns-token-data.ts +++ b/packages/user-client/src/services/channels/models/array-with-metadata-of-apns-token-data.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { apnsToken, apnsTokenRequest, apnsTokenResponse } from './apns-token'; -import { dataMetadata2, dataMetadata2Request, dataMetadata2Response } from './data-metadata-2'; +import { dataMetadata1, dataMetadata1Request, dataMetadata1Response } from './data-metadata-1'; /** * The shape of the model inside the application code - what the users use @@ -9,7 +9,7 @@ import { dataMetadata2, dataMetadata2Request, dataMetadata2Response } from './da export const arrayWithMetadataOfApnsTokenData = z.lazy(() => { return z.object({ data: apnsToken, - metadata: dataMetadata2, + metadata: dataMetadata1, }); }); @@ -17,7 +17,7 @@ export const arrayWithMetadataOfApnsTokenData = z.lazy(() => { * * @typedef {ArrayWithMetadataOfApnsTokenData} arrayWithMetadataOfApnsTokenData * @property {ApnsToken} - * @property {DataMetadata2} + * @property {DataMetadata1} */ export type ArrayWithMetadataOfApnsTokenData = z.infer; @@ -29,7 +29,7 @@ export const arrayWithMetadataOfApnsTokenDataResponse = z.lazy(() => { return z .object({ data: apnsTokenResponse, - metadata: dataMetadata2Response, + metadata: dataMetadata1Response, }) .transform((data) => ({ data: data['data'], @@ -42,7 +42,7 @@ export const arrayWithMetadataOfApnsTokenDataResponse = z.lazy(() => { * Is equal to application shape if all property names match the api schema */ export const arrayWithMetadataOfApnsTokenDataRequest = z.lazy(() => { - return z.object({ data: apnsTokenRequest.nullish(), metadata: dataMetadata2Request.nullish() }).transform((data) => ({ + return z.object({ data: apnsTokenRequest.nullish(), metadata: dataMetadata1Request.nullish() }).transform((data) => ({ data: data['data'], metadata: data['metadata'], })); diff --git a/packages/user-client/src/services/channels/models/array-with-metadata-of-expo-token-data.ts b/packages/user-client/src/services/channels/models/array-with-metadata-of-expo-token-data.ts new file mode 100644 index 00000000..cbc68219 --- /dev/null +++ b/packages/user-client/src/services/channels/models/array-with-metadata-of-expo-token-data.ts @@ -0,0 +1,49 @@ +import { z } from 'zod'; + +import { dataMetadata2, dataMetadata2Request, dataMetadata2Response } from './data-metadata-2'; +import { expoToken, expoTokenRequest, expoTokenResponse } from './expo-token'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const arrayWithMetadataOfExpoTokenData = z.lazy(() => { + return z.object({ + data: expoToken, + metadata: dataMetadata2, + }); +}); + +/** + * + * @typedef {ArrayWithMetadataOfExpoTokenData} arrayWithMetadataOfExpoTokenData + * @property {ExpoToken} + * @property {DataMetadata2} + */ +export type ArrayWithMetadataOfExpoTokenData = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const arrayWithMetadataOfExpoTokenDataResponse = z.lazy(() => { + return z + .object({ + data: expoTokenResponse, + metadata: dataMetadata2Response, + }) + .transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const arrayWithMetadataOfExpoTokenDataRequest = z.lazy(() => { + return z.object({ data: expoTokenRequest.nullish(), metadata: dataMetadata2Request.nullish() }).transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); +}); diff --git a/packages/user-client/src/services/channels/models/array-with-metadata-of-expo-token.ts b/packages/user-client/src/services/channels/models/array-with-metadata-of-expo-token.ts new file mode 100644 index 00000000..2dbc0bf5 --- /dev/null +++ b/packages/user-client/src/services/channels/models/array-with-metadata-of-expo-token.ts @@ -0,0 +1,47 @@ +import { z } from 'zod'; + +import { + arrayWithMetadataOfExpoTokenData, + arrayWithMetadataOfExpoTokenDataRequest, + arrayWithMetadataOfExpoTokenDataResponse, +} from './array-with-metadata-of-expo-token-data'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const arrayWithMetadataOfExpoToken = z.lazy(() => { + return z.object({ + data: z.array(arrayWithMetadataOfExpoTokenData), + }); +}); + +/** + * + * @typedef {ArrayWithMetadataOfExpoToken} arrayWithMetadataOfExpoToken + * @property {ArrayWithMetadataOfExpoTokenData[]} + */ +export type ArrayWithMetadataOfExpoToken = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const arrayWithMetadataOfExpoTokenResponse = z.lazy(() => { + return z + .object({ + data: z.array(arrayWithMetadataOfExpoTokenDataResponse), + }) + .transform((data) => ({ + data: data['data'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const arrayWithMetadataOfExpoTokenRequest = z.lazy(() => { + return z.object({ data: z.array(arrayWithMetadataOfExpoTokenDataRequest).nullish() }).transform((data) => ({ + data: data['data'], + })); +}); diff --git a/packages/user-client/src/services/channels/models/array-with-metadata-of-inbox-token-data.ts b/packages/user-client/src/services/channels/models/array-with-metadata-of-inbox-token-data.ts deleted file mode 100644 index 72cef23f..00000000 --- a/packages/user-client/src/services/channels/models/array-with-metadata-of-inbox-token-data.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { z } from 'zod'; - -import { dataMetadata1, dataMetadata1Request, dataMetadata1Response } from './data-metadata-1'; -import { inboxToken, inboxTokenRequest, inboxTokenResponse } from './inbox-token'; - -/** - * The shape of the model inside the application code - what the users use - */ -export const arrayWithMetadataOfInboxTokenData = z.lazy(() => { - return z.object({ - data: inboxToken, - metadata: dataMetadata1, - }); -}); - -/** - * - * @typedef {ArrayWithMetadataOfInboxTokenData} arrayWithMetadataOfInboxTokenData - * @property {InboxToken} - * @property {DataMetadata1} - */ -export type ArrayWithMetadataOfInboxTokenData = z.infer; - -/** - * The shape of the model mapping from the api schema into the application shape. - * Is equal to application shape if all property names match the api schema - */ -export const arrayWithMetadataOfInboxTokenDataResponse = z.lazy(() => { - return z - .object({ - data: inboxTokenResponse, - metadata: dataMetadata1Response, - }) - .transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); -}); - -/** - * The shape of the model mapping from the application shape into the api schema. - * Is equal to application shape if all property names match the api schema - */ -export const arrayWithMetadataOfInboxTokenDataRequest = z.lazy(() => { - return z - .object({ data: inboxTokenRequest.nullish(), metadata: dataMetadata1Request.nullish() }) - .transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); -}); diff --git a/packages/user-client/src/services/channels/models/array-with-metadata-of-inbox-token.ts b/packages/user-client/src/services/channels/models/array-with-metadata-of-inbox-token.ts deleted file mode 100644 index 02f34cdb..00000000 --- a/packages/user-client/src/services/channels/models/array-with-metadata-of-inbox-token.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { z } from 'zod'; - -import { - arrayWithMetadataOfInboxTokenData, - arrayWithMetadataOfInboxTokenDataRequest, - arrayWithMetadataOfInboxTokenDataResponse, -} from './array-with-metadata-of-inbox-token-data'; - -/** - * The shape of the model inside the application code - what the users use - */ -export const arrayWithMetadataOfInboxToken = z.lazy(() => { - return z.object({ - data: z.array(arrayWithMetadataOfInboxTokenData), - }); -}); - -/** - * - * @typedef {ArrayWithMetadataOfInboxToken} arrayWithMetadataOfInboxToken - * @property {ArrayWithMetadataOfInboxTokenData[]} - */ -export type ArrayWithMetadataOfInboxToken = z.infer; - -/** - * The shape of the model mapping from the api schema into the application shape. - * Is equal to application shape if all property names match the api schema - */ -export const arrayWithMetadataOfInboxTokenResponse = z.lazy(() => { - return z - .object({ - data: z.array(arrayWithMetadataOfInboxTokenDataResponse), - }) - .transform((data) => ({ - data: data['data'], - })); -}); - -/** - * The shape of the model mapping from the application shape into the api schema. - * Is equal to application shape if all property names match the api schema - */ -export const arrayWithMetadataOfInboxTokenRequest = z.lazy(() => { - return z.object({ data: z.array(arrayWithMetadataOfInboxTokenDataRequest).nullish() }).transform((data) => ({ - data: data['data'], - })); -}); diff --git a/packages/user-client/src/services/channels/models/array-with-metadata-of-teams-token-data.ts b/packages/user-client/src/services/channels/models/array-with-metadata-of-teams-token-data.ts index db76fcf1..80d59854 100644 --- a/packages/user-client/src/services/channels/models/array-with-metadata-of-teams-token-data.ts +++ b/packages/user-client/src/services/channels/models/array-with-metadata-of-teams-token-data.ts @@ -1,13 +1,14 @@ import { z } from 'zod'; import { dataMetadata5, dataMetadata5Request, dataMetadata5Response } from './data-metadata-5'; +import { teamsToken, teamsTokenRequest, teamsTokenResponse } from './teams-token'; /** * The shape of the model inside the application code - what the users use */ export const arrayWithMetadataOfTeamsTokenData = z.lazy(() => { return z.object({ - data: z.any(), + data: teamsToken, metadata: dataMetadata5, }); }); @@ -15,7 +16,7 @@ export const arrayWithMetadataOfTeamsTokenData = z.lazy(() => { /** * * @typedef {ArrayWithMetadataOfTeamsTokenData} arrayWithMetadataOfTeamsTokenData - * @property {any} + * @property {TeamsToken} * @property {DataMetadata5} */ export type ArrayWithMetadataOfTeamsTokenData = z.infer; @@ -27,7 +28,7 @@ export type ArrayWithMetadataOfTeamsTokenData = z.infer { return z .object({ - data: z.any(), + data: teamsTokenResponse, metadata: dataMetadata5Response, }) .transform((data) => ({ @@ -41,8 +42,10 @@ export const arrayWithMetadataOfTeamsTokenDataResponse = z.lazy(() => { * Is equal to application shape if all property names match the api schema */ export const arrayWithMetadataOfTeamsTokenDataRequest = z.lazy(() => { - return z.object({ data: z.any().nullish(), metadata: dataMetadata5Request.nullish() }).transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); + return z + .object({ data: teamsTokenRequest.nullish(), metadata: dataMetadata5Request.nullish() }) + .transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); }); diff --git a/packages/user-client/src/services/channels/models/array-with-metadata-of-web-push-token-data.ts b/packages/user-client/src/services/channels/models/array-with-metadata-of-web-push-token-data.ts index 9095a04a..374ce7e8 100644 --- a/packages/user-client/src/services/channels/models/array-with-metadata-of-web-push-token-data.ts +++ b/packages/user-client/src/services/channels/models/array-with-metadata-of-web-push-token-data.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; +import { webPushToken, webPushTokenRequest, webPushTokenResponse } from '../../common/web-push-token'; import { dataMetadata6, dataMetadata6Request, dataMetadata6Response } from './data-metadata-6'; -import { webPushToken, webPushTokenRequest, webPushTokenResponse } from './web-push-token'; /** * The shape of the model inside the application code - what the users use diff --git a/packages/project-client/src/services/channels/models/inbox-token-with-metadata-metadata.ts b/packages/user-client/src/services/channels/models/expo-token-with-metadata-metadata.ts similarity index 79% rename from packages/project-client/src/services/channels/models/inbox-token-with-metadata-metadata.ts rename to packages/user-client/src/services/channels/models/expo-token-with-metadata-metadata.ts index 47a99e2c..0f93e7bd 100644 --- a/packages/project-client/src/services/channels/models/inbox-token-with-metadata-metadata.ts +++ b/packages/user-client/src/services/channels/models/expo-token-with-metadata-metadata.ts @@ -3,7 +3,7 @@ import { z } from 'zod'; /** * The shape of the model inside the application code - what the users use */ -export const inboxTokenWithMetadataMetadata = z.lazy(() => { +export const expoTokenWithMetadataMetadata = z.lazy(() => { return z.object({ createdAt: z.string(), discardedAt: z.string().optional(), @@ -14,19 +14,19 @@ export const inboxTokenWithMetadataMetadata = z.lazy(() => { /** * - * @typedef {InboxTokenWithMetadataMetadata} inboxTokenWithMetadataMetadata + * @typedef {ExpoTokenWithMetadataMetadata} expoTokenWithMetadataMetadata * @property {string} * @property {string} * @property {string} * @property {string} */ -export type InboxTokenWithMetadataMetadata = z.infer; +export type ExpoTokenWithMetadataMetadata = z.infer; /** * The shape of the model mapping from the api schema into the application shape. * Is equal to application shape if all property names match the api schema */ -export const inboxTokenWithMetadataMetadataResponse = z.lazy(() => { +export const expoTokenWithMetadataMetadataResponse = z.lazy(() => { return z .object({ created_at: z.string(), @@ -46,7 +46,7 @@ export const inboxTokenWithMetadataMetadataResponse = z.lazy(() => { * The shape of the model mapping from the application shape into the api schema. * Is equal to application shape if all property names match the api schema */ -export const inboxTokenWithMetadataMetadataRequest = z.lazy(() => { +export const expoTokenWithMetadataMetadataRequest = z.lazy(() => { return z .object({ createdAt: z.string().nullish(), diff --git a/packages/user-client/src/services/channels/models/expo-token-with-metadata.ts b/packages/user-client/src/services/channels/models/expo-token-with-metadata.ts new file mode 100644 index 00000000..e1423654 --- /dev/null +++ b/packages/user-client/src/services/channels/models/expo-token-with-metadata.ts @@ -0,0 +1,55 @@ +import { z } from 'zod'; + +import { expoToken, expoTokenRequest, expoTokenResponse } from './expo-token'; +import { + expoTokenWithMetadataMetadata, + expoTokenWithMetadataMetadataRequest, + expoTokenWithMetadataMetadataResponse, +} from './expo-token-with-metadata-metadata'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const expoTokenWithMetadata = z.lazy(() => { + return z.object({ + data: expoToken, + metadata: expoTokenWithMetadataMetadata, + }); +}); + +/** + * + * @typedef {ExpoTokenWithMetadata} expoTokenWithMetadata + * @property {ExpoToken} + * @property {ExpoTokenWithMetadataMetadata} + */ +export type ExpoTokenWithMetadata = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const expoTokenWithMetadataResponse = z.lazy(() => { + return z + .object({ + data: expoTokenResponse, + metadata: expoTokenWithMetadataMetadataResponse, + }) + .transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const expoTokenWithMetadataRequest = z.lazy(() => { + return z + .object({ data: expoTokenRequest.nullish(), metadata: expoTokenWithMetadataMetadataRequest.nullish() }) + .transform((data) => ({ + data: data['data'], + metadata: data['metadata'], + })); +}); diff --git a/packages/user-client/src/services/channels/models/expo-token.ts b/packages/user-client/src/services/channels/models/expo-token.ts new file mode 100644 index 00000000..56d74a95 --- /dev/null +++ b/packages/user-client/src/services/channels/models/expo-token.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const expoToken = z.lazy(() => { + return z.object({ + deviceToken: z.string().min(1), + }); +}); + +/** + * + * @typedef {ExpoToken} expoToken + * @property {string} + */ +export type ExpoToken = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const expoTokenResponse = z.lazy(() => { + return z + .object({ + device_token: z.string().min(1), + }) + .transform((data) => ({ + deviceToken: data['device_token'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const expoTokenRequest = z.lazy(() => { + return z.object({ deviceToken: z.string().nullish() }).transform((data) => ({ + device_token: data['deviceToken'], + })); +}); diff --git a/packages/user-client/src/services/channels/models/inbox-token-with-metadata.ts b/packages/user-client/src/services/channels/models/inbox-token-with-metadata.ts deleted file mode 100644 index 14cb0bd2..00000000 --- a/packages/user-client/src/services/channels/models/inbox-token-with-metadata.ts +++ /dev/null @@ -1,55 +0,0 @@ -import { z } from 'zod'; - -import { inboxToken, inboxTokenRequest, inboxTokenResponse } from './inbox-token'; -import { - inboxTokenWithMetadataMetadata, - inboxTokenWithMetadataMetadataRequest, - inboxTokenWithMetadataMetadataResponse, -} from './inbox-token-with-metadata-metadata'; - -/** - * The shape of the model inside the application code - what the users use - */ -export const inboxTokenWithMetadata = z.lazy(() => { - return z.object({ - data: inboxToken, - metadata: inboxTokenWithMetadataMetadata, - }); -}); - -/** - * - * @typedef {InboxTokenWithMetadata} inboxTokenWithMetadata - * @property {InboxToken} - * @property {InboxTokenWithMetadataMetadata} - */ -export type InboxTokenWithMetadata = z.infer; - -/** - * The shape of the model mapping from the api schema into the application shape. - * Is equal to application shape if all property names match the api schema - */ -export const inboxTokenWithMetadataResponse = z.lazy(() => { - return z - .object({ - data: inboxTokenResponse, - metadata: inboxTokenWithMetadataMetadataResponse, - }) - .transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); -}); - -/** - * The shape of the model mapping from the application shape into the api schema. - * Is equal to application shape if all property names match the api schema - */ -export const inboxTokenWithMetadataRequest = z.lazy(() => { - return z - .object({ data: inboxTokenRequest.nullish(), metadata: inboxTokenWithMetadataMetadataRequest.nullish() }) - .transform((data) => ({ - data: data['data'], - metadata: data['metadata'], - })); -}); diff --git a/packages/user-client/src/services/channels/models/index.ts b/packages/user-client/src/services/channels/models/index.ts index 15a326e2..ce6e6316 100644 --- a/packages/user-client/src/services/channels/models/index.ts +++ b/packages/user-client/src/services/channels/models/index.ts @@ -4,10 +4,10 @@ export type { ApnsTokenWithMetadata } from './apns-token-with-metadata'; export type { ApnsTokenWithMetadataMetadata } from './apns-token-with-metadata-metadata'; export type { ArrayWithMetadataOfApnsToken } from './array-with-metadata-of-apns-token'; export type { ArrayWithMetadataOfApnsTokenData } from './array-with-metadata-of-apns-token-data'; +export type { ArrayWithMetadataOfExpoToken } from './array-with-metadata-of-expo-token'; +export type { ArrayWithMetadataOfExpoTokenData } from './array-with-metadata-of-expo-token-data'; export type { ArrayWithMetadataOfFcmToken } from './array-with-metadata-of-fcm-token'; export type { ArrayWithMetadataOfFcmTokenData } from './array-with-metadata-of-fcm-token-data'; -export type { ArrayWithMetadataOfInboxToken } from './array-with-metadata-of-inbox-token'; -export type { ArrayWithMetadataOfInboxTokenData } from './array-with-metadata-of-inbox-token-data'; export type { ArrayWithMetadataOfSlackToken } from './array-with-metadata-of-slack-token'; export type { ArrayWithMetadataOfSlackTokenData } from './array-with-metadata-of-slack-token-data'; export type { ArrayWithMetadataOfTeamsToken } from './array-with-metadata-of-teams-token'; @@ -21,21 +21,21 @@ export type { DataMetadata4 } from './data-metadata-4'; export type { DataMetadata5 } from './data-metadata-5'; export type { DataMetadata6 } from './data-metadata-6'; export type { DiscardResult } from './discard-result'; +export type { ExpoToken } from './expo-token'; +export type { ExpoTokenWithMetadata } from './expo-token-with-metadata'; +export type { ExpoTokenWithMetadataMetadata } from './expo-token-with-metadata-metadata'; export type { FcmToken } from './fcm-token'; export { FcmTokenInstallationId } from './fcm-token-installation-id'; export type { FcmTokenWithMetadata } from './fcm-token-with-metadata'; export type { FcmTokenWithMetadataMetadata } from './fcm-token-with-metadata-metadata'; -export type { InboxToken } from './inbox-token'; -export type { InboxTokenWithMetadata } from './inbox-token-with-metadata'; -export type { InboxTokenWithMetadataMetadata } from './inbox-token-with-metadata-metadata'; -export type { Keys } from './keys'; export type { Oauth } from './oauth'; export type { SlackToken } from './slack-token'; +export type { SlackTokenWebhook } from './slack-token-webhook'; export type { SlackTokenWithMetadata } from './slack-token-with-metadata'; export type { SlackTokenWithMetadataMetadata } from './slack-token-with-metadata-metadata'; +export type { TeamsToken } from './teams-token'; +export type { TeamsTokenWebhook } from './teams-token-webhook'; export type { TeamsTokenWithMetadata } from './teams-token-with-metadata'; export type { TeamsTokenWithMetadataMetadata } from './teams-token-with-metadata-metadata'; -export type { WebPushToken } from './web-push-token'; export type { WebPushTokenWithMetadata } from './web-push-token-with-metadata'; export type { WebPushTokenWithMetadataMetadata } from './web-push-token-with-metadata-metadata'; -export type { Webhook } from './webhook'; diff --git a/packages/user-client/src/services/channels/models/webhook.ts b/packages/user-client/src/services/channels/models/slack-token-webhook.ts similarity index 73% rename from packages/user-client/src/services/channels/models/webhook.ts rename to packages/user-client/src/services/channels/models/slack-token-webhook.ts index 80d30b9f..66d4af3b 100644 --- a/packages/user-client/src/services/channels/models/webhook.ts +++ b/packages/user-client/src/services/channels/models/slack-token-webhook.ts @@ -3,7 +3,7 @@ import { z } from 'zod'; /** * The shape of the model inside the application code - what the users use */ -export const webhook = z.lazy(() => { +export const slackTokenWebhook = z.lazy(() => { return z.object({ url: z.string(), }); @@ -11,16 +11,16 @@ export const webhook = z.lazy(() => { /** * - * @typedef {Webhook} webhook + * @typedef {SlackTokenWebhook} slackTokenWebhook * @property {string} */ -export type Webhook = z.infer; +export type SlackTokenWebhook = z.infer; /** * The shape of the model mapping from the api schema into the application shape. * Is equal to application shape if all property names match the api schema */ -export const webhookResponse = z.lazy(() => { +export const slackTokenWebhookResponse = z.lazy(() => { return z .object({ url: z.string(), @@ -34,7 +34,7 @@ export const webhookResponse = z.lazy(() => { * The shape of the model mapping from the application shape into the api schema. * Is equal to application shape if all property names match the api schema */ -export const webhookRequest = z.lazy(() => { +export const slackTokenWebhookRequest = z.lazy(() => { return z.object({ url: z.string().nullish() }).transform((data) => ({ url: data['url'], })); diff --git a/packages/user-client/src/services/channels/models/slack-token.ts b/packages/user-client/src/services/channels/models/slack-token.ts index c8087f81..e985889f 100644 --- a/packages/user-client/src/services/channels/models/slack-token.ts +++ b/packages/user-client/src/services/channels/models/slack-token.ts @@ -1,7 +1,7 @@ import { z } from 'zod'; import { oauth, oauthRequest, oauthResponse } from './oauth'; -import { webhook, webhookRequest, webhookResponse } from './webhook'; +import { slackTokenWebhook, slackTokenWebhookRequest, slackTokenWebhookResponse } from './slack-token-webhook'; /** * The shape of the model inside the application code - what the users use @@ -9,7 +9,7 @@ import { webhook, webhookRequest, webhookResponse } from './webhook'; export const slackToken = z.lazy(() => { return z.object({ oauth: oauth.optional(), - webhook: webhook.optional(), + webhook: slackTokenWebhook.optional(), }); }); @@ -17,7 +17,7 @@ export const slackToken = z.lazy(() => { * * @typedef {SlackToken} slackToken * @property {Oauth} - * @property {Webhook} + * @property {SlackTokenWebhook} */ export type SlackToken = z.infer; @@ -29,7 +29,7 @@ export const slackTokenResponse = z.lazy(() => { return z .object({ oauth: oauthResponse.optional(), - webhook: webhookResponse.optional(), + webhook: slackTokenWebhookResponse.optional(), }) .transform((data) => ({ oauth: data['oauth'], @@ -42,7 +42,7 @@ export const slackTokenResponse = z.lazy(() => { * Is equal to application shape if all property names match the api schema */ export const slackTokenRequest = z.lazy(() => { - return z.object({ oauth: oauthRequest.nullish(), webhook: webhookRequest.nullish() }).transform((data) => ({ + return z.object({ oauth: oauthRequest.nullish(), webhook: slackTokenWebhookRequest.nullish() }).transform((data) => ({ oauth: data['oauth'], webhook: data['webhook'], })); diff --git a/packages/user-client/src/services/channels/models/teams-token-webhook.ts b/packages/user-client/src/services/channels/models/teams-token-webhook.ts new file mode 100644 index 00000000..95121613 --- /dev/null +++ b/packages/user-client/src/services/channels/models/teams-token-webhook.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const teamsTokenWebhook = z.lazy(() => { + return z.object({ + url: z.string().optional(), + }); +}); + +/** + * + * @typedef {TeamsTokenWebhook} teamsTokenWebhook + * @property {string} + */ +export type TeamsTokenWebhook = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const teamsTokenWebhookResponse = z.lazy(() => { + return z + .object({ + url: z.string().optional(), + }) + .transform((data) => ({ + url: data['url'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const teamsTokenWebhookRequest = z.lazy(() => { + return z.object({ url: z.string().nullish() }).transform((data) => ({ + url: data['url'], + })); +}); diff --git a/packages/user-client/src/services/channels/models/teams-token-with-metadata.ts b/packages/user-client/src/services/channels/models/teams-token-with-metadata.ts index d64c03b6..fa95bc84 100644 --- a/packages/user-client/src/services/channels/models/teams-token-with-metadata.ts +++ b/packages/user-client/src/services/channels/models/teams-token-with-metadata.ts @@ -1,5 +1,6 @@ import { z } from 'zod'; +import { teamsToken, teamsTokenRequest, teamsTokenResponse } from './teams-token'; import { teamsTokenWithMetadataMetadata, teamsTokenWithMetadataMetadataRequest, @@ -11,7 +12,7 @@ import { */ export const teamsTokenWithMetadata = z.lazy(() => { return z.object({ - data: z.any(), + data: teamsToken, metadata: teamsTokenWithMetadataMetadata, }); }); @@ -19,7 +20,7 @@ export const teamsTokenWithMetadata = z.lazy(() => { /** * * @typedef {TeamsTokenWithMetadata} teamsTokenWithMetadata - * @property {any} + * @property {TeamsToken} * @property {TeamsTokenWithMetadataMetadata} */ export type TeamsTokenWithMetadata = z.infer; @@ -31,7 +32,7 @@ export type TeamsTokenWithMetadata = z.infer; export const teamsTokenWithMetadataResponse = z.lazy(() => { return z .object({ - data: z.any(), + data: teamsTokenResponse, metadata: teamsTokenWithMetadataMetadataResponse, }) .transform((data) => ({ @@ -46,7 +47,7 @@ export const teamsTokenWithMetadataResponse = z.lazy(() => { */ export const teamsTokenWithMetadataRequest = z.lazy(() => { return z - .object({ data: z.any().nullish(), metadata: teamsTokenWithMetadataMetadataRequest.nullish() }) + .object({ data: teamsTokenRequest.nullish(), metadata: teamsTokenWithMetadataMetadataRequest.nullish() }) .transform((data) => ({ data: data['data'], metadata: data['metadata'], diff --git a/packages/user-client/src/services/channels/models/teams-token.ts b/packages/user-client/src/services/channels/models/teams-token.ts new file mode 100644 index 00000000..992c6323 --- /dev/null +++ b/packages/user-client/src/services/channels/models/teams-token.ts @@ -0,0 +1,43 @@ +import { z } from 'zod'; + +import { teamsTokenWebhook, teamsTokenWebhookRequest, teamsTokenWebhookResponse } from './teams-token-webhook'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const teamsToken = z.lazy(() => { + return z.object({ + webhook: teamsTokenWebhook.optional(), + }); +}); + +/** + * + * @typedef {TeamsToken} teamsToken + * @property {TeamsTokenWebhook} + */ +export type TeamsToken = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const teamsTokenResponse = z.lazy(() => { + return z + .object({ + webhook: teamsTokenWebhookResponse.optional(), + }) + .transform((data) => ({ + webhook: data['webhook'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const teamsTokenRequest = z.lazy(() => { + return z.object({ webhook: teamsTokenWebhookRequest.nullish() }).transform((data) => ({ + webhook: data['webhook'], + })); +}); diff --git a/packages/user-client/src/services/channels/models/web-push-token-with-metadata.ts b/packages/user-client/src/services/channels/models/web-push-token-with-metadata.ts index 3a774fb1..071ddcfa 100644 --- a/packages/user-client/src/services/channels/models/web-push-token-with-metadata.ts +++ b/packages/user-client/src/services/channels/models/web-push-token-with-metadata.ts @@ -1,6 +1,6 @@ import { z } from 'zod'; -import { webPushToken, webPushTokenRequest, webPushTokenResponse } from './web-push-token'; +import { webPushToken, webPushTokenRequest, webPushTokenResponse } from '../../common/web-push-token'; import { webPushTokenWithMetadataMetadata, webPushTokenWithMetadataMetadataRequest, diff --git a/packages/user-client/src/services/common/index.ts b/packages/user-client/src/services/common/index.ts new file mode 100644 index 00000000..66059dcd --- /dev/null +++ b/packages/user-client/src/services/common/index.ts @@ -0,0 +1,2 @@ +export type { Keys } from './keys'; +export type { WebPushToken } from './web-push-token'; diff --git a/packages/user-client/src/services/channels/models/keys.ts b/packages/user-client/src/services/common/keys.ts similarity index 100% rename from packages/user-client/src/services/channels/models/keys.ts rename to packages/user-client/src/services/common/keys.ts diff --git a/packages/user-client/src/services/channels/models/web-push-token.ts b/packages/user-client/src/services/common/web-push-token.ts similarity index 100% rename from packages/user-client/src/services/channels/models/web-push-token.ts rename to packages/user-client/src/services/common/web-push-token.ts diff --git a/packages/user-client/src/services/integrations/integrations.ts b/packages/user-client/src/services/integrations/integrations.ts index e88d6e28..92587be3 100644 --- a/packages/user-client/src/services/integrations/integrations.ts +++ b/packages/user-client/src/services/integrations/integrations.ts @@ -3,10 +3,15 @@ import { z } from 'zod'; import { RequestBuilder } from '../../http/transport/request-builder'; import { ContentType, HttpResponse, RequestConfig } from '../../http/types'; import { BaseService } from '../base-service'; -import { InboxConfig, inboxConfigResponse } from './models/inbox-config'; +import { WebPushToken, webPushTokenRequest, webPushTokenResponse } from '../common/web-push-token'; +import { InboxConfig, inboxConfigRequest, inboxConfigResponse } from './models/inbox-config'; import { SlackFinishInstallResponse, slackFinishInstallResponseRequest } from './models/slack-finish-install-response'; import { SlackInstallation, slackInstallationRequest, slackInstallationResponse } from './models/slack-installation'; import { SlackStartInstall, slackStartInstallRequest } from './models/slack-start-install'; +import { + SlackStartInstallResponseContent, + slackStartInstallResponseContentResponse, +} from './models/slack-start-install-response-content'; import { TemplatesInstallation, templatesInstallationRequest, @@ -18,6 +23,29 @@ import { } from './models/web-push-start-installation-response'; export class IntegrationsService extends BaseService { + /** + * + * @returns {Promise>} Created + */ + async saveInboxInstallation(body: InboxConfig, requestConfig?: RequestConfig): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('POST') + .setPath('/integrations/inbox/installations') + .setRequestSchema(inboxConfigRequest) + .setResponseSchema(inboxConfigResponse) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) + .addBody(body) + .build(); + return this.client.call(request); + } + /** * * @returns {Promise>} Created @@ -93,19 +121,19 @@ export class IntegrationsService extends BaseService { /** * - * @returns {Promise>} Created + * @returns {Promise>} Created */ async startSlackInstallation( body: SlackStartInstall, requestConfig?: RequestConfig, - ): Promise> { - const request = new RequestBuilder() + ): Promise> { + const request = new RequestBuilder() .setConfig(this.config) .setBaseUrl(this.config) .setMethod('POST') .setPath('/integrations/slack/installations/start') .setRequestSchema(slackStartInstallRequest) - .setResponseSchema(z.undefined()) + .setResponseSchema(slackStartInstallResponseContentResponse) .setRequestContentType(ContentType.Json) .setResponseContentType(ContentType.Json) .setRetryAttempts(this.config, requestConfig) @@ -114,7 +142,7 @@ export class IntegrationsService extends BaseService { .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) .addBody(body) .build(); - return this.client.call(request); + return this.client.call(request); } /** @@ -143,6 +171,32 @@ export class IntegrationsService extends BaseService { return this.client.call(request); } + /** + * + * @returns {Promise>} Created + */ + async saveWebPushInstallation( + body: WebPushToken, + requestConfig?: RequestConfig, + ): Promise> { + const request = new RequestBuilder() + .setConfig(this.config) + .setBaseUrl(this.config) + .setMethod('POST') + .setPath('/integrations/web_push/installations') + .setRequestSchema(webPushTokenRequest) + .setResponseSchema(webPushTokenResponse) + .setRequestContentType(ContentType.Json) + .setResponseContentType(ContentType.Json) + .setRetryAttempts(this.config, requestConfig) + .setRetryDelayMs(this.config, requestConfig) + .setResponseValidation(this.config, requestConfig) + .addHeaderParam({ key: 'Content-Type', value: 'application/json' }) + .addBody(body) + .build(); + return this.client.call(request); + } + /** * * @returns {Promise>} Created diff --git a/packages/user-client/src/services/integrations/models/banner.ts b/packages/user-client/src/services/integrations/models/banner.ts new file mode 100644 index 00000000..ba226518 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/banner.ts @@ -0,0 +1,63 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const banner = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + backgroundOpacity: z.number().optional(), + fontSize: z.string(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Banner} banner + * @property {string} + * @property {number} + * @property {string} + * @property {string} + */ +export type Banner = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const bannerResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + backgroundOpacity: z.number().optional(), + fontSize: z.string(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + backgroundOpacity: data['backgroundOpacity'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const bannerRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + backgroundOpacity: z.number().nullish(), + fontSize: z.string().nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + backgroundOpacity: data['backgroundOpacity'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/default-hover.ts b/packages/user-client/src/services/integrations/models/default-hover.ts new file mode 100644 index 00000000..11a20f49 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/default-hover.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const defaultHover = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + }); +}); + +/** + * + * @typedef {DefaultHover} defaultHover + * @property {string} + */ +export type DefaultHover = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const defaultHoverResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const defaultHoverRequest = z.lazy(() => { + return z.object({ backgroundColor: z.string().nullish() }).transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/default-state.ts b/packages/user-client/src/services/integrations/models/default-state.ts new file mode 100644 index 00000000..236276a9 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/default-state.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const defaultState = z.lazy(() => { + return z.object({ + color: z.string(), + }); +}); + +/** + * + * @typedef {DefaultState} defaultState + * @property {string} + */ +export type DefaultState = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const defaultStateResponse = z.lazy(() => { + return z + .object({ + color: z.string(), + }) + .transform((data) => ({ + color: data['color'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const defaultStateRequest = z.lazy(() => { + return z.object({ color: z.string().nullish() }).transform((data) => ({ + color: data['color'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/default_.ts b/packages/user-client/src/services/integrations/models/default_.ts new file mode 100644 index 00000000..19689028 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/default_.ts @@ -0,0 +1,90 @@ +import { z } from 'zod'; + +import { defaultHover, defaultHoverRequest, defaultHoverResponse } from './default-hover'; +import { defaultState, defaultStateRequest, defaultStateResponse } from './default-state'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const default_ = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontFamily: z.string(), + fontSize: z.string(), + hover: defaultHover.optional(), + margin: z.string(), + state: defaultState.optional(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Default_} default_ + * @property {string} + * @property {string} + * @property {string} + * @property {string} + * @property {DefaultHover} + * @property {string} + * @property {DefaultState} + * @property {string} + */ +export type Default_ = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const defaultResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontFamily: z.string(), + fontSize: z.string(), + hover: defaultHoverResponse.optional(), + margin: z.string(), + state: defaultStateResponse.optional(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontFamily: data['fontFamily'], + fontSize: data['fontSize'], + hover: data['hover'], + margin: data['margin'], + state: data['state'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const defaultRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + borderRadius: z.string().nullish(), + fontFamily: z.string().nullish(), + fontSize: z.string().nullish(), + hover: defaultHoverRequest.nullish(), + margin: z.string().nullish(), + state: defaultStateRequest.nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontFamily: data['fontFamily'], + fontSize: data['fontSize'], + hover: data['hover'], + margin: data['margin'], + state: data['state'], + textColor: data['textColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/dialog.ts b/packages/user-client/src/services/integrations/models/dialog.ts new file mode 100644 index 00000000..258bcee9 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/dialog.ts @@ -0,0 +1,57 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const dialog = z.lazy(() => { + return z.object({ + accentColor: z.string(), + backgroundColor: z.string(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Dialog} dialog + * @property {string} + * @property {string} + * @property {string} + */ +export type Dialog = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const dialogResponse = z.lazy(() => { + return z + .object({ + accentColor: z.string(), + backgroundColor: z.string(), + textColor: z.string(), + }) + .transform((data) => ({ + accentColor: data['accentColor'], + backgroundColor: data['backgroundColor'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const dialogRequest = z.lazy(() => { + return z + .object({ + accentColor: z.string().nullish(), + backgroundColor: z.string().nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + accentColor: data['accentColor'], + backgroundColor: data['backgroundColor'], + textColor: data['textColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/footer.ts b/packages/user-client/src/services/integrations/models/footer.ts new file mode 100644 index 00000000..8e7b8717 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/footer.ts @@ -0,0 +1,63 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const footer = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontSize: z.string(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Footer} footer + * @property {string} + * @property {string} + * @property {string} + * @property {string} + */ +export type Footer = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const footerResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontSize: z.string(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const footerRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + borderRadius: z.string().nullish(), + fontSize: z.string().nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/header.ts b/packages/user-client/src/services/integrations/models/header.ts new file mode 100644 index 00000000..5d42dacf --- /dev/null +++ b/packages/user-client/src/services/integrations/models/header.ts @@ -0,0 +1,69 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const header = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontFamily: z.string(), + fontSize: z.string(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Header} header + * @property {string} + * @property {string} + * @property {string} + * @property {string} + * @property {string} + */ +export type Header = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const headerResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + borderRadius: z.string(), + fontFamily: z.string(), + fontSize: z.string(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontFamily: data['fontFamily'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const headerRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + borderRadius: z.string().nullish(), + fontFamily: z.string().nullish(), + fontSize: z.string().nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + borderRadius: data['borderRadius'], + fontFamily: data['fontFamily'], + fontSize: data['fontSize'], + textColor: data['textColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/icon.ts b/packages/user-client/src/services/integrations/models/icon.ts new file mode 100644 index 00000000..c118c4bb --- /dev/null +++ b/packages/user-client/src/services/integrations/models/icon.ts @@ -0,0 +1,46 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const icon = z.lazy(() => { + return z.object({ + borderColor: z.string(), + width: z.string(), + }); +}); + +/** + * + * @typedef {Icon} icon + * @property {string} + * @property {string} + */ +export type Icon = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const iconResponse = z.lazy(() => { + return z + .object({ + borderColor: z.string(), + width: z.string(), + }) + .transform((data) => ({ + borderColor: data['borderColor'], + width: data['width'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const iconRequest = z.lazy(() => { + return z.object({ borderColor: z.string().nullish(), width: z.string().nullish() }).transform((data) => ({ + borderColor: data['borderColor'], + width: data['width'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/images.ts b/packages/user-client/src/services/integrations/models/images.ts new file mode 100644 index 00000000..ae21479e --- /dev/null +++ b/packages/user-client/src/services/integrations/models/images.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const images = z.lazy(() => { + return z.object({ + emptyInboxUrl: z.string(), + }); +}); + +/** + * + * @typedef {Images} images + * @property {string} + */ +export type Images = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const imagesResponse = z.lazy(() => { + return z + .object({ + emptyInboxUrl: z.string(), + }) + .transform((data) => ({ + emptyInboxUrl: data['emptyInboxUrl'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const imagesRequest = z.lazy(() => { + return z.object({ emptyInboxUrl: z.string().nullish() }).transform((data) => ({ + emptyInboxUrl: data['emptyInboxUrl'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/inbox-config.ts b/packages/user-client/src/services/integrations/models/inbox-config.ts index 8513a4ef..2daa02a7 100644 --- a/packages/user-client/src/services/integrations/models/inbox-config.ts +++ b/packages/user-client/src/services/integrations/models/inbox-config.ts @@ -1,22 +1,25 @@ import { z } from 'zod'; +import { images, imagesRequest, imagesResponse } from './images'; +import { theme, themeRequest, themeResponse } from './theme'; + /** * The shape of the model inside the application code - what the users use */ export const inboxConfig = z.lazy(() => { return z.object({ - images: z.any().nullable(), + images: images.nullable(), locale: z.string().min(2).nullable(), - theme: z.any().nullable(), + theme: theme.nullable(), }); }); /** * * @typedef {InboxConfig} inboxConfig - * @property {any} + * @property {Images} * @property {string} - * @property {any} + * @property {Theme} */ export type InboxConfig = z.infer; @@ -27,9 +30,9 @@ export type InboxConfig = z.infer; export const inboxConfigResponse = z.lazy(() => { return z .object({ - images: z.any().nullable(), + images: imagesResponse.nullable(), locale: z.string().min(2).nullable(), - theme: z.any().nullable(), + theme: themeResponse.nullable(), }) .transform((data) => ({ images: data['images'], @@ -44,7 +47,7 @@ export const inboxConfigResponse = z.lazy(() => { */ export const inboxConfigRequest = z.lazy(() => { return z - .object({ images: z.any().nullish(), locale: z.string().nullish(), theme: z.any().nullish() }) + .object({ images: imagesRequest.nullish(), locale: z.string().nullish(), theme: themeRequest.nullish() }) .transform((data) => ({ images: data['images'], locale: data['locale'], diff --git a/packages/user-client/src/services/integrations/models/index.ts b/packages/user-client/src/services/integrations/models/index.ts index 61ddded6..865d544a 100644 --- a/packages/user-client/src/services/integrations/models/index.ts +++ b/packages/user-client/src/services/integrations/models/index.ts @@ -1,10 +1,29 @@ export type { AuthedUser } from './authed-user'; +export type { Banner } from './banner'; +export type { Default_ } from './default_'; +export type { DefaultHover } from './default-hover'; +export type { DefaultState } from './default-state'; +export type { Dialog } from './dialog'; export type { Enterprise } from './enterprise'; +export type { Footer } from './footer'; +export type { Header } from './header'; +export type { Icon } from './icon'; +export type { Images } from './images'; export type { InboxConfig } from './inbox-config'; export type { IncomingWebhook } from './incoming-webhook'; +export type { Notification } from './notification'; export type { SlackFinishInstallResponse } from './slack-finish-install-response'; export type { SlackInstallation } from './slack-installation'; export type { SlackStartInstall } from './slack-start-install'; +export type { SlackStartInstallResponseContent } from './slack-start-install-response-content'; export type { Team } from './team'; export type { TemplatesInstallation } from './templates-installation'; +export type { Theme } from './theme'; +export type { Unread } from './unread'; +export type { UnreadHover } from './unread-hover'; +export type { UnreadState } from './unread-state'; +export type { Unseen } from './unseen'; +export type { UnseenBadge } from './unseen-badge'; +export type { UnseenHover } from './unseen-hover'; +export type { UnseenState } from './unseen-state'; export type { WebPushStartInstallationResponse } from './web-push-start-installation-response'; diff --git a/packages/user-client/src/services/integrations/models/notification.ts b/packages/user-client/src/services/integrations/models/notification.ts new file mode 100644 index 00000000..e7c6b693 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/notification.ts @@ -0,0 +1,57 @@ +import { z } from 'zod'; + +import { default_, defaultRequest, defaultResponse } from './default_'; +import { unread, unreadRequest, unreadResponse } from './unread'; +import { unseen, unseenRequest, unseenResponse } from './unseen'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const notification = z.lazy(() => { + return z.object({ + default: default_, + unread: unread, + unseen: unseen, + }); +}); + +/** + * + * @typedef {Notification} notification + * @property {Default_} + * @property {Unread} + * @property {Unseen} + */ +export type Notification = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const notificationResponse = z.lazy(() => { + return z + .object({ + default: defaultResponse, + unread: unreadResponse, + unseen: unseenResponse, + }) + .transform((data) => ({ + default: data['default'], + unread: data['unread'], + unseen: data['unseen'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const notificationRequest = z.lazy(() => { + return z + .object({ default: defaultRequest.nullish(), unread: unreadRequest.nullish(), unseen: unseenRequest.nullish() }) + .transform((data) => ({ + default: data['default'], + unread: data['unread'], + unseen: data['unseen'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/slack-start-install-response-content.ts b/packages/user-client/src/services/integrations/models/slack-start-install-response-content.ts new file mode 100644 index 00000000..0af5beb9 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/slack-start-install-response-content.ts @@ -0,0 +1,53 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const slackStartInstallResponseContent = z.lazy(() => { + return z.object({ + appId: z.string().optional(), + authUrl: z.string().optional(), + scopes: z.array(z.string()).optional(), + }); +}); + +/** + * + * @typedef {SlackStartInstallResponseContent} slackStartInstallResponseContent + * @property {string} + * @property {string} + * @property {string[]} + */ +export type SlackStartInstallResponseContent = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const slackStartInstallResponseContentResponse = z.lazy(() => { + return z + .object({ + app_id: z.string().optional(), + auth_url: z.string().optional(), + scopes: z.array(z.string()).optional(), + }) + .transform((data) => ({ + appId: data['app_id'], + authUrl: data['auth_url'], + scopes: data['scopes'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const slackStartInstallResponseContentRequest = z.lazy(() => { + return z + .object({ appId: z.string().nullish(), authUrl: z.string().nullish(), scopes: z.array(z.string()).nullish() }) + .transform((data) => ({ + app_id: data['appId'], + auth_url: data['authUrl'], + scopes: data['scopes'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/theme.ts b/packages/user-client/src/services/integrations/models/theme.ts new file mode 100644 index 00000000..694558dc --- /dev/null +++ b/packages/user-client/src/services/integrations/models/theme.ts @@ -0,0 +1,89 @@ +import { z } from 'zod'; + +import { banner, bannerRequest, bannerResponse } from './banner'; +import { dialog, dialogRequest, dialogResponse } from './dialog'; +import { footer, footerRequest, footerResponse } from './footer'; +import { header, headerRequest, headerResponse } from './header'; +import { icon, iconRequest, iconResponse } from './icon'; +import { notification, notificationRequest, notificationResponse } from './notification'; +import { unseenBadge, unseenBadgeRequest, unseenBadgeResponse } from './unseen-badge'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const theme = z.lazy(() => { + return z.object({ + banner: banner.optional(), + dialog: dialog.optional(), + footer: footer.optional(), + header: header.optional(), + icon: icon.optional(), + notification: notification.optional(), + unseenBadge: unseenBadge.optional(), + }); +}); + +/** + * + * @typedef {Theme} theme + * @property {Banner} + * @property {Dialog} + * @property {Footer} + * @property {Header} + * @property {Icon} + * @property {Notification} + * @property {UnseenBadge} + */ +export type Theme = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const themeResponse = z.lazy(() => { + return z + .object({ + banner: bannerResponse.optional(), + dialog: dialogResponse.optional(), + footer: footerResponse.optional(), + header: headerResponse.optional(), + icon: iconResponse.optional(), + notification: notificationResponse.optional(), + unseenBadge: unseenBadgeResponse.optional(), + }) + .transform((data) => ({ + banner: data['banner'], + dialog: data['dialog'], + footer: data['footer'], + header: data['header'], + icon: data['icon'], + notification: data['notification'], + unseenBadge: data['unseenBadge'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const themeRequest = z.lazy(() => { + return z + .object({ + banner: bannerRequest.nullish(), + dialog: dialogRequest.nullish(), + footer: footerRequest.nullish(), + header: headerRequest.nullish(), + icon: iconRequest.nullish(), + notification: notificationRequest.nullish(), + unseenBadge: unseenBadgeRequest.nullish(), + }) + .transform((data) => ({ + banner: data['banner'], + dialog: data['dialog'], + footer: data['footer'], + header: data['header'], + icon: data['icon'], + notification: data['notification'], + unseenBadge: data['unseenBadge'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/unread-hover.ts b/packages/user-client/src/services/integrations/models/unread-hover.ts new file mode 100644 index 00000000..091e0886 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/unread-hover.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unreadHover = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + }); +}); + +/** + * + * @typedef {UnreadHover} unreadHover + * @property {string} + */ +export type UnreadHover = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unreadHoverResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unreadHoverRequest = z.lazy(() => { + return z.object({ backgroundColor: z.string().nullish() }).transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/unread-state.ts b/packages/user-client/src/services/integrations/models/unread-state.ts new file mode 100644 index 00000000..50a1388d --- /dev/null +++ b/packages/user-client/src/services/integrations/models/unread-state.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unreadState = z.lazy(() => { + return z.object({ + color: z.string(), + }); +}); + +/** + * + * @typedef {UnreadState} unreadState + * @property {string} + */ +export type UnreadState = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unreadStateResponse = z.lazy(() => { + return z + .object({ + color: z.string(), + }) + .transform((data) => ({ + color: data['color'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unreadStateRequest = z.lazy(() => { + return z.object({ color: z.string().nullish() }).transform((data) => ({ + color: data['color'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/unread.ts b/packages/user-client/src/services/integrations/models/unread.ts new file mode 100644 index 00000000..5f522156 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/unread.ts @@ -0,0 +1,66 @@ +import { z } from 'zod'; + +import { unreadHover, unreadHoverRequest, unreadHoverResponse } from './unread-hover'; +import { unreadState, unreadStateRequest, unreadStateResponse } from './unread-state'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unread = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + hover: unreadHover.optional(), + state: unreadState.optional(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Unread} unread + * @property {string} + * @property {UnreadHover} + * @property {UnreadState} + * @property {string} + */ +export type Unread = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unreadResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + hover: unreadHoverResponse.optional(), + state: unreadStateResponse.optional(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + hover: data['hover'], + state: data['state'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unreadRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + hover: unreadHoverRequest.nullish(), + state: unreadStateRequest.nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + hover: data['hover'], + state: data['state'], + textColor: data['textColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/unseen-badge.ts b/packages/user-client/src/services/integrations/models/unseen-badge.ts new file mode 100644 index 00000000..7f370808 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/unseen-badge.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unseenBadge = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + }); +}); + +/** + * + * @typedef {UnseenBadge} unseenBadge + * @property {string} + */ +export type UnseenBadge = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unseenBadgeResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unseenBadgeRequest = z.lazy(() => { + return z.object({ backgroundColor: z.string().nullish() }).transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/unseen-hover.ts b/packages/user-client/src/services/integrations/models/unseen-hover.ts new file mode 100644 index 00000000..32cc7e07 --- /dev/null +++ b/packages/user-client/src/services/integrations/models/unseen-hover.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unseenHover = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + }); +}); + +/** + * + * @typedef {UnseenHover} unseenHover + * @property {string} + */ +export type UnseenHover = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unseenHoverResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unseenHoverRequest = z.lazy(() => { + return z.object({ backgroundColor: z.string().nullish() }).transform((data) => ({ + backgroundColor: data['backgroundColor'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/unseen-state.ts b/packages/user-client/src/services/integrations/models/unseen-state.ts new file mode 100644 index 00000000..7a447d6c --- /dev/null +++ b/packages/user-client/src/services/integrations/models/unseen-state.ts @@ -0,0 +1,41 @@ +import { z } from 'zod'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unseenState = z.lazy(() => { + return z.object({ + color: z.string(), + }); +}); + +/** + * + * @typedef {UnseenState} unseenState + * @property {string} + */ +export type UnseenState = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unseenStateResponse = z.lazy(() => { + return z + .object({ + color: z.string(), + }) + .transform((data) => ({ + color: data['color'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unseenStateRequest = z.lazy(() => { + return z.object({ color: z.string().nullish() }).transform((data) => ({ + color: data['color'], + })); +}); diff --git a/packages/user-client/src/services/integrations/models/unseen.ts b/packages/user-client/src/services/integrations/models/unseen.ts new file mode 100644 index 00000000..ddb66e2f --- /dev/null +++ b/packages/user-client/src/services/integrations/models/unseen.ts @@ -0,0 +1,66 @@ +import { z } from 'zod'; + +import { unseenHover, unseenHoverRequest, unseenHoverResponse } from './unseen-hover'; +import { unseenState, unseenStateRequest, unseenStateResponse } from './unseen-state'; + +/** + * The shape of the model inside the application code - what the users use + */ +export const unseen = z.lazy(() => { + return z.object({ + backgroundColor: z.string(), + hover: unseenHover.optional(), + state: unseenState.optional(), + textColor: z.string(), + }); +}); + +/** + * + * @typedef {Unseen} unseen + * @property {string} + * @property {UnseenHover} + * @property {UnseenState} + * @property {string} + */ +export type Unseen = z.infer; + +/** + * The shape of the model mapping from the api schema into the application shape. + * Is equal to application shape if all property names match the api schema + */ +export const unseenResponse = z.lazy(() => { + return z + .object({ + backgroundColor: z.string(), + hover: unseenHoverResponse.optional(), + state: unseenStateResponse.optional(), + textColor: z.string(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + hover: data['hover'], + state: data['state'], + textColor: data['textColor'], + })); +}); + +/** + * The shape of the model mapping from the application shape into the api schema. + * Is equal to application shape if all property names match the api schema + */ +export const unseenRequest = z.lazy(() => { + return z + .object({ + backgroundColor: z.string().nullish(), + hover: unseenHoverRequest.nullish(), + state: unseenStateRequest.nullish(), + textColor: z.string().nullish(), + }) + .transform((data) => ({ + backgroundColor: data['backgroundColor'], + hover: data['hover'], + state: data['state'], + textColor: data['textColor'], + })); +});