From 5ad1e7c9074ff7d6b1001ccff3602910fb530689 Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Thu, 2 Feb 2023 20:20:24 +0000 Subject: [PATCH] Release 0.0.40 --- .gitignore | 12 +- .prettierignore | 6 - .prettierrc.yml | 2 + .yarn/sdks/prettier/index.js | 4 +- .yarn/sdks/typescript/bin/tsc | 4 +- .yarn/sdks/typescript/bin/tsserver | 4 +- .yarn/sdks/typescript/lib/tsc.js | 4 +- .yarn/sdks/typescript/lib/tsserver.js | 43 +-- .yarn/sdks/typescript/lib/tsserverlibrary.js | 43 +-- .yarn/sdks/typescript/lib/typescript.js | 4 +- build.js | 61 +++++ package.json | 44 ++- src/api/index.ts | 1 + src/api/resources/device/client/Client.ts | 199 ++++++++++++++ src/api/resources/device/client/index.ts | 1 + src/{ => api}/resources/device/index.ts | 0 src/api/resources/device/types/Device.ts | 23 ++ src/api/resources/device/types/Platform.ts | 11 + src/{ => api}/resources/device/types/index.ts | 0 src/api/resources/event/client/Client.ts | 117 ++++++++ src/api/resources/event/client/index.ts | 1 + .../client/requests/BulkSendEventRequest.ts | 20 ++ .../event/client/requests/SendEventRequest.ts | 23 ++ .../resources/event/client/requests/index.ts | 2 + .../event/errors/EventNotFoundError.ts | 17 ++ src/api/resources/event/errors/index.ts | 1 + src/api/resources/event/index.ts | 3 + src/api/resources/event/types/Attachment.ts | 9 + src/api/resources/event/types/BatchEvent.ts | 19 ++ .../resources/event/types/ChannelOverride.ts | 7 + src/api/resources/event/types/EmailMessage.ts | 9 + .../resources/event/types/EmailOverride.ts | 13 + .../resources/event/types/EmailRecipient.ts | 8 + .../event/types/EventNotFoundErrorBody.ts | 8 + .../resources/event/types/EventOverride.ts | 18 ++ .../resources/event/types/InAppOverride.ts | 2 +- src/api/resources/event/types/Param.ts | 8 + .../resources/event/types/ProviderOverride.ts | 13 + .../resources/event/types/PushOverride.ts | 2 +- .../event/types/SendEventResponse.ts | 10 + src/api/resources/event/types/SlackMessage.ts | 8 + .../resources/event/types/SlackOverride.ts | 4 +- src/api/resources/event/types/SmsMessage.ts | 7 + .../resources/event/types/SmsOverride.ts | 6 +- .../resources/event/types/TelegramOverride.ts | 2 +- src/api/resources/event/types/User.ts | 36 +++ .../resources/event/types/VoiceOverride.ts | 2 +- .../resources/event/types/WebhookOverride.ts | 2 +- .../resources/event/types/WhatsappOverride.ts | 4 +- .../resources}/event/types/index.ts | 3 +- src/{ => api}/resources/ids/index.ts | 0 src/api/resources/ids/types/AppId.ts | 5 + src/api/resources/ids/types/DeviceId.ts | 5 + src/api/resources/ids/types/RequestId.ts | 5 + src/api/resources/ids/types/UserId.ts | 5 + src/{ => api}/resources/ids/types/index.ts | 0 src/api/resources/index.ts | 11 + src/api/resources/user/client/Client.ts | 102 +++++++ src/api/resources/user/client/index.ts | 1 + .../user/client/requests/CreateUserRequest.ts | 12 + .../resources/user/client/requests/index.ts | 1 + .../event => api/resources/user}/index.ts | 0 src/api/resources/user/types/Channel.ts | 17 ++ .../resources/user/types/ChannelPreference.ts | 7 + .../user/types/ChannelPreferences.ts | 15 ++ src/api/resources/user/types/RavenUser.ts | 27 ++ src/api/resources/user/types/SlackProfile.ts | 9 + .../resources/user/types/TelegramProfile.ts | 7 + .../resources/user/types/UserPreferences.ts | 10 + src/{ => api}/resources/user/types/index.ts | 1 - src/core/fetcher/APIResponse.ts | 8 +- src/core/fetcher/Fetcher.ts | 193 +++++++------- src/core/fetcher/Supplier.ts | 14 +- src/core/index.ts | 2 +- src/core/schemas/Schema.ts | 20 +- src/core/schemas/builders/date/date.ts | 16 +- src/core/schemas/builders/enum/enum.ts | 2 +- .../identity/createIdentitySchemaCreator.ts | 2 +- .../schemas/builders/identity/identity.ts | 16 +- src/core/schemas/builders/lazy/index.ts | 2 +- src/core/schemas/builders/lazy/lazy.ts | 41 +-- src/core/schemas/builders/lazy/lazyObject.ts | 30 +-- src/core/schemas/builders/list/list.ts | 16 +- .../builders/literals/stringLiteral.ts | 2 +- .../object-like/getObjectLikeUtils.ts | 63 ++++- .../schemas/builders/object-like/index.ts | 3 +- .../schemas/builders/object-like/types.ts | 12 +- .../builders/object-like/withProperties.ts | 47 ---- src/core/schemas/builders/object/index.ts | 24 +- src/core/schemas/builders/object/object.ts | 224 +++++++++------- src/core/schemas/builders/object/property.ts | 24 +- src/core/schemas/builders/object/types.ts | 71 ++--- src/core/schemas/builders/record/record.ts | 48 ++-- .../builders/schema-utils/getSchemaUtils.ts | 62 ++--- .../schemas/builders/schema-utils/types.ts | 2 +- src/core/schemas/builders/set/set.ts | 16 +- .../schemas/builders/union/discriminant.ts | 16 +- src/core/schemas/builders/union/index.ts | 10 +- src/core/schemas/builders/union/types.ts | 22 +- src/core/schemas/builders/union/union.ts | 106 ++++---- .../addQuestionMarksToNullableProperties.ts | 6 +- src/core/schemas/utils/entries.ts | 2 +- src/core/schemas/utils/filterObject.ts | 10 + src/core/schemas/utils/keys.ts | 2 +- src/core/schemas/utils/partition.ts | 12 + src/environments.ts | 8 +- src/errors/RavenApiError.ts | 20 ++ src/errors/RavenApiTimeoutError.ts | 10 + src/errors/index.ts | 2 + src/index.ts | 4 +- src/resources/device/client/Client.ts | 136 ---------- src/resources/device/client/add.ts | 32 --- src/resources/device/client/delete.ts | 33 --- src/resources/device/client/getDevice.ts | 33 --- src/resources/device/client/index.ts | 4 - src/resources/device/client/update.ts | 34 --- src/resources/device/types/Device.ts | 23 -- src/resources/device/types/Platform.ts | 58 ---- src/resources/event/client/Client.ts | 79 ------ src/resources/event/client/index.ts | 2 - src/resources/event/client/send.ts | 39 --- src/resources/event/client/sendBulk.ts | 39 --- src/resources/event/types/Attachment.ts | 9 - src/resources/event/types/BatchEvent.ts | 19 -- .../event/types/BulkSendEventRequest.ts | 11 - src/resources/event/types/ChannelOverride.ts | 7 - src/resources/event/types/EmailMessage.ts | 9 - src/resources/event/types/EmailOverride.ts | 13 - src/resources/event/types/EmailRecipient.ts | 8 - src/resources/event/types/EventOverride.ts | 18 -- src/resources/event/types/Param.ts | 8 - src/resources/event/types/ProviderOverride.ts | 13 - src/resources/event/types/SendEventRequest.ts | 27 -- .../event/types/SendEventResponse.ts | 10 - src/resources/event/types/SlackMessage.ts | 8 - src/resources/event/types/SmsMessage.ts | 7 - src/resources/event/types/User.ts | 33 --- src/resources/ids/types/AppId.ts | 11 - src/resources/ids/types/DeviceId.ts | 11 - src/resources/ids/types/RequestId.ts | 11 - src/resources/ids/types/UserId.ts | 11 - src/resources/user/client/Client.ts | 78 ------ src/resources/user/client/createOrUpdate.ts | 29 -- src/resources/user/client/get.ts | 31 --- src/resources/user/client/index.ts | 2 - src/resources/user/types/Channel.ts | 112 -------- src/resources/user/types/ChannelPreference.ts | 7 - .../user/types/ChannelPreferences.ts | 15 -- src/resources/user/types/CreateUserRequest.ts | 18 -- src/resources/user/types/RavenUser.ts | 27 -- src/resources/user/types/SlackProfile.ts | 9 - src/resources/user/types/TelegramProfile.ts | 7 - src/resources/user/types/UserPreferences.ts | 10 - src/serialization/device/types/Device.ts | 44 --- src/serialization/device/types/Platform.ts | 17 -- src/serialization/event/types/Attachment.ts | 20 -- src/serialization/event/types/BatchEvent.ts | 21 -- .../event/types/BulkSendEventRequest.ts | 20 -- .../event/types/ChannelOverride.ts | 17 -- src/serialization/event/types/EmailMessage.ts | 20 -- .../event/types/EmailOverride.ts | 27 -- .../event/types/EmailRecipient.ts | 19 -- .../event/types/EventOverride.ts | 41 --- .../event/types/InAppOverride.ts | 15 -- src/serialization/event/types/Param.ts | 18 -- .../event/types/ProviderOverride.ts | 35 --- src/serialization/event/types/PushOverride.ts | 15 -- .../event/types/SendEventRequest.ts | 26 -- .../event/types/SendEventResponse.ts | 20 -- src/serialization/event/types/SlackMessage.ts | 18 -- .../event/types/SlackOverride.ts | 19 -- src/serialization/event/types/SmsMessage.ts | 16 -- src/serialization/event/types/SmsOverride.ts | 21 -- .../event/types/TelegramOverride.ts | 15 -- src/serialization/event/types/User.ts | 42 --- .../event/types/VoiceOverride.ts | 15 -- .../event/types/WebhookOverride.ts | 15 -- .../event/types/WhatsappOverride.ts | 19 -- src/serialization/ids/index.ts | 1 - src/serialization/ids/types/AppId.ts | 12 - src/serialization/ids/types/DeviceId.ts | 12 - src/serialization/ids/types/RequestId.ts | 12 - src/serialization/ids/types/UserId.ts | 12 - src/serialization/index.ts | 9 +- .../{ => resources}/device/index.ts | 0 .../resources/device/types/Device.ts | 48 ++++ .../resources/device/types/Platform.ts | 14 + .../{ => resources}/device/types/index.ts | 0 .../resources/event/client/index.ts | 1 + .../client/requests/BulkSendEventRequest.ts | 22 ++ .../event/client/requests/SendEventRequest.ts | 28 ++ .../resources/event/client/requests/index.ts | 2 + .../resources/event}/index.ts | 0 .../resources/event/types/Attachment.ts | 22 ++ .../resources/event/types/BatchEvent.ts | 22 ++ .../resources/event/types/ChannelOverride.ts | 20 ++ .../resources/event/types/EmailMessage.ts | 22 ++ .../resources/event/types/EmailOverride.ts | 34 +++ .../resources/event/types/EmailRecipient.ts | 20 ++ .../event/types/EventNotFoundErrorBody.ts | 22 ++ .../resources/event/types/EventOverride.ts | 42 +++ .../resources/event/types/InAppOverride.ts | 16 ++ .../resources/event/types/Param.ts | 19 ++ .../resources/event/types/ProviderOverride.ts | 37 +++ .../resources/event/types/PushOverride.ts | 16 ++ .../event/types/SendEventResponse.ts | 22 ++ .../resources/event/types/SlackMessage.ts | 20 ++ .../resources/event/types/SlackOverride.ts | 20 ++ .../resources/event/types/SmsMessage.ts | 18 ++ .../resources/event/types/SmsOverride.ts | 22 ++ .../resources/event/types/TelegramOverride.ts | 18 ++ .../resources/event/types/User.ts | 51 ++++ .../resources/event/types/VoiceOverride.ts | 16 ++ .../resources/event/types/WebhookOverride.ts | 18 ++ .../resources/event/types/WhatsappOverride.ts | 22 ++ .../resources/event/types/index.ts | 3 +- .../{event => resources/ids}/index.ts | 0 .../resources/ids/types/AppId.ts | 13 + .../resources/ids/types/DeviceId.ts | 14 + .../resources/ids/types/RequestId.ts | 14 + .../resources/ids/types/UserId.ts | 13 + .../{ => resources}/ids/types/index.ts | 0 src/{ => serialization}/resources/index.ts | 2 + .../resources/user/client/index.ts | 1 + .../user/client/requests/CreateUserRequest.ts | 29 ++ .../resources/user/client/requests/index.ts | 1 + src/serialization/resources/user/index.ts | 2 + .../resources/user/types/Channel.ts | 23 ++ .../resources/user/types/ChannelPreference.ts | 20 ++ .../user/types/ChannelPreferences.ts | 32 +++ .../resources/user/types/RavenUser.ts | 57 ++++ .../resources/user/types/SlackProfile.ts | 22 ++ .../resources/user/types/TelegramProfile.ts | 20 ++ .../resources/user/types/UserPreferences.ts | 28 ++ .../{ => resources}/user/types/index.ts | 1 - src/serialization/user/index.ts | 1 - src/serialization/user/types/Channel.ts | 17 -- .../user/types/ChannelPreference.ts | 17 -- .../user/types/ChannelPreferences.ts | 30 --- .../user/types/CreateUserRequest.ts | 27 -- src/serialization/user/types/RavenUser.ts | 47 ---- src/serialization/user/types/SlackProfile.ts | 20 -- .../user/types/TelegramProfile.ts | 17 -- .../user/types/UserPreferences.ts | 26 -- tsconfig.json | 7 +- yarn.lock | 252 +++++++++++++++++- 246 files changed, 2788 insertions(+), 2596 deletions(-) delete mode 100644 .prettierignore create mode 100644 .prettierrc.yml create mode 100644 build.js create mode 100644 src/api/index.ts create mode 100644 src/api/resources/device/client/Client.ts create mode 100644 src/api/resources/device/client/index.ts rename src/{ => api}/resources/device/index.ts (100%) create mode 100644 src/api/resources/device/types/Device.ts create mode 100644 src/api/resources/device/types/Platform.ts rename src/{ => api}/resources/device/types/index.ts (100%) create mode 100644 src/api/resources/event/client/Client.ts create mode 100644 src/api/resources/event/client/index.ts create mode 100644 src/api/resources/event/client/requests/BulkSendEventRequest.ts create mode 100644 src/api/resources/event/client/requests/SendEventRequest.ts create mode 100644 src/api/resources/event/client/requests/index.ts create mode 100644 src/api/resources/event/errors/EventNotFoundError.ts create mode 100644 src/api/resources/event/errors/index.ts create mode 100644 src/api/resources/event/index.ts create mode 100644 src/api/resources/event/types/Attachment.ts create mode 100644 src/api/resources/event/types/BatchEvent.ts create mode 100644 src/api/resources/event/types/ChannelOverride.ts create mode 100644 src/api/resources/event/types/EmailMessage.ts create mode 100644 src/api/resources/event/types/EmailOverride.ts create mode 100644 src/api/resources/event/types/EmailRecipient.ts create mode 100644 src/api/resources/event/types/EventNotFoundErrorBody.ts create mode 100644 src/api/resources/event/types/EventOverride.ts rename src/{ => api}/resources/event/types/InAppOverride.ts (65%) create mode 100644 src/api/resources/event/types/Param.ts create mode 100644 src/api/resources/event/types/ProviderOverride.ts rename src/{ => api}/resources/event/types/PushOverride.ts (64%) create mode 100644 src/api/resources/event/types/SendEventResponse.ts create mode 100644 src/api/resources/event/types/SlackMessage.ts rename src/{ => api}/resources/event/types/SlackOverride.ts (54%) create mode 100644 src/api/resources/event/types/SmsMessage.ts rename src/{ => api}/resources/event/types/SmsOverride.ts (50%) rename src/{ => api}/resources/event/types/TelegramOverride.ts (65%) create mode 100644 src/api/resources/event/types/User.ts rename src/{ => api}/resources/event/types/VoiceOverride.ts (65%) rename src/{ => api}/resources/event/types/WebhookOverride.ts (65%) rename src/{ => api}/resources/event/types/WhatsappOverride.ts (55%) rename src/{serialization => api/resources}/event/types/index.ts (89%) rename src/{ => api}/resources/ids/index.ts (100%) create mode 100644 src/api/resources/ids/types/AppId.ts create mode 100644 src/api/resources/ids/types/DeviceId.ts create mode 100644 src/api/resources/ids/types/RequestId.ts create mode 100644 src/api/resources/ids/types/UserId.ts rename src/{ => api}/resources/ids/types/index.ts (100%) create mode 100644 src/api/resources/index.ts create mode 100644 src/api/resources/user/client/Client.ts create mode 100644 src/api/resources/user/client/index.ts create mode 100644 src/api/resources/user/client/requests/CreateUserRequest.ts create mode 100644 src/api/resources/user/client/requests/index.ts rename src/{resources/event => api/resources/user}/index.ts (100%) create mode 100644 src/api/resources/user/types/Channel.ts create mode 100644 src/api/resources/user/types/ChannelPreference.ts create mode 100644 src/api/resources/user/types/ChannelPreferences.ts create mode 100644 src/api/resources/user/types/RavenUser.ts create mode 100644 src/api/resources/user/types/SlackProfile.ts create mode 100644 src/api/resources/user/types/TelegramProfile.ts create mode 100644 src/api/resources/user/types/UserPreferences.ts rename src/{ => api}/resources/user/types/index.ts (86%) delete mode 100644 src/core/schemas/builders/object-like/withProperties.ts create mode 100644 src/core/schemas/utils/filterObject.ts create mode 100644 src/core/schemas/utils/partition.ts create mode 100644 src/errors/RavenApiError.ts create mode 100644 src/errors/RavenApiTimeoutError.ts create mode 100644 src/errors/index.ts delete mode 100644 src/resources/device/client/Client.ts delete mode 100644 src/resources/device/client/add.ts delete mode 100644 src/resources/device/client/delete.ts delete mode 100644 src/resources/device/client/getDevice.ts delete mode 100644 src/resources/device/client/index.ts delete mode 100644 src/resources/device/client/update.ts delete mode 100644 src/resources/device/types/Device.ts delete mode 100644 src/resources/device/types/Platform.ts delete mode 100644 src/resources/event/client/Client.ts delete mode 100644 src/resources/event/client/index.ts delete mode 100644 src/resources/event/client/send.ts delete mode 100644 src/resources/event/client/sendBulk.ts delete mode 100644 src/resources/event/types/Attachment.ts delete mode 100644 src/resources/event/types/BatchEvent.ts delete mode 100644 src/resources/event/types/BulkSendEventRequest.ts delete mode 100644 src/resources/event/types/ChannelOverride.ts delete mode 100644 src/resources/event/types/EmailMessage.ts delete mode 100644 src/resources/event/types/EmailOverride.ts delete mode 100644 src/resources/event/types/EmailRecipient.ts delete mode 100644 src/resources/event/types/EventOverride.ts delete mode 100644 src/resources/event/types/Param.ts delete mode 100644 src/resources/event/types/ProviderOverride.ts delete mode 100644 src/resources/event/types/SendEventRequest.ts delete mode 100644 src/resources/event/types/SendEventResponse.ts delete mode 100644 src/resources/event/types/SlackMessage.ts delete mode 100644 src/resources/event/types/SmsMessage.ts delete mode 100644 src/resources/event/types/User.ts delete mode 100644 src/resources/ids/types/AppId.ts delete mode 100644 src/resources/ids/types/DeviceId.ts delete mode 100644 src/resources/ids/types/RequestId.ts delete mode 100644 src/resources/ids/types/UserId.ts delete mode 100644 src/resources/user/client/Client.ts delete mode 100644 src/resources/user/client/createOrUpdate.ts delete mode 100644 src/resources/user/client/get.ts delete mode 100644 src/resources/user/client/index.ts delete mode 100644 src/resources/user/types/Channel.ts delete mode 100644 src/resources/user/types/ChannelPreference.ts delete mode 100644 src/resources/user/types/ChannelPreferences.ts delete mode 100644 src/resources/user/types/CreateUserRequest.ts delete mode 100644 src/resources/user/types/RavenUser.ts delete mode 100644 src/resources/user/types/SlackProfile.ts delete mode 100644 src/resources/user/types/TelegramProfile.ts delete mode 100644 src/resources/user/types/UserPreferences.ts delete mode 100644 src/serialization/device/types/Device.ts delete mode 100644 src/serialization/device/types/Platform.ts delete mode 100644 src/serialization/event/types/Attachment.ts delete mode 100644 src/serialization/event/types/BatchEvent.ts delete mode 100644 src/serialization/event/types/BulkSendEventRequest.ts delete mode 100644 src/serialization/event/types/ChannelOverride.ts delete mode 100644 src/serialization/event/types/EmailMessage.ts delete mode 100644 src/serialization/event/types/EmailOverride.ts delete mode 100644 src/serialization/event/types/EmailRecipient.ts delete mode 100644 src/serialization/event/types/EventOverride.ts delete mode 100644 src/serialization/event/types/InAppOverride.ts delete mode 100644 src/serialization/event/types/Param.ts delete mode 100644 src/serialization/event/types/ProviderOverride.ts delete mode 100644 src/serialization/event/types/PushOverride.ts delete mode 100644 src/serialization/event/types/SendEventRequest.ts delete mode 100644 src/serialization/event/types/SendEventResponse.ts delete mode 100644 src/serialization/event/types/SlackMessage.ts delete mode 100644 src/serialization/event/types/SlackOverride.ts delete mode 100644 src/serialization/event/types/SmsMessage.ts delete mode 100644 src/serialization/event/types/SmsOverride.ts delete mode 100644 src/serialization/event/types/TelegramOverride.ts delete mode 100644 src/serialization/event/types/User.ts delete mode 100644 src/serialization/event/types/VoiceOverride.ts delete mode 100644 src/serialization/event/types/WebhookOverride.ts delete mode 100644 src/serialization/event/types/WhatsappOverride.ts delete mode 100644 src/serialization/ids/index.ts delete mode 100644 src/serialization/ids/types/AppId.ts delete mode 100644 src/serialization/ids/types/DeviceId.ts delete mode 100644 src/serialization/ids/types/RequestId.ts delete mode 100644 src/serialization/ids/types/UserId.ts rename src/serialization/{ => resources}/device/index.ts (100%) create mode 100644 src/serialization/resources/device/types/Device.ts create mode 100644 src/serialization/resources/device/types/Platform.ts rename src/serialization/{ => resources}/device/types/index.ts (100%) create mode 100644 src/serialization/resources/event/client/index.ts create mode 100644 src/serialization/resources/event/client/requests/BulkSendEventRequest.ts create mode 100644 src/serialization/resources/event/client/requests/SendEventRequest.ts create mode 100644 src/serialization/resources/event/client/requests/index.ts rename src/{resources/user => serialization/resources/event}/index.ts (100%) create mode 100644 src/serialization/resources/event/types/Attachment.ts create mode 100644 src/serialization/resources/event/types/BatchEvent.ts create mode 100644 src/serialization/resources/event/types/ChannelOverride.ts create mode 100644 src/serialization/resources/event/types/EmailMessage.ts create mode 100644 src/serialization/resources/event/types/EmailOverride.ts create mode 100644 src/serialization/resources/event/types/EmailRecipient.ts create mode 100644 src/serialization/resources/event/types/EventNotFoundErrorBody.ts create mode 100644 src/serialization/resources/event/types/EventOverride.ts create mode 100644 src/serialization/resources/event/types/InAppOverride.ts create mode 100644 src/serialization/resources/event/types/Param.ts create mode 100644 src/serialization/resources/event/types/ProviderOverride.ts create mode 100644 src/serialization/resources/event/types/PushOverride.ts create mode 100644 src/serialization/resources/event/types/SendEventResponse.ts create mode 100644 src/serialization/resources/event/types/SlackMessage.ts create mode 100644 src/serialization/resources/event/types/SlackOverride.ts create mode 100644 src/serialization/resources/event/types/SmsMessage.ts create mode 100644 src/serialization/resources/event/types/SmsOverride.ts create mode 100644 src/serialization/resources/event/types/TelegramOverride.ts create mode 100644 src/serialization/resources/event/types/User.ts create mode 100644 src/serialization/resources/event/types/VoiceOverride.ts create mode 100644 src/serialization/resources/event/types/WebhookOverride.ts create mode 100644 src/serialization/resources/event/types/WhatsappOverride.ts rename src/{ => serialization}/resources/event/types/index.ts (89%) rename src/serialization/{event => resources/ids}/index.ts (100%) create mode 100644 src/serialization/resources/ids/types/AppId.ts create mode 100644 src/serialization/resources/ids/types/DeviceId.ts create mode 100644 src/serialization/resources/ids/types/RequestId.ts create mode 100644 src/serialization/resources/ids/types/UserId.ts rename src/serialization/{ => resources}/ids/types/index.ts (100%) rename src/{ => serialization}/resources/index.ts (75%) create mode 100644 src/serialization/resources/user/client/index.ts create mode 100644 src/serialization/resources/user/client/requests/CreateUserRequest.ts create mode 100644 src/serialization/resources/user/client/requests/index.ts create mode 100644 src/serialization/resources/user/index.ts create mode 100644 src/serialization/resources/user/types/Channel.ts create mode 100644 src/serialization/resources/user/types/ChannelPreference.ts create mode 100644 src/serialization/resources/user/types/ChannelPreferences.ts create mode 100644 src/serialization/resources/user/types/RavenUser.ts create mode 100644 src/serialization/resources/user/types/SlackProfile.ts create mode 100644 src/serialization/resources/user/types/TelegramProfile.ts create mode 100644 src/serialization/resources/user/types/UserPreferences.ts rename src/serialization/{ => resources}/user/types/index.ts (86%) delete mode 100644 src/serialization/user/index.ts delete mode 100644 src/serialization/user/types/Channel.ts delete mode 100644 src/serialization/user/types/ChannelPreference.ts delete mode 100644 src/serialization/user/types/ChannelPreferences.ts delete mode 100644 src/serialization/user/types/CreateUserRequest.ts delete mode 100644 src/serialization/user/types/RavenUser.ts delete mode 100644 src/serialization/user/types/SlackProfile.ts delete mode 100644 src/serialization/user/types/TelegramProfile.ts delete mode 100644 src/serialization/user/types/UserPreferences.ts diff --git a/.gitignore b/.gitignore index c3cc207..9f6a7f8 100644 --- a/.gitignore +++ b/.gitignore @@ -1,8 +1,7 @@ node_modules .DS_Store *.d.ts -*.js -*.js.map +dist/ # yarn berry .pnp.* @@ -11,11 +10,4 @@ node_modules !.yarn/plugins !.yarn/releases !.yarn/sdks -!.yarn/versions - -# these are needed to override '*.js' above -!.yarn/patches/** -!.yarn/plugins/** -!.yarn/releases/** -!.yarn/sdks/** -!.yarn/versions/** \ No newline at end of file +!.yarn/versions \ No newline at end of file diff --git a/.prettierignore b/.prettierignore deleted file mode 100644 index 53a9b86..0000000 --- a/.prettierignore +++ /dev/null @@ -1,6 +0,0 @@ -.yarn -node_modules -.npmignore -.pnp.cjs -*.js -*.d.ts \ No newline at end of file diff --git a/.prettierrc.yml b/.prettierrc.yml new file mode 100644 index 0000000..0c06786 --- /dev/null +++ b/.prettierrc.yml @@ -0,0 +1,2 @@ +tabWidth: 4 +printWidth: 120 diff --git a/.yarn/sdks/prettier/index.js b/.yarn/sdks/prettier/index.js index 81f9bec..f6882d8 100755 --- a/.yarn/sdks/prettier/index.js +++ b/.yarn/sdks/prettier/index.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); +const {createRequire, createRequireFromPath} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = createRequire(absPnpApiPath); +const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/bin/tsc b/.yarn/sdks/typescript/bin/tsc index 454b950..5608e57 100755 --- a/.yarn/sdks/typescript/bin/tsc +++ b/.yarn/sdks/typescript/bin/tsc @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); +const {createRequire, createRequireFromPath} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = createRequire(absPnpApiPath); +const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/bin/tsserver b/.yarn/sdks/typescript/bin/tsserver index d7a6056..cd7d557 100755 --- a/.yarn/sdks/typescript/bin/tsserver +++ b/.yarn/sdks/typescript/bin/tsserver @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); +const {createRequire, createRequireFromPath} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = createRequire(absPnpApiPath); +const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/lib/tsc.js b/.yarn/sdks/typescript/lib/tsc.js index 2f62fc9..16042d0 100644 --- a/.yarn/sdks/typescript/lib/tsc.js +++ b/.yarn/sdks/typescript/lib/tsc.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); +const {createRequire, createRequireFromPath} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = createRequire(absPnpApiPath); +const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/.yarn/sdks/typescript/lib/tsserver.js b/.yarn/sdks/typescript/lib/tsserver.js index 0fb2ac1..a82ef79 100644 --- a/.yarn/sdks/typescript/lib/tsserver.js +++ b/.yarn/sdks/typescript/lib/tsserver.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); +const {createRequire, createRequireFromPath} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = createRequire(absPnpApiPath); +const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const moduleWrapper = tsserver => { if (!process.versions.pnp) { @@ -61,30 +61,14 @@ const moduleWrapper = tsserver => { // // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910 // - // 2021-10-08: VSCode changed the format in 1.61. + // Update Oct 8 2021: VSCode changed their format in 1.61. // Before | ^zip:/c:/foo/bar.zip/package.json // After | ^/zip//c:/foo/bar.zip/package.json // - // 2022-04-06: VSCode changed the format in 1.66. - // Before | ^/zip//c:/foo/bar.zip/package.json - // After | ^/zip/c:/foo/bar.zip/package.json - // - // 2022-05-06: VSCode changed the format in 1.68 - // Before | ^/zip/c:/foo/bar.zip/package.json - // After | ^/zip//c:/foo/bar.zip/package.json - // case `vscode <1.61`: { str = `^zip:${str}`; } break; - case `vscode <1.66`: { - str = `^/zip/${str}`; - } break; - - case `vscode <1.68`: { - str = `^/zip${str}`; - } break; - case `vscode`: { str = `^/zip/${str}`; } break; @@ -135,7 +119,9 @@ const moduleWrapper = tsserver => { case `vscode`: default: { - return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`) + return process.platform === `win32` + ? str.replace(/^\^?(zip:|\/zip)\/+/, ``) + : str.replace(/^\^?(zip:|\/zip)\/+/, `/`); } break; } } @@ -174,21 +160,8 @@ const moduleWrapper = tsserver => { typeof parsedMessage.arguments.hostInfo === `string` ) { hostInfo = parsedMessage.arguments.hostInfo; - if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) { - const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match( - // The RegExp from https://semver.org/ but without the caret at the start - /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ - ) ?? []).map(Number) - - if (major === 1) { - if (minor < 61) { - hostInfo += ` <1.61`; - } else if (minor < 66) { - hostInfo += ` <1.66`; - } else if (minor < 68) { - hostInfo += ` <1.68`; - } - } + if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK && process.env.VSCODE_IPC_HOOK.match(/Code\/1\.([1-5][0-9]|60)\./)) { + hostInfo += ` <1.61`; } } diff --git a/.yarn/sdks/typescript/lib/tsserverlibrary.js b/.yarn/sdks/typescript/lib/tsserverlibrary.js index e7033a8..0d70146 100644 --- a/.yarn/sdks/typescript/lib/tsserverlibrary.js +++ b/.yarn/sdks/typescript/lib/tsserverlibrary.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); +const {createRequire, createRequireFromPath} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = createRequire(absPnpApiPath); +const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); const moduleWrapper = tsserver => { if (!process.versions.pnp) { @@ -61,30 +61,14 @@ const moduleWrapper = tsserver => { // // Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910 // - // 2021-10-08: VSCode changed the format in 1.61. + // Update Oct 8 2021: VSCode changed their format in 1.61. // Before | ^zip:/c:/foo/bar.zip/package.json // After | ^/zip//c:/foo/bar.zip/package.json // - // 2022-04-06: VSCode changed the format in 1.66. - // Before | ^/zip//c:/foo/bar.zip/package.json - // After | ^/zip/c:/foo/bar.zip/package.json - // - // 2022-05-06: VSCode changed the format in 1.68 - // Before | ^/zip/c:/foo/bar.zip/package.json - // After | ^/zip//c:/foo/bar.zip/package.json - // case `vscode <1.61`: { str = `^zip:${str}`; } break; - case `vscode <1.66`: { - str = `^/zip/${str}`; - } break; - - case `vscode <1.68`: { - str = `^/zip${str}`; - } break; - case `vscode`: { str = `^/zip/${str}`; } break; @@ -135,7 +119,9 @@ const moduleWrapper = tsserver => { case `vscode`: default: { - return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`) + return process.platform === `win32` + ? str.replace(/^\^?(zip:|\/zip)\/+/, ``) + : str.replace(/^\^?(zip:|\/zip)\/+/, `/`); } break; } } @@ -174,21 +160,8 @@ const moduleWrapper = tsserver => { typeof parsedMessage.arguments.hostInfo === `string` ) { hostInfo = parsedMessage.arguments.hostInfo; - if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) { - const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match( - // The RegExp from https://semver.org/ but without the caret at the start - /(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/ - ) ?? []).map(Number) - - if (major === 1) { - if (minor < 61) { - hostInfo += ` <1.61`; - } else if (minor < 66) { - hostInfo += ` <1.66`; - } else if (minor < 68) { - hostInfo += ` <1.68`; - } - } + if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK && process.env.VSCODE_IPC_HOOK.match(/Code\/1\.([1-5][0-9]|60)\./)) { + hostInfo += ` <1.61`; } } diff --git a/.yarn/sdks/typescript/lib/typescript.js b/.yarn/sdks/typescript/lib/typescript.js index e14fa87..cbdbf15 100644 --- a/.yarn/sdks/typescript/lib/typescript.js +++ b/.yarn/sdks/typescript/lib/typescript.js @@ -1,13 +1,13 @@ #!/usr/bin/env node const {existsSync} = require(`fs`); -const {createRequire} = require(`module`); +const {createRequire, createRequireFromPath} = require(`module`); const {resolve} = require(`path`); const relPnpApiPath = "../../../../.pnp.cjs"; const absPnpApiPath = resolve(__dirname, relPnpApiPath); -const absRequire = createRequire(absPnpApiPath); +const absRequire = (createRequire || createRequireFromPath)(absPnpApiPath); if (existsSync(absPnpApiPath)) { if (!process.versions.pnp) { diff --git a/build.js b/build.js new file mode 100644 index 0000000..e67f6ac --- /dev/null +++ b/build.js @@ -0,0 +1,61 @@ +const { build } = require("esbuild"); + +void main(); + +async function main() { + await bundle({ + platform: "node", + target: "node14", + format: "cjs", + outdir: "node", + }); + await bundle({ + platform: "browser", + format: "esm", + outdir: "browser/esm", + }); + await bundle({ + platform: "browser", + format: "cjs", + outdir: "browser/cjs", + }); +} + +async function bundle({ platform, target, format, outdir }) { + await runEsbuild({ + platform, + target, + format, + entryPoint: "./src/index.ts", + outfile: `./dist/${outdir}/index.js`, + }); + await runEsbuild({ + platform, + target, + format, + entryPoint: "./src/core/index.ts", + outfile: `./dist/${outdir}/core.js`, + }); + await runEsbuild({ + platform, + target, + format, + entryPoint: "./src/serialization/index.ts", + outfile: `./dist/${outdir}/serialization.js`, + }); +} + +async function runEsbuild({ platform, target, format, entryPoint, outfile }) { + await build({ + platform, + target, + format, + entryPoints: [entryPoint], + outfile, + bundle: true, + alias: { + // matches up with tsconfig paths + "@ravenapp/raven": "./src", + } + }).catch(() => process.exit(1)); +} diff --git a/package.json b/package.json index 882e2bc..d258c3d 100644 --- a/package.json +++ b/package.json @@ -1,19 +1,42 @@ { "name": "@ravenapp/raven", - "version": "0.0.14", + "version": "0.0.40", "repository": "https://github.com/ravenappdev/raven-node", "files": [ - "core", - "resources", - "serialization", - "client", - "*.{js,js.map,d.ts}" + "dist", + "types", + "core.d.ts", + "serialization.d.ts" ], - "main": "./index.js", - "types": "./index.d.ts", + "exports": { + ".": { + "node": "./dist/node/index.js", + "import": "./dist/browser/esm/index.js", + "require": "./dist/browser/cjs/index.js", + "default": "./dist/browser/cjs/index.js", + "types": "./types/index.d.ts" + }, + "./core": { + "node": "./dist/node/core.js", + "import": "./dist/browser/esm/core.js", + "require": "./dist/browser/cjs/core.js", + "default": "./dist/browser/cjs/core.js", + "types": "./types/core/index.d.ts" + }, + "./serialization": { + "node": "./dist/node/serialization.js", + "import": "./dist/browser/esm/serialization.js", + "require": "./dist/browser/cjs/serialization.js", + "default": "./dist/browser/cjs/serialization.js", + "types": "./types/serialization/index.d.ts" + } + }, + "types": "./types/index.d.ts", "scripts": { - "format": "prettier --write --print-width 120 'src/**/*.ts'", - "build": "tsc && tsc-alias" + "format": "prettier --write src/**/*.ts", + "compile": "tsc && tsc-alias", + "bundle": "node build.js", + "build": "yarn compile && yarn bundle" }, "dependencies": { "@types/url-join": "4.0.1", @@ -22,6 +45,7 @@ }, "devDependencies": { "@types/node": "17.0.33", + "esbuild": "0.16.15", "prettier": "2.7.1", "tsc-alias": "^1.7.1", "typescript": "4.6.4" diff --git a/src/api/index.ts b/src/api/index.ts new file mode 100644 index 0000000..3e5335f --- /dev/null +++ b/src/api/index.ts @@ -0,0 +1 @@ +export * from "./resources"; diff --git a/src/api/resources/device/client/Client.ts b/src/api/resources/device/client/Client.ts new file mode 100644 index 0000000..cf1a4f4 --- /dev/null +++ b/src/api/resources/device/client/Client.ts @@ -0,0 +1,199 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import { RavenApi } from "@ravenapp/raven"; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace Client { + interface Options { + environment?: environments.RavenApiEnvironment | string; + authorization?: core.Supplier; + } +} + +export class Client { + constructor(private readonly options: Client.Options) {} + + /** + * Add Device for a User. + * If a device_sid is specified, then devices will be merged if one is found. + * If no device_sid is specified, then a new device will be created. + * + */ + public async add( + appId: RavenApi.AppId, + userId: RavenApi.UserId, + request: RavenApi.Device + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + this.options.environment ?? environments.RavenApiEnvironment.Prod, + `/v1/apps/${appId}/users/${userId}/devices` + ), + method: "POST", + headers: { + Authorization: await core.Supplier.get(this.options.authorization), + }, + body: await serializers.Device.json(request), + }); + if (_response.ok) { + return await serializers.Device.parse(_response.body as serializers.Device.Raw); + } + + if (_response.error.reason === "status-code") { + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RavenApiTimeoutError(); + case "unknown": + throw new errors.RavenApiError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Update a Device for a User. + */ + public async update( + appId: RavenApi.AppId, + userId: RavenApi.UserId, + deviceId: RavenApi.DeviceId, + request: RavenApi.Device + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + this.options.environment ?? environments.RavenApiEnvironment.Prod, + `/v1/apps/${appId}/users/${userId}/devices/${deviceId}` + ), + method: "PUT", + headers: { + Authorization: await core.Supplier.get(this.options.authorization), + }, + body: await serializers.Device.json(request), + }); + if (_response.ok) { + return await serializers.Device.parse(_response.body as serializers.Device.Raw); + } + + if (_response.error.reason === "status-code") { + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RavenApiTimeoutError(); + case "unknown": + throw new errors.RavenApiError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Delete a Device for a User + */ + public async delete(appId: RavenApi.AppId, userId: RavenApi.UserId, deviceId: RavenApi.DeviceId): Promise { + const _response = await core.fetcher({ + url: urlJoin( + this.options.environment ?? environments.RavenApiEnvironment.Prod, + `/v1/apps/${appId}/users/${userId}/devices/${deviceId}` + ), + method: "DELETE", + headers: { + Authorization: await core.Supplier.get(this.options.authorization), + }, + }); + if (_response.ok) { + return; + } + + if (_response.error.reason === "status-code") { + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RavenApiTimeoutError(); + case "unknown": + throw new errors.RavenApiError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Get a Device for a User + */ + public async getDevice( + appId: RavenApi.AppId, + userId: RavenApi.UserId, + deviceId: RavenApi.DeviceId + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + this.options.environment ?? environments.RavenApiEnvironment.Prod, + `/v1/apps/${appId}/users/${userId}/devices/${deviceId}` + ), + method: "GET", + headers: { + Authorization: await core.Supplier.get(this.options.authorization), + }, + }); + if (_response.ok) { + return await serializers.Device.parse(_response.body as serializers.Device.Raw); + } + + if (_response.error.reason === "status-code") { + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RavenApiTimeoutError(); + case "unknown": + throw new errors.RavenApiError({ + message: _response.error.errorMessage, + }); + } + } +} diff --git a/src/api/resources/device/client/index.ts b/src/api/resources/device/client/index.ts new file mode 100644 index 0000000..cb0ff5c --- /dev/null +++ b/src/api/resources/device/client/index.ts @@ -0,0 +1 @@ +export {}; diff --git a/src/resources/device/index.ts b/src/api/resources/device/index.ts similarity index 100% rename from src/resources/device/index.ts rename to src/api/resources/device/index.ts diff --git a/src/api/resources/device/types/Device.ts b/src/api/resources/device/types/Device.ts new file mode 100644 index 0000000..e0dc4d1 --- /dev/null +++ b/src/api/resources/device/types/Device.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface Device { + id?: string; + platform?: RavenApi.Platform; + onesignalPlayerId?: string; + xiaomiToken?: string; + oppoToken?: string; + vivoToken?: string; + huaweiToken?: string; + /** firebase device token */ + fcmToken?: string; + /** user id affiliated with device */ + ravenId?: string; + deviceSid?: RavenApi.DeviceId; + notificationsDisabled?: boolean; + createdAt?: number; + updatedAt?: number; +} diff --git a/src/api/resources/device/types/Platform.ts b/src/api/resources/device/types/Platform.ts new file mode 100644 index 0000000..15de22a --- /dev/null +++ b/src/api/resources/device/types/Platform.ts @@ -0,0 +1,11 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type Platform = "android" | "web" | "ios"; + +export const Platform = { + Android: "android", + Web: "web", + Ios: "ios", +} as const; diff --git a/src/resources/device/types/index.ts b/src/api/resources/device/types/index.ts similarity index 100% rename from src/resources/device/types/index.ts rename to src/api/resources/device/types/index.ts diff --git a/src/api/resources/event/client/Client.ts b/src/api/resources/event/client/Client.ts new file mode 100644 index 0000000..dc24d6b --- /dev/null +++ b/src/api/resources/event/client/Client.ts @@ -0,0 +1,117 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import { RavenApi } from "@ravenapp/raven"; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace Client { + interface Options { + environment?: environments.RavenApiEnvironment | string; + authorization?: core.Supplier; + } +} + +export class Client { + constructor(private readonly options: Client.Options) {} + + /** + * This endpoint allows you to send messages + * @throws {RavenApi.EventNotFoundError} + */ + public async send(appId: RavenApi.AppId, request: RavenApi.SendEventRequest): Promise { + const { idempotencyKey, ..._body } = request; + const _response = await core.fetcher({ + url: urlJoin( + this.options.environment ?? environments.RavenApiEnvironment.Prod, + `/v1/apps/${appId}/events/send` + ), + method: "POST", + headers: { + "Idempotency-Key": idempotencyKey, + Authorization: await core.Supplier.get(this.options.authorization), + }, + body: await serializers.SendEventRequest.json(_body), + }); + if (_response.ok) { + return await serializers.SendEventResponse.parse(_response.body as serializers.SendEventResponse.Raw); + } + + if (_response.error.reason === "status-code") { + switch (_response.error.statusCode) { + case 404: + throw new RavenApi.EventNotFoundError( + await serializers.EventNotFoundErrorBody.parse( + _response.error.body as serializers.EventNotFoundErrorBody.Raw + ) + ); + default: + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RavenApiTimeoutError(); + case "unknown": + throw new errors.RavenApiError({ + message: _response.error.errorMessage, + }); + } + } + + public async sendBulk( + appId: RavenApi.AppId, + request: RavenApi.BulkSendEventRequest + ): Promise { + const { idempotencyKey, ..._body } = request; + const _response = await core.fetcher({ + url: urlJoin( + this.options.environment ?? environments.RavenApiEnvironment.Prod, + `/v1/apps/${appId}/events/bulk_send` + ), + method: "POST", + headers: { + "Idempotency-Key": idempotencyKey, + Authorization: await core.Supplier.get(this.options.authorization), + }, + body: await serializers.BulkSendEventRequest.json(_body), + }); + if (_response.ok) { + return await serializers.SendEventResponse.parse(_response.body as serializers.SendEventResponse.Raw); + } + + if (_response.error.reason === "status-code") { + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RavenApiTimeoutError(); + case "unknown": + throw new errors.RavenApiError({ + message: _response.error.errorMessage, + }); + } + } +} diff --git a/src/api/resources/event/client/index.ts b/src/api/resources/event/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/event/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/event/client/requests/BulkSendEventRequest.ts b/src/api/resources/event/client/requests/BulkSendEventRequest.ts new file mode 100644 index 0000000..f8bcf3b --- /dev/null +++ b/src/api/resources/event/client/requests/BulkSendEventRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface BulkSendEventRequest { + /** + * The API supports idempotency for safely retrying requests without accidentally performing the same operation twice. + * This is useful when an API call is disrupted in transit and you do not receive a response. + * For example, if a request to send event does not respond due to a network connection error, you can retry the request with the same idempotency key to guarantee that no more than one event is sent. + * An idempotency key is a unique value generated by the client which the server uses to recognize subsequent retries of the same request. + * How you create unique keys is up to you, but we suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. + * Idempotency keys can be up to 255 characters long. + * + */ + idempotencyKey?: string; + event: string; + batch: RavenApi.BatchEvent[]; +} diff --git a/src/api/resources/event/client/requests/SendEventRequest.ts b/src/api/resources/event/client/requests/SendEventRequest.ts new file mode 100644 index 0000000..e9a3fd9 --- /dev/null +++ b/src/api/resources/event/client/requests/SendEventRequest.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface SendEventRequest { + /** + * The API supports idempotency for safely retrying requests without accidentally performing the same operation twice. + * This is useful when an API call is disrupted in transit and you do not receive a response. + * For example, if a request to send event does not respond due to a network connection error, you can retry the request with the same idempotency key to guarantee that no more than one event is sent. + * An idempotency key is a unique value generated by the client which the server uses to recognize subsequent retries of the same request. + * How you create unique keys is up to you, but we suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. + * Idempotency keys can be up to 255 characters long. + * + */ + idempotencyKey?: string; + event: string; + data: Record; + user?: RavenApi.User; + scheduleAt?: number; + override?: RavenApi.EventOverride; +} diff --git a/src/api/resources/event/client/requests/index.ts b/src/api/resources/event/client/requests/index.ts new file mode 100644 index 0000000..6862919 --- /dev/null +++ b/src/api/resources/event/client/requests/index.ts @@ -0,0 +1,2 @@ +export { SendEventRequest } from "./SendEventRequest"; +export { BulkSendEventRequest } from "./BulkSendEventRequest"; diff --git a/src/api/resources/event/errors/EventNotFoundError.ts b/src/api/resources/event/errors/EventNotFoundError.ts new file mode 100644 index 0000000..5c8bc47 --- /dev/null +++ b/src/api/resources/event/errors/EventNotFoundError.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as errors from "../../../../errors"; +import { RavenApi } from "@ravenapp/raven"; + +export class EventNotFoundError extends errors.RavenApiError { + constructor(body: RavenApi.EventNotFoundErrorBody) { + super({ + message: "EventNotFoundError", + statusCode: 404, + body: body, + }); + Object.setPrototypeOf(this, EventNotFoundError.prototype); + } +} diff --git a/src/api/resources/event/errors/index.ts b/src/api/resources/event/errors/index.ts new file mode 100644 index 0000000..c2d5c1f --- /dev/null +++ b/src/api/resources/event/errors/index.ts @@ -0,0 +1 @@ +export * from "./EventNotFoundError"; diff --git a/src/api/resources/event/index.ts b/src/api/resources/event/index.ts new file mode 100644 index 0000000..9dc8224 --- /dev/null +++ b/src/api/resources/event/index.ts @@ -0,0 +1,3 @@ +export * from "./types"; +export * from "./errors"; +export * from "./client"; diff --git a/src/api/resources/event/types/Attachment.ts b/src/api/resources/event/types/Attachment.ts new file mode 100644 index 0000000..76b5c92 --- /dev/null +++ b/src/api/resources/event/types/Attachment.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface Attachment { + fileName: string; + content: string; + url: string; +} diff --git a/src/api/resources/event/types/BatchEvent.ts b/src/api/resources/event/types/BatchEvent.ts new file mode 100644 index 0000000..de4cba2 --- /dev/null +++ b/src/api/resources/event/types/BatchEvent.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface BatchEvent { + /** + * { + * "param1" : "", + * "param2" : "", + * "param3" : object/array" + * } + * + */ + data: Record; + user?: RavenApi.User; + override?: RavenApi.EventOverride; +} diff --git a/src/api/resources/event/types/ChannelOverride.ts b/src/api/resources/event/types/ChannelOverride.ts new file mode 100644 index 0000000..8d0cbf6 --- /dev/null +++ b/src/api/resources/event/types/ChannelOverride.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ChannelOverride { + scheduleAt: number; +} diff --git a/src/api/resources/event/types/EmailMessage.ts b/src/api/resources/event/types/EmailMessage.ts new file mode 100644 index 0000000..5fc2d0a --- /dev/null +++ b/src/api/resources/event/types/EmailMessage.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface EmailMessage { + text: string; + htmlBody: string; + subject: string; +} diff --git a/src/api/resources/event/types/EmailOverride.ts b/src/api/resources/event/types/EmailOverride.ts new file mode 100644 index 0000000..fcf3a4b --- /dev/null +++ b/src/api/resources/event/types/EmailOverride.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface EmailOverride extends RavenApi.ChannelOverride { + from: RavenApi.EmailRecipient; + cc: RavenApi.EmailRecipient[]; + bcc: RavenApi.EmailRecipient[]; + attachments: RavenApi.Attachment[]; + message: RavenApi.EmailMessage; +} diff --git a/src/api/resources/event/types/EmailRecipient.ts b/src/api/resources/event/types/EmailRecipient.ts new file mode 100644 index 0000000..329c8cb --- /dev/null +++ b/src/api/resources/event/types/EmailRecipient.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface EmailRecipient { + name: string; + address: string; +} diff --git a/src/api/resources/event/types/EventNotFoundErrorBody.ts b/src/api/resources/event/types/EventNotFoundErrorBody.ts new file mode 100644 index 0000000..934d309 --- /dev/null +++ b/src/api/resources/event/types/EventNotFoundErrorBody.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface EventNotFoundErrorBody { + success: boolean; + error: string; +} diff --git a/src/api/resources/event/types/EventOverride.ts b/src/api/resources/event/types/EventOverride.ts new file mode 100644 index 0000000..0a8d832 --- /dev/null +++ b/src/api/resources/event/types/EventOverride.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface EventOverride { + email?: RavenApi.EmailOverride; + sms?: RavenApi.SmsOverride; + whatsapp?: RavenApi.WhatsappOverride; + push?: RavenApi.PushOverride; + webhook?: RavenApi.WebhookOverride; + voice?: RavenApi.VoiceOverride; + slack?: RavenApi.SlackOverride; + inApp?: RavenApi.InAppOverride; + telegram?: RavenApi.TelegramOverride; + providers: Record; +} diff --git a/src/resources/event/types/InAppOverride.ts b/src/api/resources/event/types/InAppOverride.ts similarity index 65% rename from src/resources/event/types/InAppOverride.ts rename to src/api/resources/event/types/InAppOverride.ts index 1120af3..430e6a0 100644 --- a/src/resources/event/types/InAppOverride.ts +++ b/src/api/resources/event/types/InAppOverride.ts @@ -1,5 +1,5 @@ /** - * This file auto-generated by Fern from our API Definition. + * This file was auto-generated by Fern from our API Definition. */ import { RavenApi } from "@ravenapp/raven"; diff --git a/src/api/resources/event/types/Param.ts b/src/api/resources/event/types/Param.ts new file mode 100644 index 0000000..32e5b9c --- /dev/null +++ b/src/api/resources/event/types/Param.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface Param { + name: string; + value: string; +} diff --git a/src/api/resources/event/types/ProviderOverride.ts b/src/api/resources/event/types/ProviderOverride.ts new file mode 100644 index 0000000..e11209a --- /dev/null +++ b/src/api/resources/event/types/ProviderOverride.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface ProviderOverride { + payload: Record; + formParams: RavenApi.Param[]; + queryParams: RavenApi.Param[]; + pathParams: RavenApi.Param[]; + headers: RavenApi.Param[]; +} diff --git a/src/resources/event/types/PushOverride.ts b/src/api/resources/event/types/PushOverride.ts similarity index 64% rename from src/resources/event/types/PushOverride.ts rename to src/api/resources/event/types/PushOverride.ts index 513da81..36b2582 100644 --- a/src/resources/event/types/PushOverride.ts +++ b/src/api/resources/event/types/PushOverride.ts @@ -1,5 +1,5 @@ /** - * This file auto-generated by Fern from our API Definition. + * This file was auto-generated by Fern from our API Definition. */ import { RavenApi } from "@ravenapp/raven"; diff --git a/src/api/resources/event/types/SendEventResponse.ts b/src/api/resources/event/types/SendEventResponse.ts new file mode 100644 index 0000000..a52bba4 --- /dev/null +++ b/src/api/resources/event/types/SendEventResponse.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface SendEventResponse { + id: RavenApi.RequestId; + success: boolean; +} diff --git a/src/api/resources/event/types/SlackMessage.ts b/src/api/resources/event/types/SlackMessage.ts new file mode 100644 index 0000000..d249860 --- /dev/null +++ b/src/api/resources/event/types/SlackMessage.ts @@ -0,0 +1,8 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SlackMessage { + text: string; + blocks?: unknown; +} diff --git a/src/resources/event/types/SlackOverride.ts b/src/api/resources/event/types/SlackOverride.ts similarity index 54% rename from src/resources/event/types/SlackOverride.ts rename to src/api/resources/event/types/SlackOverride.ts index a6e7905..a1050fc 100644 --- a/src/resources/event/types/SlackOverride.ts +++ b/src/api/resources/event/types/SlackOverride.ts @@ -1,9 +1,9 @@ /** - * This file auto-generated by Fern from our API Definition. + * This file was auto-generated by Fern from our API Definition. */ import { RavenApi } from "@ravenapp/raven"; export interface SlackOverride extends RavenApi.ChannelOverride { - message: RavenApi.SlackMessage; + message: RavenApi.SlackMessage; } diff --git a/src/api/resources/event/types/SmsMessage.ts b/src/api/resources/event/types/SmsMessage.ts new file mode 100644 index 0000000..a5c43d3 --- /dev/null +++ b/src/api/resources/event/types/SmsMessage.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SmsMessage { + text: string; +} diff --git a/src/resources/event/types/SmsOverride.ts b/src/api/resources/event/types/SmsOverride.ts similarity index 50% rename from src/resources/event/types/SmsOverride.ts rename to src/api/resources/event/types/SmsOverride.ts index 9dd9a55..5a3ea7d 100644 --- a/src/resources/event/types/SmsOverride.ts +++ b/src/api/resources/event/types/SmsOverride.ts @@ -1,10 +1,10 @@ /** - * This file auto-generated by Fern from our API Definition. + * This file was auto-generated by Fern from our API Definition. */ import { RavenApi } from "@ravenapp/raven"; export interface SmsOverride extends RavenApi.ChannelOverride { - sender: string; - message: RavenApi.SmsMessage; + sender: string; + message: RavenApi.SmsMessage; } diff --git a/src/resources/event/types/TelegramOverride.ts b/src/api/resources/event/types/TelegramOverride.ts similarity index 65% rename from src/resources/event/types/TelegramOverride.ts rename to src/api/resources/event/types/TelegramOverride.ts index cb20990..74d23d4 100644 --- a/src/resources/event/types/TelegramOverride.ts +++ b/src/api/resources/event/types/TelegramOverride.ts @@ -1,5 +1,5 @@ /** - * This file auto-generated by Fern from our API Definition. + * This file was auto-generated by Fern from our API Definition. */ import { RavenApi } from "@ravenapp/raven"; diff --git a/src/api/resources/event/types/User.ts b/src/api/resources/event/types/User.ts new file mode 100644 index 0000000..c2d7028 --- /dev/null +++ b/src/api/resources/event/types/User.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface User { + /** + * userId to send the notifications to. + * This is your own user identifier which you have used to [create user on Raven](https://docs.raven.dev/api-reference/create-user) + * + */ + userId?: RavenApi.UserId; + email?: string; + /** mobile with country code prefix (e.g +91) */ + mobile?: string; + /** + * mobile with country code prefix (e.g. +91). + * if empty, `mobile` is considered for whatsapp + * + */ + whatsappMobile?: string; + /** + * [OneSignal external user IDs](https://documentation.onesignal.com/docs/external-user-ids) + * + */ + onesignalExternalId?: string; + onesignalPlayerIds?: string[]; + /** List of fcm tokens. eg. [""] */ + fcmTokens?: string[]; + iosTokens?: string[]; + slack?: RavenApi.SlackProfile; + telegram?: RavenApi.TelegramProfile; + fcmTopic?: string; + fcmDeviceGroup?: string; +} diff --git a/src/resources/event/types/VoiceOverride.ts b/src/api/resources/event/types/VoiceOverride.ts similarity index 65% rename from src/resources/event/types/VoiceOverride.ts rename to src/api/resources/event/types/VoiceOverride.ts index e9a579c..2802578 100644 --- a/src/resources/event/types/VoiceOverride.ts +++ b/src/api/resources/event/types/VoiceOverride.ts @@ -1,5 +1,5 @@ /** - * This file auto-generated by Fern from our API Definition. + * This file was auto-generated by Fern from our API Definition. */ import { RavenApi } from "@ravenapp/raven"; diff --git a/src/resources/event/types/WebhookOverride.ts b/src/api/resources/event/types/WebhookOverride.ts similarity index 65% rename from src/resources/event/types/WebhookOverride.ts rename to src/api/resources/event/types/WebhookOverride.ts index e44bcea..72c10ec 100644 --- a/src/resources/event/types/WebhookOverride.ts +++ b/src/api/resources/event/types/WebhookOverride.ts @@ -1,5 +1,5 @@ /** - * This file auto-generated by Fern from our API Definition. + * This file was auto-generated by Fern from our API Definition. */ import { RavenApi } from "@ravenapp/raven"; diff --git a/src/resources/event/types/WhatsappOverride.ts b/src/api/resources/event/types/WhatsappOverride.ts similarity index 55% rename from src/resources/event/types/WhatsappOverride.ts rename to src/api/resources/event/types/WhatsappOverride.ts index 82094fc..de920b8 100644 --- a/src/resources/event/types/WhatsappOverride.ts +++ b/src/api/resources/event/types/WhatsappOverride.ts @@ -1,9 +1,9 @@ /** - * This file auto-generated by Fern from our API Definition. + * This file was auto-generated by Fern from our API Definition. */ import { RavenApi } from "@ravenapp/raven"; export interface WhatsappOverride extends RavenApi.ChannelOverride { - message: RavenApi.SmsMessage; + message: RavenApi.SmsMessage; } diff --git a/src/serialization/event/types/index.ts b/src/api/resources/event/types/index.ts similarity index 89% rename from src/serialization/event/types/index.ts rename to src/api/resources/event/types/index.ts index 9e5ff12..de9e836 100644 --- a/src/serialization/event/types/index.ts +++ b/src/api/resources/event/types/index.ts @@ -1,4 +1,3 @@ -export * from "./SendEventRequest"; export * from "./User"; export * from "./EventOverride"; export * from "./ChannelOverride"; @@ -19,5 +18,5 @@ export * from "./TelegramOverride"; export * from "./Param"; export * from "./ProviderOverride"; export * from "./SendEventResponse"; -export * from "./BulkSendEventRequest"; export * from "./BatchEvent"; +export * from "./EventNotFoundErrorBody"; diff --git a/src/resources/ids/index.ts b/src/api/resources/ids/index.ts similarity index 100% rename from src/resources/ids/index.ts rename to src/api/resources/ids/index.ts diff --git a/src/api/resources/ids/types/AppId.ts b/src/api/resources/ids/types/AppId.ts new file mode 100644 index 0000000..c2f4209 --- /dev/null +++ b/src/api/resources/ids/types/AppId.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type AppId = string; diff --git a/src/api/resources/ids/types/DeviceId.ts b/src/api/resources/ids/types/DeviceId.ts new file mode 100644 index 0000000..eb95b5c --- /dev/null +++ b/src/api/resources/ids/types/DeviceId.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type DeviceId = string; diff --git a/src/api/resources/ids/types/RequestId.ts b/src/api/resources/ids/types/RequestId.ts new file mode 100644 index 0000000..371fb0a --- /dev/null +++ b/src/api/resources/ids/types/RequestId.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type RequestId = string; diff --git a/src/api/resources/ids/types/UserId.ts b/src/api/resources/ids/types/UserId.ts new file mode 100644 index 0000000..f9c9a8a --- /dev/null +++ b/src/api/resources/ids/types/UserId.ts @@ -0,0 +1,5 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type UserId = string; diff --git a/src/resources/ids/types/index.ts b/src/api/resources/ids/types/index.ts similarity index 100% rename from src/resources/ids/types/index.ts rename to src/api/resources/ids/types/index.ts diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts new file mode 100644 index 0000000..9ee504c --- /dev/null +++ b/src/api/resources/index.ts @@ -0,0 +1,11 @@ +export * as device from "./device"; +export * from "./device/types"; +export * as event from "./event"; +export * from "./event/types"; +export * as ids from "./ids"; +export * from "./ids/types"; +export * as user from "./user"; +export * from "./user/types"; +export * from "./event/errors"; +export * from "./event/client/requests"; +export * from "./user/client/requests"; diff --git a/src/api/resources/user/client/Client.ts b/src/api/resources/user/client/Client.ts new file mode 100644 index 0000000..730f712 --- /dev/null +++ b/src/api/resources/user/client/Client.ts @@ -0,0 +1,102 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as environments from "../../../../environments"; +import * as core from "../../../../core"; +import { RavenApi } from "@ravenapp/raven"; +import urlJoin from "url-join"; +import * as serializers from "../../../../serialization"; +import * as errors from "../../../../errors"; + +export declare namespace Client { + interface Options { + environment?: environments.RavenApiEnvironment | string; + authorization?: core.Supplier; + } +} + +export class Client { + constructor(private readonly options: Client.Options) {} + + /** + * Creates an AppUser if doesn't exist already, or updates user properties + */ + public async createOrUpdate( + appId: RavenApi.AppId, + request: RavenApi.CreateUserRequest + ): Promise { + const _response = await core.fetcher({ + url: urlJoin(this.options.environment ?? environments.RavenApiEnvironment.Prod, `/v1/apps/${appId}/users`), + method: "POST", + headers: { + Authorization: await core.Supplier.get(this.options.authorization), + }, + body: await serializers.CreateUserRequest.json(request), + }); + if (_response.ok) { + return await serializers.RavenUser.parse(_response.body as serializers.RavenUser.Raw); + } + + if (_response.error.reason === "status-code") { + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RavenApiTimeoutError(); + case "unknown": + throw new errors.RavenApiError({ + message: _response.error.errorMessage, + }); + } + } + + /** + * Gets the requested user + */ + public async get(appId: RavenApi.AppId, userId: RavenApi.UserId): Promise { + const _response = await core.fetcher({ + url: urlJoin( + this.options.environment ?? environments.RavenApiEnvironment.Prod, + `/v1/apps/${appId}/users/${userId}` + ), + method: "GET", + headers: { + Authorization: await core.Supplier.get(this.options.authorization), + }, + }); + if (_response.ok) { + return await serializers.RavenUser.parse(_response.body as serializers.RavenUser.Raw); + } + + if (_response.error.reason === "status-code") { + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } + + switch (_response.error.reason) { + case "non-json": + throw new errors.RavenApiError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.RavenApiTimeoutError(); + case "unknown": + throw new errors.RavenApiError({ + message: _response.error.errorMessage, + }); + } + } +} diff --git a/src/api/resources/user/client/index.ts b/src/api/resources/user/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/resources/user/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/user/client/requests/CreateUserRequest.ts b/src/api/resources/user/client/requests/CreateUserRequest.ts new file mode 100644 index 0000000..fa8091e --- /dev/null +++ b/src/api/resources/user/client/requests/CreateUserRequest.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface CreateUserRequest { + userId: RavenApi.UserId; + mobile?: string; + email?: string; + whatsApp?: string; +} diff --git a/src/api/resources/user/client/requests/index.ts b/src/api/resources/user/client/requests/index.ts new file mode 100644 index 0000000..5632de8 --- /dev/null +++ b/src/api/resources/user/client/requests/index.ts @@ -0,0 +1 @@ +export { CreateUserRequest } from "./CreateUserRequest"; diff --git a/src/resources/event/index.ts b/src/api/resources/user/index.ts similarity index 100% rename from src/resources/event/index.ts rename to src/api/resources/user/index.ts diff --git a/src/api/resources/user/types/Channel.ts b/src/api/resources/user/types/Channel.ts new file mode 100644 index 0000000..2c665aa --- /dev/null +++ b/src/api/resources/user/types/Channel.ts @@ -0,0 +1,17 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export type Channel = "VOICE" | "PUSH" | "SMS" | "EMAIL" | "WHATSAPP" | "WEBHOOK" | "SLACK" | "IN_APP" | "TELEGRAM"; + +export const Channel = { + Voice: "VOICE", + Push: "PUSH", + Sms: "SMS", + Email: "EMAIL", + Whatsapp: "WHATSAPP", + Webhook: "WEBHOOK", + Slack: "SLACK", + InApp: "IN_APP", + Telegram: "TELEGRAM", +} as const; diff --git a/src/api/resources/user/types/ChannelPreference.ts b/src/api/resources/user/types/ChannelPreference.ts new file mode 100644 index 0000000..72a99b7 --- /dev/null +++ b/src/api/resources/user/types/ChannelPreference.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface ChannelPreference { + disabled: boolean; +} diff --git a/src/api/resources/user/types/ChannelPreferences.ts b/src/api/resources/user/types/ChannelPreferences.ts new file mode 100644 index 0000000..8f45bc8 --- /dev/null +++ b/src/api/resources/user/types/ChannelPreferences.ts @@ -0,0 +1,15 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface ChannelPreferences { + sms?: RavenApi.ChannelPreference; + push?: RavenApi.ChannelPreference; + whatsapp?: RavenApi.ChannelPreference; + email?: RavenApi.ChannelPreference; + slack?: RavenApi.ChannelPreference; + voice?: RavenApi.ChannelPreference; + teams?: RavenApi.ChannelPreference; +} diff --git a/src/api/resources/user/types/RavenUser.ts b/src/api/resources/user/types/RavenUser.ts new file mode 100644 index 0000000..1f04ea6 --- /dev/null +++ b/src/api/resources/user/types/RavenUser.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface RavenUser { + /** + * Your user identifier. + * If user_id already exists, user properties will be updated else a new user will be created + * + */ + userId: RavenApi.UserId; + userSid?: string; + onesignalExternalId?: string; + mobile?: string; + email?: string; + /** Include this only when user's whatsapp mobile is different than primary mobile */ + whatsappMobile?: string; + slack?: RavenApi.SlackProfile; + telegram?: RavenApi.TelegramProfile; + fcmTokens?: string[]; + onesignalPlayerIds?: string[]; + iosTokens?: string[]; + createdAt?: number; + updatedAt?: number; +} diff --git a/src/api/resources/user/types/SlackProfile.ts b/src/api/resources/user/types/SlackProfile.ts new file mode 100644 index 0000000..0bfbadd --- /dev/null +++ b/src/api/resources/user/types/SlackProfile.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface SlackProfile { + accessToken: string; + email?: string; + channelId?: string; +} diff --git a/src/api/resources/user/types/TelegramProfile.ts b/src/api/resources/user/types/TelegramProfile.ts new file mode 100644 index 0000000..65a5983 --- /dev/null +++ b/src/api/resources/user/types/TelegramProfile.ts @@ -0,0 +1,7 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export interface TelegramProfile { + chatId: string; +} diff --git a/src/api/resources/user/types/UserPreferences.ts b/src/api/resources/user/types/UserPreferences.ts new file mode 100644 index 0000000..4c81699 --- /dev/null +++ b/src/api/resources/user/types/UserPreferences.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import { RavenApi } from "@ravenapp/raven"; + +export interface UserPreferences { + preferredChannel?: RavenApi.Channel; + channelPreferences?: RavenApi.ChannelPreferences; +} diff --git a/src/resources/user/types/index.ts b/src/api/resources/user/types/index.ts similarity index 86% rename from src/resources/user/types/index.ts rename to src/api/resources/user/types/index.ts index 0dea612..148e556 100644 --- a/src/resources/user/types/index.ts +++ b/src/api/resources/user/types/index.ts @@ -1,4 +1,3 @@ -export * from "./CreateUserRequest"; export * from "./RavenUser"; export * from "./SlackProfile"; export * from "./TelegramProfile"; diff --git a/src/core/fetcher/APIResponse.ts b/src/core/fetcher/APIResponse.ts index 8dbf295..ea838f3 100644 --- a/src/core/fetcher/APIResponse.ts +++ b/src/core/fetcher/APIResponse.ts @@ -1,11 +1,11 @@ export type APIResponse = SuccessfulResponse | FailedResponse; export interface SuccessfulResponse { - ok: true; - body: T; + ok: true; + body: T; } export interface FailedResponse { - ok: false; - error: T; + ok: false; + error: T; } diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts index fa837cc..6e5775f 100644 --- a/src/core/fetcher/Fetcher.ts +++ b/src/core/fetcher/Fetcher.ts @@ -2,120 +2,121 @@ import axios, { AxiosError } from "axios"; import { APIResponse } from "./APIResponse"; export interface Fetcher { - fetch: FetchFunction; + fetch: FetchFunction; } export type FetchFunction = (args: Fetcher.Args) => Promise>; export declare namespace Fetcher { - export interface Args { - url: string; - method: string; - headers?: Record; - queryParameters?: URLSearchParams; - body?: unknown; - timeoutMs?: number; - } + export interface Args { + url: string; + method: string; + headers?: Record; + queryParameters?: URLSearchParams; + body?: unknown; + timeoutMs?: number; + } - export type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; + export type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; - export interface FailedStatusCodeError { - reason: "status-code"; - statusCode: number; - body: unknown; - } + export interface FailedStatusCodeError { + reason: "status-code"; + statusCode: number; + body: unknown; + } - export interface NonJsonError { - reason: "non-json"; - statusCode: number; - rawBody: string; - } + export interface NonJsonError { + reason: "non-json"; + statusCode: number; + rawBody: string; + } - export interface TimeoutError { - reason: "timeout"; - } + export interface TimeoutError { + reason: "timeout"; + } - export interface UnknownError { - reason: "unknown"; - errorMessage: string; - } + export interface UnknownError { + reason: "unknown"; + errorMessage: string; + } } export const fetcher: FetchFunction = async (args) => { - const headers: Record = { - "Content-Type": "application/json", - }; + const headers: Record = { + "Content-Type": "application/json", + }; - if (args.headers != null) { - for (const [key, value] of Object.entries(args.headers)) { - if (value != null) { - headers[key] = value; - } + if (args.headers != null) { + for (const [key, value] of Object.entries(args.headers)) { + if (value != null) { + headers[key] = value; + } + } } - } - try { - const response = await axios({ - url: args.url, - params: args.queryParameters, - method: args.method, - headers, - data: args.body, - validateStatus: () => true, - transformResponse: (response) => response, - timeout: args.timeoutMs ?? 60_000, - transitional: { - clarifyTimeoutError: true, - }, - }); + try { + const response = await axios({ + url: args.url, + params: args.queryParameters, + method: args.method, + headers, + data: args.body, + validateStatus: () => true, + transformResponse: (response) => response, + timeout: args.timeoutMs ?? 60_000, + transitional: { + clarifyTimeoutError: true, + }, + withCredentials: true, + }); + + let body: unknown; + if (response.data != null && response.data.length > 0) { + try { + body = JSON.parse(response.data) ?? undefined; + } catch { + return { + ok: false, + error: { + reason: "non-json", + statusCode: response.status, + rawBody: response.data, + }, + }; + } + } + + if (response.status >= 200 && response.status < 300) { + return { + ok: true, + body, + }; + } else { + return { + ok: false, + error: { + reason: "status-code", + statusCode: response.status, + body, + }, + }; + } + } catch (error) { + if ((error as AxiosError).code === "ETIMEDOUT") { + return { + ok: false, + error: { + reason: "timeout", + }, + }; + } - let body: unknown; - if (response.data != null) { - try { - body = JSON.parse(response.data) ?? undefined; - } catch { return { - ok: false, - error: { - reason: "non-json", - statusCode: response.status, - rawBody: response.data, - }, + ok: false, + error: { + reason: "unknown", + errorMessage: (error as AxiosError).message, + }, }; - } - } - - if (response.status >= 200 && response.status < 300) { - return { - ok: true, - body, - }; - } else { - return { - ok: false, - error: { - reason: "status-code", - statusCode: response.status, - body, - }, - }; } - } catch (error) { - if ((error as AxiosError).code === "ETIMEDOUT") { - return { - ok: false, - error: { - reason: "timeout", - }, - }; - } - - return { - ok: false, - error: { - reason: "unknown", - errorMessage: (error as AxiosError).message, - }, - }; - } }; diff --git a/src/core/fetcher/Supplier.ts b/src/core/fetcher/Supplier.ts index 01a529a..867c931 100644 --- a/src/core/fetcher/Supplier.ts +++ b/src/core/fetcher/Supplier.ts @@ -1,11 +1,11 @@ export type Supplier = T | Promise | (() => T | Promise); export const Supplier = { - get: async (supplier: Supplier): Promise => { - if (typeof supplier === "function") { - return (supplier as () => T)(); - } else { - return supplier; - } - }, + get: async (supplier: Supplier): Promise => { + if (typeof supplier === "function") { + return (supplier as () => T)(); + } else { + return supplier; + } + }, }; diff --git a/src/core/index.ts b/src/core/index.ts index b014e2d..bdd3645 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,2 +1,2 @@ -export * as schemas from "./schemas"; +export * as serialization from "./schemas"; export * from "./fetcher"; diff --git a/src/core/schemas/Schema.ts b/src/core/schemas/Schema.ts index dccd550..c27d983 100644 --- a/src/core/schemas/Schema.ts +++ b/src/core/schemas/Schema.ts @@ -6,18 +6,18 @@ export type inferRaw = S extends Schema ? Raw export type inferParsed = S extends Schema ? Parsed : never; export interface BaseSchema { - parse: (raw: Raw, opts?: SchemaOptions) => Parsed | Promise; - json: (parsed: Parsed, opts?: SchemaOptions) => Raw | Promise; + parse: (raw: Raw, opts?: SchemaOptions) => Parsed | Promise; + json: (parsed: Parsed, opts?: SchemaOptions) => Raw | Promise; } export interface SchemaOptions { - /** - * @default false - */ - skipUnknownKeysOnParse?: boolean; + /** + * @default false + */ + skipUnknownKeysOnParse?: boolean; - /** - * @default false - */ - includeUnknownKeysOnJson?: boolean; + /** + * @default false + */ + includeUnknownKeysOnJson?: boolean; } diff --git a/src/core/schemas/builders/date/date.ts b/src/core/schemas/builders/date/date.ts index ba1bd43..20aab31 100644 --- a/src/core/schemas/builders/date/date.ts +++ b/src/core/schemas/builders/date/date.ts @@ -2,13 +2,13 @@ import { BaseSchema, Schema } from "../../Schema"; import { getSchemaUtils } from "../schema-utils"; export function date(): Schema { - const baseSchema: BaseSchema = { - parse: (raw) => new Date(raw), - json: (date) => date.toISOString(), - }; + const baseSchema: BaseSchema = { + parse: (raw) => new Date(raw), + json: (date) => date.toISOString(), + }; - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - }; + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; } diff --git a/src/core/schemas/builders/enum/enum.ts b/src/core/schemas/builders/enum/enum.ts index efef725..957cf2a 100644 --- a/src/core/schemas/builders/enum/enum.ts +++ b/src/core/schemas/builders/enum/enum.ts @@ -2,5 +2,5 @@ import { Schema } from "../../Schema"; import { createIdentitySchemaCreator } from "../identity"; export function enum_>(_values: E): Schema { - return createIdentitySchemaCreator()(); + return createIdentitySchemaCreator()(); } diff --git a/src/core/schemas/builders/identity/createIdentitySchemaCreator.ts b/src/core/schemas/builders/identity/createIdentitySchemaCreator.ts index 908ad92..e8bd362 100644 --- a/src/core/schemas/builders/identity/createIdentitySchemaCreator.ts +++ b/src/core/schemas/builders/identity/createIdentitySchemaCreator.ts @@ -2,5 +2,5 @@ import { Schema } from "../../Schema"; import { identity } from "./identity"; export function createIdentitySchemaCreator(): () => Schema { - return () => identity(); + return () => identity(); } diff --git a/src/core/schemas/builders/identity/identity.ts b/src/core/schemas/builders/identity/identity.ts index f401a6c..917b537 100644 --- a/src/core/schemas/builders/identity/identity.ts +++ b/src/core/schemas/builders/identity/identity.ts @@ -2,13 +2,13 @@ import { BaseSchema, Schema } from "../../Schema"; import { getSchemaUtils } from "../schema-utils"; export function identity(): Schema { - const baseSchema: BaseSchema = { - parse: (raw) => raw, - json: (parsed) => parsed, - }; + const baseSchema: BaseSchema = { + parse: (raw) => raw, + json: (parsed) => parsed, + }; - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - }; + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; } diff --git a/src/core/schemas/builders/lazy/index.ts b/src/core/schemas/builders/lazy/index.ts index 17c3982..ad14bf0 100644 --- a/src/core/schemas/builders/lazy/index.ts +++ b/src/core/schemas/builders/lazy/index.ts @@ -1,2 +1,2 @@ -export { lazy } from "./lazy"; +export { lazy, type SchemaGetter } from "./lazy"; export { lazyObject } from "./lazyObject"; diff --git a/src/core/schemas/builders/lazy/lazy.ts b/src/core/schemas/builders/lazy/lazy.ts index ae0dd45..107fa3d 100644 --- a/src/core/schemas/builders/lazy/lazy.ts +++ b/src/core/schemas/builders/lazy/lazy.ts @@ -1,28 +1,33 @@ import { BaseSchema, Schema } from "../../Schema"; import { getSchemaUtils } from "../schema-utils"; -type Getter = () => Schema | Promise>; -type MemoizedGetter = Getter & { __zurg_memoized?: Schema }; +export type SchemaGetter> = () => SchemaType | Promise; -export function lazy(getter: Getter): Schema { - const baseSchema = constructLazyBaseSchema(getter); - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - }; +export function lazy(getter: SchemaGetter>): Schema { + const baseSchema = constructLazyBaseSchema(getter); + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; } -export function constructLazyBaseSchema(getter: Getter): BaseSchema { - const getSchema = async () => { - const castedGetter = getter as MemoizedGetter; +export function constructLazyBaseSchema( + getter: SchemaGetter> +): BaseSchema { + return { + parse: async (raw) => (await getMemoizedSchema(getter)).parse(raw), + json: async (parsed) => (await getMemoizedSchema(getter)).json(parsed), + }; +} + +type MemoizedGetter> = SchemaGetter & { __zurg_memoized?: SchemaType }; + +export async function getMemoizedSchema>( + getter: SchemaGetter +): Promise { + const castedGetter = getter as MemoizedGetter; if (castedGetter.__zurg_memoized == null) { - castedGetter.__zurg_memoized = await getter(); + castedGetter.__zurg_memoized = await getter(); } return castedGetter.__zurg_memoized; - }; - - return { - parse: async (raw) => (await getSchema()).parse(raw), - json: async (parsed) => (await getSchema()).json(parsed), - }; } diff --git a/src/core/schemas/builders/lazy/lazyObject.ts b/src/core/schemas/builders/lazy/lazyObject.ts index d4163d6..77cadf8 100644 --- a/src/core/schemas/builders/lazy/lazyObject.ts +++ b/src/core/schemas/builders/lazy/lazyObject.ts @@ -1,21 +1,21 @@ import { getObjectUtils } from "../object"; import { getObjectLikeUtils, OBJECT_LIKE_BRAND } from "../object-like"; -import { ObjectSchema } from "../object/types"; +import { BaseObjectSchema, ObjectSchema } from "../object/types"; import { getSchemaUtils } from "../schema-utils"; -import { constructLazyBaseSchema } from "./lazy"; +import { constructLazyBaseSchema, getMemoizedSchema, SchemaGetter } from "./lazy"; -type Getter = () => ObjectSchema | Promise>; +export function lazyObject(getter: SchemaGetter>): ObjectSchema { + const baseSchema: BaseObjectSchema = { + ...OBJECT_LIKE_BRAND, + ...constructLazyBaseSchema(getter), + _getRawProperties: async () => (await getMemoizedSchema(getter))._getRawProperties(), + _getParsedProperties: async () => (await getMemoizedSchema(getter))._getParsedProperties(), + }; -export function lazyObject(getter: Getter): ObjectSchema { - const baseSchema = { - ...OBJECT_LIKE_BRAND, - ...constructLazyBaseSchema(getter), - }; - - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - ...getObjectLikeUtils(baseSchema), - ...getObjectUtils(baseSchema), - }; + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + ...getObjectLikeUtils(baseSchema), + ...getObjectUtils(baseSchema), + }; } diff --git a/src/core/schemas/builders/list/list.ts b/src/core/schemas/builders/list/list.ts index bb5dda5..d250f84 100644 --- a/src/core/schemas/builders/list/list.ts +++ b/src/core/schemas/builders/list/list.ts @@ -2,13 +2,13 @@ import { BaseSchema, Schema } from "../../Schema"; import { getSchemaUtils } from "../schema-utils"; export function list(schema: Schema): Schema { - const baseSchema: BaseSchema = { - parse: (raw, opts) => Promise.all(raw.map((item) => schema.parse(item, opts))), - json: (parsed, opts) => Promise.all(parsed.map((item) => schema.json(item, opts))), - }; + const baseSchema: BaseSchema = { + parse: (raw, opts) => Promise.all(raw.map((item) => schema.parse(item, opts))), + json: (parsed, opts) => Promise.all(parsed.map((item) => schema.json(item, opts))), + }; - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - }; + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; } diff --git a/src/core/schemas/builders/literals/stringLiteral.ts b/src/core/schemas/builders/literals/stringLiteral.ts index 30f0f6f..9edf1bf 100644 --- a/src/core/schemas/builders/literals/stringLiteral.ts +++ b/src/core/schemas/builders/literals/stringLiteral.ts @@ -2,5 +2,5 @@ import { Schema } from "../../Schema"; import { createIdentitySchemaCreator } from "../identity"; export function stringLiteral(_value: V): Schema { - return createIdentitySchemaCreator()(); + return createIdentitySchemaCreator()(); } diff --git a/src/core/schemas/builders/object-like/getObjectLikeUtils.ts b/src/core/schemas/builders/object-like/getObjectLikeUtils.ts index 92fe228..78d5579 100644 --- a/src/core/schemas/builders/object-like/getObjectLikeUtils.ts +++ b/src/core/schemas/builders/object-like/getObjectLikeUtils.ts @@ -1,10 +1,61 @@ -import { BaseObjectLikeSchema, ObjectLikeUtils } from "./types"; -import { withProperties } from "./withProperties"; +import { getSchemaUtils } from "../schema-utils"; +import { BaseObjectLikeSchema, ObjectLikeSchema, ObjectLikeUtils, OBJECT_LIKE_BRAND } from "./types"; export function getObjectLikeUtils( - schema: BaseObjectLikeSchema + schema: BaseObjectLikeSchema ): ObjectLikeUtils { - return { - withProperties: (properties) => withProperties(schema, properties), - }; + return { + withProperties: (properties) => withProperties(schema, properties), + }; +} + +/** + * object-like utils are defined in one file to resolve issues with circular imports + */ + +export function withProperties( + objectLike: BaseObjectLikeSchema, + properties: { [K in keyof Properties]: Properties[K] | ((parsed: ParsedObjectShape) => Properties[K]) } +): ObjectLikeSchema { + const objectSchema: BaseObjectLikeSchema = { + ...OBJECT_LIKE_BRAND, + parse: async (raw, opts) => { + const parsedObject = await objectLike.parse(raw, opts); + const additionalProperties = Object.entries(properties).reduce>( + (processed, [key, value]) => { + return { + ...processed, + [key]: typeof value === "function" ? value(parsedObject) : value, + }; + }, + {} + ); + + return { + ...parsedObject, + ...(additionalProperties as Properties), + }; + }, + json: (parsed, opts) => { + // strip out added properties + const addedPropertyKeys = new Set(Object.keys(properties)); + const parsedWithoutAddedProperties = Object.entries(parsed).reduce>( + (filtered, [key, value]) => { + if (!addedPropertyKeys.has(key)) { + filtered[key] = value; + } + return filtered; + }, + {} + ); + + return objectLike.json(parsedWithoutAddedProperties as ParsedObjectShape, opts); + }, + }; + + return { + ...objectSchema, + ...getSchemaUtils(objectSchema), + ...getObjectLikeUtils(objectSchema), + }; } diff --git a/src/core/schemas/builders/object-like/index.ts b/src/core/schemas/builders/object-like/index.ts index 45de54a..c18a342 100644 --- a/src/core/schemas/builders/object-like/index.ts +++ b/src/core/schemas/builders/object-like/index.ts @@ -1,3 +1,2 @@ -export { getObjectLikeUtils } from "./getObjectLikeUtils"; +export { getObjectLikeUtils, withProperties } from "./getObjectLikeUtils"; export { OBJECT_LIKE_BRAND, type BaseObjectLikeSchema, type ObjectLikeSchema, type ObjectLikeUtils } from "./types"; -export { withProperties } from "./withProperties"; diff --git a/src/core/schemas/builders/object-like/types.ts b/src/core/schemas/builders/object-like/types.ts index 0c2fceb..90509e4 100644 --- a/src/core/schemas/builders/object-like/types.ts +++ b/src/core/schemas/builders/object-like/types.ts @@ -1,17 +1,17 @@ import { BaseSchema, Schema } from "../../Schema"; export type ObjectLikeSchema = Schema & - BaseObjectLikeSchema & - ObjectLikeUtils; + BaseObjectLikeSchema & + ObjectLikeUtils; export type BaseObjectLikeSchema = BaseSchema & { - _objectLike: void; + _objectLike: void; }; export interface ObjectLikeUtils { - withProperties: >(properties: { - [K in keyof T]: T[K] | ((parsed: Parsed) => T[K]); - }) => ObjectLikeSchema; + withProperties: >(properties: { + [K in keyof T]: T[K] | ((parsed: Parsed) => T[K]); + }) => ObjectLikeSchema; } export const OBJECT_LIKE_BRAND = undefined as unknown as { _objectLike: void }; diff --git a/src/core/schemas/builders/object-like/withProperties.ts b/src/core/schemas/builders/object-like/withProperties.ts deleted file mode 100644 index 7299248..0000000 --- a/src/core/schemas/builders/object-like/withProperties.ts +++ /dev/null @@ -1,47 +0,0 @@ -import { getSchemaUtils } from "../schema-utils"; -import { getObjectLikeUtils } from "./getObjectLikeUtils"; -import { BaseObjectLikeSchema, ObjectLikeSchema, OBJECT_LIKE_BRAND } from "./types"; - -export function withProperties( - objectLike: BaseObjectLikeSchema, - properties: { [K in keyof Properties]: Properties[K] | ((parsed: ParsedObjectShape) => Properties[K]) } -): ObjectLikeSchema { - const objectSchema: BaseObjectLikeSchema = { - ...OBJECT_LIKE_BRAND, - parse: async (raw, opts) => { - const parsedObject = await objectLike.parse(raw, opts); - const additionalProperties = Object.entries(properties).reduce>((processed, [key, value]) => { - return { - ...processed, - [key]: typeof value === "function" ? value(parsedObject) : value, - }; - }, {}); - - return { - ...parsedObject, - ...(additionalProperties as Properties), - }; - }, - json: (parsed, opts) => { - // strip out added properties - const addedPropertyKeys = new Set(Object.keys(properties)); - const parsedWithoutAddedProperties = Object.entries(parsed).reduce>( - (filtered, [key, value]) => { - if (!addedPropertyKeys.has(key)) { - filtered[key] = value; - } - return filtered; - }, - {} - ); - - return objectLike.json(parsedWithoutAddedProperties as ParsedObjectShape, opts); - }, - }; - - return { - ...objectSchema, - ...getSchemaUtils(objectSchema), - ...getObjectLikeUtils(objectSchema), - }; -} diff --git a/src/core/schemas/builders/object/index.ts b/src/core/schemas/builders/object/index.ts index eea18b6..7120224 100644 --- a/src/core/schemas/builders/object/index.ts +++ b/src/core/schemas/builders/object/index.ts @@ -1,16 +1,16 @@ export { getObjectUtils, object } from "./object"; export { isProperty, property, type Property } from "./property"; export { - type BaseObjectSchema, - type inferObjectSchemaFromPropertySchemas, - type inferParsedObject, - type inferParsedObjectFromPropertySchemas, - type inferParsedPropertySchema, - type inferRawKey, - type inferRawObject, - type inferRawObjectFromPropertySchemas, - type inferRawPropertySchema, - type ObjectSchema, - type ObjectUtils, - type PropertySchemas, + type BaseObjectSchema, + type inferObjectSchemaFromPropertySchemas, + type inferParsedObject, + type inferParsedObjectFromPropertySchemas, + type inferParsedPropertySchema, + type inferRawKey, + type inferRawObject, + type inferRawObjectFromPropertySchemas, + type inferRawPropertySchema, + type ObjectSchema, + type ObjectUtils, + type PropertySchemas, } from "./types"; diff --git a/src/core/schemas/builders/object/object.ts b/src/core/schemas/builders/object/object.ts index 46a7b4e..7746cb5 100644 --- a/src/core/schemas/builders/object/object.ts +++ b/src/core/schemas/builders/object/object.ts @@ -1,113 +1,149 @@ import { Schema } from "../../Schema"; import { entries } from "../../utils/entries"; +import { filterObject } from "../../utils/filterObject"; +import { keys } from "../../utils/keys"; +import { partition } from "../../utils/partition"; import { getObjectLikeUtils, OBJECT_LIKE_BRAND } from "../object-like"; import { getSchemaUtils } from "../schema-utils"; import { isProperty } from "./property"; import { - BaseObjectSchema, - inferObjectSchemaFromPropertySchemas, - inferParsedObjectFromPropertySchemas, - inferRawObjectFromPropertySchemas, - ObjectSchema, - ObjectUtils, - PropertySchemas, + BaseObjectSchema, + inferObjectSchemaFromPropertySchemas, + inferParsedObjectFromPropertySchemas, + inferRawObjectFromPropertySchemas, + ObjectSchema, + ObjectUtils, + PropertySchemas, } from "./types"; interface ObjectPropertyWithRawKey { - rawKey: string; - parsedKey: string | number | symbol; - valueSchema: Schema; + rawKey: string; + parsedKey: string | number | symbol; + valueSchema: Schema; } export function object>( - schemas: T + schemas: T ): inferObjectSchemaFromPropertySchemas { - const baseSchema: BaseObjectSchema, inferParsedObjectFromPropertySchemas> = { - ...OBJECT_LIKE_BRAND, - - parse: async (raw, { skipUnknownKeysOnParse = false } = {}) => { - const rawKeyToProperty: Record = {}; - - for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) { - const rawKey = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey; - - const property: ObjectPropertyWithRawKey = { - rawKey, - parsedKey, - valueSchema: isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.valueSchema : schemaOrObjectProperty, - }; - - rawKeyToProperty[rawKey] = property; - } - - const parsed: Record = {}; - - for (const [rawKey, rawPropertyValue] of Object.entries(raw)) { - const property = rawKeyToProperty[rawKey]; - - if (property != null) { - const value = await property.valueSchema.parse(rawPropertyValue); - parsed[property.parsedKey] = value; - } else if (!skipUnknownKeysOnParse && rawPropertyValue != null) { - parsed[rawKey] = rawPropertyValue; - } - } - - return parsed as inferParsedObjectFromPropertySchemas; - }, - - json: async (parsed, { includeUnknownKeysOnJson = false } = {}) => { - const raw: Record = {}; - - for (const [parsedKey, parsedPropertyValue] of entries(parsed)) { - const schemaOrObjectProperty = schemas[parsedKey as keyof T]; - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (schemaOrObjectProperty != null) { - if (isProperty(schemaOrObjectProperty)) { - const value = await schemaOrObjectProperty.valueSchema.json(parsedPropertyValue); - raw[schemaOrObjectProperty.rawKey] = value; - } else { - const value = await schemaOrObjectProperty.json(parsedPropertyValue); - raw[parsedKey] = value; - } - } else if (includeUnknownKeysOnJson && parsedPropertyValue != null) { - raw[parsedKey] = parsedPropertyValue; - } - } - - return raw as inferRawObjectFromPropertySchemas; - }, - }; - - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - ...getObjectLikeUtils(baseSchema), - ...getObjectUtils(baseSchema), - }; -} - -export function getObjectUtils(schema: BaseObjectSchema): ObjectUtils { - return { - extend: (extension: ObjectSchema) => { - const baseSchema: BaseObjectSchema = { + const baseSchema: BaseObjectSchema< + inferRawObjectFromPropertySchemas, + inferParsedObjectFromPropertySchemas + > = { ...OBJECT_LIKE_BRAND, - parse: async (raw, opts) => ({ - ...(await schema.parse(raw, opts)), - ...(await extension.parse(raw, opts)), - }), - json: async (parsed, opts) => ({ - ...(await schema.json(parsed, opts)), - ...(await extension.json(parsed, opts)), - }), - }; - - return { + _getRawProperties: () => + Promise.resolve( + Object.entries(schemas).map(([parsedKey, propertySchema]) => + isProperty(propertySchema) ? propertySchema.rawKey : parsedKey + ) as unknown as (keyof inferRawObjectFromPropertySchemas)[] + ), + _getParsedProperties: () => + Promise.resolve(keys(schemas) as unknown as (keyof inferParsedObjectFromPropertySchemas)[]), + + parse: async (raw, { skipUnknownKeysOnParse = false } = {}) => { + const rawKeyToProperty: Record = {}; + + for (const [parsedKey, schemaOrObjectProperty] of entries(schemas)) { + const rawKey = isProperty(schemaOrObjectProperty) ? schemaOrObjectProperty.rawKey : parsedKey; + + const property: ObjectPropertyWithRawKey = { + rawKey, + parsedKey, + valueSchema: isProperty(schemaOrObjectProperty) + ? schemaOrObjectProperty.valueSchema + : schemaOrObjectProperty, + }; + + rawKeyToProperty[rawKey] = property; + } + + const parsed: Record = {}; + + for (const [rawKey, rawPropertyValue] of Object.entries(raw)) { + const property = rawKeyToProperty[rawKey]; + + if (property != null) { + const value = await property.valueSchema.parse(rawPropertyValue); + parsed[property.parsedKey] = value; + } else if (!skipUnknownKeysOnParse) { + parsed[rawKey] = rawPropertyValue; + } + } + + return parsed as inferParsedObjectFromPropertySchemas; + }, + + json: async (parsed, { includeUnknownKeysOnJson = false } = {}) => { + const raw: Record = {}; + + for (const [parsedKey, parsedPropertyValue] of entries(parsed)) { + const schemaOrObjectProperty = schemas[parsedKey as keyof T]; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (schemaOrObjectProperty != null) { + if (isProperty(schemaOrObjectProperty)) { + const value = await schemaOrObjectProperty.valueSchema.json(parsedPropertyValue); + raw[schemaOrObjectProperty.rawKey] = value; + } else { + const value = await schemaOrObjectProperty.json(parsedPropertyValue); + raw[parsedKey] = value; + } + } else if (includeUnknownKeysOnJson) { + raw[parsedKey] = parsedPropertyValue; + } + } + + return raw as inferRawObjectFromPropertySchemas; + }, + }; + + return { ...baseSchema, ...getSchemaUtils(baseSchema), ...getObjectLikeUtils(baseSchema), ...getObjectUtils(baseSchema), - }; - }, - }; + }; +} + +export function getObjectUtils(schema: BaseObjectSchema): ObjectUtils { + return { + extend: (extension: ObjectSchema) => { + const baseSchema: BaseObjectSchema = { + ...OBJECT_LIKE_BRAND, + _getParsedProperties: async () => [ + ...(await schema._getParsedProperties()), + ...(await extension._getParsedProperties()), + ], + _getRawProperties: async () => [ + ...(await schema._getRawProperties()), + ...(await extension._getRawProperties()), + ], + parse: async (raw, opts) => { + const rawExtensionPropertiesSet = new Set(await extension._getRawProperties()); + const [extensionProperties, otherProperties] = partition(keys(raw), (key) => + rawExtensionPropertiesSet.has(key as keyof RawExtension) + ); + return { + ...(await schema.parse(filterObject(raw, otherProperties), opts)), + ...(await extension.parse(filterObject(raw, extensionProperties), opts)), + }; + }, + json: async (parsed, opts) => { + const parsedExtensionPropertiesSet = new Set(await extension._getParsedProperties()); + const [extensionProperties, otherProperties] = partition(keys(parsed), (key) => + parsedExtensionPropertiesSet.has(key as keyof ParsedExtension) + ); + return { + ...(await schema.json(filterObject(parsed, otherProperties), opts)), + ...(await extension.json(filterObject(parsed, extensionProperties), opts)), + }; + }, + }; + + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + ...getObjectLikeUtils(baseSchema), + ...getObjectUtils(baseSchema), + }; + }, + }; } diff --git a/src/core/schemas/builders/object/property.ts b/src/core/schemas/builders/object/property.ts index 04347ad..d245c4b 100644 --- a/src/core/schemas/builders/object/property.ts +++ b/src/core/schemas/builders/object/property.ts @@ -1,23 +1,23 @@ import { Schema } from "../../Schema"; export function property( - rawKey: RawKey, - valueSchema: Schema + rawKey: RawKey, + valueSchema: Schema ): Property { - return { - rawKey, - valueSchema, - isProperty: true, - }; + return { + rawKey, + valueSchema, + isProperty: true, + }; } export interface Property { - rawKey: RawKey; - valueSchema: Schema; - isProperty: true; + rawKey: RawKey; + valueSchema: Schema; + isProperty: true; } export function isProperty>(maybeProperty: unknown): maybeProperty is O { - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - return (maybeProperty as O).isProperty; + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + return (maybeProperty as O).isProperty; } diff --git a/src/core/schemas/builders/object/types.ts b/src/core/schemas/builders/object/types.ts index dad6d6b..d4b4cc7 100644 --- a/src/core/schemas/builders/object/types.ts +++ b/src/core/schemas/builders/object/types.ts @@ -4,64 +4,67 @@ import { BaseObjectLikeSchema, ObjectLikeSchema } from "../object-like"; import { Property } from "./property"; export type ObjectSchema = BaseObjectSchema & - ObjectLikeSchema & - ObjectUtils; + ObjectLikeSchema & + ObjectUtils; -export type BaseObjectSchema = BaseObjectLikeSchema; +export interface BaseObjectSchema extends BaseObjectLikeSchema { + _getRawProperties: () => Promise<(keyof Raw)[]>; + _getParsedProperties: () => Promise<(keyof Parsed)[]>; +} export interface ObjectUtils { - extend: ( - schemas: ObjectSchema - ) => ObjectSchema; + extend: ( + schemas: ObjectSchema + ) => ObjectSchema; } export type inferRawObject> = O extends ObjectSchema ? Raw : never; export type inferParsedObject> = O extends ObjectSchema - ? Parsed - : never; + ? Parsed + : never; export type inferObjectSchemaFromPropertySchemas> = ObjectSchema< - inferRawObjectFromPropertySchemas, - inferParsedObjectFromPropertySchemas + inferRawObjectFromPropertySchemas, + inferParsedObjectFromPropertySchemas >; export type inferRawObjectFromPropertySchemas> = - addQuestionMarksToNullableProperties<{ - [ParsedKey in keyof T as inferRawKey]: inferRawPropertySchema; - }>; + addQuestionMarksToNullableProperties<{ + [ParsedKey in keyof T as inferRawKey]: inferRawPropertySchema; + }>; export type inferParsedObjectFromPropertySchemas> = - addQuestionMarksToNullableProperties<{ - [K in keyof T]: inferParsedPropertySchema; - }>; + addQuestionMarksToNullableProperties<{ + [K in keyof T]: inferParsedPropertySchema; + }>; export type PropertySchemas = Record< - ParsedKeys, - Property | Schema + ParsedKeys, + Property | Schema >; export type inferRawPropertySchema

| Schema> = P extends Property< - any, - infer Raw, - any + any, + infer Raw, + any > - ? Raw - : P extends Schema - ? inferRaw

- : never; + ? Raw + : P extends Schema + ? inferRaw

+ : never; export type inferParsedPropertySchema

| Schema> = P extends Property< - any, - any, - infer Parsed + any, + any, + infer Parsed > - ? Parsed - : P extends Schema - ? inferParsed

- : never; + ? Parsed + : P extends Schema + ? inferParsed

+ : never; export type inferRawKey< - ParsedKey extends string | number | symbol, - P extends Property | Schema + ParsedKey extends string | number | symbol, + P extends Property | Schema > = P extends Property ? Raw : ParsedKey; diff --git a/src/core/schemas/builders/record/record.ts b/src/core/schemas/builders/record/record.ts index 991efb9..2d342b2 100644 --- a/src/core/schemas/builders/record/record.ts +++ b/src/core/schemas/builders/record/record.ts @@ -3,30 +3,30 @@ import { entries } from "../../utils/entries"; import { getSchemaUtils } from "../schema-utils"; export function record( - keySchema: Schema, - valueSchema: Schema + keySchema: Schema, + valueSchema: Schema ): Schema, Record> { - const baseSchema: BaseSchema, Record> = { - parse: (raw, opts) => { - return entries(raw).reduce(async (parsedPromise, [key, value]) => { - const parsed: Record = await parsedPromise; - const parsedKey = await keySchema.parse(key, opts); - parsed[parsedKey] = await valueSchema.parse(value, opts); - return parsedPromise; - }, Promise.resolve({} as Record)); - }, - json: (parsed, opts) => { - return entries(parsed).reduce(async (rawPromise, [key, value]) => { - const raw: Record = await rawPromise; - const rawKey = await keySchema.json(key, opts); - raw[rawKey] = await valueSchema.json(value, opts); - return rawPromise; - }, Promise.resolve({} as Record)); - }, - }; + const baseSchema: BaseSchema, Record> = { + parse: (raw, opts) => { + return entries(raw).reduce(async (parsedPromise, [key, value]) => { + const parsed: Record = await parsedPromise; + const parsedKey = await keySchema.parse(key, opts); + parsed[parsedKey] = await valueSchema.parse(value, opts); + return parsedPromise; + }, Promise.resolve({} as Record)); + }, + json: (parsed, opts) => { + return entries(parsed).reduce(async (rawPromise, [key, value]) => { + const raw: Record = await rawPromise; + const rawKey = await keySchema.json(key, opts); + raw[rawKey] = await valueSchema.json(value, opts); + return rawPromise; + }, Promise.resolve({} as Record)); + }, + }; - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - }; + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; } diff --git a/src/core/schemas/builders/schema-utils/getSchemaUtils.ts b/src/core/schemas/builders/schema-utils/getSchemaUtils.ts index e00bf43..2eaf136 100644 --- a/src/core/schemas/builders/schema-utils/getSchemaUtils.ts +++ b/src/core/schemas/builders/schema-utils/getSchemaUtils.ts @@ -2,15 +2,15 @@ import { BaseSchema, Schema } from "../../Schema"; import { OptionalSchema, OPTIONAL_BRAND } from "./types"; export interface SchemaUtils { - optional: () => OptionalSchema; - transform: (transformer: BaseSchema) => Schema; + optional: () => OptionalSchema; + transform: (transformer: BaseSchema) => Schema; } export function getSchemaUtils(schema: BaseSchema): SchemaUtils { - return { - optional: () => optional(schema), - transform: (transformer) => transform(schema, transformer), - }; + return { + optional: () => optional(schema), + transform: (transformer) => transform(schema, transformer), + }; } /** @@ -18,35 +18,35 @@ export function getSchemaUtils(schema: BaseSchema): Sc */ export function optional(schema: BaseSchema): OptionalSchema { - const baseSchema: BaseSchema = { - parse: (raw, opts) => (raw != null ? schema.parse(raw, opts) : undefined), - json: (parsed, opts) => (parsed != null ? schema.json(parsed, opts) : undefined), - }; + const baseSchema: BaseSchema = { + parse: (raw, opts) => (raw != null ? schema.parse(raw, opts) : undefined), + json: (parsed, opts) => (parsed != null ? schema.json(parsed, opts) : null), + }; - return { - ...OPTIONAL_BRAND, - ...baseSchema, - ...getSchemaUtils(baseSchema), - }; + return { + ...OPTIONAL_BRAND, + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; } export function transform( - schema: BaseSchema, - transformer: BaseSchema + schema: BaseSchema, + transformer: BaseSchema ): Schema { - const baseSchema: BaseSchema = { - parse: async (raw, opts) => { - const postTransformParsed = await schema.parse(raw, opts); - return transformer.parse(postTransformParsed, opts); - }, - json: async (parsed, opts) => { - const preTransformParsed = await transformer.json(parsed, opts); - return schema.json(preTransformParsed, opts); - }, - }; + const baseSchema: BaseSchema = { + parse: async (raw, opts) => { + const postTransformParsed = await schema.parse(raw, opts); + return transformer.parse(postTransformParsed, opts); + }, + json: async (parsed, opts) => { + const preTransformParsed = await transformer.json(parsed, opts); + return schema.json(preTransformParsed, opts); + }, + }; - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - }; + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; } diff --git a/src/core/schemas/builders/schema-utils/types.ts b/src/core/schemas/builders/schema-utils/types.ts index 9bc7615..1dbc0da 100644 --- a/src/core/schemas/builders/schema-utils/types.ts +++ b/src/core/schemas/builders/schema-utils/types.ts @@ -3,5 +3,5 @@ import { Schema } from "../../Schema"; export const OPTIONAL_BRAND = undefined as unknown as { _isOptional: void }; export type OptionalSchema = Schema & { - _isOptional: void; + _isOptional: void; }; diff --git a/src/core/schemas/builders/set/set.ts b/src/core/schemas/builders/set/set.ts index a85b278..a9cac6f 100644 --- a/src/core/schemas/builders/set/set.ts +++ b/src/core/schemas/builders/set/set.ts @@ -2,13 +2,13 @@ import { BaseSchema, Schema } from "../../Schema"; import { getSchemaUtils } from "../schema-utils"; export function set(schema: Schema): Schema> { - const baseSchema: BaseSchema> = { - parse: async (raw, opts) => new Set(await Promise.all(raw.map((item) => schema.parse(item, opts)))), - json: (parsed, opts) => Promise.all([...parsed].map((item) => schema.json(item, opts))), - }; + const baseSchema: BaseSchema> = { + parse: async (raw, opts) => new Set(await Promise.all(raw.map((item) => schema.parse(item, opts)))), + json: (parsed, opts) => Promise.all([...parsed].map((item) => schema.json(item, opts))), + }; - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - }; + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + }; } diff --git a/src/core/schemas/builders/union/discriminant.ts b/src/core/schemas/builders/union/discriminant.ts index e68cd93..55065bc 100644 --- a/src/core/schemas/builders/union/discriminant.ts +++ b/src/core/schemas/builders/union/discriminant.ts @@ -1,14 +1,14 @@ export function discriminant( - parsedDiscriminant: ParsedDiscriminant, - rawDiscriminant: RawDiscriminant + parsedDiscriminant: ParsedDiscriminant, + rawDiscriminant: RawDiscriminant ): Discriminant { - return { - parsedDiscriminant, - rawDiscriminant, - }; + return { + parsedDiscriminant, + rawDiscriminant, + }; } export interface Discriminant { - parsedDiscriminant: ParsedDiscriminant; - rawDiscriminant: RawDiscriminant; + parsedDiscriminant: ParsedDiscriminant; + rawDiscriminant: RawDiscriminant; } diff --git a/src/core/schemas/builders/union/index.ts b/src/core/schemas/builders/union/index.ts index 93b2dae..9f52942 100644 --- a/src/core/schemas/builders/union/index.ts +++ b/src/core/schemas/builders/union/index.ts @@ -1,9 +1,9 @@ export { discriminant, type Discriminant } from "./discriminant"; export { - type inferParsedDiscriminant, - type inferParsedUnion, - type inferRawDiscriminant, - type inferRawUnion, - type UnionSubtypes, + type inferParsedDiscriminant, + type inferParsedUnion, + type inferRawDiscriminant, + type inferRawUnion, + type UnionSubtypes, } from "./types"; export { union } from "./union"; diff --git a/src/core/schemas/builders/union/types.ts b/src/core/schemas/builders/union/types.ts index 6957c93..6f82c86 100644 --- a/src/core/schemas/builders/union/types.ts +++ b/src/core/schemas/builders/union/types.ts @@ -2,25 +2,25 @@ import { inferParsedObject, inferRawObject, ObjectSchema } from "../object"; import { Discriminant } from "./discriminant"; export type UnionSubtypes = { - [K in DiscriminantValues]: ObjectSchema; + [K in DiscriminantValues]: ObjectSchema; }; export type inferRawUnion, U extends UnionSubtypes> = { - [K in keyof U]: Record, K> & inferRawObject; + [K in keyof U]: Record, K> & inferRawObject; }[keyof U]; export type inferParsedUnion, U extends UnionSubtypes> = { - [K in keyof U]: Record, K> & inferParsedObject; + [K in keyof U]: Record, K> & inferParsedObject; }[keyof U]; export type inferRawDiscriminant> = D extends string - ? D - : D extends Discriminant - ? Raw - : never; + ? D + : D extends Discriminant + ? Raw + : never; export type inferParsedDiscriminant> = D extends string - ? D - : D extends Discriminant - ? Parsed - : never; + ? D + : D extends Discriminant + ? Parsed + : never; diff --git a/src/core/schemas/builders/union/union.ts b/src/core/schemas/builders/union/union.ts index a0a0803..4ef88b7 100644 --- a/src/core/schemas/builders/union/union.ts +++ b/src/core/schemas/builders/union/union.ts @@ -4,57 +4,59 @@ import { Discriminant } from "./discriminant"; import { inferParsedDiscriminant, inferParsedUnion, inferRawDiscriminant, inferRawUnion, UnionSubtypes } from "./types"; export function union, U extends UnionSubtypes>( - discriminant: D, - union: U + discriminant: D, + union: U ): ObjectLikeSchema, inferParsedUnion> { - const rawDiscriminant = - typeof discriminant === "string" ? discriminant : (discriminant.rawDiscriminant as inferRawDiscriminant); - const parsedDiscriminant = - typeof discriminant === "string" ? discriminant : (discriminant.parsedDiscriminant as inferParsedDiscriminant); - - const baseSchema: BaseObjectLikeSchema, inferParsedUnion> = { - ...OBJECT_LIKE_BRAND, - - parse: async (raw, opts) => { - const { [rawDiscriminant]: discriminantValue, ...additionalProperties } = raw; - const additionalPropertySchemas = union[discriminantValue]; - - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (additionalPropertySchemas == null) { - return { - ...additionalProperties, - [parsedDiscriminant]: discriminantValue, - } as inferParsedUnion; - } - - return { - ...(await additionalPropertySchemas.parse(additionalProperties, opts)), - [parsedDiscriminant]: discriminantValue, - } as inferParsedUnion; - }, - - json: async (parsed, opts) => { - const { [parsedDiscriminant]: discriminantValue, ...additionalProperties } = parsed; - const additionalPropertySchemas = union[discriminantValue]; - - // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition - if (additionalPropertySchemas == null) { - return { - ...additionalProperties, - [rawDiscriminant]: discriminantValue, - } as unknown as inferRawUnion; - } - - return { - ...(await additionalPropertySchemas.json(additionalProperties, opts)), - [rawDiscriminant]: discriminantValue, - } as inferRawUnion; - }, - }; - - return { - ...baseSchema, - ...getSchemaUtils(baseSchema), - ...getObjectLikeUtils(baseSchema), - }; + const rawDiscriminant = + typeof discriminant === "string" ? discriminant : (discriminant.rawDiscriminant as inferRawDiscriminant); + const parsedDiscriminant = + typeof discriminant === "string" + ? discriminant + : (discriminant.parsedDiscriminant as inferParsedDiscriminant); + + const baseSchema: BaseObjectLikeSchema, inferParsedUnion> = { + ...OBJECT_LIKE_BRAND, + + parse: async (raw, opts) => { + const { [rawDiscriminant]: discriminantValue, ...additionalProperties } = raw; + const additionalPropertySchemas = union[discriminantValue]; + + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (additionalPropertySchemas == null) { + return { + ...additionalProperties, + [parsedDiscriminant]: discriminantValue, + } as inferParsedUnion; + } + + return { + ...(await additionalPropertySchemas.parse(additionalProperties, opts)), + [parsedDiscriminant]: discriminantValue, + } as inferParsedUnion; + }, + + json: async (parsed, opts) => { + const { [parsedDiscriminant]: discriminantValue, ...additionalProperties } = parsed; + const additionalPropertySchemas = union[discriminantValue]; + + // eslint-disable-next-line @typescript-eslint/no-unnecessary-condition + if (additionalPropertySchemas == null) { + return { + ...additionalProperties, + [rawDiscriminant]: discriminantValue, + } as unknown as inferRawUnion; + } + + return { + ...(await additionalPropertySchemas.json(additionalProperties, opts)), + [rawDiscriminant]: discriminantValue, + } as inferRawUnion; + }, + }; + + return { + ...baseSchema, + ...getSchemaUtils(baseSchema), + ...getObjectLikeUtils(baseSchema), + }; } diff --git a/src/core/schemas/utils/addQuestionMarksToNullableProperties.ts b/src/core/schemas/utils/addQuestionMarksToNullableProperties.ts index 25ccd9e..e8a02ed 100644 --- a/src/core/schemas/utils/addQuestionMarksToNullableProperties.ts +++ b/src/core/schemas/utils/addQuestionMarksToNullableProperties.ts @@ -1,11 +1,11 @@ export type addQuestionMarksToNullableProperties = { - [K in OptionalKeys]?: undefined extends T[K] ? T[K] : never; + [K in OptionalKeys]?: T[K]; } & Pick>; export type OptionalKeys = { - [K in keyof T]: undefined extends T[K] ? K : never; + [K in keyof T]: undefined extends T[K] ? K : null extends T[K] ? K : never; }[keyof T]; export type RequiredKeys = { - [K in keyof T]: undefined extends T[K] ? never : K; + [K in keyof T]: undefined extends T[K] ? never : null extends T[K] ? never : K; }[keyof T]; diff --git a/src/core/schemas/utils/entries.ts b/src/core/schemas/utils/entries.ts index 3df2b84..e122952 100644 --- a/src/core/schemas/utils/entries.ts +++ b/src/core/schemas/utils/entries.ts @@ -1,3 +1,3 @@ export function entries(object: T): [keyof T, T[keyof T]][] { - return Object.entries(object) as [keyof T, T[keyof T]][]; + return Object.entries(object) as [keyof T, T[keyof T]][]; } diff --git a/src/core/schemas/utils/filterObject.ts b/src/core/schemas/utils/filterObject.ts new file mode 100644 index 0000000..2c25a34 --- /dev/null +++ b/src/core/schemas/utils/filterObject.ts @@ -0,0 +1,10 @@ +export function filterObject(obj: T, keysToInclude: K[]): Pick { + const keysToIncludeSet = new Set(keysToInclude); + return Object.entries(obj).reduce((acc, [key, value]) => { + if (keysToIncludeSet.has(key as K)) { + acc[key as K] = value; + } + return acc; + // eslint-disable-next-line @typescript-eslint/prefer-reduce-type-parameter + }, {} as Pick); +} diff --git a/src/core/schemas/utils/keys.ts b/src/core/schemas/utils/keys.ts index fa22db9..0186709 100644 --- a/src/core/schemas/utils/keys.ts +++ b/src/core/schemas/utils/keys.ts @@ -1,3 +1,3 @@ export function keys(object: T): (keyof T)[] { - return Object.keys(object) as (keyof T)[]; + return Object.keys(object) as (keyof T)[]; } diff --git a/src/core/schemas/utils/partition.ts b/src/core/schemas/utils/partition.ts new file mode 100644 index 0000000..f58d6f3 --- /dev/null +++ b/src/core/schemas/utils/partition.ts @@ -0,0 +1,12 @@ +export function partition(items: readonly T[], predicate: (item: T) => boolean): [T[], T[]] { + const trueItems: T[] = [], + falseItems: T[] = []; + for (const item of items) { + if (predicate(item)) { + trueItems.push(item); + } else { + falseItems.push(item); + } + } + return [trueItems, falseItems]; +} diff --git a/src/environments.ts b/src/environments.ts index 7dd54c0..1056069 100644 --- a/src/environments.ts +++ b/src/environments.ts @@ -1,9 +1,9 @@ /** - * This file auto-generated by Fern from our API Definition. + * This file was auto-generated by Fern from our API Definition. */ -export const Environment = { - Prod: "https://api.ravenapp.dev", +export const RavenApiEnvironment = { + Prod: "https://api.ravenapp.dev", } as const; -export type Environment = typeof Environment.Prod; +export type RavenApiEnvironment = typeof RavenApiEnvironment.Prod; diff --git a/src/errors/RavenApiError.ts b/src/errors/RavenApiError.ts new file mode 100644 index 0000000..eebfac1 --- /dev/null +++ b/src/errors/RavenApiError.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export class RavenApiError extends Error { + readonly statusCode?: number; + readonly body?: unknown; + + constructor({ message, statusCode, body }: { message?: string; statusCode?: number; body?: unknown }) { + super(message); + Object.setPrototypeOf(this, RavenApiError.prototype); + if (statusCode != null) { + this.statusCode = statusCode; + } + + if (body !== undefined) { + this.body = body; + } + } +} diff --git a/src/errors/RavenApiTimeoutError.ts b/src/errors/RavenApiTimeoutError.ts new file mode 100644 index 0000000..429b44a --- /dev/null +++ b/src/errors/RavenApiTimeoutError.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +export class RavenApiTimeoutError extends Error { + constructor() { + super("Timeout"); + Object.setPrototypeOf(this, RavenApiTimeoutError.prototype); + } +} diff --git a/src/errors/index.ts b/src/errors/index.ts new file mode 100644 index 0000000..577bf60 --- /dev/null +++ b/src/errors/index.ts @@ -0,0 +1,2 @@ +export { RavenApiError } from "./RavenApiError"; +export { RavenApiTimeoutError } from "./RavenApiTimeoutError"; diff --git a/src/index.ts b/src/index.ts index 6e94d55..a7b1a09 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,2 +1,4 @@ -export * as RavenApi from "./resources"; +export * as RavenApi from "./api"; export { RavenApiClient } from "./Client"; +export { RavenApiEnvironment } from "./environments"; +export { RavenApiError, RavenApiTimeoutError } from "./errors"; diff --git a/src/resources/device/client/Client.ts b/src/resources/device/client/Client.ts deleted file mode 100644 index 69327ca..0000000 --- a/src/resources/device/client/Client.ts +++ /dev/null @@ -1,136 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import * as environments from "../../../environments"; -import * as core from "../../../core"; -import { RavenApi } from "@ravenapp/raven"; -import urlJoin from "url-join"; -import * as serializers from "../../../serialization"; - -export declare namespace Client { - interface Options { - environment?: environments.Environment | string; - auth?: { - authorization?: core.Supplier; - }; - } -} - -export class Client { - constructor(private readonly options: Client.Options) {} - - public async add(request: RavenApi.device.add.Request): Promise { - const response = await core.fetcher({ - url: urlJoin( - this.options.environment ?? environments.Environment.Prod, - `/v1/apps/${request.appId}/users/${request.userId}/devices` - ), - method: "POST", - headers: { - Authorization: await core.Supplier.get(this.options.auth?.authorization), - }, - body: await serializers.Device.json(request._body), - }); - if (response.ok) { - return { - ok: true, - body: await serializers.Device.parse(response.body as serializers.Device.Raw), - }; - } - - return { - ok: false, - error: { - errorName: undefined, - content: response.error, - _visit: (visitor) => visitor._other(response.error), - }, - }; - } - - public async update(request: RavenApi.device.update.Request): Promise { - const response = await core.fetcher({ - url: urlJoin( - this.options.environment ?? environments.Environment.Prod, - `/v1/apps/${request.appId}/users/${request.userId}/devices/${request.deviceId}` - ), - method: "PUT", - headers: { - Authorization: await core.Supplier.get(this.options.auth?.authorization), - }, - body: await serializers.Device.json(request._body), - }); - if (response.ok) { - return { - ok: true, - body: await serializers.Device.parse(response.body as serializers.Device.Raw), - }; - } - - return { - ok: false, - error: { - errorName: undefined, - content: response.error, - _visit: (visitor) => visitor._other(response.error), - }, - }; - } - - public async delete(request: RavenApi.device.delete.Request): Promise { - const response = await core.fetcher({ - url: urlJoin( - this.options.environment ?? environments.Environment.Prod, - `/v1/apps/${request.appId}/users/${request.userId}/devices/${request.deviceId}` - ), - method: "DELETE", - headers: { - Authorization: await core.Supplier.get(this.options.auth?.authorization), - }, - }); - if (response.ok) { - return { - ok: true, - body: undefined, - }; - } - - return { - ok: false, - error: { - errorName: undefined, - content: response.error, - _visit: (visitor) => visitor._other(response.error), - }, - }; - } - - public async getDevice(request: RavenApi.device.getDevice.Request): Promise { - const response = await core.fetcher({ - url: urlJoin( - this.options.environment ?? environments.Environment.Prod, - `/v1/apps/${request.appId}/users/${request.userId}/devices/${request.deviceId}` - ), - method: "GET", - headers: { - Authorization: await core.Supplier.get(this.options.auth?.authorization), - }, - }); - if (response.ok) { - return { - ok: true, - body: await serializers.Device.parse(response.body as serializers.Device.Raw), - }; - } - - return { - ok: false, - error: { - errorName: undefined, - content: response.error, - _visit: (visitor) => visitor._other(response.error), - }, - }; - } -} diff --git a/src/resources/device/client/add.ts b/src/resources/device/client/add.ts deleted file mode 100644 index 7d5eb3f..0000000 --- a/src/resources/device/client/add.ts +++ /dev/null @@ -1,32 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export interface Request { - /** your app identifier */ - appId: RavenApi.AppId; - /** your user identifier */ - userId: RavenApi.UserId; - _body: RavenApi.Device; -} - -export type Response = core.APIResponse; -export type Error = RavenApi.device.add.Error._Unknown; - -export declare namespace Error { - interface _Unknown extends _Utils { - errorName: void; - content: core.Fetcher.Error; - } - - interface _Utils { - _visit: <_Result>(visitor: RavenApi.device.add.Error._Visitor<_Result>) => _Result; - } - - interface _Visitor<_Result> { - _other: (value: core.Fetcher.Error) => _Result; - } -} diff --git a/src/resources/device/client/delete.ts b/src/resources/device/client/delete.ts deleted file mode 100644 index b3c8b94..0000000 --- a/src/resources/device/client/delete.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export interface Request { - /** your app identifier */ - appId: RavenApi.AppId; - /** your user identifier */ - userId: RavenApi.UserId; - /** your device identifier */ - deviceId: RavenApi.DeviceId; -} - -export type Response = core.APIResponse; -export type Error = RavenApi.device.delete.Error._Unknown; - -export declare namespace Error { - interface _Unknown extends _Utils { - errorName: void; - content: core.Fetcher.Error; - } - - interface _Utils { - _visit: <_Result>(visitor: RavenApi.device.delete.Error._Visitor<_Result>) => _Result; - } - - interface _Visitor<_Result> { - _other: (value: core.Fetcher.Error) => _Result; - } -} diff --git a/src/resources/device/client/getDevice.ts b/src/resources/device/client/getDevice.ts deleted file mode 100644 index e799386..0000000 --- a/src/resources/device/client/getDevice.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export interface Request { - /** your app identifier */ - appId: RavenApi.AppId; - /** your user identifier */ - userId: RavenApi.UserId; - /** your device identifier */ - deviceId: RavenApi.DeviceId; -} - -export type Response = core.APIResponse; -export type Error = RavenApi.device.getDevice.Error._Unknown; - -export declare namespace Error { - interface _Unknown extends _Utils { - errorName: void; - content: core.Fetcher.Error; - } - - interface _Utils { - _visit: <_Result>(visitor: RavenApi.device.getDevice.Error._Visitor<_Result>) => _Result; - } - - interface _Visitor<_Result> { - _other: (value: core.Fetcher.Error) => _Result; - } -} diff --git a/src/resources/device/client/index.ts b/src/resources/device/client/index.ts deleted file mode 100644 index 64a15b9..0000000 --- a/src/resources/device/client/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * as add from "./add"; -export * as update from "./update"; -export * as delete from "./delete"; -export * as getDevice from "./getDevice"; diff --git a/src/resources/device/client/update.ts b/src/resources/device/client/update.ts deleted file mode 100644 index fa4f1fa..0000000 --- a/src/resources/device/client/update.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export interface Request { - /** your app identifier */ - appId: RavenApi.AppId; - /** your user identifier */ - userId: RavenApi.UserId; - /** your device identifier; the same as device_sid */ - deviceId: RavenApi.DeviceId; - _body: RavenApi.Device; -} - -export type Response = core.APIResponse; -export type Error = RavenApi.device.update.Error._Unknown; - -export declare namespace Error { - interface _Unknown extends _Utils { - errorName: void; - content: core.Fetcher.Error; - } - - interface _Utils { - _visit: <_Result>(visitor: RavenApi.device.update.Error._Visitor<_Result>) => _Result; - } - - interface _Visitor<_Result> { - _other: (value: core.Fetcher.Error) => _Result; - } -} diff --git a/src/resources/device/types/Device.ts b/src/resources/device/types/Device.ts deleted file mode 100644 index b3f6624..0000000 --- a/src/resources/device/types/Device.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface Device { - id?: string; - platform?: RavenApi.Platform; - onesignalPlayerId?: string; - xiaomiToken?: string; - oppoToken?: string; - vivoToken?: string; - huaweiToken?: string; - /** firebase device token */ - fcmToken?: string; - /** user id affiliated with device */ - ravenId?: string; - deviceSid?: RavenApi.DeviceId; - notificationsDisabled?: boolean; - createdAt?: number; - updatedAt?: number; -} diff --git a/src/resources/device/types/Platform.ts b/src/resources/device/types/Platform.ts deleted file mode 100644 index 992abd6..0000000 --- a/src/resources/device/types/Platform.ts +++ /dev/null @@ -1,58 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface Platform { - value: RawValue; - visit: <_Result>(visitor: RavenApi.Platform._Visitor<_Result>) => _Result; -} - -const _Android: Platform<"android"> = { - value: "android", - visit: (visitor) => visitor.android(), -}; -const _Web: Platform<"web"> = { - value: "web", - visit: (visitor) => visitor.web(), -}; -const _Ios: Platform<"ios"> = { - value: "ios", - visit: (visitor) => visitor.ios(), -}; -export const Platform = { - Android: _Android, - Web: _Web, - Ios: _Ios, - _parse: (value: string): Platform => { - switch (value) { - case "android": { - return _Android; - } - case "web": { - return _Web; - } - case "ios": { - return _Ios; - } - default: { - return { - value: value as Platform.RawValue, - visit: (visitor) => visitor._other(value), - }; - } - } - }, -} as const; - -export declare namespace Platform { - type RawValue = "android" | "web" | "ios"; - - interface _Visitor<_Result> { - android: () => _Result; - web: () => _Result; - ios: () => _Result; - _other: (value: string) => _Result; - } -} diff --git a/src/resources/event/client/Client.ts b/src/resources/event/client/Client.ts deleted file mode 100644 index 7021226..0000000 --- a/src/resources/event/client/Client.ts +++ /dev/null @@ -1,79 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import * as environments from "../../../environments"; -import * as core from "../../../core"; -import { RavenApi } from "@ravenapp/raven"; -import urlJoin from "url-join"; -import * as serializers from "../../../serialization"; - -export declare namespace Client { - interface Options { - environment?: environments.Environment | string; - auth?: { - authorization?: core.Supplier; - }; - } -} - -export class Client { - constructor(private readonly options: Client.Options) {} - - public async send(request: RavenApi.event.send.Request): Promise { - const response = await core.fetcher({ - url: urlJoin(this.options.environment ?? environments.Environment.Prod, `/v1/apps/${request.appId}/events/send`), - method: "POST", - headers: { - Authorization: await core.Supplier.get(this.options.auth?.authorization), - "Idempotency-Key": request.idempotencyKey, - }, - body: await serializers.SendEventRequest.json(request._body), - }); - if (response.ok) { - return { - ok: true, - body: await serializers.SendEventResponse.parse(response.body as serializers.SendEventResponse.Raw), - }; - } - - return { - ok: false, - error: { - errorName: undefined, - content: response.error, - _visit: (visitor) => visitor._other(response.error), - }, - }; - } - - public async sendBulk(request: RavenApi.event.sendBulk.Request): Promise { - const response = await core.fetcher({ - url: urlJoin( - this.options.environment ?? environments.Environment.Prod, - `/v1/apps/${request.appId}/events/bulk_send` - ), - method: "POST", - headers: { - Authorization: await core.Supplier.get(this.options.auth?.authorization), - "Idempotency-Key": request.idempotencyKey, - }, - body: await serializers.BulkSendEventRequest.json(request._body), - }); - if (response.ok) { - return { - ok: true, - body: await serializers.SendEventResponse.parse(response.body as serializers.SendEventResponse.Raw), - }; - } - - return { - ok: false, - error: { - errorName: undefined, - content: response.error, - _visit: (visitor) => visitor._other(response.error), - }, - }; - } -} diff --git a/src/resources/event/client/index.ts b/src/resources/event/client/index.ts deleted file mode 100644 index c422bdc..0000000 --- a/src/resources/event/client/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * as send from "./send"; -export * as sendBulk from "./sendBulk"; diff --git a/src/resources/event/client/send.ts b/src/resources/event/client/send.ts deleted file mode 100644 index 5d63d3a..0000000 --- a/src/resources/event/client/send.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export interface Request { - appId: RavenApi.AppId; - /** - * The API supports idempotency for safely retrying requests without accidentally performing the same operation twice. - * This is useful when an API call is disrupted in transit and you do not receive a response. - * For example, if a request to send event does not respond due to a network connection error, you can retry the request with the same idempotency key to guarantee that no more than one event is sent. - * An idempotency key is a unique value generated by the client which the server uses to recognize subsequent retries of the same request. - * How you create unique keys is up to you, but we suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. - * Idempotency keys can be up to 255 characters long. - * - */ - idempotencyKey?: string; - _body: RavenApi.SendEventRequest; -} - -export type Response = core.APIResponse; -export type Error = RavenApi.event.send.Error._Unknown; - -export declare namespace Error { - interface _Unknown extends _Utils { - errorName: void; - content: core.Fetcher.Error; - } - - interface _Utils { - _visit: <_Result>(visitor: RavenApi.event.send.Error._Visitor<_Result>) => _Result; - } - - interface _Visitor<_Result> { - _other: (value: core.Fetcher.Error) => _Result; - } -} diff --git a/src/resources/event/client/sendBulk.ts b/src/resources/event/client/sendBulk.ts deleted file mode 100644 index 5b54859..0000000 --- a/src/resources/event/client/sendBulk.ts +++ /dev/null @@ -1,39 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export interface Request { - appId: RavenApi.AppId; - /** - * The API supports idempotency for safely retrying requests without accidentally performing the same operation twice. - * This is useful when an API call is disrupted in transit and you do not receive a response. - * For example, if a request to send event does not respond due to a network connection error, you can retry the request with the same idempotency key to guarantee that no more than one event is sent. - * An idempotency key is a unique value generated by the client which the server uses to recognize subsequent retries of the same request. - * How you create unique keys is up to you, but we suggest using V4 UUIDs, or another random string with enough entropy to avoid collisions. - * Idempotency keys can be up to 255 characters long. - * - */ - idempotencyKey?: string; - _body: RavenApi.BulkSendEventRequest; -} - -export type Response = core.APIResponse; -export type Error = RavenApi.event.sendBulk.Error._Unknown; - -export declare namespace Error { - interface _Unknown extends _Utils { - errorName: void; - content: core.Fetcher.Error; - } - - interface _Utils { - _visit: <_Result>(visitor: RavenApi.event.sendBulk.Error._Visitor<_Result>) => _Result; - } - - interface _Visitor<_Result> { - _other: (value: core.Fetcher.Error) => _Result; - } -} diff --git a/src/resources/event/types/Attachment.ts b/src/resources/event/types/Attachment.ts deleted file mode 100644 index f183cd0..0000000 --- a/src/resources/event/types/Attachment.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface Attachment { - fileName: string; - content: string; - url: string; -} diff --git a/src/resources/event/types/BatchEvent.ts b/src/resources/event/types/BatchEvent.ts deleted file mode 100644 index f268a91..0000000 --- a/src/resources/event/types/BatchEvent.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface BatchEvent { - /** - * { - * "param1" : "", - * "param2" : "", - * "param3" : object/array" - * } - * - */ - data: Record; - user?: RavenApi.User; - override?: RavenApi.EventOverride; -} diff --git a/src/resources/event/types/BulkSendEventRequest.ts b/src/resources/event/types/BulkSendEventRequest.ts deleted file mode 100644 index 19ed607..0000000 --- a/src/resources/event/types/BulkSendEventRequest.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface BulkSendEventRequest { - event: string; - /** List of events */ - batch: RavenApi.BatchEvent[]; -} diff --git a/src/resources/event/types/ChannelOverride.ts b/src/resources/event/types/ChannelOverride.ts deleted file mode 100644 index b3b111b..0000000 --- a/src/resources/event/types/ChannelOverride.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface ChannelOverride { - scheduleAt: number; -} diff --git a/src/resources/event/types/EmailMessage.ts b/src/resources/event/types/EmailMessage.ts deleted file mode 100644 index d98bad9..0000000 --- a/src/resources/event/types/EmailMessage.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface EmailMessage { - text: string; - htmlBody: string; - subject: string; -} diff --git a/src/resources/event/types/EmailOverride.ts b/src/resources/event/types/EmailOverride.ts deleted file mode 100644 index 494da91..0000000 --- a/src/resources/event/types/EmailOverride.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface EmailOverride extends RavenApi.ChannelOverride { - from: RavenApi.EmailRecipient; - cc: RavenApi.EmailRecipient[]; - bcc: RavenApi.EmailRecipient[]; - attachments: RavenApi.Attachment[]; - message: RavenApi.EmailMessage; -} diff --git a/src/resources/event/types/EmailRecipient.ts b/src/resources/event/types/EmailRecipient.ts deleted file mode 100644 index f1bc3b5..0000000 --- a/src/resources/event/types/EmailRecipient.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface EmailRecipient { - name: string; - address: string; -} diff --git a/src/resources/event/types/EventOverride.ts b/src/resources/event/types/EventOverride.ts deleted file mode 100644 index 35e020d..0000000 --- a/src/resources/event/types/EventOverride.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface EventOverride { - email?: RavenApi.EmailOverride; - sms?: RavenApi.SmsOverride; - whatsapp?: RavenApi.WhatsappOverride; - push?: RavenApi.PushOverride; - webhook?: RavenApi.WebhookOverride; - voice?: RavenApi.VoiceOverride; - slack?: RavenApi.SlackOverride; - inApp?: RavenApi.InAppOverride; - telegram?: RavenApi.TelegramOverride; - providers: Record; -} diff --git a/src/resources/event/types/Param.ts b/src/resources/event/types/Param.ts deleted file mode 100644 index 2393606..0000000 --- a/src/resources/event/types/Param.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface Param { - name: string; - value: string; -} diff --git a/src/resources/event/types/ProviderOverride.ts b/src/resources/event/types/ProviderOverride.ts deleted file mode 100644 index 7c91a52..0000000 --- a/src/resources/event/types/ProviderOverride.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface ProviderOverride { - payload: Record; - formParams: RavenApi.Param[]; - queryParams: RavenApi.Param[]; - pathParams: RavenApi.Param[]; - headers: RavenApi.Param[]; -} diff --git a/src/resources/event/types/SendEventRequest.ts b/src/resources/event/types/SendEventRequest.ts deleted file mode 100644 index f3f7080..0000000 --- a/src/resources/event/types/SendEventRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface SendEventRequest { - /** event name */ - event: string; - /** - * { - * "param1" : "", - * "param2" : "", - * "param3" : object/array" - * } - * - */ - data: Record; - user?: RavenApi.User; - /** - * Time to send message expressed as UTC milliseconds. - * If not present, message will be sent immediately. - * - */ - scheduleAt?: number; - override?: RavenApi.EventOverride; -} diff --git a/src/resources/event/types/SendEventResponse.ts b/src/resources/event/types/SendEventResponse.ts deleted file mode 100644 index 65afe64..0000000 --- a/src/resources/event/types/SendEventResponse.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface SendEventResponse { - id: RavenApi.RequestId; - success: boolean; -} diff --git a/src/resources/event/types/SlackMessage.ts b/src/resources/event/types/SlackMessage.ts deleted file mode 100644 index 808cab5..0000000 --- a/src/resources/event/types/SlackMessage.ts +++ /dev/null @@ -1,8 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface SlackMessage { - text: string; - blocks?: unknown; -} diff --git a/src/resources/event/types/SmsMessage.ts b/src/resources/event/types/SmsMessage.ts deleted file mode 100644 index 0c18cb2..0000000 --- a/src/resources/event/types/SmsMessage.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface SmsMessage { - text: string; -} diff --git a/src/resources/event/types/User.ts b/src/resources/event/types/User.ts deleted file mode 100644 index 35e96c4..0000000 --- a/src/resources/event/types/User.ts +++ /dev/null @@ -1,33 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface User { - /** - * userId to send the notifications to. - * This is your own user identifier which you have used to create user on Raven - * - */ - userId?: RavenApi.UserId; - email?: string; - /** mobile with country code prefix (e.g +91) */ - mobile?: string; - /** - * mobile with country code prefix (e.g. +91). - * if empty, `mobile` is considered for whatsapp - * - */ - whatsappMobile?: string; - /** [OneSignal external user IDs](https://documentation.onesignal.com/docs/external-user-ids) */ - onesignalExternalId?: string; - onesignalPlayerIds?: string[]; - /** List of fcm tokens. eg. [""] */ - fcmTokens?: string[]; - iosTokens?: string[]; - slack?: RavenApi.SlackProfile; - telegram?: RavenApi.TelegramProfile; - fcmTopic?: string; - fcmDeviceGroup?: string; -} diff --git a/src/resources/ids/types/AppId.ts b/src/resources/ids/types/AppId.ts deleted file mode 100644 index bddc6fc..0000000 --- a/src/resources/ids/types/AppId.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export type AppId = string; - -export function AppId(value: string): RavenApi.AppId { - return value as unknown as RavenApi.AppId; -} diff --git a/src/resources/ids/types/DeviceId.ts b/src/resources/ids/types/DeviceId.ts deleted file mode 100644 index 47f10c4..0000000 --- a/src/resources/ids/types/DeviceId.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export type DeviceId = string; - -export function DeviceId(value: string): RavenApi.DeviceId { - return value as unknown as RavenApi.DeviceId; -} diff --git a/src/resources/ids/types/RequestId.ts b/src/resources/ids/types/RequestId.ts deleted file mode 100644 index abf020f..0000000 --- a/src/resources/ids/types/RequestId.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export type RequestId = string; - -export function RequestId(value: string): RavenApi.RequestId { - return value as unknown as RavenApi.RequestId; -} diff --git a/src/resources/ids/types/UserId.ts b/src/resources/ids/types/UserId.ts deleted file mode 100644 index 97386cf..0000000 --- a/src/resources/ids/types/UserId.ts +++ /dev/null @@ -1,11 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export type UserId = string; - -export function UserId(value: string): RavenApi.UserId { - return value as unknown as RavenApi.UserId; -} diff --git a/src/resources/user/client/Client.ts b/src/resources/user/client/Client.ts deleted file mode 100644 index 5257993..0000000 --- a/src/resources/user/client/Client.ts +++ /dev/null @@ -1,78 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import * as environments from "../../../environments"; -import * as core from "../../../core"; -import { RavenApi } from "@ravenapp/raven"; -import urlJoin from "url-join"; -import * as serializers from "../../../serialization"; - -export declare namespace Client { - interface Options { - environment?: environments.Environment | string; - auth?: { - authorization?: core.Supplier; - }; - } -} - -export class Client { - constructor(private readonly options: Client.Options) {} - - public async createOrUpdate( - request: RavenApi.user.createOrUpdate.Request - ): Promise { - const response = await core.fetcher({ - url: urlJoin(this.options.environment ?? environments.Environment.Prod, `/v1/apps/${request.appId}/users`), - method: "POST", - headers: { - Authorization: await core.Supplier.get(this.options.auth?.authorization), - }, - body: await serializers.CreateUserRequest.json(request._body), - }); - if (response.ok) { - return { - ok: true, - body: await serializers.RavenUser.parse(response.body as serializers.RavenUser.Raw), - }; - } - - return { - ok: false, - error: { - errorName: undefined, - content: response.error, - _visit: (visitor) => visitor._other(response.error), - }, - }; - } - - public async get(request: RavenApi.user.get.Request): Promise { - const response = await core.fetcher({ - url: urlJoin( - this.options.environment ?? environments.Environment.Prod, - `/v1/apps/${request.appId}/users/${request.userId}` - ), - method: "GET", - headers: { - Authorization: await core.Supplier.get(this.options.auth?.authorization), - }, - }); - if (response.ok) { - return { - ok: true, - body: await serializers.RavenUser.parse(response.body as serializers.RavenUser.Raw), - }; - } - - return { - ok: false, - error: { - errorName: undefined, - content: response.error, - _visit: (visitor) => visitor._other(response.error), - }, - }; - } -} diff --git a/src/resources/user/client/createOrUpdate.ts b/src/resources/user/client/createOrUpdate.ts deleted file mode 100644 index 2617c9e..0000000 --- a/src/resources/user/client/createOrUpdate.ts +++ /dev/null @@ -1,29 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export interface Request { - appId: RavenApi.AppId; - _body: RavenApi.CreateUserRequest; -} - -export type Response = core.APIResponse; -export type Error = RavenApi.user.createOrUpdate.Error._Unknown; - -export declare namespace Error { - interface _Unknown extends _Utils { - errorName: void; - content: core.Fetcher.Error; - } - - interface _Utils { - _visit: <_Result>(visitor: RavenApi.user.createOrUpdate.Error._Visitor<_Result>) => _Result; - } - - interface _Visitor<_Result> { - _other: (value: core.Fetcher.Error) => _Result; - } -} diff --git a/src/resources/user/client/get.ts b/src/resources/user/client/get.ts deleted file mode 100644 index 7d96f6d..0000000 --- a/src/resources/user/client/get.ts +++ /dev/null @@ -1,31 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export interface Request { - /** your app identifier */ - appId: RavenApi.AppId; - /** your user identifier */ - userId: RavenApi.UserId; -} - -export type Response = core.APIResponse; -export type Error = RavenApi.user.get.Error._Unknown; - -export declare namespace Error { - interface _Unknown extends _Utils { - errorName: void; - content: core.Fetcher.Error; - } - - interface _Utils { - _visit: <_Result>(visitor: RavenApi.user.get.Error._Visitor<_Result>) => _Result; - } - - interface _Visitor<_Result> { - _other: (value: core.Fetcher.Error) => _Result; - } -} diff --git a/src/resources/user/client/index.ts b/src/resources/user/client/index.ts deleted file mode 100644 index 61aaf54..0000000 --- a/src/resources/user/client/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * as createOrUpdate from "./createOrUpdate"; -export * as get from "./get"; diff --git a/src/resources/user/types/Channel.ts b/src/resources/user/types/Channel.ts deleted file mode 100644 index 677a898..0000000 --- a/src/resources/user/types/Channel.ts +++ /dev/null @@ -1,112 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface Channel { - value: RawValue; - visit: <_Result>(visitor: RavenApi.Channel._Visitor<_Result>) => _Result; -} - -const _Voice: Channel<"VOICE"> = { - value: "VOICE", - visit: (visitor) => visitor.voice(), -}; -const _Push: Channel<"PUSH"> = { - value: "PUSH", - visit: (visitor) => visitor.push(), -}; -const _Sms: Channel<"SMS"> = { - value: "SMS", - visit: (visitor) => visitor.sms(), -}; -const _Email: Channel<"EMAIL"> = { - value: "EMAIL", - visit: (visitor) => visitor.email(), -}; -const _Whatsapp: Channel<"WHATSAPP"> = { - value: "WHATSAPP", - visit: (visitor) => visitor.whatsapp(), -}; -const _Webhook: Channel<"WEBHOOK"> = { - value: "WEBHOOK", - visit: (visitor) => visitor.webhook(), -}; -const _Slack: Channel<"SLACK"> = { - value: "SLACK", - visit: (visitor) => visitor.slack(), -}; -const _InApp: Channel<"IN_APP"> = { - value: "IN_APP", - visit: (visitor) => visitor.inApp(), -}; -const _Telegram: Channel<"TELEGRAM"> = { - value: "TELEGRAM", - visit: (visitor) => visitor.telegram(), -}; -export const Channel = { - Voice: _Voice, - Push: _Push, - Sms: _Sms, - Email: _Email, - Whatsapp: _Whatsapp, - Webhook: _Webhook, - Slack: _Slack, - InApp: _InApp, - Telegram: _Telegram, - _parse: (value: string): Channel => { - switch (value) { - case "VOICE": { - return _Voice; - } - case "PUSH": { - return _Push; - } - case "SMS": { - return _Sms; - } - case "EMAIL": { - return _Email; - } - case "WHATSAPP": { - return _Whatsapp; - } - case "WEBHOOK": { - return _Webhook; - } - case "SLACK": { - return _Slack; - } - case "IN_APP": { - return _InApp; - } - case "TELEGRAM": { - return _Telegram; - } - default: { - return { - value: value as Channel.RawValue, - visit: (visitor) => visitor._other(value), - }; - } - } - }, -} as const; - -export declare namespace Channel { - type RawValue = "VOICE" | "PUSH" | "SMS" | "EMAIL" | "WHATSAPP" | "WEBHOOK" | "SLACK" | "IN_APP" | "TELEGRAM"; - - interface _Visitor<_Result> { - voice: () => _Result; - push: () => _Result; - sms: () => _Result; - email: () => _Result; - whatsapp: () => _Result; - webhook: () => _Result; - slack: () => _Result; - inApp: () => _Result; - telegram: () => _Result; - _other: (value: string) => _Result; - } -} diff --git a/src/resources/user/types/ChannelPreference.ts b/src/resources/user/types/ChannelPreference.ts deleted file mode 100644 index dcb7f83..0000000 --- a/src/resources/user/types/ChannelPreference.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface ChannelPreference { - disabled: boolean; -} diff --git a/src/resources/user/types/ChannelPreferences.ts b/src/resources/user/types/ChannelPreferences.ts deleted file mode 100644 index a9255c9..0000000 --- a/src/resources/user/types/ChannelPreferences.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface ChannelPreferences { - sms?: RavenApi.ChannelPreference; - push?: RavenApi.ChannelPreference; - whatsapp?: RavenApi.ChannelPreference; - email?: RavenApi.ChannelPreference; - slack?: RavenApi.ChannelPreference; - voice?: RavenApi.ChannelPreference; - teams?: RavenApi.ChannelPreference; -} diff --git a/src/resources/user/types/CreateUserRequest.ts b/src/resources/user/types/CreateUserRequest.ts deleted file mode 100644 index 7c1da57..0000000 --- a/src/resources/user/types/CreateUserRequest.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface CreateUserRequest { - /** - * Your user identifier. - * if user_id already exists, user properties will be updated else a new user will be created - * - */ - userId: RavenApi.UserId; - mobile?: string; - email?: string; - /** include this only when user's whatsapp mobile is different than primary mobile */ - whatsApp?: string; -} diff --git a/src/resources/user/types/RavenUser.ts b/src/resources/user/types/RavenUser.ts deleted file mode 100644 index e91468d..0000000 --- a/src/resources/user/types/RavenUser.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface RavenUser { - /** - * Your user identifier. - * If user_id already exists, user properties will be updated else a new user will be created - * - */ - userId: RavenApi.UserId; - userSid?: string; - onesignalExternalId?: string; - mobile?: string; - email?: string; - /** Include this only when user's whatsapp mobile is different than primary mobile */ - whatsappMobile?: string; - slack?: RavenApi.SlackProfile; - telegram?: RavenApi.TelegramProfile; - fcmTokens?: string[]; - onesignalPlayerIds?: string[]; - iosTokens?: string[]; - createdAt?: number; - updatedAt?: number; -} diff --git a/src/resources/user/types/SlackProfile.ts b/src/resources/user/types/SlackProfile.ts deleted file mode 100644 index 0d4b3da..0000000 --- a/src/resources/user/types/SlackProfile.ts +++ /dev/null @@ -1,9 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface SlackProfile { - accessToken: string; - email?: string; - channelId?: string; -} diff --git a/src/resources/user/types/TelegramProfile.ts b/src/resources/user/types/TelegramProfile.ts deleted file mode 100644 index 4424e9e..0000000 --- a/src/resources/user/types/TelegramProfile.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -export interface TelegramProfile { - chatId: string; -} diff --git a/src/resources/user/types/UserPreferences.ts b/src/resources/user/types/UserPreferences.ts deleted file mode 100644 index 33559ac..0000000 --- a/src/resources/user/types/UserPreferences.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; - -export interface UserPreferences { - preferredChannel?: RavenApi.Channel; - channelPreferences?: RavenApi.ChannelPreferences; -} diff --git a/src/serialization/device/types/Device.ts b/src/serialization/device/types/Device.ts deleted file mode 100644 index c52e79f..0000000 --- a/src/serialization/device/types/Device.ts +++ /dev/null @@ -1,44 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const Device: core.schemas.ObjectSchema = core.schemas.object({ - id: core.schemas.string().optional(), - platform: core.schemas.lazy(async () => (await import("../..")).Platform).optional(), - onesignalPlayerId: core.schemas.property("onesignal_player_id", core.schemas.string().optional()), - xiaomiToken: core.schemas.property("xiaomi_token", core.schemas.string().optional()), - oppoToken: core.schemas.property("oppo_token", core.schemas.string().optional()), - vivoToken: core.schemas.property("vivo_token", core.schemas.string().optional()), - huaweiToken: core.schemas.string().optional(), - fcmToken: core.schemas.property("fcm_token", core.schemas.string().optional()), - ravenId: core.schemas.property("raven_id", core.schemas.string().optional()), - deviceSid: core.schemas.property( - "device_sid", - core.schemas.lazy(async () => (await import("../..")).DeviceId).optional() - ), - notificationsDisabled: core.schemas.property("notifications_disabled", core.schemas.boolean().optional()), - createdAt: core.schemas.property("created_at", core.schemas.number().optional()), - updatedAt: core.schemas.property("updated_at", core.schemas.number().optional()), -}); - -export declare namespace Device { - interface Raw { - id?: string | null; - platform?: serializers.Platform.Raw | null; - onesignal_player_id?: string | null; - xiaomi_token?: string | null; - oppo_token?: string | null; - vivo_token?: string | null; - huaweiToken?: string | null; - fcm_token?: string | null; - raven_id?: string | null; - device_sid?: serializers.DeviceId.Raw | null; - notifications_disabled?: boolean | null; - created_at?: number | null; - updated_at?: number | null; - } -} diff --git a/src/serialization/device/types/Platform.ts b/src/serialization/device/types/Platform.ts deleted file mode 100644 index a8ab318..0000000 --- a/src/serialization/device/types/Platform.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const Platform: core.schemas.Schema = core.schemas - .string() - .transform({ - parse: (value) => RavenApi.Platform._parse(value), - json: ({ value }) => value, - }); - -export declare namespace Platform { - type Raw = string; -} diff --git a/src/serialization/event/types/Attachment.ts b/src/serialization/event/types/Attachment.ts deleted file mode 100644 index fa586c0..0000000 --- a/src/serialization/event/types/Attachment.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const Attachment: core.schemas.ObjectSchema = core.schemas.object({ - fileName: core.schemas.property("file_name", core.schemas.string()), - content: core.schemas.string(), - url: core.schemas.string(), -}); - -export declare namespace Attachment { - interface Raw { - file_name: string; - content: string; - url: string; - } -} diff --git a/src/serialization/event/types/BatchEvent.ts b/src/serialization/event/types/BatchEvent.ts deleted file mode 100644 index 158ed63..0000000 --- a/src/serialization/event/types/BatchEvent.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const BatchEvent: core.schemas.ObjectSchema = core.schemas.object({ - data: core.schemas.record(core.schemas.string(), core.schemas.unknown()), - user: core.schemas.lazyObject(async () => (await import("../..")).User).optional(), - override: core.schemas.lazyObject(async () => (await import("../..")).EventOverride).optional(), -}); - -export declare namespace BatchEvent { - interface Raw { - data: Record; - user?: serializers.User.Raw | null; - override?: serializers.EventOverride.Raw | null; - } -} diff --git a/src/serialization/event/types/BulkSendEventRequest.ts b/src/serialization/event/types/BulkSendEventRequest.ts deleted file mode 100644 index d9de5c3..0000000 --- a/src/serialization/event/types/BulkSendEventRequest.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const BulkSendEventRequest: core.schemas.ObjectSchema = - core.schemas.object({ - event: core.schemas.string(), - batch: core.schemas.list(core.schemas.lazyObject(async () => (await import("../..")).BatchEvent)), - }); - -export declare namespace BulkSendEventRequest { - interface Raw { - event: string; - batch: serializers.BatchEvent.Raw[]; - } -} diff --git a/src/serialization/event/types/ChannelOverride.ts b/src/serialization/event/types/ChannelOverride.ts deleted file mode 100644 index cbb6b42..0000000 --- a/src/serialization/event/types/ChannelOverride.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const ChannelOverride: core.schemas.ObjectSchema = - core.schemas.object({ - scheduleAt: core.schemas.property("schedule_at", core.schemas.number()), - }); - -export declare namespace ChannelOverride { - interface Raw { - schedule_at: number; - } -} diff --git a/src/serialization/event/types/EmailMessage.ts b/src/serialization/event/types/EmailMessage.ts deleted file mode 100644 index b217530..0000000 --- a/src/serialization/event/types/EmailMessage.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const EmailMessage: core.schemas.ObjectSchema = core.schemas.object({ - text: core.schemas.string(), - htmlBody: core.schemas.property("html_body", core.schemas.string()), - subject: core.schemas.string(), -}); - -export declare namespace EmailMessage { - interface Raw { - text: string; - html_body: string; - subject: string; - } -} diff --git a/src/serialization/event/types/EmailOverride.ts b/src/serialization/event/types/EmailOverride.ts deleted file mode 100644 index acbb2f0..0000000 --- a/src/serialization/event/types/EmailOverride.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const EmailOverride: core.schemas.ObjectSchema = core.schemas - .object({ - from: core.schemas.lazyObject(async () => (await import("../..")).EmailRecipient), - cc: core.schemas.list(core.schemas.lazyObject(async () => (await import("../..")).EmailRecipient)), - bcc: core.schemas.list(core.schemas.lazyObject(async () => (await import("../..")).EmailRecipient)), - attachments: core.schemas.list(core.schemas.lazyObject(async () => (await import("../..")).Attachment)), - message: core.schemas.lazyObject(async () => (await import("../..")).EmailMessage), - }) - .extend(core.schemas.lazyObject(async () => (await import("../..")).ChannelOverride)); - -export declare namespace EmailOverride { - interface Raw extends serializers.ChannelOverride.Raw { - from: serializers.EmailRecipient.Raw; - cc: serializers.EmailRecipient.Raw[]; - bcc: serializers.EmailRecipient.Raw[]; - attachments: serializers.Attachment.Raw[]; - message: serializers.EmailMessage.Raw; - } -} diff --git a/src/serialization/event/types/EmailRecipient.ts b/src/serialization/event/types/EmailRecipient.ts deleted file mode 100644 index 54fd371..0000000 --- a/src/serialization/event/types/EmailRecipient.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const EmailRecipient: core.schemas.ObjectSchema = - core.schemas.object({ - name: core.schemas.string(), - address: core.schemas.string(), - }); - -export declare namespace EmailRecipient { - interface Raw { - name: string; - address: string; - } -} diff --git a/src/serialization/event/types/EventOverride.ts b/src/serialization/event/types/EventOverride.ts deleted file mode 100644 index 74dafc6..0000000 --- a/src/serialization/event/types/EventOverride.ts +++ /dev/null @@ -1,41 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const EventOverride: core.schemas.ObjectSchema = core.schemas.object({ - email: core.schemas.lazyObject(async () => (await import("../..")).EmailOverride).optional(), - sms: core.schemas.lazyObject(async () => (await import("../..")).SmsOverride).optional(), - whatsapp: core.schemas.lazyObject(async () => (await import("../..")).WhatsappOverride).optional(), - push: core.schemas.lazyObject(async () => (await import("../..")).PushOverride).optional(), - webhook: core.schemas.lazyObject(async () => (await import("../..")).WebhookOverride).optional(), - voice: core.schemas.lazyObject(async () => (await import("../..")).VoiceOverride).optional(), - slack: core.schemas.lazyObject(async () => (await import("../..")).SlackOverride).optional(), - inApp: core.schemas.property( - "in_app", - core.schemas.lazyObject(async () => (await import("../..")).InAppOverride).optional() - ), - telegram: core.schemas.lazyObject(async () => (await import("../..")).TelegramOverride).optional(), - providers: core.schemas.record( - core.schemas.string(), - core.schemas.lazyObject(async () => (await import("../..")).ProviderOverride) - ), -}); - -export declare namespace EventOverride { - interface Raw { - email?: serializers.EmailOverride.Raw | null; - sms?: serializers.SmsOverride.Raw | null; - whatsapp?: serializers.WhatsappOverride.Raw | null; - push?: serializers.PushOverride.Raw | null; - webhook?: serializers.WebhookOverride.Raw | null; - voice?: serializers.VoiceOverride.Raw | null; - slack?: serializers.SlackOverride.Raw | null; - in_app?: serializers.InAppOverride.Raw | null; - telegram?: serializers.TelegramOverride.Raw | null; - providers: Record; - } -} diff --git a/src/serialization/event/types/InAppOverride.ts b/src/serialization/event/types/InAppOverride.ts deleted file mode 100644 index 56acf70..0000000 --- a/src/serialization/event/types/InAppOverride.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const InAppOverride: core.schemas.ObjectSchema = core.schemas - .object({}) - .extend(core.schemas.lazyObject(async () => (await import("../..")).ChannelOverride)); - -export declare namespace InAppOverride { - interface Raw extends serializers.ChannelOverride.Raw {} -} diff --git a/src/serialization/event/types/Param.ts b/src/serialization/event/types/Param.ts deleted file mode 100644 index 728820f..0000000 --- a/src/serialization/event/types/Param.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const Param: core.schemas.ObjectSchema = core.schemas.object({ - name: core.schemas.string(), - value: core.schemas.string(), -}); - -export declare namespace Param { - interface Raw { - name: string; - value: string; - } -} diff --git a/src/serialization/event/types/ProviderOverride.ts b/src/serialization/event/types/ProviderOverride.ts deleted file mode 100644 index 48331db..0000000 --- a/src/serialization/event/types/ProviderOverride.ts +++ /dev/null @@ -1,35 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const ProviderOverride: core.schemas.ObjectSchema = - core.schemas.object({ - payload: core.schemas.record(core.schemas.string(), core.schemas.unknown()), - formParams: core.schemas.property( - "form_params", - core.schemas.list(core.schemas.lazyObject(async () => (await import("../..")).Param)) - ), - queryParams: core.schemas.property( - "query_params", - core.schemas.list(core.schemas.lazyObject(async () => (await import("../..")).Param)) - ), - pathParams: core.schemas.property( - "path_params", - core.schemas.list(core.schemas.lazyObject(async () => (await import("../..")).Param)) - ), - headers: core.schemas.list(core.schemas.lazyObject(async () => (await import("../..")).Param)), - }); - -export declare namespace ProviderOverride { - interface Raw { - payload: Record; - form_params: serializers.Param.Raw[]; - query_params: serializers.Param.Raw[]; - path_params: serializers.Param.Raw[]; - headers: serializers.Param.Raw[]; - } -} diff --git a/src/serialization/event/types/PushOverride.ts b/src/serialization/event/types/PushOverride.ts deleted file mode 100644 index 782f9e1..0000000 --- a/src/serialization/event/types/PushOverride.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const PushOverride: core.schemas.ObjectSchema = core.schemas - .object({}) - .extend(core.schemas.lazyObject(async () => (await import("../..")).ChannelOverride)); - -export declare namespace PushOverride { - interface Raw extends serializers.ChannelOverride.Raw {} -} diff --git a/src/serialization/event/types/SendEventRequest.ts b/src/serialization/event/types/SendEventRequest.ts deleted file mode 100644 index 6a6df14..0000000 --- a/src/serialization/event/types/SendEventRequest.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const SendEventRequest: core.schemas.ObjectSchema = - core.schemas.object({ - event: core.schemas.string(), - data: core.schemas.record(core.schemas.string(), core.schemas.unknown()), - user: core.schemas.lazyObject(async () => (await import("../..")).User).optional(), - scheduleAt: core.schemas.number().optional(), - override: core.schemas.lazyObject(async () => (await import("../..")).EventOverride).optional(), - }); - -export declare namespace SendEventRequest { - interface Raw { - event: string; - data: Record; - user?: serializers.User.Raw | null; - scheduleAt?: number | null; - override?: serializers.EventOverride.Raw | null; - } -} diff --git a/src/serialization/event/types/SendEventResponse.ts b/src/serialization/event/types/SendEventResponse.ts deleted file mode 100644 index 91779e9..0000000 --- a/src/serialization/event/types/SendEventResponse.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const SendEventResponse: core.schemas.ObjectSchema = - core.schemas.object({ - id: core.schemas.lazy(async () => (await import("../..")).RequestId), - success: core.schemas.boolean(), - }); - -export declare namespace SendEventResponse { - interface Raw { - id: serializers.RequestId.Raw; - success: boolean; - } -} diff --git a/src/serialization/event/types/SlackMessage.ts b/src/serialization/event/types/SlackMessage.ts deleted file mode 100644 index b07f0e3..0000000 --- a/src/serialization/event/types/SlackMessage.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const SlackMessage: core.schemas.ObjectSchema = core.schemas.object({ - text: core.schemas.string(), - blocks: core.schemas.unknown(), -}); - -export declare namespace SlackMessage { - interface Raw { - text: string; - blocks?: unknown; - } -} diff --git a/src/serialization/event/types/SlackOverride.ts b/src/serialization/event/types/SlackOverride.ts deleted file mode 100644 index 013e14d..0000000 --- a/src/serialization/event/types/SlackOverride.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const SlackOverride: core.schemas.ObjectSchema = core.schemas - .object({ - message: core.schemas.lazyObject(async () => (await import("../..")).SlackMessage), - }) - .extend(core.schemas.lazyObject(async () => (await import("../..")).ChannelOverride)); - -export declare namespace SlackOverride { - interface Raw extends serializers.ChannelOverride.Raw { - message: serializers.SlackMessage.Raw; - } -} diff --git a/src/serialization/event/types/SmsMessage.ts b/src/serialization/event/types/SmsMessage.ts deleted file mode 100644 index 89fae16..0000000 --- a/src/serialization/event/types/SmsMessage.ts +++ /dev/null @@ -1,16 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const SmsMessage: core.schemas.ObjectSchema = core.schemas.object({ - text: core.schemas.string(), -}); - -export declare namespace SmsMessage { - interface Raw { - text: string; - } -} diff --git a/src/serialization/event/types/SmsOverride.ts b/src/serialization/event/types/SmsOverride.ts deleted file mode 100644 index 2cef4ea..0000000 --- a/src/serialization/event/types/SmsOverride.ts +++ /dev/null @@ -1,21 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const SmsOverride: core.schemas.ObjectSchema = core.schemas - .object({ - sender: core.schemas.string(), - message: core.schemas.lazyObject(async () => (await import("../..")).SmsMessage), - }) - .extend(core.schemas.lazyObject(async () => (await import("../..")).ChannelOverride)); - -export declare namespace SmsOverride { - interface Raw extends serializers.ChannelOverride.Raw { - sender: string; - message: serializers.SmsMessage.Raw; - } -} diff --git a/src/serialization/event/types/TelegramOverride.ts b/src/serialization/event/types/TelegramOverride.ts deleted file mode 100644 index f4dea73..0000000 --- a/src/serialization/event/types/TelegramOverride.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const TelegramOverride: core.schemas.ObjectSchema = core.schemas - .object({}) - .extend(core.schemas.lazyObject(async () => (await import("../..")).ChannelOverride)); - -export declare namespace TelegramOverride { - interface Raw extends serializers.ChannelOverride.Raw {} -} diff --git a/src/serialization/event/types/User.ts b/src/serialization/event/types/User.ts deleted file mode 100644 index da9958a..0000000 --- a/src/serialization/event/types/User.ts +++ /dev/null @@ -1,42 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const User: core.schemas.ObjectSchema = core.schemas.object({ - userId: core.schemas.property("user_id", core.schemas.lazy(async () => (await import("../..")).UserId).optional()), - email: core.schemas.string().optional(), - mobile: core.schemas.string().optional(), - whatsappMobile: core.schemas.property("whatsapp_mobile", core.schemas.string().optional()), - onesignalExternalId: core.schemas.property("onesignal_external_id", core.schemas.string().optional()), - onesignalPlayerIds: core.schemas.property( - "onesignal_player_ids", - core.schemas.list(core.schemas.string()).optional() - ), - fcmTokens: core.schemas.property("fcm_tokens", core.schemas.list(core.schemas.string()).optional()), - iosTokens: core.schemas.property("ios_tokens", core.schemas.list(core.schemas.string()).optional()), - slack: core.schemas.lazyObject(async () => (await import("../..")).SlackProfile).optional(), - telegram: core.schemas.lazyObject(async () => (await import("../..")).TelegramProfile).optional(), - fcmTopic: core.schemas.property("fcm_topic", core.schemas.string().optional()), - fcmDeviceGroup: core.schemas.property("fcm_device_group", core.schemas.string().optional()), -}); - -export declare namespace User { - interface Raw { - user_id?: serializers.UserId.Raw | null; - email?: string | null; - mobile?: string | null; - whatsapp_mobile?: string | null; - onesignal_external_id?: string | null; - onesignal_player_ids?: string[] | null; - fcm_tokens?: string[] | null; - ios_tokens?: string[] | null; - slack?: serializers.SlackProfile.Raw | null; - telegram?: serializers.TelegramProfile.Raw | null; - fcm_topic?: string | null; - fcm_device_group?: string | null; - } -} diff --git a/src/serialization/event/types/VoiceOverride.ts b/src/serialization/event/types/VoiceOverride.ts deleted file mode 100644 index 2a6254d..0000000 --- a/src/serialization/event/types/VoiceOverride.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const VoiceOverride: core.schemas.ObjectSchema = core.schemas - .object({}) - .extend(core.schemas.lazyObject(async () => (await import("../..")).ChannelOverride)); - -export declare namespace VoiceOverride { - interface Raw extends serializers.ChannelOverride.Raw {} -} diff --git a/src/serialization/event/types/WebhookOverride.ts b/src/serialization/event/types/WebhookOverride.ts deleted file mode 100644 index ce8be4d..0000000 --- a/src/serialization/event/types/WebhookOverride.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const WebhookOverride: core.schemas.ObjectSchema = core.schemas - .object({}) - .extend(core.schemas.lazyObject(async () => (await import("../..")).ChannelOverride)); - -export declare namespace WebhookOverride { - interface Raw extends serializers.ChannelOverride.Raw {} -} diff --git a/src/serialization/event/types/WhatsappOverride.ts b/src/serialization/event/types/WhatsappOverride.ts deleted file mode 100644 index 160e5c4..0000000 --- a/src/serialization/event/types/WhatsappOverride.ts +++ /dev/null @@ -1,19 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const WhatsappOverride: core.schemas.ObjectSchema = core.schemas - .object({ - message: core.schemas.lazyObject(async () => (await import("../..")).SmsMessage), - }) - .extend(core.schemas.lazyObject(async () => (await import("../..")).ChannelOverride)); - -export declare namespace WhatsappOverride { - interface Raw extends serializers.ChannelOverride.Raw { - message: serializers.SmsMessage.Raw; - } -} diff --git a/src/serialization/ids/index.ts b/src/serialization/ids/index.ts deleted file mode 100644 index eea524d..0000000 --- a/src/serialization/ids/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types"; diff --git a/src/serialization/ids/types/AppId.ts b/src/serialization/ids/types/AppId.ts deleted file mode 100644 index 42ebb03..0000000 --- a/src/serialization/ids/types/AppId.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const AppId: core.schemas.Schema = core.schemas.string(); - -export declare namespace AppId { - type Raw = string; -} diff --git a/src/serialization/ids/types/DeviceId.ts b/src/serialization/ids/types/DeviceId.ts deleted file mode 100644 index 8cd04ea..0000000 --- a/src/serialization/ids/types/DeviceId.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const DeviceId: core.schemas.Schema = core.schemas.string(); - -export declare namespace DeviceId { - type Raw = string; -} diff --git a/src/serialization/ids/types/RequestId.ts b/src/serialization/ids/types/RequestId.ts deleted file mode 100644 index 0a2825a..0000000 --- a/src/serialization/ids/types/RequestId.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const RequestId: core.schemas.Schema = core.schemas.string(); - -export declare namespace RequestId { - type Raw = string; -} diff --git a/src/serialization/ids/types/UserId.ts b/src/serialization/ids/types/UserId.ts deleted file mode 100644 index 32219ae..0000000 --- a/src/serialization/ids/types/UserId.ts +++ /dev/null @@ -1,12 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const UserId: core.schemas.Schema = core.schemas.string(); - -export declare namespace UserId { - type Raw = string; -} diff --git a/src/serialization/index.ts b/src/serialization/index.ts index cde086e..3e5335f 100644 --- a/src/serialization/index.ts +++ b/src/serialization/index.ts @@ -1,8 +1 @@ -export * as device from "./device"; -export * from "./device/types"; -export * as event from "./event"; -export * from "./event/types"; -export * as ids from "./ids"; -export * from "./ids/types"; -export * as user from "./user"; -export * from "./user/types"; +export * from "./resources"; diff --git a/src/serialization/device/index.ts b/src/serialization/resources/device/index.ts similarity index 100% rename from src/serialization/device/index.ts rename to src/serialization/resources/device/index.ts diff --git a/src/serialization/resources/device/types/Device.ts b/src/serialization/resources/device/types/Device.ts new file mode 100644 index 0000000..c013d57 --- /dev/null +++ b/src/serialization/resources/device/types/Device.ts @@ -0,0 +1,48 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const Device: core.serialization.ObjectSchema = + core.serialization.object({ + id: core.serialization.string().optional(), + platform: core.serialization.lazy(async () => (await import("../../..")).Platform).optional(), + onesignalPlayerId: core.serialization.property("onesignal_player_id", core.serialization.string().optional()), + xiaomiToken: core.serialization.property("xiaomi_token", core.serialization.string().optional()), + oppoToken: core.serialization.property("oppo_token", core.serialization.string().optional()), + vivoToken: core.serialization.property("vivo_token", core.serialization.string().optional()), + huaweiToken: core.serialization.string().optional(), + fcmToken: core.serialization.property("fcm_token", core.serialization.string().optional()), + ravenId: core.serialization.property("raven_id", core.serialization.string().optional()), + deviceSid: core.serialization.property( + "device_sid", + core.serialization.lazy(async () => (await import("../../..")).DeviceId).optional() + ), + notificationsDisabled: core.serialization.property( + "notifications_disabled", + core.serialization.boolean().optional() + ), + createdAt: core.serialization.property("created_at", core.serialization.number().optional()), + updatedAt: core.serialization.property("updated_at", core.serialization.number().optional()), + }); + +export declare namespace Device { + interface Raw { + id?: string | null; + platform?: serializers.Platform.Raw | null; + onesignal_player_id?: string | null; + xiaomi_token?: string | null; + oppo_token?: string | null; + vivo_token?: string | null; + huaweiToken?: string | null; + fcm_token?: string | null; + raven_id?: string | null; + device_sid?: serializers.DeviceId.Raw | null; + notifications_disabled?: boolean | null; + created_at?: number | null; + updated_at?: number | null; + } +} diff --git a/src/serialization/resources/device/types/Platform.ts b/src/serialization/resources/device/types/Platform.ts new file mode 100644 index 0000000..abcc7e6 --- /dev/null +++ b/src/serialization/resources/device/types/Platform.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const Platform: core.serialization.Schema = + core.serialization.enum_(["android", "web", "ios"]); + +export declare namespace Platform { + type Raw = "android" | "web" | "ios"; +} diff --git a/src/serialization/device/types/index.ts b/src/serialization/resources/device/types/index.ts similarity index 100% rename from src/serialization/device/types/index.ts rename to src/serialization/resources/device/types/index.ts diff --git a/src/serialization/resources/event/client/index.ts b/src/serialization/resources/event/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/serialization/resources/event/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/serialization/resources/event/client/requests/BulkSendEventRequest.ts b/src/serialization/resources/event/client/requests/BulkSendEventRequest.ts new file mode 100644 index 0000000..7162695 --- /dev/null +++ b/src/serialization/resources/event/client/requests/BulkSendEventRequest.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../../core"; + +export const BulkSendEventRequest: core.serialization.Schema< + serializers.BulkSendEventRequest.Raw, + Omit +> = core.serialization.object({ + event: core.serialization.string(), + batch: core.serialization.list(core.serialization.lazyObject(async () => (await import("../../../..")).BatchEvent)), +}); + +export declare namespace BulkSendEventRequest { + interface Raw { + event: string; + batch: serializers.BatchEvent.Raw[]; + } +} diff --git a/src/serialization/resources/event/client/requests/SendEventRequest.ts b/src/serialization/resources/event/client/requests/SendEventRequest.ts new file mode 100644 index 0000000..dd9e0d1 --- /dev/null +++ b/src/serialization/resources/event/client/requests/SendEventRequest.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../../core"; + +export const SendEventRequest: core.serialization.Schema< + serializers.SendEventRequest.Raw, + Omit +> = core.serialization.object({ + event: core.serialization.string(), + data: core.serialization.record(core.serialization.string(), core.serialization.unknown()), + user: core.serialization.lazyObject(async () => (await import("../../../..")).User).optional(), + scheduleAt: core.serialization.number().optional(), + override: core.serialization.lazyObject(async () => (await import("../../../..")).EventOverride).optional(), +}); + +export declare namespace SendEventRequest { + interface Raw { + event: string; + data: Record; + user?: serializers.User.Raw | null; + scheduleAt?: number | null; + override?: serializers.EventOverride.Raw | null; + } +} diff --git a/src/serialization/resources/event/client/requests/index.ts b/src/serialization/resources/event/client/requests/index.ts new file mode 100644 index 0000000..6862919 --- /dev/null +++ b/src/serialization/resources/event/client/requests/index.ts @@ -0,0 +1,2 @@ +export { SendEventRequest } from "./SendEventRequest"; +export { BulkSendEventRequest } from "./BulkSendEventRequest"; diff --git a/src/resources/user/index.ts b/src/serialization/resources/event/index.ts similarity index 100% rename from src/resources/user/index.ts rename to src/serialization/resources/event/index.ts diff --git a/src/serialization/resources/event/types/Attachment.ts b/src/serialization/resources/event/types/Attachment.ts new file mode 100644 index 0000000..c046b68 --- /dev/null +++ b/src/serialization/resources/event/types/Attachment.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const Attachment: core.serialization.ObjectSchema = + core.serialization.object({ + fileName: core.serialization.property("file_name", core.serialization.string()), + content: core.serialization.string(), + url: core.serialization.string(), + }); + +export declare namespace Attachment { + interface Raw { + file_name: string; + content: string; + url: string; + } +} diff --git a/src/serialization/resources/event/types/BatchEvent.ts b/src/serialization/resources/event/types/BatchEvent.ts new file mode 100644 index 0000000..6e54ff1 --- /dev/null +++ b/src/serialization/resources/event/types/BatchEvent.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const BatchEvent: core.serialization.ObjectSchema = + core.serialization.object({ + data: core.serialization.record(core.serialization.string(), core.serialization.unknown()), + user: core.serialization.lazyObject(async () => (await import("../../..")).User).optional(), + override: core.serialization.lazyObject(async () => (await import("../../..")).EventOverride).optional(), + }); + +export declare namespace BatchEvent { + interface Raw { + data: Record; + user?: serializers.User.Raw | null; + override?: serializers.EventOverride.Raw | null; + } +} diff --git a/src/serialization/resources/event/types/ChannelOverride.ts b/src/serialization/resources/event/types/ChannelOverride.ts new file mode 100644 index 0000000..730f36a --- /dev/null +++ b/src/serialization/resources/event/types/ChannelOverride.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const ChannelOverride: core.serialization.ObjectSchema< + serializers.ChannelOverride.Raw, + RavenApi.ChannelOverride +> = core.serialization.object({ + scheduleAt: core.serialization.property("schedule_at", core.serialization.number()), +}); + +export declare namespace ChannelOverride { + interface Raw { + schedule_at: number; + } +} diff --git a/src/serialization/resources/event/types/EmailMessage.ts b/src/serialization/resources/event/types/EmailMessage.ts new file mode 100644 index 0000000..2345054 --- /dev/null +++ b/src/serialization/resources/event/types/EmailMessage.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const EmailMessage: core.serialization.ObjectSchema = + core.serialization.object({ + text: core.serialization.string(), + htmlBody: core.serialization.property("html_body", core.serialization.string()), + subject: core.serialization.string(), + }); + +export declare namespace EmailMessage { + interface Raw { + text: string; + html_body: string; + subject: string; + } +} diff --git a/src/serialization/resources/event/types/EmailOverride.ts b/src/serialization/resources/event/types/EmailOverride.ts new file mode 100644 index 0000000..5d54301 --- /dev/null +++ b/src/serialization/resources/event/types/EmailOverride.ts @@ -0,0 +1,34 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const EmailOverride: core.serialization.ObjectSchema = + core.serialization + .object({ + from: core.serialization.lazyObject(async () => (await import("../../..")).EmailRecipient), + cc: core.serialization.list( + core.serialization.lazyObject(async () => (await import("../../..")).EmailRecipient) + ), + bcc: core.serialization.list( + core.serialization.lazyObject(async () => (await import("../../..")).EmailRecipient) + ), + attachments: core.serialization.list( + core.serialization.lazyObject(async () => (await import("../../..")).Attachment) + ), + message: core.serialization.lazyObject(async () => (await import("../../..")).EmailMessage), + }) + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ChannelOverride)); + +export declare namespace EmailOverride { + interface Raw extends serializers.ChannelOverride.Raw { + from: serializers.EmailRecipient.Raw; + cc: serializers.EmailRecipient.Raw[]; + bcc: serializers.EmailRecipient.Raw[]; + attachments: serializers.Attachment.Raw[]; + message: serializers.EmailMessage.Raw; + } +} diff --git a/src/serialization/resources/event/types/EmailRecipient.ts b/src/serialization/resources/event/types/EmailRecipient.ts new file mode 100644 index 0000000..fa16068 --- /dev/null +++ b/src/serialization/resources/event/types/EmailRecipient.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const EmailRecipient: core.serialization.ObjectSchema = + core.serialization.object({ + name: core.serialization.string(), + address: core.serialization.string(), + }); + +export declare namespace EmailRecipient { + interface Raw { + name: string; + address: string; + } +} diff --git a/src/serialization/resources/event/types/EventNotFoundErrorBody.ts b/src/serialization/resources/event/types/EventNotFoundErrorBody.ts new file mode 100644 index 0000000..2945dbc --- /dev/null +++ b/src/serialization/resources/event/types/EventNotFoundErrorBody.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const EventNotFoundErrorBody: core.serialization.ObjectSchema< + serializers.EventNotFoundErrorBody.Raw, + RavenApi.EventNotFoundErrorBody +> = core.serialization.object({ + success: core.serialization.boolean(), + error: core.serialization.string(), +}); + +export declare namespace EventNotFoundErrorBody { + interface Raw { + success: boolean; + error: string; + } +} diff --git a/src/serialization/resources/event/types/EventOverride.ts b/src/serialization/resources/event/types/EventOverride.ts new file mode 100644 index 0000000..fa89567 --- /dev/null +++ b/src/serialization/resources/event/types/EventOverride.ts @@ -0,0 +1,42 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const EventOverride: core.serialization.ObjectSchema = + core.serialization.object({ + email: core.serialization.lazyObject(async () => (await import("../../..")).EmailOverride).optional(), + sms: core.serialization.lazyObject(async () => (await import("../../..")).SmsOverride).optional(), + whatsapp: core.serialization.lazyObject(async () => (await import("../../..")).WhatsappOverride).optional(), + push: core.serialization.lazyObject(async () => (await import("../../..")).PushOverride).optional(), + webhook: core.serialization.lazyObject(async () => (await import("../../..")).WebhookOverride).optional(), + voice: core.serialization.lazyObject(async () => (await import("../../..")).VoiceOverride).optional(), + slack: core.serialization.lazyObject(async () => (await import("../../..")).SlackOverride).optional(), + inApp: core.serialization.property( + "in_app", + core.serialization.lazyObject(async () => (await import("../../..")).InAppOverride).optional() + ), + telegram: core.serialization.lazyObject(async () => (await import("../../..")).TelegramOverride).optional(), + providers: core.serialization.record( + core.serialization.string(), + core.serialization.lazyObject(async () => (await import("../../..")).ProviderOverride) + ), + }); + +export declare namespace EventOverride { + interface Raw { + email?: serializers.EmailOverride.Raw | null; + sms?: serializers.SmsOverride.Raw | null; + whatsapp?: serializers.WhatsappOverride.Raw | null; + push?: serializers.PushOverride.Raw | null; + webhook?: serializers.WebhookOverride.Raw | null; + voice?: serializers.VoiceOverride.Raw | null; + slack?: serializers.SlackOverride.Raw | null; + in_app?: serializers.InAppOverride.Raw | null; + telegram?: serializers.TelegramOverride.Raw | null; + providers: Record; + } +} diff --git a/src/serialization/resources/event/types/InAppOverride.ts b/src/serialization/resources/event/types/InAppOverride.ts new file mode 100644 index 0000000..ba003df --- /dev/null +++ b/src/serialization/resources/event/types/InAppOverride.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const InAppOverride: core.serialization.ObjectSchema = + core.serialization + .object({}) + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ChannelOverride)); + +export declare namespace InAppOverride { + interface Raw extends serializers.ChannelOverride.Raw {} +} diff --git a/src/serialization/resources/event/types/Param.ts b/src/serialization/resources/event/types/Param.ts new file mode 100644 index 0000000..1eb9572 --- /dev/null +++ b/src/serialization/resources/event/types/Param.ts @@ -0,0 +1,19 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const Param: core.serialization.ObjectSchema = core.serialization.object({ + name: core.serialization.string(), + value: core.serialization.string(), +}); + +export declare namespace Param { + interface Raw { + name: string; + value: string; + } +} diff --git a/src/serialization/resources/event/types/ProviderOverride.ts b/src/serialization/resources/event/types/ProviderOverride.ts new file mode 100644 index 0000000..0699c3d --- /dev/null +++ b/src/serialization/resources/event/types/ProviderOverride.ts @@ -0,0 +1,37 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const ProviderOverride: core.serialization.ObjectSchema< + serializers.ProviderOverride.Raw, + RavenApi.ProviderOverride +> = core.serialization.object({ + payload: core.serialization.record(core.serialization.string(), core.serialization.unknown()), + formParams: core.serialization.property( + "form_params", + core.serialization.list(core.serialization.lazyObject(async () => (await import("../../..")).Param)) + ), + queryParams: core.serialization.property( + "query_params", + core.serialization.list(core.serialization.lazyObject(async () => (await import("../../..")).Param)) + ), + pathParams: core.serialization.property( + "path_params", + core.serialization.list(core.serialization.lazyObject(async () => (await import("../../..")).Param)) + ), + headers: core.serialization.list(core.serialization.lazyObject(async () => (await import("../../..")).Param)), +}); + +export declare namespace ProviderOverride { + interface Raw { + payload: Record; + form_params: serializers.Param.Raw[]; + query_params: serializers.Param.Raw[]; + path_params: serializers.Param.Raw[]; + headers: serializers.Param.Raw[]; + } +} diff --git a/src/serialization/resources/event/types/PushOverride.ts b/src/serialization/resources/event/types/PushOverride.ts new file mode 100644 index 0000000..2a188f7 --- /dev/null +++ b/src/serialization/resources/event/types/PushOverride.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const PushOverride: core.serialization.ObjectSchema = + core.serialization + .object({}) + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ChannelOverride)); + +export declare namespace PushOverride { + interface Raw extends serializers.ChannelOverride.Raw {} +} diff --git a/src/serialization/resources/event/types/SendEventResponse.ts b/src/serialization/resources/event/types/SendEventResponse.ts new file mode 100644 index 0000000..19bc140 --- /dev/null +++ b/src/serialization/resources/event/types/SendEventResponse.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const SendEventResponse: core.serialization.ObjectSchema< + serializers.SendEventResponse.Raw, + RavenApi.SendEventResponse +> = core.serialization.object({ + id: core.serialization.lazy(async () => (await import("../../..")).RequestId), + success: core.serialization.boolean(), +}); + +export declare namespace SendEventResponse { + interface Raw { + id: serializers.RequestId.Raw; + success: boolean; + } +} diff --git a/src/serialization/resources/event/types/SlackMessage.ts b/src/serialization/resources/event/types/SlackMessage.ts new file mode 100644 index 0000000..727f2a7 --- /dev/null +++ b/src/serialization/resources/event/types/SlackMessage.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const SlackMessage: core.serialization.ObjectSchema = + core.serialization.object({ + text: core.serialization.string(), + blocks: core.serialization.unknown(), + }); + +export declare namespace SlackMessage { + interface Raw { + text: string; + blocks?: unknown; + } +} diff --git a/src/serialization/resources/event/types/SlackOverride.ts b/src/serialization/resources/event/types/SlackOverride.ts new file mode 100644 index 0000000..73a6025 --- /dev/null +++ b/src/serialization/resources/event/types/SlackOverride.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const SlackOverride: core.serialization.ObjectSchema = + core.serialization + .object({ + message: core.serialization.lazyObject(async () => (await import("../../..")).SlackMessage), + }) + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ChannelOverride)); + +export declare namespace SlackOverride { + interface Raw extends serializers.ChannelOverride.Raw { + message: serializers.SlackMessage.Raw; + } +} diff --git a/src/serialization/resources/event/types/SmsMessage.ts b/src/serialization/resources/event/types/SmsMessage.ts new file mode 100644 index 0000000..79a5b2b --- /dev/null +++ b/src/serialization/resources/event/types/SmsMessage.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const SmsMessage: core.serialization.ObjectSchema = + core.serialization.object({ + text: core.serialization.string(), + }); + +export declare namespace SmsMessage { + interface Raw { + text: string; + } +} diff --git a/src/serialization/resources/event/types/SmsOverride.ts b/src/serialization/resources/event/types/SmsOverride.ts new file mode 100644 index 0000000..d4a290d --- /dev/null +++ b/src/serialization/resources/event/types/SmsOverride.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const SmsOverride: core.serialization.ObjectSchema = + core.serialization + .object({ + sender: core.serialization.string(), + message: core.serialization.lazyObject(async () => (await import("../../..")).SmsMessage), + }) + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ChannelOverride)); + +export declare namespace SmsOverride { + interface Raw extends serializers.ChannelOverride.Raw { + sender: string; + message: serializers.SmsMessage.Raw; + } +} diff --git a/src/serialization/resources/event/types/TelegramOverride.ts b/src/serialization/resources/event/types/TelegramOverride.ts new file mode 100644 index 0000000..7092732 --- /dev/null +++ b/src/serialization/resources/event/types/TelegramOverride.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const TelegramOverride: core.serialization.ObjectSchema< + serializers.TelegramOverride.Raw, + RavenApi.TelegramOverride +> = core.serialization + .object({}) + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ChannelOverride)); + +export declare namespace TelegramOverride { + interface Raw extends serializers.ChannelOverride.Raw {} +} diff --git a/src/serialization/resources/event/types/User.ts b/src/serialization/resources/event/types/User.ts new file mode 100644 index 0000000..05799e1 --- /dev/null +++ b/src/serialization/resources/event/types/User.ts @@ -0,0 +1,51 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const User: core.serialization.ObjectSchema = core.serialization.object({ + userId: core.serialization.property( + "user_id", + core.serialization.lazy(async () => (await import("../../..")).UserId).optional() + ), + email: core.serialization.string().optional(), + mobile: core.serialization.string().optional(), + whatsappMobile: core.serialization.property("whatsapp_mobile", core.serialization.string().optional()), + onesignalExternalId: core.serialization.property("onesignal_external_id", core.serialization.string().optional()), + onesignalPlayerIds: core.serialization.property( + "onesignal_player_ids", + core.serialization.list(core.serialization.string()).optional() + ), + fcmTokens: core.serialization.property( + "fcm_tokens", + core.serialization.list(core.serialization.string()).optional() + ), + iosTokens: core.serialization.property( + "ios_tokens", + core.serialization.list(core.serialization.string()).optional() + ), + slack: core.serialization.lazyObject(async () => (await import("../../..")).SlackProfile).optional(), + telegram: core.serialization.lazyObject(async () => (await import("../../..")).TelegramProfile).optional(), + fcmTopic: core.serialization.property("fcm_topic", core.serialization.string().optional()), + fcmDeviceGroup: core.serialization.property("fcm_device_group", core.serialization.string().optional()), +}); + +export declare namespace User { + interface Raw { + user_id?: serializers.UserId.Raw | null; + email?: string | null; + mobile?: string | null; + whatsapp_mobile?: string | null; + onesignal_external_id?: string | null; + onesignal_player_ids?: string[] | null; + fcm_tokens?: string[] | null; + ios_tokens?: string[] | null; + slack?: serializers.SlackProfile.Raw | null; + telegram?: serializers.TelegramProfile.Raw | null; + fcm_topic?: string | null; + fcm_device_group?: string | null; + } +} diff --git a/src/serialization/resources/event/types/VoiceOverride.ts b/src/serialization/resources/event/types/VoiceOverride.ts new file mode 100644 index 0000000..d7d120e --- /dev/null +++ b/src/serialization/resources/event/types/VoiceOverride.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const VoiceOverride: core.serialization.ObjectSchema = + core.serialization + .object({}) + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ChannelOverride)); + +export declare namespace VoiceOverride { + interface Raw extends serializers.ChannelOverride.Raw {} +} diff --git a/src/serialization/resources/event/types/WebhookOverride.ts b/src/serialization/resources/event/types/WebhookOverride.ts new file mode 100644 index 0000000..922d6e7 --- /dev/null +++ b/src/serialization/resources/event/types/WebhookOverride.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const WebhookOverride: core.serialization.ObjectSchema< + serializers.WebhookOverride.Raw, + RavenApi.WebhookOverride +> = core.serialization + .object({}) + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ChannelOverride)); + +export declare namespace WebhookOverride { + interface Raw extends serializers.ChannelOverride.Raw {} +} diff --git a/src/serialization/resources/event/types/WhatsappOverride.ts b/src/serialization/resources/event/types/WhatsappOverride.ts new file mode 100644 index 0000000..0d30f59 --- /dev/null +++ b/src/serialization/resources/event/types/WhatsappOverride.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const WhatsappOverride: core.serialization.ObjectSchema< + serializers.WhatsappOverride.Raw, + RavenApi.WhatsappOverride +> = core.serialization + .object({ + message: core.serialization.lazyObject(async () => (await import("../../..")).SmsMessage), + }) + .extend(core.serialization.lazyObject(async () => (await import("../../..")).ChannelOverride)); + +export declare namespace WhatsappOverride { + interface Raw extends serializers.ChannelOverride.Raw { + message: serializers.SmsMessage.Raw; + } +} diff --git a/src/resources/event/types/index.ts b/src/serialization/resources/event/types/index.ts similarity index 89% rename from src/resources/event/types/index.ts rename to src/serialization/resources/event/types/index.ts index 9e5ff12..de9e836 100644 --- a/src/resources/event/types/index.ts +++ b/src/serialization/resources/event/types/index.ts @@ -1,4 +1,3 @@ -export * from "./SendEventRequest"; export * from "./User"; export * from "./EventOverride"; export * from "./ChannelOverride"; @@ -19,5 +18,5 @@ export * from "./TelegramOverride"; export * from "./Param"; export * from "./ProviderOverride"; export * from "./SendEventResponse"; -export * from "./BulkSendEventRequest"; export * from "./BatchEvent"; +export * from "./EventNotFoundErrorBody"; diff --git a/src/serialization/event/index.ts b/src/serialization/resources/ids/index.ts similarity index 100% rename from src/serialization/event/index.ts rename to src/serialization/resources/ids/index.ts diff --git a/src/serialization/resources/ids/types/AppId.ts b/src/serialization/resources/ids/types/AppId.ts new file mode 100644 index 0000000..cd94f6a --- /dev/null +++ b/src/serialization/resources/ids/types/AppId.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const AppId: core.serialization.Schema = core.serialization.string(); + +export declare namespace AppId { + type Raw = string; +} diff --git a/src/serialization/resources/ids/types/DeviceId.ts b/src/serialization/resources/ids/types/DeviceId.ts new file mode 100644 index 0000000..bbc5894 --- /dev/null +++ b/src/serialization/resources/ids/types/DeviceId.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const DeviceId: core.serialization.Schema = + core.serialization.string(); + +export declare namespace DeviceId { + type Raw = string; +} diff --git a/src/serialization/resources/ids/types/RequestId.ts b/src/serialization/resources/ids/types/RequestId.ts new file mode 100644 index 0000000..c36a582 --- /dev/null +++ b/src/serialization/resources/ids/types/RequestId.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const RequestId: core.serialization.Schema = + core.serialization.string(); + +export declare namespace RequestId { + type Raw = string; +} diff --git a/src/serialization/resources/ids/types/UserId.ts b/src/serialization/resources/ids/types/UserId.ts new file mode 100644 index 0000000..8dbf828 --- /dev/null +++ b/src/serialization/resources/ids/types/UserId.ts @@ -0,0 +1,13 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const UserId: core.serialization.Schema = core.serialization.string(); + +export declare namespace UserId { + type Raw = string; +} diff --git a/src/serialization/ids/types/index.ts b/src/serialization/resources/ids/types/index.ts similarity index 100% rename from src/serialization/ids/types/index.ts rename to src/serialization/resources/ids/types/index.ts diff --git a/src/resources/index.ts b/src/serialization/resources/index.ts similarity index 75% rename from src/resources/index.ts rename to src/serialization/resources/index.ts index cde086e..b65e776 100644 --- a/src/resources/index.ts +++ b/src/serialization/resources/index.ts @@ -6,3 +6,5 @@ export * as ids from "./ids"; export * from "./ids/types"; export * as user from "./user"; export * from "./user/types"; +export * from "./event/client/requests"; +export * from "./user/client/requests"; diff --git a/src/serialization/resources/user/client/index.ts b/src/serialization/resources/user/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/serialization/resources/user/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/serialization/resources/user/client/requests/CreateUserRequest.ts b/src/serialization/resources/user/client/requests/CreateUserRequest.ts new file mode 100644 index 0000000..02d0b9f --- /dev/null +++ b/src/serialization/resources/user/client/requests/CreateUserRequest.ts @@ -0,0 +1,29 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../../core"; + +export const CreateUserRequest: core.serialization.Schema< + serializers.CreateUserRequest.Raw, + RavenApi.CreateUserRequest +> = core.serialization.object({ + userId: core.serialization.property( + "user_id", + core.serialization.lazy(async () => (await import("../../../..")).UserId) + ), + mobile: core.serialization.string().optional(), + email: core.serialization.string().optional(), + whatsApp: core.serialization.property("whats_app", core.serialization.string().optional()), +}); + +export declare namespace CreateUserRequest { + interface Raw { + user_id: serializers.UserId.Raw; + mobile?: string | null; + email?: string | null; + whats_app?: string | null; + } +} diff --git a/src/serialization/resources/user/client/requests/index.ts b/src/serialization/resources/user/client/requests/index.ts new file mode 100644 index 0000000..5632de8 --- /dev/null +++ b/src/serialization/resources/user/client/requests/index.ts @@ -0,0 +1 @@ +export { CreateUserRequest } from "./CreateUserRequest"; diff --git a/src/serialization/resources/user/index.ts b/src/serialization/resources/user/index.ts new file mode 100644 index 0000000..c9240f8 --- /dev/null +++ b/src/serialization/resources/user/index.ts @@ -0,0 +1,2 @@ +export * from "./types"; +export * from "./client"; diff --git a/src/serialization/resources/user/types/Channel.ts b/src/serialization/resources/user/types/Channel.ts new file mode 100644 index 0000000..9157b35 --- /dev/null +++ b/src/serialization/resources/user/types/Channel.ts @@ -0,0 +1,23 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const Channel: core.serialization.Schema = core.serialization.enum_([ + "VOICE", + "PUSH", + "SMS", + "EMAIL", + "WHATSAPP", + "WEBHOOK", + "SLACK", + "IN_APP", + "TELEGRAM", +]); + +export declare namespace Channel { + type Raw = "VOICE" | "PUSH" | "SMS" | "EMAIL" | "WHATSAPP" | "WEBHOOK" | "SLACK" | "IN_APP" | "TELEGRAM"; +} diff --git a/src/serialization/resources/user/types/ChannelPreference.ts b/src/serialization/resources/user/types/ChannelPreference.ts new file mode 100644 index 0000000..4f3b9ee --- /dev/null +++ b/src/serialization/resources/user/types/ChannelPreference.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const ChannelPreference: core.serialization.ObjectSchema< + serializers.ChannelPreference.Raw, + RavenApi.ChannelPreference +> = core.serialization.object({ + disabled: core.serialization.boolean(), +}); + +export declare namespace ChannelPreference { + interface Raw { + disabled: boolean; + } +} diff --git a/src/serialization/resources/user/types/ChannelPreferences.ts b/src/serialization/resources/user/types/ChannelPreferences.ts new file mode 100644 index 0000000..4c1ff76 --- /dev/null +++ b/src/serialization/resources/user/types/ChannelPreferences.ts @@ -0,0 +1,32 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const ChannelPreferences: core.serialization.ObjectSchema< + serializers.ChannelPreferences.Raw, + RavenApi.ChannelPreferences +> = core.serialization.object({ + sms: core.serialization.lazyObject(async () => (await import("../../..")).ChannelPreference).optional(), + push: core.serialization.lazyObject(async () => (await import("../../..")).ChannelPreference).optional(), + whatsapp: core.serialization.lazyObject(async () => (await import("../../..")).ChannelPreference).optional(), + email: core.serialization.lazyObject(async () => (await import("../../..")).ChannelPreference).optional(), + slack: core.serialization.lazyObject(async () => (await import("../../..")).ChannelPreference).optional(), + voice: core.serialization.lazyObject(async () => (await import("../../..")).ChannelPreference).optional(), + teams: core.serialization.lazyObject(async () => (await import("../../..")).ChannelPreference).optional(), +}); + +export declare namespace ChannelPreferences { + interface Raw { + sms?: serializers.ChannelPreference.Raw | null; + push?: serializers.ChannelPreference.Raw | null; + whatsapp?: serializers.ChannelPreference.Raw | null; + email?: serializers.ChannelPreference.Raw | null; + slack?: serializers.ChannelPreference.Raw | null; + voice?: serializers.ChannelPreference.Raw | null; + teams?: serializers.ChannelPreference.Raw | null; + } +} diff --git a/src/serialization/resources/user/types/RavenUser.ts b/src/serialization/resources/user/types/RavenUser.ts new file mode 100644 index 0000000..387d461 --- /dev/null +++ b/src/serialization/resources/user/types/RavenUser.ts @@ -0,0 +1,57 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const RavenUser: core.serialization.ObjectSchema = + core.serialization.object({ + userId: core.serialization.property( + "user_id", + core.serialization.lazy(async () => (await import("../../..")).UserId) + ), + userSid: core.serialization.property("user_sid", core.serialization.string().optional()), + onesignalExternalId: core.serialization.property( + "onesignal_external_id", + core.serialization.string().optional() + ), + mobile: core.serialization.string().optional(), + email: core.serialization.string().optional(), + whatsappMobile: core.serialization.property("whatsapp_mobile", core.serialization.string().optional()), + slack: core.serialization.lazyObject(async () => (await import("../../..")).SlackProfile).optional(), + telegram: core.serialization.lazyObject(async () => (await import("../../..")).TelegramProfile).optional(), + fcmTokens: core.serialization.property( + "fcm_tokens", + core.serialization.list(core.serialization.string()).optional() + ), + onesignalPlayerIds: core.serialization.property( + "onesignal_player_ids", + core.serialization.list(core.serialization.string()).optional() + ), + iosTokens: core.serialization.property( + "ios_tokens", + core.serialization.list(core.serialization.string()).optional() + ), + createdAt: core.serialization.property("created_at", core.serialization.number().optional()), + updatedAt: core.serialization.property("updated_at", core.serialization.number().optional()), + }); + +export declare namespace RavenUser { + interface Raw { + user_id: serializers.UserId.Raw; + user_sid?: string | null; + onesignal_external_id?: string | null; + mobile?: string | null; + email?: string | null; + whatsapp_mobile?: string | null; + slack?: serializers.SlackProfile.Raw | null; + telegram?: serializers.TelegramProfile.Raw | null; + fcm_tokens?: string[] | null; + onesignal_player_ids?: string[] | null; + ios_tokens?: string[] | null; + created_at?: number | null; + updated_at?: number | null; + } +} diff --git a/src/serialization/resources/user/types/SlackProfile.ts b/src/serialization/resources/user/types/SlackProfile.ts new file mode 100644 index 0000000..051ea61 --- /dev/null +++ b/src/serialization/resources/user/types/SlackProfile.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const SlackProfile: core.serialization.ObjectSchema = + core.serialization.object({ + accessToken: core.serialization.property("access_token", core.serialization.string()), + email: core.serialization.string().optional(), + channelId: core.serialization.property("channel_id", core.serialization.string().optional()), + }); + +export declare namespace SlackProfile { + interface Raw { + access_token: string; + email?: string | null; + channel_id?: string | null; + } +} diff --git a/src/serialization/resources/user/types/TelegramProfile.ts b/src/serialization/resources/user/types/TelegramProfile.ts new file mode 100644 index 0000000..70f5204 --- /dev/null +++ b/src/serialization/resources/user/types/TelegramProfile.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const TelegramProfile: core.serialization.ObjectSchema< + serializers.TelegramProfile.Raw, + RavenApi.TelegramProfile +> = core.serialization.object({ + chatId: core.serialization.property("chat_id", core.serialization.string()), +}); + +export declare namespace TelegramProfile { + interface Raw { + chat_id: string; + } +} diff --git a/src/serialization/resources/user/types/UserPreferences.ts b/src/serialization/resources/user/types/UserPreferences.ts new file mode 100644 index 0000000..50c822e --- /dev/null +++ b/src/serialization/resources/user/types/UserPreferences.ts @@ -0,0 +1,28 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../.."; +import { RavenApi } from "@ravenapp/raven"; +import * as core from "../../../../core"; + +export const UserPreferences: core.serialization.ObjectSchema< + serializers.UserPreferences.Raw, + RavenApi.UserPreferences +> = core.serialization.object({ + preferredChannel: core.serialization.property( + "preferred_channel", + core.serialization.lazy(async () => (await import("../../..")).Channel).optional() + ), + channelPreferences: core.serialization.property( + "channel_preferences", + core.serialization.lazyObject(async () => (await import("../../..")).ChannelPreferences).optional() + ), +}); + +export declare namespace UserPreferences { + interface Raw { + preferred_channel?: serializers.Channel.Raw | null; + channel_preferences?: serializers.ChannelPreferences.Raw | null; + } +} diff --git a/src/serialization/user/types/index.ts b/src/serialization/resources/user/types/index.ts similarity index 86% rename from src/serialization/user/types/index.ts rename to src/serialization/resources/user/types/index.ts index 0dea612..148e556 100644 --- a/src/serialization/user/types/index.ts +++ b/src/serialization/resources/user/types/index.ts @@ -1,4 +1,3 @@ -export * from "./CreateUserRequest"; export * from "./RavenUser"; export * from "./SlackProfile"; export * from "./TelegramProfile"; diff --git a/src/serialization/user/index.ts b/src/serialization/user/index.ts deleted file mode 100644 index eea524d..0000000 --- a/src/serialization/user/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types"; diff --git a/src/serialization/user/types/Channel.ts b/src/serialization/user/types/Channel.ts deleted file mode 100644 index ffd51e3..0000000 --- a/src/serialization/user/types/Channel.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const Channel: core.schemas.Schema = core.schemas - .string() - .transform({ - parse: (value) => RavenApi.Channel._parse(value), - json: ({ value }) => value, - }); - -export declare namespace Channel { - type Raw = string; -} diff --git a/src/serialization/user/types/ChannelPreference.ts b/src/serialization/user/types/ChannelPreference.ts deleted file mode 100644 index fabb71f..0000000 --- a/src/serialization/user/types/ChannelPreference.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const ChannelPreference: core.schemas.ObjectSchema = - core.schemas.object({ - disabled: core.schemas.boolean(), - }); - -export declare namespace ChannelPreference { - interface Raw { - disabled: boolean; - } -} diff --git a/src/serialization/user/types/ChannelPreferences.ts b/src/serialization/user/types/ChannelPreferences.ts deleted file mode 100644 index e372ca5..0000000 --- a/src/serialization/user/types/ChannelPreferences.ts +++ /dev/null @@ -1,30 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const ChannelPreferences: core.schemas.ObjectSchema = - core.schemas.object({ - sms: core.schemas.lazyObject(async () => (await import("../..")).ChannelPreference).optional(), - push: core.schemas.lazyObject(async () => (await import("../..")).ChannelPreference).optional(), - whatsapp: core.schemas.lazyObject(async () => (await import("../..")).ChannelPreference).optional(), - email: core.schemas.lazyObject(async () => (await import("../..")).ChannelPreference).optional(), - slack: core.schemas.lazyObject(async () => (await import("../..")).ChannelPreference).optional(), - voice: core.schemas.lazyObject(async () => (await import("../..")).ChannelPreference).optional(), - teams: core.schemas.lazyObject(async () => (await import("../..")).ChannelPreference).optional(), - }); - -export declare namespace ChannelPreferences { - interface Raw { - sms?: serializers.ChannelPreference.Raw | null; - push?: serializers.ChannelPreference.Raw | null; - whatsapp?: serializers.ChannelPreference.Raw | null; - email?: serializers.ChannelPreference.Raw | null; - slack?: serializers.ChannelPreference.Raw | null; - voice?: serializers.ChannelPreference.Raw | null; - teams?: serializers.ChannelPreference.Raw | null; - } -} diff --git a/src/serialization/user/types/CreateUserRequest.ts b/src/serialization/user/types/CreateUserRequest.ts deleted file mode 100644 index 5f3d69f..0000000 --- a/src/serialization/user/types/CreateUserRequest.ts +++ /dev/null @@ -1,27 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const CreateUserRequest: core.schemas.ObjectSchema = - core.schemas.object({ - userId: core.schemas.property( - "user_id", - core.schemas.lazy(async () => (await import("../..")).UserId) - ), - mobile: core.schemas.string().optional(), - email: core.schemas.string().optional(), - whatsApp: core.schemas.property("whats_app", core.schemas.string().optional()), - }); - -export declare namespace CreateUserRequest { - interface Raw { - user_id: serializers.UserId.Raw; - mobile?: string | null; - email?: string | null; - whats_app?: string | null; - } -} diff --git a/src/serialization/user/types/RavenUser.ts b/src/serialization/user/types/RavenUser.ts deleted file mode 100644 index 8ae2517..0000000 --- a/src/serialization/user/types/RavenUser.ts +++ /dev/null @@ -1,47 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const RavenUser: core.schemas.ObjectSchema = core.schemas.object({ - userId: core.schemas.property( - "user_id", - core.schemas.lazy(async () => (await import("../..")).UserId) - ), - userSid: core.schemas.property("user_sid", core.schemas.string().optional()), - onesignalExternalId: core.schemas.property("onesignal_external_id", core.schemas.string().optional()), - mobile: core.schemas.string().optional(), - email: core.schemas.string().optional(), - whatsappMobile: core.schemas.property("whatsapp_mobile", core.schemas.string().optional()), - slack: core.schemas.lazyObject(async () => (await import("../..")).SlackProfile).optional(), - telegram: core.schemas.lazyObject(async () => (await import("../..")).TelegramProfile).optional(), - fcmTokens: core.schemas.property("fcm_tokens", core.schemas.list(core.schemas.string()).optional()), - onesignalPlayerIds: core.schemas.property( - "onesignal_player_ids", - core.schemas.list(core.schemas.string()).optional() - ), - iosTokens: core.schemas.property("ios_tokens", core.schemas.list(core.schemas.string()).optional()), - createdAt: core.schemas.property("created_at", core.schemas.number().optional()), - updatedAt: core.schemas.property("updated_at", core.schemas.number().optional()), -}); - -export declare namespace RavenUser { - interface Raw { - user_id: serializers.UserId.Raw; - user_sid?: string | null; - onesignal_external_id?: string | null; - mobile?: string | null; - email?: string | null; - whatsapp_mobile?: string | null; - slack?: serializers.SlackProfile.Raw | null; - telegram?: serializers.TelegramProfile.Raw | null; - fcm_tokens?: string[] | null; - onesignal_player_ids?: string[] | null; - ios_tokens?: string[] | null; - created_at?: number | null; - updated_at?: number | null; - } -} diff --git a/src/serialization/user/types/SlackProfile.ts b/src/serialization/user/types/SlackProfile.ts deleted file mode 100644 index de31925..0000000 --- a/src/serialization/user/types/SlackProfile.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const SlackProfile: core.schemas.ObjectSchema = core.schemas.object({ - accessToken: core.schemas.property("access_token", core.schemas.string()), - email: core.schemas.string().optional(), - channelId: core.schemas.property("channel_id", core.schemas.string().optional()), -}); - -export declare namespace SlackProfile { - interface Raw { - access_token: string; - email?: string | null; - channel_id?: string | null; - } -} diff --git a/src/serialization/user/types/TelegramProfile.ts b/src/serialization/user/types/TelegramProfile.ts deleted file mode 100644 index deaac93..0000000 --- a/src/serialization/user/types/TelegramProfile.ts +++ /dev/null @@ -1,17 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; - -export const TelegramProfile: core.schemas.ObjectSchema = - core.schemas.object({ - chatId: core.schemas.property("chat_id", core.schemas.string()), - }); - -export declare namespace TelegramProfile { - interface Raw { - chat_id: string; - } -} diff --git a/src/serialization/user/types/UserPreferences.ts b/src/serialization/user/types/UserPreferences.ts deleted file mode 100644 index 27c2ebe..0000000 --- a/src/serialization/user/types/UserPreferences.ts +++ /dev/null @@ -1,26 +0,0 @@ -/** - * This file auto-generated by Fern from our API Definition. - */ - -import { RavenApi } from "@ravenapp/raven"; -import * as core from "../../../core"; -import * as serializers from "../.."; - -export const UserPreferences: core.schemas.ObjectSchema = - core.schemas.object({ - preferredChannel: core.schemas.property( - "preferred_channel", - core.schemas.lazy(async () => (await import("../..")).Channel).optional() - ), - channelPreferences: core.schemas.property( - "channel_preferences", - core.schemas.lazyObject(async () => (await import("../..")).ChannelPreferences).optional() - ), - }); - -export declare namespace UserPreferences { - interface Raw { - preferred_channel?: serializers.Channel.Raw | null; - channel_preferences?: serializers.ChannelPreferences.Raw | null; - } -} diff --git a/tsconfig.json b/tsconfig.json index b2b13a8..64c5e64 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,17 +2,16 @@ "compilerOptions": { "strict": true, "target": "esnext", - "module": "commonjs", + "module": "esnext", "moduleResolution": "node", "esModuleInterop": true, "skipLibCheck": true, "declaration": true, + "emitDeclarationOnly": true, "sourceMap": true, - "inlineSources": true, - "noUncheckedIndexedAccess": true, "noUnusedLocals": true, "noUnusedParameters": true, - "outDir": ".", + "outDir": "types", "rootDir": "src", "baseUrl": "src", "paths": { diff --git a/yarn.lock b/yarn.lock index 343682e..ecf88a5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5,6 +5,160 @@ __metadata: version: 6 cacheKey: 8 +"@esbuild/android-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/android-arm64@npm:0.16.15" + conditions: os=android & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/android-arm@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/android-arm@npm:0.16.15" + conditions: os=android & cpu=arm + languageName: node + linkType: hard + +"@esbuild/android-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/android-x64@npm:0.16.15" + conditions: os=android & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/darwin-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/darwin-arm64@npm:0.16.15" + conditions: os=darwin & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/darwin-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/darwin-x64@npm:0.16.15" + conditions: os=darwin & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/freebsd-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/freebsd-arm64@npm:0.16.15" + conditions: os=freebsd & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/freebsd-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/freebsd-x64@npm:0.16.15" + conditions: os=freebsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/linux-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-arm64@npm:0.16.15" + conditions: os=linux & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/linux-arm@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-arm@npm:0.16.15" + conditions: os=linux & cpu=arm + languageName: node + linkType: hard + +"@esbuild/linux-ia32@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-ia32@npm:0.16.15" + conditions: os=linux & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/linux-loong64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-loong64@npm:0.16.15" + conditions: os=linux & cpu=loong64 + languageName: node + linkType: hard + +"@esbuild/linux-mips64el@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-mips64el@npm:0.16.15" + conditions: os=linux & cpu=mips64el + languageName: node + linkType: hard + +"@esbuild/linux-ppc64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-ppc64@npm:0.16.15" + conditions: os=linux & cpu=ppc64 + languageName: node + linkType: hard + +"@esbuild/linux-riscv64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-riscv64@npm:0.16.15" + conditions: os=linux & cpu=riscv64 + languageName: node + linkType: hard + +"@esbuild/linux-s390x@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-s390x@npm:0.16.15" + conditions: os=linux & cpu=s390x + languageName: node + linkType: hard + +"@esbuild/linux-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/linux-x64@npm:0.16.15" + conditions: os=linux & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/netbsd-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/netbsd-x64@npm:0.16.15" + conditions: os=netbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/openbsd-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/openbsd-x64@npm:0.16.15" + conditions: os=openbsd & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/sunos-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/sunos-x64@npm:0.16.15" + conditions: os=sunos & cpu=x64 + languageName: node + linkType: hard + +"@esbuild/win32-arm64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/win32-arm64@npm:0.16.15" + conditions: os=win32 & cpu=arm64 + languageName: node + linkType: hard + +"@esbuild/win32-ia32@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/win32-ia32@npm:0.16.15" + conditions: os=win32 & cpu=ia32 + languageName: node + linkType: hard + +"@esbuild/win32-x64@npm:0.16.15": + version: 0.16.15 + resolution: "@esbuild/win32-x64@npm:0.16.15" + conditions: os=win32 & cpu=x64 + languageName: node + linkType: hard + "@gar/promisify@npm:^1.1.3": version: 1.1.3 resolution: "@gar/promisify@npm:1.1.3" @@ -66,6 +220,7 @@ __metadata: "@types/node": 17.0.33 "@types/url-join": 4.0.1 axios: ^0.27.2 + esbuild: 0.16.15 prettier: 2.7.1 tsc-alias: ^1.7.1 typescript: 4.6.4 @@ -401,6 +556,83 @@ __metadata: languageName: node linkType: hard +"esbuild@npm:0.16.15": + version: 0.16.15 + resolution: "esbuild@npm:0.16.15" + dependencies: + "@esbuild/android-arm": 0.16.15 + "@esbuild/android-arm64": 0.16.15 + "@esbuild/android-x64": 0.16.15 + "@esbuild/darwin-arm64": 0.16.15 + "@esbuild/darwin-x64": 0.16.15 + "@esbuild/freebsd-arm64": 0.16.15 + "@esbuild/freebsd-x64": 0.16.15 + "@esbuild/linux-arm": 0.16.15 + "@esbuild/linux-arm64": 0.16.15 + "@esbuild/linux-ia32": 0.16.15 + "@esbuild/linux-loong64": 0.16.15 + "@esbuild/linux-mips64el": 0.16.15 + "@esbuild/linux-ppc64": 0.16.15 + "@esbuild/linux-riscv64": 0.16.15 + "@esbuild/linux-s390x": 0.16.15 + "@esbuild/linux-x64": 0.16.15 + "@esbuild/netbsd-x64": 0.16.15 + "@esbuild/openbsd-x64": 0.16.15 + "@esbuild/sunos-x64": 0.16.15 + "@esbuild/win32-arm64": 0.16.15 + "@esbuild/win32-ia32": 0.16.15 + "@esbuild/win32-x64": 0.16.15 + dependenciesMeta: + "@esbuild/android-arm": + optional: true + "@esbuild/android-arm64": + optional: true + "@esbuild/android-x64": + optional: true + "@esbuild/darwin-arm64": + optional: true + "@esbuild/darwin-x64": + optional: true + "@esbuild/freebsd-arm64": + optional: true + "@esbuild/freebsd-x64": + optional: true + "@esbuild/linux-arm": + optional: true + "@esbuild/linux-arm64": + optional: true + "@esbuild/linux-ia32": + optional: true + "@esbuild/linux-loong64": + optional: true + "@esbuild/linux-mips64el": + optional: true + "@esbuild/linux-ppc64": + optional: true + "@esbuild/linux-riscv64": + optional: true + "@esbuild/linux-s390x": + optional: true + "@esbuild/linux-x64": + optional: true + "@esbuild/netbsd-x64": + optional: true + "@esbuild/openbsd-x64": + optional: true + "@esbuild/sunos-x64": + optional: true + "@esbuild/win32-arm64": + optional: true + "@esbuild/win32-ia32": + optional: true + "@esbuild/win32-x64": + optional: true + bin: + esbuild: bin/esbuild + checksum: 38a2784bced605b81352f05b151928c27ac7ed9ecd3f265339ef937b3f9571443bb233edb97f2de24bbdb0e6097ec68ffa096b0475f716a3d8bb3034e20066bf + languageName: node + linkType: hard + "fast-glob@npm:^3.2.9": version: 3.2.12 resolution: "fast-glob@npm:3.2.12" @@ -569,9 +801,9 @@ __metadata: linkType: hard "http-cache-semantics@npm:^4.1.0": - version: 4.1.0 - resolution: "http-cache-semantics@npm:4.1.0" - checksum: 974de94a81c5474be07f269f9fd8383e92ebb5a448208223bfb39e172a9dbc26feff250192ecc23b9593b3f92098e010406b0f24bd4d588d631f80214648ed42 + version: 4.1.1 + resolution: "http-cache-semantics@npm:4.1.1" + checksum: 83ac0bc60b17a3a36f9953e7be55e5c8f41acc61b22583060e8dedc9dd5e3607c823a88d0926f9150e571f90946835c7fe150732801010845c72cd8bbff1a236 languageName: node linkType: hard @@ -802,11 +1034,11 @@ __metadata: linkType: hard "minimatch@npm:^5.0.1": - version: 5.1.4 - resolution: "minimatch@npm:5.1.4" + version: 5.1.6 + resolution: "minimatch@npm:5.1.6" dependencies: brace-expansion: ^2.0.1 - checksum: 0de6d7d154e70d12487b30a7bfcb74bd15fd1f1ec007a2516699ba76e63f78ca2e5016c200b242ed75123aff8dcccf49947f71b629fb1b1f221c8e76a13ed8de + checksum: 7564208ef81d7065a370f788d337cd80a689e981042cb9a1d0e6580b6c6a8c9279eba80010516e258835a988363f99f54a6f711a315089b8b42694f5da9d0d77 languageName: node linkType: hard @@ -871,11 +1103,9 @@ __metadata: linkType: hard "minipass@npm:^4.0.0": - version: 4.0.0 - resolution: "minipass@npm:4.0.0" - dependencies: - yallist: ^4.0.0 - checksum: 7a609afbf394abfcf9c48e6c90226f471676c8f2a67f07f6838871afb03215ede431d1433feffe1b855455bcb13ef0eb89162841b9796109d6fed8d89790f381 + version: 4.0.1 + resolution: "minipass@npm:4.0.1" + checksum: 48eb3141cc247b44f738944cbd789aedeed9288ebdb64c7de9b3bf23e9e71d611381bfecf643d877d25f7ca9f3d5ab7b6757ef6f46282086812ac5372b7cd291 languageName: node linkType: hard