magicbell-js 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -3
- package/dist/commonjs/project-client/http/errors/throwable-error.d.ts +7 -0
- package/dist/commonjs/project-client/http/errors/throwable-error.d.ts.map +1 -0
- package/dist/commonjs/project-client/http/errors/throwable-error.js +25 -0
- package/dist/commonjs/project-client/http/errors/throwable-error.js.map +1 -0
- package/dist/commonjs/project-client/http/handlers/hook-handler.d.ts.map +1 -1
- package/dist/commonjs/project-client/http/handlers/hook-handler.js +2 -2
- package/dist/commonjs/project-client/http/handlers/hook-handler.js.map +1 -1
- package/dist/commonjs/project-client/http/transport/types.d.ts +2 -1
- package/dist/commonjs/project-client/http/transport/types.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/broadcasts/broadcasts-service.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/broadcasts/broadcasts-service.js.map +1 -1
- package/dist/commonjs/project-client/services/channels/channels-service.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/channels/channels-service.js.map +1 -1
- package/dist/commonjs/project-client/services/events/events-service.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/events/events-service.js.map +1 -1
- package/dist/commonjs/project-client/services/integrations/integrations-service.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/integrations/integrations-service.js.map +1 -1
- package/dist/commonjs/project-client/services/jwt/jwt-service.d.ts +1 -25
- package/dist/commonjs/project-client/services/jwt/jwt-service.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/jwt/jwt-service.js +0 -103
- package/dist/commonjs/project-client/services/jwt/jwt-service.js.map +1 -1
- package/dist/commonjs/project-client/services/jwt/models/index.d.ts +0 -1
- package/dist/commonjs/project-client/services/jwt/models/index.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/jwt/request-params.d.ts +0 -5
- package/dist/commonjs/project-client/services/jwt/request-params.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/notifications/notifications-service.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/notifications/notifications-service.js.map +1 -1
- package/dist/commonjs/project-client/services/users/users-service.d.ts.map +1 -1
- package/dist/commonjs/project-client/services/users/users-service.js.map +1 -1
- package/dist/commonjs/user-client/http/errors/throwable-error.d.ts +7 -0
- package/dist/commonjs/user-client/http/errors/throwable-error.d.ts.map +1 -0
- package/dist/commonjs/user-client/http/errors/throwable-error.js +25 -0
- package/dist/commonjs/user-client/http/errors/throwable-error.js.map +1 -0
- package/dist/commonjs/user-client/http/handlers/hook-handler.d.ts.map +1 -1
- package/dist/commonjs/user-client/http/handlers/hook-handler.js +2 -2
- package/dist/commonjs/user-client/http/handlers/hook-handler.js.map +1 -1
- package/dist/commonjs/user-client/http/transport/types.d.ts +2 -1
- package/dist/commonjs/user-client/http/transport/types.d.ts.map +1 -1
- package/dist/commonjs/user-client/services/channels/channels-service.d.ts.map +1 -1
- package/dist/commonjs/user-client/services/channels/channels-service.js.map +1 -1
- package/dist/commonjs/user-client/services/integrations/integrations-service.d.ts.map +1 -1
- package/dist/commonjs/user-client/services/integrations/integrations-service.js.map +1 -1
- package/dist/commonjs/user-client/services/notifications/notifications-service.d.ts +26 -1
- package/dist/commonjs/user-client/services/notifications/notifications-service.d.ts.map +1 -1
- package/dist/commonjs/user-client/services/notifications/notifications-service.js +106 -0
- package/dist/commonjs/user-client/services/notifications/notifications-service.js.map +1 -1
- package/dist/commonjs/user-client/services/notifications/request-params.d.ts +9 -0
- package/dist/commonjs/user-client/services/notifications/request-params.d.ts.map +1 -1
- package/dist/esm/project-client/http/errors/throwable-error.d.ts +7 -0
- package/dist/esm/project-client/http/errors/throwable-error.d.ts.map +1 -0
- package/dist/esm/project-client/http/errors/throwable-error.js +21 -0
- package/dist/esm/project-client/http/errors/throwable-error.js.map +1 -0
- package/dist/esm/project-client/http/handlers/hook-handler.d.ts.map +1 -1
- package/dist/esm/project-client/http/handlers/hook-handler.js +2 -2
- package/dist/esm/project-client/http/handlers/hook-handler.js.map +1 -1
- package/dist/esm/project-client/http/transport/types.d.ts +2 -1
- package/dist/esm/project-client/http/transport/types.d.ts.map +1 -1
- package/dist/esm/project-client/services/broadcasts/broadcasts-service.d.ts.map +1 -1
- package/dist/esm/project-client/services/broadcasts/broadcasts-service.js.map +1 -1
- package/dist/esm/project-client/services/channels/channels-service.d.ts.map +1 -1
- package/dist/esm/project-client/services/channels/channels-service.js.map +1 -1
- package/dist/esm/project-client/services/events/events-service.d.ts.map +1 -1
- package/dist/esm/project-client/services/events/events-service.js.map +1 -1
- package/dist/esm/project-client/services/integrations/integrations-service.d.ts.map +1 -1
- package/dist/esm/project-client/services/integrations/integrations-service.js.map +1 -1
- package/dist/esm/project-client/services/jwt/jwt-service.d.ts +1 -25
- package/dist/esm/project-client/services/jwt/jwt-service.d.ts.map +1 -1
- package/dist/esm/project-client/services/jwt/jwt-service.js +0 -103
- package/dist/esm/project-client/services/jwt/jwt-service.js.map +1 -1
- package/dist/esm/project-client/services/jwt/models/index.d.ts +0 -1
- package/dist/esm/project-client/services/jwt/models/index.d.ts.map +1 -1
- package/dist/esm/project-client/services/jwt/request-params.d.ts +0 -5
- package/dist/esm/project-client/services/jwt/request-params.d.ts.map +1 -1
- package/dist/esm/project-client/services/notifications/notifications-service.d.ts.map +1 -1
- package/dist/esm/project-client/services/notifications/notifications-service.js.map +1 -1
- package/dist/esm/project-client/services/users/users-service.d.ts.map +1 -1
- package/dist/esm/project-client/services/users/users-service.js.map +1 -1
- package/dist/esm/user-client/http/errors/throwable-error.d.ts +7 -0
- package/dist/esm/user-client/http/errors/throwable-error.d.ts.map +1 -0
- package/dist/esm/user-client/http/errors/throwable-error.js +21 -0
- package/dist/esm/user-client/http/errors/throwable-error.js.map +1 -0
- package/dist/esm/user-client/http/handlers/hook-handler.d.ts.map +1 -1
- package/dist/esm/user-client/http/handlers/hook-handler.js +2 -2
- package/dist/esm/user-client/http/handlers/hook-handler.js.map +1 -1
- package/dist/esm/user-client/http/transport/types.d.ts +2 -1
- package/dist/esm/user-client/http/transport/types.d.ts.map +1 -1
- package/dist/esm/user-client/services/channels/channels-service.d.ts.map +1 -1
- package/dist/esm/user-client/services/channels/channels-service.js.map +1 -1
- package/dist/esm/user-client/services/integrations/integrations-service.d.ts.map +1 -1
- package/dist/esm/user-client/services/integrations/integrations-service.js.map +1 -1
- package/dist/esm/user-client/services/notifications/notifications-service.d.ts +26 -1
- package/dist/esm/user-client/services/notifications/notifications-service.d.ts.map +1 -1
- package/dist/esm/user-client/services/notifications/notifications-service.js +106 -0
- package/dist/esm/user-client/services/notifications/notifications-service.js.map +1 -1
- package/dist/esm/user-client/services/notifications/request-params.d.ts +9 -0
- package/dist/esm/user-client/services/notifications/request-params.d.ts.map +1 -1
- package/package.json +3 -1
- package/src/project-client/http/client.ts +71 -0
- package/src/project-client/http/environment.ts +3 -0
- package/src/project-client/http/error.ts +14 -0
- package/src/project-client/http/errors/throwable-error.ts +9 -0
- package/src/project-client/http/errors/validation-error.ts +25 -0
- package/src/project-client/http/handlers/handler-chain.ts +30 -0
- package/src/project-client/http/handlers/hook-handler.ts +80 -0
- package/src/project-client/http/handlers/request-validation-handler.ts +111 -0
- package/src/project-client/http/handlers/response-validation-handler.ts +203 -0
- package/src/project-client/http/handlers/retry-handler.ts +60 -0
- package/src/project-client/http/handlers/terminating-handler.ts +14 -0
- package/src/project-client/http/hooks/custom-hook.ts +25 -0
- package/src/project-client/http/hooks/hook.ts +41 -0
- package/src/project-client/http/index.ts +11 -0
- package/src/project-client/http/serialization/base-serializer.ts +139 -0
- package/src/project-client/http/serialization/header-serializer.ts +19 -0
- package/src/project-client/http/serialization/path-serializer.ts +12 -0
- package/src/project-client/http/serialization/query-serializer.ts +18 -0
- package/src/project-client/http/transport/request-builder.ts +242 -0
- package/src/project-client/http/transport/request-fetch-adapter.ts +131 -0
- package/src/project-client/http/transport/request.ts +222 -0
- package/src/project-client/http/transport/transport-hook-adapter.ts +91 -0
- package/src/project-client/http/transport/types.ts +51 -0
- package/src/project-client/http/types.ts +74 -0
- package/src/project-client/http/utils/content-type.ts +33 -0
- package/src/project-client/http/utils/line-decoder.ts +35 -0
- package/src/project-client/http/utils/response-matcher.ts +25 -0
- package/src/project-client/index.ts +94 -0
- package/src/project-client/services/base-service.ts +27 -0
- package/src/project-client/services/broadcasts/broadcasts-service.ts +116 -0
- package/src/project-client/services/broadcasts/index.ts +2 -0
- package/src/project-client/services/broadcasts/models/broadcast-collection.ts +54 -0
- package/src/project-client/services/broadcasts/models/broadcast-status.ts +60 -0
- package/src/project-client/services/broadcasts/models/broadcast.ts +143 -0
- package/src/project-client/services/broadcasts/models/email.ts +57 -0
- package/src/project-client/services/broadcasts/models/errors.ts +45 -0
- package/src/project-client/services/broadcasts/models/in-app.ts +57 -0
- package/src/project-client/services/broadcasts/models/index.ts +15 -0
- package/src/project-client/services/broadcasts/models/mobile-push.ts +57 -0
- package/src/project-client/services/broadcasts/models/overrides-channels.ts +82 -0
- package/src/project-client/services/broadcasts/models/overrides.ts +59 -0
- package/src/project-client/services/broadcasts/models/providers.ts +81 -0
- package/src/project-client/services/broadcasts/models/slack.ts +57 -0
- package/src/project-client/services/broadcasts/models/sms.ts +57 -0
- package/src/project-client/services/broadcasts/models/status-status.ts +7 -0
- package/src/project-client/services/broadcasts/models/summary.ts +51 -0
- package/src/project-client/services/broadcasts/models/web-push.ts +57 -0
- package/src/project-client/services/broadcasts/request-params.ts +5 -0
- package/src/project-client/services/channels/channels-service.ts +1018 -0
- package/src/project-client/services/channels/index.ts +2 -0
- package/src/project-client/services/channels/models/apns-token-collection.ts +54 -0
- package/src/project-client/services/channels/models/apns-token-installation-id.ts +6 -0
- package/src/project-client/services/channels/models/apns-token.ts +90 -0
- package/src/project-client/services/channels/models/category-delivery-config-channels.ts +57 -0
- package/src/project-client/services/channels/models/category-delivery-config.ts +73 -0
- package/src/project-client/services/channels/models/channel.ts +11 -0
- package/src/project-client/services/channels/models/discard-result.ts +51 -0
- package/src/project-client/services/channels/models/expo-token-collection.ts +54 -0
- package/src/project-client/services/channels/models/expo-token.ts +69 -0
- package/src/project-client/services/channels/models/fcm-token-collection.ts +54 -0
- package/src/project-client/services/channels/models/fcm-token-installation-id.ts +6 -0
- package/src/project-client/services/channels/models/fcm-token.ts +75 -0
- package/src/project-client/services/channels/models/inbox-token-response-collection.ts +59 -0
- package/src/project-client/services/channels/models/inbox-token-response.ts +75 -0
- package/src/project-client/services/channels/models/index.ts +24 -0
- package/src/project-client/services/channels/models/keys.ts +51 -0
- package/src/project-client/services/channels/models/oauth.ts +57 -0
- package/src/project-client/services/channels/models/slack-token-collection.ts +54 -0
- package/src/project-client/services/channels/models/slack-token-webhook.ts +45 -0
- package/src/project-client/services/channels/models/slack-token.ts +83 -0
- package/src/project-client/services/channels/models/teams-token-collection.ts +54 -0
- package/src/project-client/services/channels/models/teams-token-webhook.ts +45 -0
- package/src/project-client/services/channels/models/teams-token.ts +76 -0
- package/src/project-client/services/channels/models/web-push-token-collection.ts +54 -0
- package/src/project-client/services/channels/models/web-push-token.ts +77 -0
- package/src/project-client/services/channels/request-params.ts +45 -0
- package/src/project-client/services/common/index.ts +1 -0
- package/src/project-client/services/common/links.ts +57 -0
- package/src/project-client/services/events/events-service.ts +85 -0
- package/src/project-client/services/events/index.ts +2 -0
- package/src/project-client/services/events/models/event-collection.ts +54 -0
- package/src/project-client/services/events/models/event.ts +81 -0
- package/src/project-client/services/events/models/index.ts +2 -0
- package/src/project-client/services/events/request-params.ts +5 -0
- package/src/project-client/services/integrations/index.ts +2 -0
- package/src/project-client/services/integrations/integrations-service.ts +1966 -0
- package/src/project-client/services/integrations/models/apns-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/apns-config-payload.ts +81 -0
- package/src/project-client/services/integrations/models/apns-config.ts +64 -0
- package/src/project-client/services/integrations/models/awssns-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/awssns-config-payload.ts +45 -0
- package/src/project-client/services/integrations/models/awssns-config.ts +64 -0
- package/src/project-client/services/integrations/models/badge.ts +6 -0
- package/src/project-client/services/integrations/models/banner.ts +63 -0
- package/src/project-client/services/integrations/models/default-hover.ts +45 -0
- package/src/project-client/services/integrations/models/default-state.ts +45 -0
- package/src/project-client/services/integrations/models/default_.ts +90 -0
- package/src/project-client/services/integrations/models/dialog.ts +57 -0
- package/src/project-client/services/integrations/models/event-source-config-collection.ts +59 -0
- package/src/project-client/services/integrations/models/event-source-config-payload.ts +45 -0
- package/src/project-client/services/integrations/models/event-source-config.ts +64 -0
- package/src/project-client/services/integrations/models/expo-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/expo-config-payload.ts +45 -0
- package/src/project-client/services/integrations/models/expo-config.ts +64 -0
- package/src/project-client/services/integrations/models/fcm-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/fcm-config-payload.ts +105 -0
- package/src/project-client/services/integrations/models/fcm-config.ts +64 -0
- package/src/project-client/services/integrations/models/footer.ts +63 -0
- package/src/project-client/services/integrations/models/github-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/github-config-payload.ts +45 -0
- package/src/project-client/services/integrations/models/github-config.ts +64 -0
- package/src/project-client/services/integrations/models/header.ts +69 -0
- package/src/project-client/services/integrations/models/icon.ts +51 -0
- package/src/project-client/services/integrations/models/images.ts +45 -0
- package/src/project-client/services/integrations/models/inbox-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/inbox-config-payload.ts +60 -0
- package/src/project-client/services/integrations/models/inbox-config.ts +64 -0
- package/src/project-client/services/integrations/models/index.ts +75 -0
- package/src/project-client/services/integrations/models/integration-config-collection.ts +59 -0
- package/src/project-client/services/integrations/models/integration-config.ts +57 -0
- package/src/project-client/services/integrations/models/mailgun-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/mailgun-config-payload-from.ts +51 -0
- package/src/project-client/services/integrations/models/mailgun-config-payload.ts +70 -0
- package/src/project-client/services/integrations/models/mailgun-config.ts +64 -0
- package/src/project-client/services/integrations/models/notification.ts +61 -0
- package/src/project-client/services/integrations/models/payload-version.ts +6 -0
- package/src/project-client/services/integrations/models/ping-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/ping-config-payload.ts +45 -0
- package/src/project-client/services/integrations/models/ping-config.ts +64 -0
- package/src/project-client/services/integrations/models/region.ts +6 -0
- package/src/project-client/services/integrations/models/reply-to.ts +51 -0
- package/src/project-client/services/integrations/models/sendgrid-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/sendgrid-config-payload-from.ts +51 -0
- package/src/project-client/services/integrations/models/sendgrid-config-payload.ts +65 -0
- package/src/project-client/services/integrations/models/sendgrid-config.ts +64 -0
- package/src/project-client/services/integrations/models/ses-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/ses-config-payload-from.ts +51 -0
- package/src/project-client/services/integrations/models/ses-config-payload.ts +70 -0
- package/src/project-client/services/integrations/models/ses-config.ts +64 -0
- package/src/project-client/services/integrations/models/slack-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/slack-config-payload.ts +63 -0
- package/src/project-client/services/integrations/models/slack-config.ts +64 -0
- package/src/project-client/services/integrations/models/stripe-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/stripe-config-payload.ts +45 -0
- package/src/project-client/services/integrations/models/stripe-config.ts +64 -0
- package/src/project-client/services/integrations/models/templates-config-collection.ts +59 -0
- package/src/project-client/services/integrations/models/templates-config.ts +57 -0
- package/src/project-client/services/integrations/models/theme.ts +89 -0
- package/src/project-client/services/integrations/models/twilio-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/twilio-config-payload.ts +75 -0
- package/src/project-client/services/integrations/models/twilio-config.ts +64 -0
- package/src/project-client/services/integrations/models/type_.ts +5 -0
- package/src/project-client/services/integrations/models/unread-hover.ts +45 -0
- package/src/project-client/services/integrations/models/unread-state.ts +45 -0
- package/src/project-client/services/integrations/models/unread.ts +66 -0
- package/src/project-client/services/integrations/models/unseen-badge.ts +45 -0
- package/src/project-client/services/integrations/models/unseen-hover.ts +45 -0
- package/src/project-client/services/integrations/models/unseen-state.ts +45 -0
- package/src/project-client/services/integrations/models/unseen.ts +66 -0
- package/src/project-client/services/integrations/models/webpush-config-collection.ts +54 -0
- package/src/project-client/services/integrations/models/webpush-config-payload.ts +51 -0
- package/src/project-client/services/integrations/models/webpush-config.ts +64 -0
- package/src/project-client/services/integrations/request-params.ts +5 -0
- package/src/project-client/services/jwt/index.ts +2 -0
- package/src/project-client/services/jwt/jwt-service.ts +121 -0
- package/src/project-client/services/jwt/models/access-token-collection.ts +54 -0
- package/src/project-client/services/jwt/models/access-token.ts +69 -0
- package/src/project-client/services/jwt/models/create-project-token-request.ts +51 -0
- package/src/project-client/services/jwt/models/create-token-response.ts +63 -0
- package/src/project-client/services/jwt/models/discard-token-response.ts +51 -0
- package/src/project-client/services/jwt/models/index.ts +5 -0
- package/src/project-client/services/jwt/request-params.ts +5 -0
- package/src/project-client/services/notifications/index.ts +2 -0
- package/src/project-client/services/notifications/models/delivery-plan-collection.ts +54 -0
- package/src/project-client/services/notifications/models/delivery-plan.ts +93 -0
- package/src/project-client/services/notifications/models/index.ts +2 -0
- package/src/project-client/services/notifications/notifications-service.ts +45 -0
- package/src/project-client/services/users/index.ts +2 -0
- package/src/project-client/services/users/models/index.ts +2 -0
- package/src/project-client/services/users/models/user-collection.ts +54 -0
- package/src/project-client/services/users/models/user.ts +99 -0
- package/src/project-client/services/users/request-params.ts +6 -0
- package/src/project-client/services/users/users-service.ts +118 -0
- package/src/project-client.ts +1 -0
- package/src/user-client/http/client.ts +71 -0
- package/src/user-client/http/environment.ts +3 -0
- package/src/user-client/http/error.ts +14 -0
- package/src/user-client/http/errors/throwable-error.ts +9 -0
- package/src/user-client/http/errors/validation-error.ts +25 -0
- package/src/user-client/http/handlers/handler-chain.ts +30 -0
- package/src/user-client/http/handlers/hook-handler.ts +80 -0
- package/src/user-client/http/handlers/request-validation-handler.ts +111 -0
- package/src/user-client/http/handlers/response-validation-handler.ts +203 -0
- package/src/user-client/http/handlers/retry-handler.ts +60 -0
- package/src/user-client/http/handlers/terminating-handler.ts +14 -0
- package/src/user-client/http/hooks/custom-hook.ts +25 -0
- package/src/user-client/http/hooks/hook.ts +41 -0
- package/src/user-client/http/index.ts +11 -0
- package/src/user-client/http/serialization/base-serializer.ts +139 -0
- package/src/user-client/http/serialization/header-serializer.ts +19 -0
- package/src/user-client/http/serialization/path-serializer.ts +12 -0
- package/src/user-client/http/serialization/query-serializer.ts +18 -0
- package/src/user-client/http/transport/request-builder.ts +242 -0
- package/src/user-client/http/transport/request-fetch-adapter.ts +131 -0
- package/src/user-client/http/transport/request.ts +222 -0
- package/src/user-client/http/transport/transport-hook-adapter.ts +91 -0
- package/src/user-client/http/transport/types.ts +51 -0
- package/src/user-client/http/types.ts +74 -0
- package/src/user-client/http/utils/content-type.ts +33 -0
- package/src/user-client/http/utils/line-decoder.ts +35 -0
- package/src/user-client/http/utils/response-matcher.ts +25 -0
- package/src/user-client/index.ts +54 -0
- package/src/user-client/services/base-service.ts +27 -0
- package/src/user-client/services/channels/channels-service.ts +1021 -0
- package/src/user-client/services/channels/index.ts +2 -0
- package/src/user-client/services/channels/models/apns-token-collection.ts +54 -0
- package/src/user-client/services/channels/models/apns-token-installation-id.ts +6 -0
- package/src/user-client/services/channels/models/apns-token-payload-installation-id.ts +6 -0
- package/src/user-client/services/channels/models/apns-token-payload.ts +66 -0
- package/src/user-client/services/channels/models/apns-token.ts +90 -0
- package/src/user-client/services/channels/models/discard-result.ts +51 -0
- package/src/user-client/services/channels/models/expo-token-collection.ts +54 -0
- package/src/user-client/services/channels/models/expo-token-payload.ts +45 -0
- package/src/user-client/services/channels/models/expo-token.ts +69 -0
- package/src/user-client/services/channels/models/fcm-token-collection.ts +54 -0
- package/src/user-client/services/channels/models/fcm-token-installation-id.ts +6 -0
- package/src/user-client/services/channels/models/fcm-token-payload-installation-id.ts +6 -0
- package/src/user-client/services/channels/models/fcm-token-payload.ts +51 -0
- package/src/user-client/services/channels/models/fcm-token.ts +75 -0
- package/src/user-client/services/channels/models/inbox-token-response-collection.ts +59 -0
- package/src/user-client/services/channels/models/inbox-token-response.ts +75 -0
- package/src/user-client/services/channels/models/inbox-token.ts +51 -0
- package/src/user-client/services/channels/models/index.ts +33 -0
- package/src/user-client/services/channels/models/slack-token-collection.ts +54 -0
- package/src/user-client/services/channels/models/slack-token-oauth.ts +57 -0
- package/src/user-client/services/channels/models/slack-token-payload-oauth.ts +57 -0
- package/src/user-client/services/channels/models/slack-token-payload-webhook.ts +45 -0
- package/src/user-client/services/channels/models/slack-token-payload.ts +64 -0
- package/src/user-client/services/channels/models/slack-token-webhook.ts +45 -0
- package/src/user-client/services/channels/models/slack-token.ts +88 -0
- package/src/user-client/services/channels/models/teams-token-collection.ts +54 -0
- package/src/user-client/services/channels/models/teams-token-payload-webhook.ts +45 -0
- package/src/user-client/services/channels/models/teams-token-payload.ts +52 -0
- package/src/user-client/services/channels/models/teams-token-webhook.ts +45 -0
- package/src/user-client/services/channels/models/teams-token.ts +76 -0
- package/src/user-client/services/channels/models/web-push-token-collection.ts +54 -0
- package/src/user-client/services/channels/models/web-push-token-keys.ts +51 -0
- package/src/user-client/services/channels/models/web-push-token-payload-keys.ts +51 -0
- package/src/user-client/services/channels/models/web-push-token.ts +82 -0
- package/src/user-client/services/channels/request-params.ts +41 -0
- package/src/user-client/services/common/index.ts +2 -0
- package/src/user-client/services/common/links.ts +57 -0
- package/src/user-client/services/common/web-push-token-payload.ts +58 -0
- package/src/user-client/services/integrations/index.ts +2 -0
- package/src/user-client/services/integrations/integrations-service.ts +279 -0
- package/src/user-client/services/integrations/models/authed-user.ts +75 -0
- package/src/user-client/services/integrations/models/banner.ts +63 -0
- package/src/user-client/services/integrations/models/default-hover.ts +45 -0
- package/src/user-client/services/integrations/models/default-state.ts +45 -0
- package/src/user-client/services/integrations/models/default_.ts +90 -0
- package/src/user-client/services/integrations/models/dialog.ts +57 -0
- package/src/user-client/services/integrations/models/enterprise.ts +51 -0
- package/src/user-client/services/integrations/models/footer.ts +63 -0
- package/src/user-client/services/integrations/models/header.ts +69 -0
- package/src/user-client/services/integrations/models/icon.ts +51 -0
- package/src/user-client/services/integrations/models/images.ts +45 -0
- package/src/user-client/services/integrations/models/inbox-config-payload.ts +60 -0
- package/src/user-client/services/integrations/models/incoming-webhook.ts +57 -0
- package/src/user-client/services/integrations/models/index.ts +29 -0
- package/src/user-client/services/integrations/models/slack-finish-install-response.ts +57 -0
- package/src/user-client/services/integrations/models/slack-installation.ts +136 -0
- package/src/user-client/services/integrations/models/slack-start-install-response-content.ts +57 -0
- package/src/user-client/services/integrations/models/slack-start-install.ts +63 -0
- package/src/user-client/services/integrations/models/team.ts +51 -0
- package/src/user-client/services/integrations/models/templates-installation.ts +57 -0
- package/src/user-client/services/integrations/models/theme-notification.ts +61 -0
- package/src/user-client/services/integrations/models/theme.ts +94 -0
- package/src/user-client/services/integrations/models/unread-hover.ts +45 -0
- package/src/user-client/services/integrations/models/unread-state.ts +45 -0
- package/src/user-client/services/integrations/models/unread.ts +66 -0
- package/src/user-client/services/integrations/models/unseen-badge.ts +45 -0
- package/src/user-client/services/integrations/models/unseen-hover.ts +45 -0
- package/src/user-client/services/integrations/models/unseen-state.ts +45 -0
- package/src/user-client/services/integrations/models/unseen.ts +66 -0
- package/src/user-client/services/integrations/models/web-push-start-installation-response.ts +51 -0
- package/src/user-client/services/notifications/index.ts +2 -0
- package/src/user-client/services/notifications/models/index.ts +2 -0
- package/src/user-client/services/notifications/models/notification-collection.ts +54 -0
- package/src/user-client/services/notifications/models/notification.ts +129 -0
- package/src/user-client/services/notifications/notifications-service.ts +305 -0
- package/src/user-client/services/notifications/request-params.ts +18 -0
- package/src/user-client.ts +1 -0
- package/dist/commonjs/project-client/services/jwt/models/create-user-token-request.d.ts +0 -90
- package/dist/commonjs/project-client/services/jwt/models/create-user-token-request.d.ts.map +0 -1
- package/dist/commonjs/project-client/services/jwt/models/create-user-token-request.js +0 -54
- package/dist/commonjs/project-client/services/jwt/models/create-user-token-request.js.map +0 -1
- package/dist/esm/project-client/services/jwt/models/create-user-token-request.d.ts +0 -90
- package/dist/esm/project-client/services/jwt/models/create-user-token-request.d.ts.map +0 -1
- package/dist/esm/project-client/services/jwt/models/create-user-token-request.js +0 -51
- package/dist/esm/project-client/services/jwt/models/create-user-token-request.js.map +0 -1
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
type HttpMethod = 'GET' | 'POST' | 'PUT' | 'PATCH' | 'DELETE' | 'HEAD' | 'OPTIONS';
|
|
2
|
+
|
|
3
|
+
export interface HttpRequest {
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
method: HttpMethod;
|
|
6
|
+
path: string;
|
|
7
|
+
headers: Map<string, unknown>;
|
|
8
|
+
body?: BodyInit;
|
|
9
|
+
abortSignal?: AbortSignal;
|
|
10
|
+
queryParams: Map<string, unknown>;
|
|
11
|
+
pathParams: Map<string, unknown>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
interface HttpMetadata {
|
|
15
|
+
status: number;
|
|
16
|
+
statusText: string;
|
|
17
|
+
headers: Record<string, string>;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface HttpResponse<T> {
|
|
21
|
+
data?: T;
|
|
22
|
+
metadata: HttpMetadata;
|
|
23
|
+
raw: ArrayBuffer;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export interface HttpError {
|
|
27
|
+
error: string;
|
|
28
|
+
metadata: HttpMetadata;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export interface Hook {
|
|
32
|
+
beforeRequest(request: HttpRequest, params: Map<string, string>): Promise<HttpRequest>;
|
|
33
|
+
|
|
34
|
+
afterResponse(
|
|
35
|
+
request: HttpRequest,
|
|
36
|
+
response: HttpResponse<any>,
|
|
37
|
+
params: Map<string, string>,
|
|
38
|
+
): Promise<HttpResponse<any>>;
|
|
39
|
+
|
|
40
|
+
onError(request: HttpRequest, response: HttpResponse<any>, params: Map<string, string>): Promise<HttpError>;
|
|
41
|
+
}
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { RequestParameter } from '../transport/types.js';
|
|
2
|
+
|
|
3
|
+
export type SerializationOptions = {
|
|
4
|
+
explode: boolean;
|
|
5
|
+
style: SerializationStyle;
|
|
6
|
+
encode: boolean;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export enum SerializationStyle {
|
|
10
|
+
SIMPLE = 'simple',
|
|
11
|
+
LABEL = 'label',
|
|
12
|
+
MATRIX = 'matrix',
|
|
13
|
+
FORM = 'form',
|
|
14
|
+
SPACE_DELIMITED = 'space_delimited',
|
|
15
|
+
PIPE_DELIMITED = 'pipe_delimited',
|
|
16
|
+
DEEP_OBJECT = 'deep_object',
|
|
17
|
+
NONE = 'none',
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export class Serializer {
|
|
21
|
+
protected serializeValue(param: RequestParameter): string {
|
|
22
|
+
if (Array.isArray(param.value)) {
|
|
23
|
+
return this.serializeArray(param.value, param);
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (this.isNonNullObject(param.value)) {
|
|
27
|
+
return this.serializeObject(param.value, param);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return this.serializePrimitive(param);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
private serializePrimitive(param: RequestParameter): string {
|
|
34
|
+
if (param.style === SerializationStyle.LABEL) {
|
|
35
|
+
return `.${param.value}`;
|
|
36
|
+
} else if (param.style === SerializationStyle.MATRIX) {
|
|
37
|
+
return `;${param.key}=${param.value}`;
|
|
38
|
+
} else if (param.style === SerializationStyle.FORM) {
|
|
39
|
+
return `${encodeURIComponent(param.key || '')}=${encodeURIComponent(`${param.value}`)}`;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return `${param.value}`;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
private serializeArray(value: unknown[], param: RequestParameter): string {
|
|
46
|
+
if (param.explode) {
|
|
47
|
+
this.serializeArrayExploded(value, param);
|
|
48
|
+
return this.serializeArrayExploded(value, param);
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
if (param.style === SerializationStyle.SIMPLE) {
|
|
52
|
+
return `${value.join(',')}`;
|
|
53
|
+
} else if (param.style === SerializationStyle.LABEL) {
|
|
54
|
+
return `.${value.join(',')}`;
|
|
55
|
+
} else if (param.style === SerializationStyle.MATRIX) {
|
|
56
|
+
return `;${param.key}=${value.join(',')}`;
|
|
57
|
+
} else if (param.style === SerializationStyle.FORM) {
|
|
58
|
+
return `${encodeURIComponent(param.key || '')}=${encodeURIComponent(value.join(','))}`;
|
|
59
|
+
} else if (param.style === SerializationStyle.SPACE_DELIMITED) {
|
|
60
|
+
return `${param.key}=${value.join(' ')}`;
|
|
61
|
+
} else if (param.style === SerializationStyle.PIPE_DELIMITED) {
|
|
62
|
+
return `${param.key}=${value.join('|')}`;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
return `${value.join(',')}`;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
private serializeArrayExploded(value: unknown[], param: RequestParameter): string {
|
|
69
|
+
if (param.style === SerializationStyle.SIMPLE) {
|
|
70
|
+
return value.map((val) => `${val}`).join(',');
|
|
71
|
+
} else if (param.style === SerializationStyle.LABEL) {
|
|
72
|
+
return value.map((val) => `.${val}`).join('');
|
|
73
|
+
} else if (param.style === SerializationStyle.MATRIX) {
|
|
74
|
+
return value.map((val) => `;${param.key}=${val}`).join('');
|
|
75
|
+
} else if (
|
|
76
|
+
param.style === SerializationStyle.FORM ||
|
|
77
|
+
param.style === SerializationStyle.SPACE_DELIMITED ||
|
|
78
|
+
param.style === SerializationStyle.PIPE_DELIMITED
|
|
79
|
+
) {
|
|
80
|
+
return value.map((val) => `${encodeURIComponent(param.key || '')}=${encodeURIComponent(`${val}`)}`).join('&');
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return `${value.join(',')}`;
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
private serializeObject(obj: object, param: RequestParameter): string {
|
|
87
|
+
if (param.explode) {
|
|
88
|
+
if (param.style === SerializationStyle.SIMPLE) {
|
|
89
|
+
return Object.entries(obj)
|
|
90
|
+
.map(([key, val]) => `${key}=${val}`)
|
|
91
|
+
.join(',');
|
|
92
|
+
} else if (param.style === SerializationStyle.LABEL) {
|
|
93
|
+
return Object.entries(obj)
|
|
94
|
+
.map(([key, val]) => `.${key}=${val}`)
|
|
95
|
+
.join('');
|
|
96
|
+
} else if (param.style === SerializationStyle.MATRIX) {
|
|
97
|
+
return Object.entries(obj)
|
|
98
|
+
.map(([key, val]) => `;${key}=${val}`)
|
|
99
|
+
.join('');
|
|
100
|
+
} else if (param.style === SerializationStyle.FORM) {
|
|
101
|
+
return Object.entries(obj)
|
|
102
|
+
.map(([key, val]) => `${key}=${val}`)
|
|
103
|
+
.join('&');
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (param.style === SerializationStyle.SIMPLE) {
|
|
108
|
+
return Object.entries(obj)
|
|
109
|
+
.map(([key, val]) => `${key},${val}`)
|
|
110
|
+
.join(',');
|
|
111
|
+
} else if (param.style === SerializationStyle.LABEL) {
|
|
112
|
+
return `.${Object.entries(obj)
|
|
113
|
+
.map(([key, val]) => `${key},${val}`)
|
|
114
|
+
.join(',')}`;
|
|
115
|
+
} else if (param.style === SerializationStyle.MATRIX) {
|
|
116
|
+
return `;${param.key}=${Object.entries(obj)
|
|
117
|
+
.map(([key, val]) => `${key},${val}`)
|
|
118
|
+
.join(',')}`;
|
|
119
|
+
} else if (param.style === SerializationStyle.FORM) {
|
|
120
|
+
return Object.entries(obj)
|
|
121
|
+
.map(([key, val]) => `${key}=${val}`)
|
|
122
|
+
.join('&');
|
|
123
|
+
} else if (param.style === SerializationStyle.DEEP_OBJECT) {
|
|
124
|
+
return Object.entries(obj)
|
|
125
|
+
.map(([key, val]) => {
|
|
126
|
+
return `${param.key}[${key}]=${val}`;
|
|
127
|
+
})
|
|
128
|
+
.join('&');
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
return Object.entries(obj)
|
|
132
|
+
.map(([key, val]) => `${key}=${val}`)
|
|
133
|
+
.join('&');
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
private isNonNullObject(value: unknown): value is object {
|
|
137
|
+
return typeof value === 'object' && value !== null;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { RequestParameter } from '../transport/types.js';
|
|
2
|
+
import { Serializer } from './base-serializer.js';
|
|
3
|
+
|
|
4
|
+
export class HeaderSerializer extends Serializer {
|
|
5
|
+
public serialize(headerParams: Map<string, RequestParameter> | undefined): HeadersInit | undefined {
|
|
6
|
+
if (!headerParams || !headerParams.size) {
|
|
7
|
+
return undefined;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const headers: HeadersInit = {};
|
|
11
|
+
headerParams.forEach((param) => {
|
|
12
|
+
if (!param.key) {
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
headers[param.key] = this.serializeValue(param);
|
|
16
|
+
});
|
|
17
|
+
return headers;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { RequestParameter } from '../transport/types.js';
|
|
2
|
+
import { Serializer } from './base-serializer.js';
|
|
3
|
+
|
|
4
|
+
export class PathSerializer extends Serializer {
|
|
5
|
+
public serialize(pathPattern: string, pathArguments: Map<string, RequestParameter>): string {
|
|
6
|
+
let serializedPath = pathPattern;
|
|
7
|
+
pathArguments.forEach((param: RequestParameter) => {
|
|
8
|
+
serializedPath = serializedPath.replace(`{${param.key}}`, `${this.serializeValue(param)}`);
|
|
9
|
+
});
|
|
10
|
+
return serializedPath;
|
|
11
|
+
}
|
|
12
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { RequestParameter } from '../transport/types.js';
|
|
2
|
+
import { SerializationOptions, Serializer } from './base-serializer.js';
|
|
3
|
+
|
|
4
|
+
export class QuerySerializer extends Serializer {
|
|
5
|
+
public serialize(queryParams: Map<string, RequestParameter>): string {
|
|
6
|
+
if (!queryParams || !queryParams.size) {
|
|
7
|
+
return '';
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const query: string[] = [];
|
|
11
|
+
|
|
12
|
+
queryParams.forEach((param) => {
|
|
13
|
+
return query.push(`${this.serializeValue(param)}`);
|
|
14
|
+
});
|
|
15
|
+
|
|
16
|
+
return query.length ? `?${query.join('&')}` : '';
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
import z, { ZodType } from 'zod';
|
|
2
|
+
|
|
3
|
+
import { Environment } from '../environment.js';
|
|
4
|
+
import { SerializationStyle } from '../serialization/base-serializer.js';
|
|
5
|
+
import { ContentType, HttpMethod, RequestConfig, RetryOptions, SdkConfig, ValidationOptions } from '../types.js';
|
|
6
|
+
import { Request } from './request.js';
|
|
7
|
+
import {
|
|
8
|
+
CreateRequestParameters,
|
|
9
|
+
ErrorDefinition,
|
|
10
|
+
RequestPagination,
|
|
11
|
+
RequestParameter,
|
|
12
|
+
ResponseDefinition,
|
|
13
|
+
} from './types.js';
|
|
14
|
+
|
|
15
|
+
export class RequestBuilder<Page extends unknown[] = unknown[]> {
|
|
16
|
+
private params: CreateRequestParameters<Page>;
|
|
17
|
+
|
|
18
|
+
constructor() {
|
|
19
|
+
this.params = {
|
|
20
|
+
baseUrl: Environment.DEFAULT,
|
|
21
|
+
method: 'GET',
|
|
22
|
+
path: '',
|
|
23
|
+
config: {},
|
|
24
|
+
responses: [],
|
|
25
|
+
errors: [],
|
|
26
|
+
requestSchema: z.any(),
|
|
27
|
+
requestContentType: ContentType.Json,
|
|
28
|
+
retry: {
|
|
29
|
+
attempts: 3,
|
|
30
|
+
delayMs: 150,
|
|
31
|
+
},
|
|
32
|
+
validation: {
|
|
33
|
+
responseValidation: true,
|
|
34
|
+
},
|
|
35
|
+
pathParams: new Map(),
|
|
36
|
+
queryParams: new Map(),
|
|
37
|
+
headers: new Map(),
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
setRetryAttempts(sdkConfig?: SdkConfig, requestConfig?: RequestConfig): RequestBuilder<Page> {
|
|
42
|
+
if (requestConfig?.retry?.attempts !== undefined) {
|
|
43
|
+
this.params.retry.attempts = requestConfig.retry.attempts;
|
|
44
|
+
} else if (sdkConfig?.retry?.attempts !== undefined) {
|
|
45
|
+
this.params.retry.attempts = sdkConfig.retry.attempts;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return this;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
setRetryDelayMs(sdkConfig?: SdkConfig, requestConfig?: RequestConfig): RequestBuilder<Page> {
|
|
52
|
+
if (requestConfig?.retry?.delayMs !== undefined) {
|
|
53
|
+
this.params.retry.delayMs = requestConfig.retry.delayMs;
|
|
54
|
+
} else if (sdkConfig?.retry?.delayMs !== undefined) {
|
|
55
|
+
this.params.retry.delayMs = sdkConfig.retry.delayMs;
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return this;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
setResponseValidation(sdkConfig: SdkConfig, requestConfig?: RequestConfig): RequestBuilder<Page> {
|
|
62
|
+
if (requestConfig?.validation?.responseValidation !== undefined) {
|
|
63
|
+
this.params.validation.responseValidation = requestConfig.validation.responseValidation;
|
|
64
|
+
} else if (sdkConfig?.validation?.responseValidation !== undefined) {
|
|
65
|
+
this.params.validation.responseValidation = sdkConfig.validation.responseValidation;
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return this;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
setBaseUrl(baseUrl: string | undefined): RequestBuilder<Page> {
|
|
72
|
+
if (baseUrl) {
|
|
73
|
+
this.params.baseUrl = baseUrl;
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
return this;
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
setMethod(method: HttpMethod): RequestBuilder<Page> {
|
|
80
|
+
this.params.method = method;
|
|
81
|
+
return this;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
setPath(path: string): RequestBuilder<Page> {
|
|
85
|
+
this.params.path = path;
|
|
86
|
+
return this;
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
setConfig(config: SdkConfig): RequestBuilder<Page> {
|
|
90
|
+
this.params.config = config;
|
|
91
|
+
return this;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
setRequestContentType(contentType: ContentType): RequestBuilder<Page> {
|
|
95
|
+
this.params.requestContentType = contentType;
|
|
96
|
+
return this;
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
setRequestSchema(requestSchema: ZodType): RequestBuilder<Page> {
|
|
100
|
+
this.params.requestSchema = requestSchema;
|
|
101
|
+
return this;
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
setPagination(pagination: RequestPagination<Page>): RequestBuilder<Page> {
|
|
105
|
+
this.params.pagination = pagination;
|
|
106
|
+
return this;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
addAccessTokenAuth(accessToken?: string, prefix?: string): RequestBuilder<Page> {
|
|
110
|
+
if (accessToken === undefined) {
|
|
111
|
+
return this;
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
this.params.headers.set('Authorization', {
|
|
115
|
+
key: 'Authorization',
|
|
116
|
+
value: `${prefix ?? 'Bearer'} ${accessToken}`,
|
|
117
|
+
explode: false,
|
|
118
|
+
style: SerializationStyle.SIMPLE,
|
|
119
|
+
encode: true,
|
|
120
|
+
isLimit: false,
|
|
121
|
+
isOffset: false,
|
|
122
|
+
});
|
|
123
|
+
return this;
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
addBasicAuth(username?: string, password?: string): RequestBuilder<Page> {
|
|
127
|
+
if (username === undefined || password === undefined) {
|
|
128
|
+
return this;
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
this.params.headers.set('Authorization', {
|
|
132
|
+
key: 'Authorization',
|
|
133
|
+
value: `Basic ${this.toBase64(`${username}:${password}`)}`,
|
|
134
|
+
explode: false,
|
|
135
|
+
style: SerializationStyle.SIMPLE,
|
|
136
|
+
encode: true,
|
|
137
|
+
isLimit: false,
|
|
138
|
+
isOffset: false,
|
|
139
|
+
});
|
|
140
|
+
return this;
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
addApiKeyAuth(apiKey?: string, keyName?: string): RequestBuilder<Page> {
|
|
144
|
+
if (apiKey === undefined) {
|
|
145
|
+
return this;
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
this.params.headers.set(keyName ?? 'X-API-KEY', {
|
|
149
|
+
key: keyName ?? 'X-API-KEY',
|
|
150
|
+
value: apiKey,
|
|
151
|
+
explode: false,
|
|
152
|
+
style: SerializationStyle.SIMPLE,
|
|
153
|
+
encode: true,
|
|
154
|
+
isLimit: false,
|
|
155
|
+
isOffset: false,
|
|
156
|
+
});
|
|
157
|
+
return this;
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
addResponse(response: ResponseDefinition): RequestBuilder<Page> {
|
|
161
|
+
this.params.responses.push(response);
|
|
162
|
+
return this;
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
addError(error: ErrorDefinition): RequestBuilder<Page> {
|
|
166
|
+
this.params.errors.push(error);
|
|
167
|
+
return this;
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
addBody(body?: any): RequestBuilder<Page> {
|
|
171
|
+
if (body !== undefined) {
|
|
172
|
+
this.params.body = body;
|
|
173
|
+
}
|
|
174
|
+
return this;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
addPathParam(param: Partial<RequestParameter>): RequestBuilder<Page> {
|
|
178
|
+
if (param.value === undefined || param.key === undefined) {
|
|
179
|
+
return this;
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
this.params.pathParams.set(param.key, {
|
|
183
|
+
key: param.key,
|
|
184
|
+
value: param.value,
|
|
185
|
+
explode: param.explode ?? true,
|
|
186
|
+
style: param.style ?? SerializationStyle.SIMPLE,
|
|
187
|
+
encode: param.encode ?? true,
|
|
188
|
+
isLimit: !!param.isLimit,
|
|
189
|
+
isOffset: !!param.isOffset,
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
return this;
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
addQueryParam(param: Partial<RequestParameter>): RequestBuilder<Page> {
|
|
196
|
+
if (param.value === undefined || param.key === undefined) {
|
|
197
|
+
return this;
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
this.params.queryParams.set(param.key, {
|
|
201
|
+
key: param.key,
|
|
202
|
+
value: param.value,
|
|
203
|
+
explode: param.explode ?? true,
|
|
204
|
+
style: param.style ?? SerializationStyle.FORM,
|
|
205
|
+
encode: param.encode ?? true,
|
|
206
|
+
isLimit: !!param.isLimit,
|
|
207
|
+
isOffset: !!param.isOffset,
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
return this;
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
addHeaderParam(param: Partial<RequestParameter>): RequestBuilder<Page> {
|
|
214
|
+
if (param.value === undefined || param.key === undefined) {
|
|
215
|
+
return this;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
this.params.headers.set(param.key, {
|
|
219
|
+
key: param.key,
|
|
220
|
+
value: param.value,
|
|
221
|
+
explode: param.explode ?? true,
|
|
222
|
+
style: param.style ?? SerializationStyle.SIMPLE,
|
|
223
|
+
encode: param.encode ?? false,
|
|
224
|
+
isLimit: !!param.isLimit,
|
|
225
|
+
isOffset: !!param.isOffset,
|
|
226
|
+
});
|
|
227
|
+
|
|
228
|
+
return this;
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
public build(): Request<Page> {
|
|
232
|
+
return new Request<Page>(this.params);
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
private toBase64(str: string): string {
|
|
236
|
+
if (typeof window === 'undefined') {
|
|
237
|
+
return Buffer.from(str, 'utf-8').toString('base64');
|
|
238
|
+
} else {
|
|
239
|
+
return btoa(unescape(encodeURIComponent(str)));
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
}
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { HttpError } from '../error.js';
|
|
2
|
+
import { HttpMetadata, HttpMethod, HttpResponse } from '../types.js';
|
|
3
|
+
import { LineDecoder } from '../utils/line-decoder.js';
|
|
4
|
+
import { Request } from './request.js';
|
|
5
|
+
|
|
6
|
+
interface HttpAdapter {
|
|
7
|
+
send(): Promise<HttpResponse>;
|
|
8
|
+
stream(): AsyncGenerator<HttpResponse>;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export class RequestFetchAdapter<T> implements HttpAdapter {
|
|
12
|
+
private requestInit: RequestInit = {};
|
|
13
|
+
|
|
14
|
+
constructor(private request: Request) {
|
|
15
|
+
this.setMethod(request.method);
|
|
16
|
+
this.setHeaders(request.getHeaders());
|
|
17
|
+
this.setBody(request.body);
|
|
18
|
+
this.setTimeout(request.config.timeoutMs);
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
public async send(): Promise<HttpResponse<T>> {
|
|
22
|
+
const response = await fetch(this.request.constructFullUrl(), this.requestInit);
|
|
23
|
+
|
|
24
|
+
const metadata: HttpMetadata = {
|
|
25
|
+
status: response.status,
|
|
26
|
+
statusText: response.statusText || '',
|
|
27
|
+
headers: this.getHeaders(response),
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
metadata,
|
|
32
|
+
raw: await response.clone().arrayBuffer(),
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
public async *stream(): AsyncGenerator<HttpResponse<T>> {
|
|
37
|
+
const response = await fetch(this.request.constructFullUrl(), this.requestInit);
|
|
38
|
+
|
|
39
|
+
const metadata: HttpMetadata = {
|
|
40
|
+
status: response.status,
|
|
41
|
+
statusText: response.statusText || '',
|
|
42
|
+
headers: this.getHeaders(response),
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
if (response.status >= 400) {
|
|
46
|
+
throw new HttpError(metadata, await response.clone().arrayBuffer());
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
if (!response.body) {
|
|
50
|
+
return yield {
|
|
51
|
+
metadata,
|
|
52
|
+
raw: await response.clone().arrayBuffer(),
|
|
53
|
+
};
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
const reader = response.body.getReader();
|
|
57
|
+
const lineDecoder = new LineDecoder();
|
|
58
|
+
|
|
59
|
+
while (true) {
|
|
60
|
+
const { done, value } = await reader.read();
|
|
61
|
+
if (done) {
|
|
62
|
+
break;
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
for (const line of lineDecoder.splitLines(value)) {
|
|
66
|
+
yield {
|
|
67
|
+
metadata,
|
|
68
|
+
raw: line,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
for (const line of lineDecoder.flush()) {
|
|
74
|
+
yield {
|
|
75
|
+
metadata,
|
|
76
|
+
raw: line,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
private setMethod(method: HttpMethod): void {
|
|
82
|
+
if (!method) {
|
|
83
|
+
return;
|
|
84
|
+
}
|
|
85
|
+
this.requestInit = {
|
|
86
|
+
...this.requestInit,
|
|
87
|
+
method,
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
private setBody(body: ReadableStream<Uint8Array> | null): void {
|
|
92
|
+
if (!body) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
this.requestInit = {
|
|
96
|
+
...this.requestInit,
|
|
97
|
+
body,
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
private setHeaders(headers: HeadersInit | undefined): void {
|
|
102
|
+
if (!headers) {
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
this.requestInit = {
|
|
107
|
+
...this.requestInit,
|
|
108
|
+
headers,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
private setTimeout(timeoutMs: number | undefined): void {
|
|
113
|
+
if (!timeoutMs) {
|
|
114
|
+
return;
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
this.requestInit = {
|
|
118
|
+
...this.requestInit,
|
|
119
|
+
signal: AbortSignal.timeout(timeoutMs),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
private getHeaders(response: Response): Record<string, string> {
|
|
124
|
+
const headers: Record<string, string> = {};
|
|
125
|
+
response.headers.forEach((value: string, key: string) => {
|
|
126
|
+
headers[key] = value;
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
return headers;
|
|
130
|
+
}
|
|
131
|
+
}
|