From 4dec3f14d25c5cc38f48f58669955a568470182c Mon Sep 17 00:00:00 2001 From: fern-api <115122769+fern-api[bot]@users.noreply.github.com> Date: Tue, 29 Aug 2023 05:28:24 +0000 Subject: [PATCH] SDK regeneration --- package.json | 11 +- src/Client.ts | 100 +++++- src/api/client/index.ts | 1 + .../PostUsersHandleOAuthIdentitiesRequest.ts} | 2 +- src/api/client/requests/index.ts | 1 + src/api/index.ts | 2 + src/api/resources/auth/client/Client.ts | 42 ++- ...serAuthRequest.ts => LoginOauthRequest.ts} | 2 +- .../resources/auth/client/requests/index.ts | 2 +- src/api/resources/clans/client/Client.ts | 44 ++- ...Request.ts => ClansUpsertMemberRequest.ts} | 2 +- .../resources/clans/client/requests/index.ts | 2 +- src/api/resources/clans/index.ts | 1 - src/api/resources/clans/types/index.ts | 1 - src/api/resources/classrooms/client/Client.ts | 161 +++++++--- ...mRequest.ts => ClassroomsCreateRequest.ts} | 6 +- ...=> ClassroomsEnrollUserInCourseRequest.ts} | 4 +- ...ts => ClassroomsGetMembersStatsRequest.ts} | 2 +- ...ailsRequest.ts => ClassroomsGetRequest.ts} | 2 +- ...=> ClassroomsRemoveEnrolledUserRequest.ts} | 4 +- ...st.ts => ClassroomsRemoveMemberRequest.ts} | 2 +- ...st.ts => ClassroomsUpsertMemberRequest.ts} | 2 +- .../classrooms/client/requests/index.ts | 14 +- src/api/resources/classrooms/index.ts | 1 - .../resources/classrooms/types/MemberStat.ts | 10 - src/api/resources/classrooms/types/index.ts | 6 - src/api/resources/commons/index.ts | 1 - src/api/resources/commons/types/index.ts | 11 - src/api/resources/index.ts | 8 +- src/api/resources/stats/client/Client.ts | 52 +++- ...ats.ts => StatsGetPlaytimeStatsRequest.ts} | 2 +- .../resources/stats/client/requests/index.ts | 2 +- src/api/resources/stats/index.ts | 1 - src/api/resources/stats/types/index.ts | 2 - src/api/resources/users/client/Client.ts | 284 ++++++++++-------- .../client/requests/CreateUserRequest.ts | 15 - .../client/requests/GrantLicenseRequest.ts | 7 - .../client/requests/ShortenLicenseRequest.ts | 7 - .../requests/ShortenSubscriptionRequest.ts | 7 - .../requests/UpdateSubscriptionRequest.ts | 7 - .../client/requests/UsersCreateRequest.ts | 18 ++ ...equest.ts => UsersGetClassroomsRequest.ts} | 2 +- .../{GetUserRequest.ts => UsersGetRequest.ts} | 2 +- .../requests/UsersGrantLicenseRequest.ts | 9 + .../UsersGrantPremiumSubscriptionRequest.ts | 9 + ...eConfig.ts => UsersSetAceConfigRequest.ts} | 2 +- .../requests/UsersSetHeroRequest.ts} | 4 +- .../requests/UsersShortenLicenseRequest.ts | 9 + .../UsersShortenSubscriptionRequest.ts | 9 + ...teUserRequest.ts => UsersUpdateRequest.ts} | 2 +- .../resources/users/client/requests/index.ts | 21 +- src/api/resources/users/index.ts | 1 - src/api/resources/users/types/UserRole.ts | 13 - src/api/resources/users/types/index.ts | 2 - .../clans => }/types/ClanResponse.ts | 2 +- .../commons => }/types/ClassroomResponse.ts | 7 +- .../ClassroomResponseCoursesItem.ts} | 4 +- .../types/ClassroomResponseWithCode.ts | 4 +- .../ClassroomResponseWithCodeCoursesItem.ts | 12 + .../ClassroomsCreateRequestAceConfig.ts} | 2 +- .../ClassroomsGetMembersStatsResponseItem.ts | 10 + ...sroomsGetMembersStatsResponseItemStats.ts} | 2 +- .../commons => }/types/DatetimeString.ts | 0 .../types/LevelSessionResponse.ts | 6 +- .../LevelSessionResponseLevel.ts} | 2 +- .../LevelSessionResponseState.ts} | 2 +- .../stats => }/types/LicenseStatsResponse.ts | 0 .../commons => }/types/ObjectIdString.ts | 0 .../stats => }/types/PlaytimeStatsResponse.ts | 0 .../commons => }/types/RoleString.ts | 0 .../commons => }/types/UserResponse.ts | 10 +- .../UserResponseLicense.ts} | 4 +- .../UserResponseOAuthIdentitiesItem.ts} | 2 +- .../UserResponseStats.ts} | 2 +- .../UserResponseSubscription.ts} | 4 +- .../UsersCreateRequestHeroConfig.ts} | 4 +- src/api/types/UsersCreateRequestRole.ts | 14 + src/api/types/index.ts | 23 ++ src/core/fetcher/Fetcher.ts | 27 +- src/core/fetcher/index.ts | 5 +- src/core/index.ts | 4 +- src/core/schemas/Schema.ts | 20 ++ src/core/schemas/builders/date/date.ts | 34 ++- src/core/schemas/builders/enum/enum.ts | 27 +- src/core/schemas/builders/lazy/index.ts | 3 +- src/core/schemas/builders/list/list.ts | 35 ++- .../builders/literals/stringLiteral.ts | 38 +-- .../object-like/getObjectLikeUtils.ts | 7 +- .../schemas/builders/object-like/index.ts | 2 +- src/core/schemas/builders/object/index.ts | 29 +- src/core/schemas/builders/object/object.ts | 52 ++-- .../schemas/builders/primitives/boolean.ts | 38 +-- .../schemas/builders/primitives/number.ts | 38 +-- .../schemas/builders/primitives/string.ts | 38 +-- src/core/schemas/builders/record/index.ts | 2 +- src/core/schemas/builders/record/record.ts | 56 ++-- .../schemas/builders/schema-utils/index.ts | 3 +- src/core/schemas/builders/set/set.ts | 8 +- .../builders/undiscriminated-union/index.ts | 8 +- .../undiscriminatedUnion.ts | 33 +- src/core/schemas/builders/union/index.ts | 15 +- src/core/schemas/builders/union/union.ts | 27 +- src/core/schemas/index.ts | 2 +- .../utils/createIdentitySchemaCreator.ts | 3 +- .../utils/getErrorMessageForIncorrectType.ts | 21 ++ src/core/schemas/utils/isPlainObject.ts | 2 - src/core/schemas/utils/maybeSkipValidation.ts | 39 +++ src/environments.ts | 4 +- src/errors/CodeCombatError.ts | 27 +- src/serialization/client/index.ts | 1 + .../PostUsersHandleOAuthIdentitiesRequest.ts} | 14 +- src/serialization/client/requests/index.ts | 1 + src/serialization/index.ts | 2 + ...Request.ts => ClansUpsertMemberRequest.ts} | 10 +- .../resources/clans/client/requests/index.ts | 2 +- src/serialization/resources/clans/index.ts | 1 - .../resources/clans/types/index.ts | 1 - ...{getLevelSession.ts => getLevelsPlayed.ts} | 4 +- .../classrooms/client/getMembersStats.ts | 10 +- .../resources/classrooms/client/index.ts | 2 +- ...mRequest.ts => ClassroomsCreateRequest.ts} | 16 +- ...=> ClassroomsEnrollUserInCourseRequest.ts} | 10 +- ...=> ClassroomsRemoveEnrolledUserRequest.ts} | 10 +- ...st.ts => ClassroomsRemoveMemberRequest.ts} | 10 +- ...st.ts => ClassroomsUpsertMemberRequest.ts} | 10 +- .../classrooms/client/requests/index.ts | 10 +- .../resources/classrooms/index.ts | 1 - .../resources/classrooms/types/AceConfig.ts | 18 -- .../resources/classrooms/types/Level.ts | 18 -- .../resources/classrooms/types/MemberStat.ts | 23 -- .../resources/classrooms/types/PlayStats.ts | 20 -- .../resources/classrooms/types/State.ts | 18 -- .../resources/classrooms/types/index.ts | 6 - src/serialization/resources/commons/index.ts | 1 - .../resources/commons/types/AuthIdentity.ts | 20 -- .../resources/commons/types/Course.ts | 34 --- .../resources/commons/types/License.ts | 20 -- .../resources/commons/types/Subscription.ts | 20 -- .../resources/commons/types/UserStats.ts | 22 -- .../resources/commons/types/index.ts | 11 - src/serialization/resources/index.ts | 9 +- src/serialization/resources/stats/index.ts | 1 - .../resources/stats/types/index.ts | 2 - .../resources/users/client/getClassrooms.ts | 2 +- .../users/client/requests/GetHeroRequest.ts | 18 -- .../client/requests/GrantLicenseRequest.ts | 20 -- .../users/client/requests/SetAceConfig.ts | 22 -- .../client/requests/ShortenLicenseRequest.ts | 20 -- .../requests/ShortenSubscriptionRequest.ts | 20 -- .../requests/UpdateSubscriptionRequest.ts | 20 -- ...teUserRequest.ts => UsersCreateRequest.ts} | 20 +- .../requests/UsersGrantLicenseRequest.ts | 20 ++ .../UsersGrantPremiumSubscriptionRequest.ts | 20 ++ .../requests/UsersSetAceConfigRequest.ts | 24 ++ .../client/requests/UsersSetHeroRequest.ts | 20 ++ .../requests/UsersShortenLicenseRequest.ts | 20 ++ .../UsersShortenSubscriptionRequest.ts | 20 ++ ...teUserRequest.ts => UsersUpdateRequest.ts} | 10 +- .../resources/users/client/requests/index.ts | 17 +- src/serialization/resources/users/index.ts | 1 - .../resources/users/types/HeroConfig.ts | 18 -- .../resources/users/types/UserRole.ts | 14 - .../resources/users/types/index.ts | 2 - .../clans => }/types/ClanResponse.ts | 12 +- .../commons => }/types/ClassroomResponse.ts | 16 +- .../types/ClassroomResponseCoursesItem.ts | 36 +++ .../types/ClassroomResponseWithCode.ts | 18 +- .../ClassroomResponseWithCodeCoursesItem.ts | 36 +++ .../types/ClassroomsCreateRequestAceConfig.ts | 20 ++ .../ClassroomsGetMembersStatsResponseItem.ts | 27 ++ ...ssroomsGetMembersStatsResponseItemStats.ts | 22 ++ .../commons => }/types/DatetimeString.ts | 6 +- .../types/LevelSessionResponse.ts | 22 +- .../types/LevelSessionResponseLevel.ts | 20 ++ .../types/LevelSessionResponseState.ts | 20 ++ .../stats => }/types/LicenseStatsResponse.ts | 6 +- .../commons => }/types/ObjectIdString.ts | 6 +- .../stats => }/types/PlaytimeStatsResponse.ts | 6 +- .../commons => }/types/RoleString.ts | 6 +- .../commons => }/types/UserResponse.ts | 28 +- .../types/UserResponseLicense.ts | 22 ++ .../types/UserResponseOAuthIdentitiesItem.ts | 22 ++ src/serialization/types/UserResponseStats.ts | 24 ++ .../types/UserResponseSubscription.ts | 22 ++ .../types/UsersCreateRequestHeroConfig.ts | 20 ++ .../types/UsersCreateRequestRole.ts | 16 + src/serialization/types/index.ts | 23 ++ tsconfig.json | 9 +- yarn.lock | 244 --------------- 189 files changed, 1673 insertions(+), 1421 deletions(-) create mode 100644 src/api/client/index.ts rename src/api/{resources/users/client/requests/AddOAuthIdentityRequest.ts => client/requests/PostUsersHandleOAuthIdentitiesRequest.ts} (86%) create mode 100644 src/api/client/requests/index.ts rename src/api/resources/auth/client/requests/{GetUserAuthRequest.ts => LoginOauthRequest.ts} (94%) rename src/api/resources/clans/client/requests/{UpsertClanRequest.ts => ClansUpsertMemberRequest.ts} (78%) delete mode 100644 src/api/resources/clans/types/index.ts rename src/api/resources/classrooms/client/requests/{CreateClassroomRequest.ts => ClassroomsCreateRequest.ts} (53%) rename src/api/resources/classrooms/client/requests/{EnrollUserInCourseRequest.ts => ClassroomsEnrollUserInCourseRequest.ts} (71%) rename src/api/resources/classrooms/client/requests/{GetMembersStatsRequest.ts => ClassroomsGetMembersStatsRequest.ts} (91%) rename src/api/resources/classrooms/client/requests/{GetClassroomDetailsRequest.ts => ClassroomsGetRequest.ts} (84%) rename src/api/resources/classrooms/client/requests/{RemoveUserFromClassroomRequest.ts => ClassroomsRemoveEnrolledUserRequest.ts} (71%) rename src/api/resources/classrooms/client/requests/{DeleteUserFromClassroomRequest.ts => ClassroomsRemoveMemberRequest.ts} (85%) rename src/api/resources/classrooms/client/requests/{UpsertClassroomRequest.ts => ClassroomsUpsertMemberRequest.ts} (87%) delete mode 100644 src/api/resources/classrooms/types/MemberStat.ts delete mode 100644 src/api/resources/classrooms/types/index.ts delete mode 100644 src/api/resources/commons/index.ts delete mode 100644 src/api/resources/commons/types/index.ts rename src/api/resources/stats/client/requests/{GetPlaytimeStats.ts => StatsGetPlaytimeStatsRequest.ts} (86%) delete mode 100644 src/api/resources/stats/types/index.ts delete mode 100644 src/api/resources/users/client/requests/CreateUserRequest.ts delete mode 100644 src/api/resources/users/client/requests/GrantLicenseRequest.ts delete mode 100644 src/api/resources/users/client/requests/ShortenLicenseRequest.ts delete mode 100644 src/api/resources/users/client/requests/ShortenSubscriptionRequest.ts delete mode 100644 src/api/resources/users/client/requests/UpdateSubscriptionRequest.ts create mode 100644 src/api/resources/users/client/requests/UsersCreateRequest.ts rename src/api/resources/users/client/requests/{GetClassroomsRequest.ts => UsersGetClassroomsRequest.ts} (80%) rename src/api/resources/users/client/requests/{GetUserRequest.ts => UsersGetRequest.ts} (84%) create mode 100644 src/api/resources/users/client/requests/UsersGrantLicenseRequest.ts create mode 100644 src/api/resources/users/client/requests/UsersGrantPremiumSubscriptionRequest.ts rename src/api/resources/users/client/requests/{SetAceConfig.ts => UsersSetAceConfigRequest.ts} (91%) rename src/api/resources/users/{types/HeroConfig.ts => client/requests/UsersSetHeroRequest.ts} (59%) create mode 100644 src/api/resources/users/client/requests/UsersShortenLicenseRequest.ts create mode 100644 src/api/resources/users/client/requests/UsersShortenSubscriptionRequest.ts rename src/api/resources/users/client/requests/{UpdateUserRequest.ts => UsersUpdateRequest.ts} (82%) delete mode 100644 src/api/resources/users/types/UserRole.ts delete mode 100644 src/api/resources/users/types/index.ts rename src/api/{resources/clans => }/types/ClanResponse.ts (89%) rename src/api/{resources/commons => }/types/ClassroomResponse.ts (56%) rename src/api/{resources/commons/types/Course.ts => types/ClassroomResponseCoursesItem.ts} (74%) rename src/api/{resources/commons => }/types/ClassroomResponseWithCode.ts (80%) create mode 100644 src/api/types/ClassroomResponseWithCodeCoursesItem.ts rename src/api/{resources/classrooms/types/AceConfig.ts => types/ClassroomsCreateRequestAceConfig.ts} (74%) create mode 100644 src/api/types/ClassroomsGetMembersStatsResponseItem.ts rename src/api/{resources/classrooms/types/PlayStats.ts => types/ClassroomsGetMembersStatsResponseItemStats.ts} (72%) rename src/api/{resources/commons => }/types/DatetimeString.ts (100%) rename src/api/{resources/classrooms => }/types/LevelSessionResponse.ts (82%) rename src/api/{resources/classrooms/types/Level.ts => types/LevelSessionResponseLevel.ts} (74%) rename src/api/{resources/classrooms/types/State.ts => types/LevelSessionResponseState.ts} (68%) rename src/api/{resources/stats => }/types/LicenseStatsResponse.ts (100%) rename src/api/{resources/commons => }/types/ObjectIdString.ts (100%) rename src/api/{resources/stats => }/types/PlaytimeStatsResponse.ts (100%) rename src/api/{resources/commons => }/types/RoleString.ts (100%) rename src/api/{resources/commons => }/types/UserResponse.ts (53%) rename src/api/{resources/commons/types/License.ts => types/UserResponseLicense.ts} (63%) rename src/api/{resources/commons/types/AuthIdentity.ts => types/UserResponseOAuthIdentitiesItem.ts} (69%) rename src/api/{resources/commons/types/UserStats.ts => types/UserResponseStats.ts} (86%) rename src/api/{resources/commons/types/Subscription.ts => types/UserResponseSubscription.ts} (62%) rename src/api/{resources/users/client/requests/GetHeroRequest.ts => types/UsersCreateRequestHeroConfig.ts} (58%) create mode 100644 src/api/types/UsersCreateRequestRole.ts create mode 100644 src/api/types/index.ts create mode 100644 src/core/schemas/utils/getErrorMessageForIncorrectType.ts create mode 100644 src/core/schemas/utils/maybeSkipValidation.ts create mode 100644 src/serialization/client/index.ts rename src/serialization/{resources/users/client/requests/AddOAuthIdentityRequest.ts => client/requests/PostUsersHandleOAuthIdentitiesRequest.ts} (50%) create mode 100644 src/serialization/client/requests/index.ts rename src/serialization/resources/clans/client/requests/{UpsertClanRequest.ts => ClansUpsertMemberRequest.ts} (53%) delete mode 100644 src/serialization/resources/clans/types/index.ts rename src/serialization/resources/classrooms/client/{getLevelSession.ts => getLevelsPlayed.ts} (81%) rename src/serialization/resources/classrooms/client/requests/{CreateClassroomRequest.ts => ClassroomsCreateRequest.ts} (52%) rename src/serialization/resources/classrooms/client/requests/{EnrollUserInCourseRequest.ts => ClassroomsEnrollUserInCourseRequest.ts} (53%) rename src/serialization/resources/classrooms/client/requests/{RemoveUserFromClassroomRequest.ts => ClassroomsRemoveEnrolledUserRequest.ts} (53%) rename src/serialization/resources/classrooms/client/requests/{DeleteUserFromClassroomRequest.ts => ClassroomsRemoveMemberRequest.ts} (58%) rename src/serialization/resources/classrooms/client/requests/{UpsertClassroomRequest.ts => ClassroomsUpsertMemberRequest.ts} (62%) delete mode 100644 src/serialization/resources/classrooms/types/AceConfig.ts delete mode 100644 src/serialization/resources/classrooms/types/Level.ts delete mode 100644 src/serialization/resources/classrooms/types/MemberStat.ts delete mode 100644 src/serialization/resources/classrooms/types/PlayStats.ts delete mode 100644 src/serialization/resources/classrooms/types/State.ts delete mode 100644 src/serialization/resources/classrooms/types/index.ts delete mode 100644 src/serialization/resources/commons/index.ts delete mode 100644 src/serialization/resources/commons/types/AuthIdentity.ts delete mode 100644 src/serialization/resources/commons/types/Course.ts delete mode 100644 src/serialization/resources/commons/types/License.ts delete mode 100644 src/serialization/resources/commons/types/Subscription.ts delete mode 100644 src/serialization/resources/commons/types/UserStats.ts delete mode 100644 src/serialization/resources/commons/types/index.ts delete mode 100644 src/serialization/resources/stats/index.ts delete mode 100644 src/serialization/resources/stats/types/index.ts delete mode 100644 src/serialization/resources/users/client/requests/GetHeroRequest.ts delete mode 100644 src/serialization/resources/users/client/requests/GrantLicenseRequest.ts delete mode 100644 src/serialization/resources/users/client/requests/SetAceConfig.ts delete mode 100644 src/serialization/resources/users/client/requests/ShortenLicenseRequest.ts delete mode 100644 src/serialization/resources/users/client/requests/ShortenSubscriptionRequest.ts delete mode 100644 src/serialization/resources/users/client/requests/UpdateSubscriptionRequest.ts rename src/serialization/resources/users/client/requests/{CreateUserRequest.ts => UsersCreateRequest.ts} (52%) create mode 100644 src/serialization/resources/users/client/requests/UsersGrantLicenseRequest.ts create mode 100644 src/serialization/resources/users/client/requests/UsersGrantPremiumSubscriptionRequest.ts create mode 100644 src/serialization/resources/users/client/requests/UsersSetAceConfigRequest.ts create mode 100644 src/serialization/resources/users/client/requests/UsersSetHeroRequest.ts create mode 100644 src/serialization/resources/users/client/requests/UsersShortenLicenseRequest.ts create mode 100644 src/serialization/resources/users/client/requests/UsersShortenSubscriptionRequest.ts rename src/serialization/resources/users/client/requests/{UpdateUserRequest.ts => UsersUpdateRequest.ts} (62%) delete mode 100644 src/serialization/resources/users/types/HeroConfig.ts delete mode 100644 src/serialization/resources/users/types/UserRole.ts delete mode 100644 src/serialization/resources/users/types/index.ts rename src/serialization/{resources/clans => }/types/ClanResponse.ts (85%) rename src/serialization/{resources/commons => }/types/ClassroomResponse.ts (70%) create mode 100644 src/serialization/types/ClassroomResponseCoursesItem.ts rename src/serialization/{resources/commons => }/types/ClassroomResponseWithCode.ts (73%) create mode 100644 src/serialization/types/ClassroomResponseWithCodeCoursesItem.ts create mode 100644 src/serialization/types/ClassroomsCreateRequestAceConfig.ts create mode 100644 src/serialization/types/ClassroomsGetMembersStatsResponseItem.ts create mode 100644 src/serialization/types/ClassroomsGetMembersStatsResponseItemStats.ts rename src/serialization/{resources/commons => }/types/DatetimeString.ts (68%) rename src/serialization/{resources/classrooms => }/types/LevelSessionResponse.ts (73%) create mode 100644 src/serialization/types/LevelSessionResponseLevel.ts create mode 100644 src/serialization/types/LevelSessionResponseState.ts rename src/serialization/{resources/stats => }/types/LicenseStatsResponse.ts (84%) rename src/serialization/{resources/commons => }/types/ObjectIdString.ts (68%) rename src/serialization/{resources/stats => }/types/PlaytimeStatsResponse.ts (79%) rename src/serialization/{resources/commons => }/types/RoleString.ts (67%) rename src/serialization/{resources/commons => }/types/UserResponse.ts (59%) create mode 100644 src/serialization/types/UserResponseLicense.ts create mode 100644 src/serialization/types/UserResponseOAuthIdentitiesItem.ts create mode 100644 src/serialization/types/UserResponseStats.ts create mode 100644 src/serialization/types/UserResponseSubscription.ts create mode 100644 src/serialization/types/UsersCreateRequestHeroConfig.ts create mode 100644 src/serialization/types/UsersCreateRequestRole.ts create mode 100644 src/serialization/types/index.ts diff --git a/package.json b/package.json index d0ff5fa..f39e6b1 100644 --- a/package.json +++ b/package.json @@ -1,26 +1,25 @@ { "name": "@fern-api/codecombat", - "version": "0.0.18", + "version": "0.1.5", "private": false, "repository": "https://github.com/codecombat/codecombat-node", "main": "./index.js", "types": "./index.d.ts", "scripts": { "format": "prettier --write 'src/**/*.ts'", - "build": "tsc && tsc-alias", + "build": "tsc", "prepack": "cp -rv dist/. ." }, "dependencies": { - "@ungap/url-search-params": "0.2.2", "url-join": "4.0.1", "@types/url-join": "4.0.1", - "js-base64": "3.7.2", - "axios": "0.27.2" + "@ungap/url-search-params": "0.2.2", + "axios": "0.27.2", + "js-base64": "3.7.2" }, "devDependencies": { "@types/node": "17.0.33", "prettier": "2.7.1", - "tsc-alias": "1.7.1", "typescript": "4.6.4" } } \ No newline at end of file diff --git a/src/Client.ts b/src/Client.ts index e187235..d9a9760 100644 --- a/src/Client.ts +++ b/src/Client.ts @@ -4,6 +4,10 @@ import * as environments from "./environments"; import * as core from "./core"; +import * as CodeCombat from "./api"; +import * as serializers from "./serialization"; +import urlJoin from "url-join"; +import * as errors from "./errors"; import { Auth } from "./api/resources/auth/client/Client"; import { Clans } from "./api/resources/clans/client/Client"; import { Classrooms } from "./api/resources/classrooms/client/Client"; @@ -12,41 +16,111 @@ import { Users } from "./api/resources/users/client/Client"; export declare namespace CodeCombatClient { interface Options { - environment?: environments.CodeCombatEnvironment | string; - credentials: core.Supplier; + environment?: core.Supplier; + username: core.Supplier; + password: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; } } export class CodeCombatClient { - constructor(private readonly options: CodeCombatClient.Options) {} + constructor(protected readonly _options: CodeCombatClient.Options) {} + + /** + * Adds an OAuth2 identity to the user, so that they can be logged in with that identity. You need to send the OAuth code or the access token to this endpoint. 1. If no access token is provided, it will use your OAuth2 token URL to exchange the given code for an access token. 2. Then it will use the access token (given by you, or received from step 1) to look up the user on your service using the lookup URL, and expects a JSON object in response with an `id` property. 3. It will then save that user `id` to the user in our db as a new OAuthIdentity. In this example, we call your lookup URL (let's say, `https://oauth.provider/user?t=<%= accessToken %>`) with the access token (`1234`). The lookup URL returns `{ id: 'abcd' }` in this case, which we save to the user in our db. + * + */ + public async postUsersHandleOAuthIdentities( + handle: string, + request: CodeCombat.PostUsersHandleOAuthIdentitiesRequest, + requestOptions?: CodeCombatClient.RequestOptions + ): Promise { + const _response = await core.fetcher({ + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}/o-auth-identities` + ), + method: "POST", + headers: { + Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", + }, + contentType: "application/json", + body: await serializers.PostUsersHandleOAuthIdentitiesRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, + }); + if (_response.ok) { + return await serializers.UserResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); + } + + if (_response.error.reason === "status-code") { + throw new errors.CodeCombatError({ + statusCode: _response.error.statusCode, + body: _response.error.body, + }); + } - private _auth: Auth | undefined; + switch (_response.error.reason) { + case "non-json": + throw new errors.CodeCombatError({ + statusCode: _response.error.statusCode, + body: _response.error.rawBody, + }); + case "timeout": + throw new errors.CodeCombatTimeoutError(); + case "unknown": + throw new errors.CodeCombatError({ + message: _response.error.errorMessage, + }); + } + } + + protected _auth: Auth | undefined; public get auth(): Auth { - return (this._auth ??= new Auth(this.options)); + return (this._auth ??= new Auth(this._options)); } - private _clans: Clans | undefined; + protected _clans: Clans | undefined; public get clans(): Clans { - return (this._clans ??= new Clans(this.options)); + return (this._clans ??= new Clans(this._options)); } - private _classrooms: Classrooms | undefined; + protected _classrooms: Classrooms | undefined; public get classrooms(): Classrooms { - return (this._classrooms ??= new Classrooms(this.options)); + return (this._classrooms ??= new Classrooms(this._options)); } - private _stats: Stats | undefined; + protected _stats: Stats | undefined; public get stats(): Stats { - return (this._stats ??= new Stats(this.options)); + return (this._stats ??= new Stats(this._options)); } - private _users: Users | undefined; + protected _users: Users | undefined; public get users(): Users { - return (this._users ??= new Users(this.options)); + return (this._users ??= new Users(this._options)); + } + + protected async _getAuthorizationHeader() { + return core.BasicAuth.toAuthorizationHeader({ + username: await core.Supplier.get(this._options.username), + password: await core.Supplier.get(this._options.password), + }); } } diff --git a/src/api/client/index.ts b/src/api/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/api/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/api/resources/users/client/requests/AddOAuthIdentityRequest.ts b/src/api/client/requests/PostUsersHandleOAuthIdentitiesRequest.ts similarity index 86% rename from src/api/resources/users/client/requests/AddOAuthIdentityRequest.ts rename to src/api/client/requests/PostUsersHandleOAuthIdentitiesRequest.ts index f745413..fdb5784 100644 --- a/src/api/resources/users/client/requests/AddOAuthIdentityRequest.ts +++ b/src/api/client/requests/PostUsersHandleOAuthIdentitiesRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface AddOAuthIdentityRequest { +export interface PostUsersHandleOAuthIdentitiesRequest { /** Your OAuth Provider ID. */ provider: string; /** Will be passed through your lookup URL to get the user ID. Required if no `code`. */ diff --git a/src/api/client/requests/index.ts b/src/api/client/requests/index.ts new file mode 100644 index 0000000..69715ca --- /dev/null +++ b/src/api/client/requests/index.ts @@ -0,0 +1 @@ +export { PostUsersHandleOAuthIdentitiesRequest } from "./PostUsersHandleOAuthIdentitiesRequest"; diff --git a/src/api/index.ts b/src/api/index.ts index 3e5335f..a931b36 100644 --- a/src/api/index.ts +++ b/src/api/index.ts @@ -1 +1,3 @@ +export * from "./types"; export * from "./resources"; +export * from "./client"; diff --git a/src/api/resources/auth/client/Client.ts b/src/api/resources/auth/client/Client.ts index 039a15c..b8bb3ec 100644 --- a/src/api/resources/auth/client/Client.ts +++ b/src/api/resources/auth/client/Client.ts @@ -4,26 +4,34 @@ import * as environments from "../../../../environments"; import * as core from "../../../../core"; -import { CodeCombat } from "@fern-api/codecombat"; -import URLSearchParams from "@ungap/url-search-params"; +import * as CodeCombat from "../../.."; +import { default as URLSearchParams } from "@ungap/url-search-params"; import urlJoin from "url-join"; import * as errors from "../../../../errors"; export declare namespace Auth { interface Options { - environment?: environments.CodeCombatEnvironment | string; - credentials: core.Supplier; + environment?: core.Supplier; + username: core.Supplier; + password: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; } } export class Auth { - constructor(private readonly options: Auth.Options) {} + constructor(protected readonly _options: Auth.Options) {} /** - * Logs a [user](#users) in. #### Example ```javascript url = `https://codecombat.com/auth/login-o-auth?provider=${OAUTH_PROVIDER_ID}&accessToken=1234` res.redirect(url) // User is sent to this CodeCombat URL and assuming everything checks out, // is logged in and redirected to the home page. ``` In this example, we call your lookup URL (let's say, `https://oauth.provider/user?t=<%= accessToken %>`) with the access token (`1234`). The lookup URL returns `{ id: 'abcd' }` in this case. We will match this `id` with the OAuthIdentity stored in the user information in our db. If everything checks out, the user is logged in and redirected to the home page. + * Logs a user in. In this example, we call your lookup URL (let's say, `https://oauth.provider/user?t=<%= accessToken %>`) with the access token (`1234`). The lookup URL returns `{ id: 'abcd' }` in this case. We will match this `id` with the OAuthIdentity stored in the user information in our db. If everything checks out, the user is logged in and redirected to the home page. * */ - public async get(request: CodeCombat.GetUserAuthRequest): Promise { + public async loginOauth( + request: CodeCombat.LoginOauthRequest, + requestOptions?: Auth.RequestOptions + ): Promise { const { provider, accessToken, code, redirect, errorRedirect } = request; const _queryParams = new URLSearchParams(); _queryParams.append("provider", provider); @@ -45,15 +53,19 @@ export class Auth { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - "/auth/login-o-auth" + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + "auth/login-o-auth" ), method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return; @@ -81,12 +93,10 @@ export class Auth { } } - private async _getAuthorizationHeader() { - const credentials = await core.Supplier.get(this.options.credentials); - if (credentials != null) { - return core.BasicAuth.toAuthorizationHeader(await core.Supplier.get(credentials)); - } - - return undefined; + protected async _getAuthorizationHeader() { + return core.BasicAuth.toAuthorizationHeader({ + username: await core.Supplier.get(this._options.username), + password: await core.Supplier.get(this._options.password), + }); } } diff --git a/src/api/resources/auth/client/requests/GetUserAuthRequest.ts b/src/api/resources/auth/client/requests/LoginOauthRequest.ts similarity index 94% rename from src/api/resources/auth/client/requests/GetUserAuthRequest.ts rename to src/api/resources/auth/client/requests/LoginOauthRequest.ts index cf672c9..d2f015f 100644 --- a/src/api/resources/auth/client/requests/GetUserAuthRequest.ts +++ b/src/api/resources/auth/client/requests/LoginOauthRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface GetUserAuthRequest { +export interface LoginOauthRequest { /** * Your OAuth Provider ID */ diff --git a/src/api/resources/auth/client/requests/index.ts b/src/api/resources/auth/client/requests/index.ts index b690629..f76add8 100644 --- a/src/api/resources/auth/client/requests/index.ts +++ b/src/api/resources/auth/client/requests/index.ts @@ -1 +1 @@ -export { GetUserAuthRequest } from "./GetUserAuthRequest"; +export { LoginOauthRequest } from "./LoginOauthRequest"; diff --git a/src/api/resources/clans/client/Client.ts b/src/api/resources/clans/client/Client.ts index 81d36d5..cd3d58e 100644 --- a/src/api/resources/clans/client/Client.ts +++ b/src/api/resources/clans/client/Client.ts @@ -4,42 +4,56 @@ import * as environments from "../../../../environments"; import * as core from "../../../../core"; -import { CodeCombat } from "@fern-api/codecombat"; -import urlJoin from "url-join"; +import * as CodeCombat from "../../.."; import * as serializers from "../../../../serialization"; +import urlJoin from "url-join"; import * as errors from "../../../../errors"; export declare namespace Clans { interface Options { - environment?: environments.CodeCombatEnvironment | string; - credentials: core.Supplier; + environment?: core.Supplier; + username: core.Supplier; + password: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; } } export class Clans { - constructor(private readonly options: Clans.Options) {} + constructor(protected readonly _options: Clans.Options) {} /** * Upserts a user into the clan. */ - public async upsertClan(handle: string, request: CodeCombat.UpsertClanRequest): Promise { + public async upsertMember( + handle: string, + request: CodeCombat.ClansUpsertMemberRequest, + requestOptions?: Clans.RequestOptions + ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/clan/${handle}/members` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `clan/${handle}/members` ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.UpsertClanRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.ClansUpsertMemberRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.ClanResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -65,12 +79,10 @@ export class Clans { } } - private async _getAuthorizationHeader() { - const credentials = await core.Supplier.get(this.options.credentials); - if (credentials != null) { - return core.BasicAuth.toAuthorizationHeader(await core.Supplier.get(credentials)); - } - - return undefined; + protected async _getAuthorizationHeader() { + return core.BasicAuth.toAuthorizationHeader({ + username: await core.Supplier.get(this._options.username), + password: await core.Supplier.get(this._options.password), + }); } } diff --git a/src/api/resources/clans/client/requests/UpsertClanRequest.ts b/src/api/resources/clans/client/requests/ClansUpsertMemberRequest.ts similarity index 78% rename from src/api/resources/clans/client/requests/UpsertClanRequest.ts rename to src/api/resources/clans/client/requests/ClansUpsertMemberRequest.ts index c438c5a..1d22da9 100644 --- a/src/api/resources/clans/client/requests/UpsertClanRequest.ts +++ b/src/api/resources/clans/client/requests/ClansUpsertMemberRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface UpsertClanRequest { +export interface ClansUpsertMemberRequest { /** The `_id` or `slug` of the user to add to the clan. */ userId: string; } diff --git a/src/api/resources/clans/client/requests/index.ts b/src/api/resources/clans/client/requests/index.ts index 5bbb7a7..173b4df 100644 --- a/src/api/resources/clans/client/requests/index.ts +++ b/src/api/resources/clans/client/requests/index.ts @@ -1 +1 @@ -export { UpsertClanRequest } from "./UpsertClanRequest"; +export { ClansUpsertMemberRequest } from "./ClansUpsertMemberRequest"; diff --git a/src/api/resources/clans/index.ts b/src/api/resources/clans/index.ts index c9240f8..5ec7692 100644 --- a/src/api/resources/clans/index.ts +++ b/src/api/resources/clans/index.ts @@ -1,2 +1 @@ -export * from "./types"; export * from "./client"; diff --git a/src/api/resources/clans/types/index.ts b/src/api/resources/clans/types/index.ts deleted file mode 100644 index 77565d4..0000000 --- a/src/api/resources/clans/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./ClanResponse"; diff --git a/src/api/resources/classrooms/client/Client.ts b/src/api/resources/classrooms/client/Client.ts index 824bbfc..05654d5 100644 --- a/src/api/resources/classrooms/client/Client.ts +++ b/src/api/resources/classrooms/client/Client.ts @@ -4,26 +4,34 @@ import * as environments from "../../../../environments"; import * as core from "../../../../core"; -import { CodeCombat } from "@fern-api/codecombat"; -import URLSearchParams from "@ungap/url-search-params"; +import * as CodeCombat from "../../.."; +import { default as URLSearchParams } from "@ungap/url-search-params"; import urlJoin from "url-join"; import * as serializers from "../../../../serialization"; import * as errors from "../../../../errors"; export declare namespace Classrooms { interface Options { - environment?: environments.CodeCombatEnvironment | string; - credentials: core.Supplier; + environment?: core.Supplier; + username: core.Supplier; + password: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; } } export class Classrooms { - constructor(private readonly options: Classrooms.Options) {} + constructor(protected readonly _options: Classrooms.Options) {} /** * Returns the classroom details for a class code. */ - public async get(request: CodeCombat.GetClassroomDetailsRequest): Promise { + public async get( + request: CodeCombat.ClassroomsGetRequest, + requestOptions?: Classrooms.RequestOptions + ): Promise { const { code, retMemberLimit } = request; const _queryParams = new URLSearchParams(); _queryParams.append("code", code); @@ -32,19 +40,27 @@ export class Classrooms { } const _response = await core.fetcher({ - url: urlJoin(this.options.environment ?? environments.CodeCombatEnvironment.Production, "/classrooms"), + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + "classrooms" + ), method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.ClassroomResponseWithCode.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -73,18 +89,33 @@ export class Classrooms { /** * Creates a new empty `Classroom`. */ - public async create(request: CodeCombat.CreateClassroomRequest): Promise { + public async create( + request: CodeCombat.ClassroomsCreateRequest, + requestOptions?: Classrooms.RequestOptions + ): Promise { const _response = await core.fetcher({ - url: urlJoin(this.options.environment ?? environments.CodeCombatEnvironment.Production, "/classrooms"), + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + "classrooms" + ), method: "POST", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.CreateClassroomRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.ClassroomsCreateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { - return; + return await serializers.ClassroomResponseWithCode.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); } if (_response.error.reason === "status-code") { @@ -112,27 +143,35 @@ export class Classrooms { /** * Upserts a user into the classroom. */ - public async upsertFromClassroom( + public async upsertMember( handle: string, - request: CodeCombat.UpsertClassroomRequest + request: CodeCombat.ClassroomsUpsertMemberRequest, + requestOptions?: Classrooms.RequestOptions ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/classrooms/${handle}/members` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `classrooms/${handle}/members` ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.UpsertClassroomRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.ClassroomsUpsertMemberRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.ClassroomResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -161,29 +200,35 @@ export class Classrooms { /** * Remove a user from the classroom. */ - public async deleteUserFromClassroom( + public async removeMember( handle: string, - request: CodeCombat.DeleteUserFromClassroomRequest + request: CodeCombat.ClassroomsRemoveMemberRequest, + requestOptions?: Classrooms.RequestOptions ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/classrooms/${handle}/members` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `classrooms/${handle}/members` ), method: "DELETE", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.DeleteUserFromClassroomRequest.jsonOrThrow(request, { + body: await serializers.ClassroomsRemoveMemberRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip", }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.ClassroomResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -218,7 +263,8 @@ export class Classrooms { public async enrollUserInCourse( classroomHandle: string, courseHandle: string, - request: CodeCombat.EnrollUserInCourseRequest + request: CodeCombat.ClassroomsEnrollUserInCourseRequest, + requestOptions?: Classrooms.RequestOptions ): Promise { const { retMemberLimit, ..._body } = request; const _queryParams = new URLSearchParams(); @@ -228,22 +274,29 @@ export class Classrooms { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/classrooms/${classroomHandle}/courses/${courseHandle}/enrolled` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `classrooms/${classroomHandle}/courses/${courseHandle}/enrolled` ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", queryParameters: _queryParams, - body: await serializers.EnrollUserInCourseRequest.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip" }), + body: await serializers.ClassroomsEnrollUserInCourseRequest.jsonOrThrow(_body, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.ClassroomResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -273,10 +326,11 @@ export class Classrooms { * Removes an enrolled user from a course in a classroom. * */ - public async removeUserFromClassroom( + public async removeEnrolledUser( classroomHandle: string, courseHandle: string, - request: CodeCombat.RemoveUserFromClassroomRequest + request: CodeCombat.ClassroomsRemoveEnrolledUserRequest, + requestOptions?: Classrooms.RequestOptions ): Promise { const { retMemberLimit, ..._body } = request; const _queryParams = new URLSearchParams(); @@ -286,24 +340,29 @@ export class Classrooms { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/classrooms/${classroomHandle}/courses/${courseHandle}/remove-enrolled` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `classrooms/${classroomHandle}/courses/${courseHandle}/remove-enrolled` ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", queryParameters: _queryParams, - body: await serializers.RemoveUserFromClassroomRequest.jsonOrThrow(_body, { + body: await serializers.ClassroomsRemoveEnrolledUserRequest.jsonOrThrow(_body, { unrecognizedObjectKeys: "strip", }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.ClassroomResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -335,8 +394,9 @@ export class Classrooms { */ public async getMembersStats( classroomHandle: string, - request: CodeCombat.GetMembersStatsRequest = {} - ): Promise { + request: CodeCombat.ClassroomsGetMembersStatsRequest = {}, + requestOptions?: Classrooms.RequestOptions + ): Promise { const { project, memberLimit, memberSkip } = request; const _queryParams = new URLSearchParams(); if (project != null) { @@ -353,21 +413,26 @@ export class Classrooms { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/classrooms/${classroomHandle}/stats` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `classrooms/${classroomHandle}/stats` ), method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.classrooms.getMembersStats.Response.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -397,26 +462,32 @@ export class Classrooms { * Returns a list of all levels played by the user for the classroom. * */ - public async getLevelSession( + public async getLevelsPlayed( classroomHandle: string, - memberHandle: string + memberHandle: string, + requestOptions?: Classrooms.RequestOptions ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/classrooms/${classroomHandle}/members/${memberHandle}/sessions` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `classrooms/${classroomHandle}/members/${memberHandle}/sessions` ), method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { - return await serializers.classrooms.getLevelSession.Response.parseOrThrow(_response.body, { + return await serializers.classrooms.getLevelsPlayed.Response.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -442,12 +513,10 @@ export class Classrooms { } } - private async _getAuthorizationHeader() { - const credentials = await core.Supplier.get(this.options.credentials); - if (credentials != null) { - return core.BasicAuth.toAuthorizationHeader(await core.Supplier.get(credentials)); - } - - return undefined; + protected async _getAuthorizationHeader() { + return core.BasicAuth.toAuthorizationHeader({ + username: await core.Supplier.get(this._options.username), + password: await core.Supplier.get(this._options.password), + }); } } diff --git a/src/api/resources/classrooms/client/requests/CreateClassroomRequest.ts b/src/api/resources/classrooms/client/requests/ClassroomsCreateRequest.ts similarity index 53% rename from src/api/resources/classrooms/client/requests/CreateClassroomRequest.ts rename to src/api/resources/classrooms/client/requests/ClassroomsCreateRequest.ts index 797d2ee..048a54f 100644 --- a/src/api/resources/classrooms/client/requests/CreateClassroomRequest.ts +++ b/src/api/resources/classrooms/client/requests/ClassroomsCreateRequest.ts @@ -2,11 +2,11 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../.."; -export interface CreateClassroomRequest { +export interface ClassroomsCreateRequest { /** Name of the classroom */ name: string; ownerId: CodeCombat.ObjectIdString; - aceConfig: CodeCombat.AceConfig; + aceConfig: CodeCombat.ClassroomsCreateRequestAceConfig; } diff --git a/src/api/resources/classrooms/client/requests/EnrollUserInCourseRequest.ts b/src/api/resources/classrooms/client/requests/ClassroomsEnrollUserInCourseRequest.ts similarity index 71% rename from src/api/resources/classrooms/client/requests/EnrollUserInCourseRequest.ts rename to src/api/resources/classrooms/client/requests/ClassroomsEnrollUserInCourseRequest.ts index 2ab934f..2a67e31 100644 --- a/src/api/resources/classrooms/client/requests/EnrollUserInCourseRequest.ts +++ b/src/api/resources/classrooms/client/requests/ClassroomsEnrollUserInCourseRequest.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../.."; -export interface EnrollUserInCourseRequest { +export interface ClassroomsEnrollUserInCourseRequest { /** * limit the return number of members for the classroom, the default value is 1000 */ diff --git a/src/api/resources/classrooms/client/requests/GetMembersStatsRequest.ts b/src/api/resources/classrooms/client/requests/ClassroomsGetMembersStatsRequest.ts similarity index 91% rename from src/api/resources/classrooms/client/requests/GetMembersStatsRequest.ts rename to src/api/resources/classrooms/client/requests/ClassroomsGetMembersStatsRequest.ts index 729d471..9f2b9f1 100644 --- a/src/api/resources/classrooms/client/requests/GetMembersStatsRequest.ts +++ b/src/api/resources/classrooms/client/requests/ClassroomsGetMembersStatsRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface GetMembersStatsRequest { +export interface ClassroomsGetMembersStatsRequest { /** * If specified, include only the specified projection of returned stats; else, return all stats. Format as a comma-separated list, like `creator,playtime,state.complete`. * diff --git a/src/api/resources/classrooms/client/requests/GetClassroomDetailsRequest.ts b/src/api/resources/classrooms/client/requests/ClassroomsGetRequest.ts similarity index 84% rename from src/api/resources/classrooms/client/requests/GetClassroomDetailsRequest.ts rename to src/api/resources/classrooms/client/requests/ClassroomsGetRequest.ts index 92040f2..4bd1374 100644 --- a/src/api/resources/classrooms/client/requests/GetClassroomDetailsRequest.ts +++ b/src/api/resources/classrooms/client/requests/ClassroomsGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface GetClassroomDetailsRequest { +export interface ClassroomsGetRequest { /** * The classroom's `code`. */ diff --git a/src/api/resources/classrooms/client/requests/RemoveUserFromClassroomRequest.ts b/src/api/resources/classrooms/client/requests/ClassroomsRemoveEnrolledUserRequest.ts similarity index 71% rename from src/api/resources/classrooms/client/requests/RemoveUserFromClassroomRequest.ts rename to src/api/resources/classrooms/client/requests/ClassroomsRemoveEnrolledUserRequest.ts index 0c08b5a..cc22550 100644 --- a/src/api/resources/classrooms/client/requests/RemoveUserFromClassroomRequest.ts +++ b/src/api/resources/classrooms/client/requests/ClassroomsRemoveEnrolledUserRequest.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../.."; -export interface RemoveUserFromClassroomRequest { +export interface ClassroomsRemoveEnrolledUserRequest { /** * limit the return number of members for the classroom, the default value is 1000 */ diff --git a/src/api/resources/classrooms/client/requests/DeleteUserFromClassroomRequest.ts b/src/api/resources/classrooms/client/requests/ClassroomsRemoveMemberRequest.ts similarity index 85% rename from src/api/resources/classrooms/client/requests/DeleteUserFromClassroomRequest.ts rename to src/api/resources/classrooms/client/requests/ClassroomsRemoveMemberRequest.ts index a5acd8d..b6533e0 100644 --- a/src/api/resources/classrooms/client/requests/DeleteUserFromClassroomRequest.ts +++ b/src/api/resources/classrooms/client/requests/ClassroomsRemoveMemberRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface DeleteUserFromClassroomRequest { +export interface ClassroomsRemoveMemberRequest { /** The `_id` or `slug` of the user to remove from the class. */ userId: string; /** limit the return number of members for the classroom, the default value is 1000 */ diff --git a/src/api/resources/classrooms/client/requests/UpsertClassroomRequest.ts b/src/api/resources/classrooms/client/requests/ClassroomsUpsertMemberRequest.ts similarity index 87% rename from src/api/resources/classrooms/client/requests/UpsertClassroomRequest.ts rename to src/api/resources/classrooms/client/requests/ClassroomsUpsertMemberRequest.ts index 80711be..cd00022 100644 --- a/src/api/resources/classrooms/client/requests/UpsertClassroomRequest.ts +++ b/src/api/resources/classrooms/client/requests/ClassroomsUpsertMemberRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface UpsertClassroomRequest { +export interface ClassroomsUpsertMemberRequest { /** The code for joining this classroom */ code: string; /** The `_id` or `slug` of the user to add to the class. */ diff --git a/src/api/resources/classrooms/client/requests/index.ts b/src/api/resources/classrooms/client/requests/index.ts index 21b0c0b..03d1dd3 100644 --- a/src/api/resources/classrooms/client/requests/index.ts +++ b/src/api/resources/classrooms/client/requests/index.ts @@ -1,7 +1,7 @@ -export { GetClassroomDetailsRequest } from "./GetClassroomDetailsRequest"; -export { CreateClassroomRequest } from "./CreateClassroomRequest"; -export { UpsertClassroomRequest } from "./UpsertClassroomRequest"; -export { DeleteUserFromClassroomRequest } from "./DeleteUserFromClassroomRequest"; -export { EnrollUserInCourseRequest } from "./EnrollUserInCourseRequest"; -export { RemoveUserFromClassroomRequest } from "./RemoveUserFromClassroomRequest"; -export { GetMembersStatsRequest } from "./GetMembersStatsRequest"; +export { ClassroomsGetRequest } from "./ClassroomsGetRequest"; +export { ClassroomsCreateRequest } from "./ClassroomsCreateRequest"; +export { ClassroomsUpsertMemberRequest } from "./ClassroomsUpsertMemberRequest"; +export { ClassroomsRemoveMemberRequest } from "./ClassroomsRemoveMemberRequest"; +export { ClassroomsEnrollUserInCourseRequest } from "./ClassroomsEnrollUserInCourseRequest"; +export { ClassroomsRemoveEnrolledUserRequest } from "./ClassroomsRemoveEnrolledUserRequest"; +export { ClassroomsGetMembersStatsRequest } from "./ClassroomsGetMembersStatsRequest"; diff --git a/src/api/resources/classrooms/index.ts b/src/api/resources/classrooms/index.ts index c9240f8..5ec7692 100644 --- a/src/api/resources/classrooms/index.ts +++ b/src/api/resources/classrooms/index.ts @@ -1,2 +1 @@ -export * from "./types"; export * from "./client"; diff --git a/src/api/resources/classrooms/types/MemberStat.ts b/src/api/resources/classrooms/types/MemberStat.ts deleted file mode 100644 index d264cec..0000000 --- a/src/api/resources/classrooms/types/MemberStat.ts +++ /dev/null @@ -1,10 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import { CodeCombat } from "@fern-api/codecombat"; - -export interface MemberStat { - id?: CodeCombat.ObjectIdString; - stats?: CodeCombat.PlayStats; -} diff --git a/src/api/resources/classrooms/types/index.ts b/src/api/resources/classrooms/types/index.ts deleted file mode 100644 index a217cb9..0000000 --- a/src/api/resources/classrooms/types/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./LevelSessionResponse"; -export * from "./State"; -export * from "./Level"; -export * from "./AceConfig"; -export * from "./PlayStats"; -export * from "./MemberStat"; diff --git a/src/api/resources/commons/index.ts b/src/api/resources/commons/index.ts deleted file mode 100644 index eea524d..0000000 --- a/src/api/resources/commons/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types"; diff --git a/src/api/resources/commons/types/index.ts b/src/api/resources/commons/types/index.ts deleted file mode 100644 index 374d90d..0000000 --- a/src/api/resources/commons/types/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export * from "./UserResponse"; -export * from "./UserStats"; -export * from "./AuthIdentity"; -export * from "./Subscription"; -export * from "./License"; -export * from "./ObjectIdString"; -export * from "./RoleString"; -export * from "./DatetimeString"; -export * from "./ClassroomResponseWithCode"; -export * from "./Course"; -export * from "./ClassroomResponse"; diff --git a/src/api/resources/index.ts b/src/api/resources/index.ts index 4ebfe69..1369826 100644 --- a/src/api/resources/index.ts +++ b/src/api/resources/index.ts @@ -1,14 +1,8 @@ +export * as auth from "./auth"; export * as clans from "./clans"; -export * from "./clans/types"; export * as classrooms from "./classrooms"; -export * from "./classrooms/types"; -export * as commons from "./commons"; -export * from "./commons/types"; export * as stats from "./stats"; -export * from "./stats/types"; export * as users from "./users"; -export * from "./users/types"; -export * as auth from "./auth"; export * from "./auth/client/requests"; export * from "./clans/client/requests"; export * from "./classrooms/client/requests"; diff --git a/src/api/resources/stats/client/Client.ts b/src/api/resources/stats/client/Client.ts index a0adc83..a034e0a 100644 --- a/src/api/resources/stats/client/Client.ts +++ b/src/api/resources/stats/client/Client.ts @@ -4,27 +4,33 @@ import * as environments from "../../../../environments"; import * as core from "../../../../core"; -import { CodeCombat } from "@fern-api/codecombat"; -import URLSearchParams from "@ungap/url-search-params"; +import * as CodeCombat from "../../.."; +import { default as URLSearchParams } from "@ungap/url-search-params"; import urlJoin from "url-join"; import * as serializers from "../../../../serialization"; import * as errors from "../../../../errors"; export declare namespace Stats { interface Options { - environment?: environments.CodeCombatEnvironment | string; - credentials: core.Supplier; + environment?: core.Supplier; + username: core.Supplier; + password: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; } } export class Stats { - constructor(private readonly options: Stats.Options) {} + constructor(protected readonly _options: Stats.Options) {} /** * Returns the playtime stats */ public async getPlaytimeStats( - request: CodeCombat.GetPlaytimeStats = {} + request: CodeCombat.StatsGetPlaytimeStatsRequest = {}, + requestOptions?: Stats.RequestOptions ): Promise { const { startDate, endDate, country } = request; const _queryParams = new URLSearchParams(); @@ -41,19 +47,27 @@ export class Stats { } const _response = await core.fetcher({ - url: urlJoin(this.options.environment ?? environments.CodeCombatEnvironment.Production, "/playtime-stats"), + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + "playtime-stats" + ), method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.PlaytimeStatsResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -82,20 +96,28 @@ export class Stats { /** * Returns the license stats */ - public async getLicenseStats(): Promise { + public async getLicenseStats(requestOptions?: Stats.RequestOptions): Promise { const _response = await core.fetcher({ - url: urlJoin(this.options.environment ?? environments.CodeCombatEnvironment.Production, "/license-stats"), + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + "license-stats" + ), method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.LicenseStatsResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -121,12 +143,10 @@ export class Stats { } } - private async _getAuthorizationHeader() { - const credentials = await core.Supplier.get(this.options.credentials); - if (credentials != null) { - return core.BasicAuth.toAuthorizationHeader(await core.Supplier.get(credentials)); - } - - return undefined; + protected async _getAuthorizationHeader() { + return core.BasicAuth.toAuthorizationHeader({ + username: await core.Supplier.get(this._options.username), + password: await core.Supplier.get(this._options.password), + }); } } diff --git a/src/api/resources/stats/client/requests/GetPlaytimeStats.ts b/src/api/resources/stats/client/requests/StatsGetPlaytimeStatsRequest.ts similarity index 86% rename from src/api/resources/stats/client/requests/GetPlaytimeStats.ts rename to src/api/resources/stats/client/requests/StatsGetPlaytimeStatsRequest.ts index d16e463..5cbad0a 100644 --- a/src/api/resources/stats/client/requests/GetPlaytimeStats.ts +++ b/src/api/resources/stats/client/requests/StatsGetPlaytimeStatsRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface GetPlaytimeStats { +export interface StatsGetPlaytimeStatsRequest { /** * Earliest an included user was created */ diff --git a/src/api/resources/stats/client/requests/index.ts b/src/api/resources/stats/client/requests/index.ts index 1a3f226..270a177 100644 --- a/src/api/resources/stats/client/requests/index.ts +++ b/src/api/resources/stats/client/requests/index.ts @@ -1 +1 @@ -export { GetPlaytimeStats } from "./GetPlaytimeStats"; +export { StatsGetPlaytimeStatsRequest } from "./StatsGetPlaytimeStatsRequest"; diff --git a/src/api/resources/stats/index.ts b/src/api/resources/stats/index.ts index c9240f8..5ec7692 100644 --- a/src/api/resources/stats/index.ts +++ b/src/api/resources/stats/index.ts @@ -1,2 +1 @@ -export * from "./types"; export * from "./client"; diff --git a/src/api/resources/stats/types/index.ts b/src/api/resources/stats/types/index.ts deleted file mode 100644 index aa26a9e..0000000 --- a/src/api/resources/stats/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./PlaytimeStatsResponse"; -export * from "./LicenseStatsResponse"; diff --git a/src/api/resources/users/client/Client.ts b/src/api/resources/users/client/Client.ts index 93f23ec..9b6694c 100644 --- a/src/api/resources/users/client/Client.ts +++ b/src/api/resources/users/client/Client.ts @@ -4,44 +4,58 @@ import * as environments from "../../../../environments"; import * as core from "../../../../core"; -import { CodeCombat } from "@fern-api/codecombat"; -import urlJoin from "url-join"; +import * as CodeCombat from "../../.."; import * as serializers from "../../../../serialization"; +import urlJoin from "url-join"; import * as errors from "../../../../errors"; -import URLSearchParams from "@ungap/url-search-params"; +import { default as URLSearchParams } from "@ungap/url-search-params"; export declare namespace Users { interface Options { - environment?: environments.CodeCombatEnvironment | string; - credentials: core.Supplier; + environment?: core.Supplier; + username: core.Supplier; + password: core.Supplier; + } + + interface RequestOptions { + timeoutInSeconds?: number; } } export class Users { - constructor(private readonly options: Users.Options) {} + constructor(protected readonly _options: Users.Options) {} /** * Creates a `User`. - * #### Example - * ```javascript - * url = 'https://codecombat.com/api/users' - * json = { email: 'an@email.com', name: 'Some Username', role: 'student' } - * request.post({ url, json, auth }) - * ``` * */ - public async create(request: CodeCombat.CreateUserRequest): Promise { + public async create( + request: CodeCombat.UsersCreateRequest, + requestOptions?: Users.RequestOptions + ): Promise { const _response = await core.fetcher({ - url: urlJoin(this.options.environment ?? environments.CodeCombatEnvironment.Production, "/users"), + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + "users" + ), method: "POST", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.CreateUserRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.UsersCreateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { - return; + return await serializers.UserResponse.parseOrThrow(_response.body, { + unrecognizedObjectKeys: "passthrough", + allowUnrecognizedUnionMembers: true, + allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], + }); } if (_response.error.reason === "status-code") { @@ -69,7 +83,11 @@ export class Users { /** * Returns a `User`. */ - public async get(handle: string, request: CodeCombat.GetUserRequest = {}): Promise { + public async get( + handle: string, + request: CodeCombat.UsersGetRequest = {}, + requestOptions?: Users.RequestOptions + ): Promise { const { includePlayTime } = request; const _queryParams = new URLSearchParams(); if (includePlayTime != null) { @@ -77,19 +95,27 @@ export class Users { } const _response = await core.fetcher({ - url: urlJoin(this.options.environment ?? environments.CodeCombatEnvironment.Production, `/users/${handle}`), + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}` + ), method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.UserResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -118,21 +144,33 @@ export class Users { /** * Modify name of a `User` */ - public async update(handle: string, request: CodeCombat.UpdateUserRequest): Promise { + public async update( + handle: string, + request: CodeCombat.UsersUpdateRequest, + requestOptions?: Users.RequestOptions + ): Promise { const _response = await core.fetcher({ - url: urlJoin(this.options.environment ?? environments.CodeCombatEnvironment.Production, `/users/${handle}`), + url: urlJoin( + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}` + ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.UpdateUserRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.UsersUpdateRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.UserResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -163,7 +201,8 @@ export class Users { */ public async getClassrooms( handle: string, - request: CodeCombat.GetClassroomsRequest = {} + request: CodeCombat.UsersGetClassroomsRequest = {}, + requestOptions?: Users.RequestOptions ): Promise { const { retMemberLimit } = request; const _queryParams = new URLSearchParams(); @@ -173,21 +212,26 @@ export class Users { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/users/${handle}/classrooms` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}/classrooms` ), method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", queryParameters: _queryParams, + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.users.getClassrooms.Response.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -216,24 +260,33 @@ export class Users { /** * Set the user's hero. */ - public async getHero(handle: string, request: CodeCombat.GetHeroRequest = {}): Promise { + public async setHero( + handle: string, + request: CodeCombat.UsersSetHeroRequest = {}, + requestOptions?: Users.RequestOptions + ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/users/${handle}/hero-config` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}/hero-config` ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.GetHeroRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.UsersSetHeroRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.UserResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -262,76 +315,33 @@ export class Users { /** * Set the user's aceConfig (the settings for the in-game Ace code editor), such as whether to enable autocomplete. */ - public async setAceConfig(handle: string, request: CodeCombat.SetAceConfig = {}): Promise { - const _response = await core.fetcher({ - url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/users/${handle}/ace-config` - ), - method: "PUT", - headers: { - Authorization: await this._getAuthorizationHeader(), - }, - contentType: "application/json", - body: await serializers.SetAceConfig.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), - }); - if (_response.ok) { - return await serializers.UserResponse.parseOrThrow(_response.body, { - unrecognizedObjectKeys: "passthrough", - allowUnrecognizedUnionMembers: true, - allowUnrecognizedEnumValues: true, - }); - } - - if (_response.error.reason === "status-code") { - throw new errors.CodeCombatError({ - statusCode: _response.error.statusCode, - body: _response.error.body, - }); - } - - switch (_response.error.reason) { - case "non-json": - throw new errors.CodeCombatError({ - statusCode: _response.error.statusCode, - body: _response.error.rawBody, - }); - case "timeout": - throw new errors.CodeCombatTimeoutError(); - case "unknown": - throw new errors.CodeCombatError({ - message: _response.error.errorMessage, - }); - } - } - - /** - * Adds an OAuth2 identity to the user, so that they can be logged in with that identity. You need to send the OAuth code or the access token to this endpoint. 1. If no access token is provided, it will use your OAuth2 token URL to exchange the given code for an access token. 1. Then it will use the access token (given by you, or received from step 1) to look up the user on your service using the lookup URL, and expects a JSON object in response with an `id` property. 1. It will then save that user `id` to the user in our db as a new OAuthIdentity. #### Example ```javascript url = `https://codecombat.com/api/users/${userID}/o-auth-identities` OAUTH_PROVIDER_ID = 'xyz' json = { provider: OAUTH_PROVIDER_ID, accessToken: '1234' } request.post({ url, json, auth}, (err, res) => { - * console.log(res.body.oAuthIdentities) // [ { provider: 'xyx', id: 'abcd' } ] - * }) ``` In this example, we call your lookup URL (let's say, `https://oauth.provider/user?t=<%= accessToken %>`) with the access token (`1234`). The lookup URL returns `{ id: 'abcd' }` in this case, which we save to the user in our db. - * - */ - public async addOAuthIdentity( + public async setAceConfig( handle: string, - request: CodeCombat.AddOAuthIdentityRequest + request: CodeCombat.UsersSetAceConfigRequest = {}, + requestOptions?: Users.RequestOptions ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/users/${handle}/o-auth-identities` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}/ace-config` ), - method: "POST", + method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.AddOAuthIdentityRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.UsersSetAceConfigRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.UserResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -359,37 +369,37 @@ export class Users { /** * Grants a user premium access to the "Home" version up to a certain time. - * #### Example - * ```javascript - * url = `https://codecombat.com/api/users/${userID}/subscription` - * json = { ends: new Date('2017-01-01').toISOString() } - * request.put({ url, json, auth }, (err, res) => { - * console.log(res.body.subscription) // { ends: '2017-01-01T00:00:00.000Z', active: true } - * }) - * ``` * */ - public async updateSubscription( + public async grantPremiumSubscription( handle: string, - request: CodeCombat.UpdateSubscriptionRequest + request: CodeCombat.UsersGrantPremiumSubscriptionRequest, + requestOptions?: Users.RequestOptions ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/users/${handle}/subscription` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}/subscription` ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.UpdateSubscriptionRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.UsersGrantPremiumSubscriptionRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.UserResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -416,34 +426,38 @@ export class Users { } /** - * If the user already has a premium access up to a certain time, this shortens/revokes his/her premium access. If the ends is less than or equal to the current time, it revokes the subscription and sets the end date to be the current time, else it just shortens the subscription. #### Example ```javascript url = `https://codecombat.com/api/users/${userID}/shorten-subscription` json = { ends: new Date().toISOString() } request.put({ url, json, auth }, (err, res) => { - * console.log(res.body.subscription.active) // false - * }) ``` + * If the user already has a premium access up to a certain time, this shortens/revokes his/her premium access. If the ends is less than or equal to the current time, it revokes the subscription and sets the end date to be the current time, else it just shortens the subscription. * */ public async shortenSubscription( handle: string, - request: CodeCombat.ShortenSubscriptionRequest + request: CodeCombat.UsersShortenSubscriptionRequest, + requestOptions?: Users.RequestOptions ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/users/${handle}/shorten-subscription` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}/shorten-subscription` ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.ShortenSubscriptionRequest.jsonOrThrow(request, { + body: await serializers.UsersShortenSubscriptionRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip", }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.UserResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -472,37 +486,35 @@ export class Users { /** * Grants a user access to the "Classroom" version up to a certain time. * Sets their role to "student". - * #### Example - * ```javascript - * url = `https://codecombat.com/api/users/${userID}/license` - * json = { ends: new Date('2017-01-01').toISOString() } - * request.put({ url, json, auth }, (err, res) => { - * console.log(res.body.license) // { ends: '2017-01-01T00:00:00.000Z', active: true } - * }) - * ``` * */ public async grantLicense( handle: string, - request: CodeCombat.GrantLicenseRequest + request: CodeCombat.UsersGrantLicenseRequest, + requestOptions?: Users.RequestOptions ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/users/${handle}/license` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}/license` ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.GrantLicenseRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.UsersGrantLicenseRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.UserResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -529,32 +541,38 @@ export class Users { } /** - * If the user already has access to the "Classroom" version up to a certain time, this shortens/revokes his/her access. If the ends is less than or equal to the current time, it revokes the enrollment and sets the end date to be the current time, else it just shortens the enrollment. #### Example ```javascript url = `https://codecombat.com/api/users/${userID}/shorten-license` json = { ends: new Date().toISOString() } request.put({ url, json, auth }, (err, res) => { - * console.log(res.body.license.active) // false - * }) ``` + * If the user already has access to the "Classroom" version up to a certain time, this shortens/revokes his/her access. If the ends is less than or equal to the current time, it revokes the enrollment and sets the end date to be the current time, else it just shortens the enrollment. * */ public async shortenLicense( handle: string, - request: CodeCombat.ShortenLicenseRequest + request: CodeCombat.UsersShortenLicenseRequest, + requestOptions?: Users.RequestOptions ): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/users/${handle}/shorten-license` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `users/${handle}/shorten-license` ), method: "PUT", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", - body: await serializers.ShortenLicenseRequest.jsonOrThrow(request, { unrecognizedObjectKeys: "strip" }), + body: await serializers.UsersShortenLicenseRequest.jsonOrThrow(request, { + unrecognizedObjectKeys: "strip", + }), + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return await serializers.UserResponse.parseOrThrow(_response.body, { unrecognizedObjectKeys: "passthrough", allowUnrecognizedUnionMembers: true, allowUnrecognizedEnumValues: true, + breadcrumbsPrefix: ["response"], }); } @@ -583,17 +601,21 @@ export class Users { /** * Redirects to `/users/{handle}` given a unique, identifying property */ - public async findUser(property: string, value: string): Promise { + public async lookup(property: string, value: string, requestOptions?: Users.RequestOptions): Promise { const _response = await core.fetcher({ url: urlJoin( - this.options.environment ?? environments.CodeCombatEnvironment.Production, - `/user-lookup/${property}/${value}` + (await core.Supplier.get(this._options.environment)) ?? environments.CodeCombatEnvironment.Default, + `user-lookup/${property}/${value}` ), method: "GET", headers: { Authorization: await this._getAuthorizationHeader(), + "X-Fern-Language": "JavaScript", + "X-Fern-SDK-Name": "@fern-api/codecombat", + "X-Fern-SDK-Version": "0.1.5", }, contentType: "application/json", + timeoutMs: requestOptions?.timeoutInSeconds != null ? requestOptions.timeoutInSeconds * 1000 : 60000, }); if (_response.ok) { return; @@ -621,12 +643,10 @@ export class Users { } } - private async _getAuthorizationHeader() { - const credentials = await core.Supplier.get(this.options.credentials); - if (credentials != null) { - return core.BasicAuth.toAuthorizationHeader(await core.Supplier.get(credentials)); - } - - return undefined; + protected async _getAuthorizationHeader() { + return core.BasicAuth.toAuthorizationHeader({ + username: await core.Supplier.get(this._options.username), + password: await core.Supplier.get(this._options.password), + }); } } diff --git a/src/api/resources/users/client/requests/CreateUserRequest.ts b/src/api/resources/users/client/requests/CreateUserRequest.ts deleted file mode 100644 index ba96efb..0000000 --- a/src/api/resources/users/client/requests/CreateUserRequest.ts +++ /dev/null @@ -1,15 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import { CodeCombat } from "@fern-api/codecombat"; - -export interface CreateUserRequest { - name: string; - email: string; - /** A `"student"` or `"teacher"`. If unset, a home user will be created, unable to join classrooms. */ - role?: CodeCombat.UserRole; - preferredLanguage?: string; - heroConfig?: CodeCombat.HeroConfig; - birthday?: string; -} diff --git a/src/api/resources/users/client/requests/GrantLicenseRequest.ts b/src/api/resources/users/client/requests/GrantLicenseRequest.ts deleted file mode 100644 index 5f48cf8..0000000 --- a/src/api/resources/users/client/requests/GrantLicenseRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -export interface GrantLicenseRequest { - ends: Date; -} diff --git a/src/api/resources/users/client/requests/ShortenLicenseRequest.ts b/src/api/resources/users/client/requests/ShortenLicenseRequest.ts deleted file mode 100644 index 6306ff7..0000000 --- a/src/api/resources/users/client/requests/ShortenLicenseRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -export interface ShortenLicenseRequest { - ends: Date; -} diff --git a/src/api/resources/users/client/requests/ShortenSubscriptionRequest.ts b/src/api/resources/users/client/requests/ShortenSubscriptionRequest.ts deleted file mode 100644 index e3db030..0000000 --- a/src/api/resources/users/client/requests/ShortenSubscriptionRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -export interface ShortenSubscriptionRequest { - ends: Date; -} diff --git a/src/api/resources/users/client/requests/UpdateSubscriptionRequest.ts b/src/api/resources/users/client/requests/UpdateSubscriptionRequest.ts deleted file mode 100644 index adeddd1..0000000 --- a/src/api/resources/users/client/requests/UpdateSubscriptionRequest.ts +++ /dev/null @@ -1,7 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -export interface UpdateSubscriptionRequest { - ends: Date; -} diff --git a/src/api/resources/users/client/requests/UsersCreateRequest.ts b/src/api/resources/users/client/requests/UsersCreateRequest.ts new file mode 100644 index 0000000..0802cbc --- /dev/null +++ b/src/api/resources/users/client/requests/UsersCreateRequest.ts @@ -0,0 +1,18 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as CodeCombat from "../../../.."; + +export interface UsersCreateRequest { + name: string; + email: string; + /** + * `"student"` or `"teacher"`. If unset, a home user will be created, unable to join classrooms. + * + */ + role?: CodeCombat.UsersCreateRequestRole; + preferredLanguage?: string; + heroConfig?: CodeCombat.UsersCreateRequestHeroConfig; + birthday?: string; +} diff --git a/src/api/resources/users/client/requests/GetClassroomsRequest.ts b/src/api/resources/users/client/requests/UsersGetClassroomsRequest.ts similarity index 80% rename from src/api/resources/users/client/requests/GetClassroomsRequest.ts rename to src/api/resources/users/client/requests/UsersGetClassroomsRequest.ts index 684007b..0a5d6d8 100644 --- a/src/api/resources/users/client/requests/GetClassroomsRequest.ts +++ b/src/api/resources/users/client/requests/UsersGetClassroomsRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface GetClassroomsRequest { +export interface UsersGetClassroomsRequest { /** * limit the return number of members for each classroom */ diff --git a/src/api/resources/users/client/requests/GetUserRequest.ts b/src/api/resources/users/client/requests/UsersGetRequest.ts similarity index 84% rename from src/api/resources/users/client/requests/GetUserRequest.ts rename to src/api/resources/users/client/requests/UsersGetRequest.ts index 6761e6e..cb08244 100644 --- a/src/api/resources/users/client/requests/GetUserRequest.ts +++ b/src/api/resources/users/client/requests/UsersGetRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface GetUserRequest { +export interface UsersGetRequest { /** * Set to non-empty string to include stats.playTime in response */ diff --git a/src/api/resources/users/client/requests/UsersGrantLicenseRequest.ts b/src/api/resources/users/client/requests/UsersGrantLicenseRequest.ts new file mode 100644 index 0000000..7197256 --- /dev/null +++ b/src/api/resources/users/client/requests/UsersGrantLicenseRequest.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as CodeCombat from "../../../.."; + +export interface UsersGrantLicenseRequest { + ends: CodeCombat.DatetimeString; +} diff --git a/src/api/resources/users/client/requests/UsersGrantPremiumSubscriptionRequest.ts b/src/api/resources/users/client/requests/UsersGrantPremiumSubscriptionRequest.ts new file mode 100644 index 0000000..5e12daa --- /dev/null +++ b/src/api/resources/users/client/requests/UsersGrantPremiumSubscriptionRequest.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as CodeCombat from "../../../.."; + +export interface UsersGrantPremiumSubscriptionRequest { + ends: CodeCombat.DatetimeString; +} diff --git a/src/api/resources/users/client/requests/SetAceConfig.ts b/src/api/resources/users/client/requests/UsersSetAceConfigRequest.ts similarity index 91% rename from src/api/resources/users/client/requests/SetAceConfig.ts rename to src/api/resources/users/client/requests/UsersSetAceConfigRequest.ts index 0699504..7fe4f6a 100644 --- a/src/api/resources/users/client/requests/SetAceConfig.ts +++ b/src/api/resources/users/client/requests/UsersSetAceConfigRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface SetAceConfig { +export interface UsersSetAceConfigRequest { /** controls whether autocompletion snippets show up, the default value is true */ liveCompletion?: boolean; /** controls whether things like automatic parenthesis and quote completion happens, the default value is false */ diff --git a/src/api/resources/users/types/HeroConfig.ts b/src/api/resources/users/client/requests/UsersSetHeroRequest.ts similarity index 59% rename from src/api/resources/users/types/HeroConfig.ts rename to src/api/resources/users/client/requests/UsersSetHeroRequest.ts index 516c7e1..3946c2c 100644 --- a/src/api/resources/users/types/HeroConfig.ts +++ b/src/api/resources/users/client/requests/UsersSetHeroRequest.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../.."; -export interface HeroConfig { +export interface UsersSetHeroRequest { thangType?: CodeCombat.ObjectIdString; } diff --git a/src/api/resources/users/client/requests/UsersShortenLicenseRequest.ts b/src/api/resources/users/client/requests/UsersShortenLicenseRequest.ts new file mode 100644 index 0000000..746d1fb --- /dev/null +++ b/src/api/resources/users/client/requests/UsersShortenLicenseRequest.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as CodeCombat from "../../../.."; + +export interface UsersShortenLicenseRequest { + ends: CodeCombat.DatetimeString; +} diff --git a/src/api/resources/users/client/requests/UsersShortenSubscriptionRequest.ts b/src/api/resources/users/client/requests/UsersShortenSubscriptionRequest.ts new file mode 100644 index 0000000..26a36b2 --- /dev/null +++ b/src/api/resources/users/client/requests/UsersShortenSubscriptionRequest.ts @@ -0,0 +1,9 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as CodeCombat from "../../../.."; + +export interface UsersShortenSubscriptionRequest { + ends: CodeCombat.DatetimeString; +} diff --git a/src/api/resources/users/client/requests/UpdateUserRequest.ts b/src/api/resources/users/client/requests/UsersUpdateRequest.ts similarity index 82% rename from src/api/resources/users/client/requests/UpdateUserRequest.ts rename to src/api/resources/users/client/requests/UsersUpdateRequest.ts index 4112d25..02c32ff 100644 --- a/src/api/resources/users/client/requests/UpdateUserRequest.ts +++ b/src/api/resources/users/client/requests/UsersUpdateRequest.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface UpdateUserRequest { +export interface UsersUpdateRequest { /** Set to new name string */ name: string; /** Set the birthday */ diff --git a/src/api/resources/users/client/requests/index.ts b/src/api/resources/users/client/requests/index.ts index 368a3e2..99a9f97 100644 --- a/src/api/resources/users/client/requests/index.ts +++ b/src/api/resources/users/client/requests/index.ts @@ -1,11 +1,10 @@ -export { CreateUserRequest } from "./CreateUserRequest"; -export { GetUserRequest } from "./GetUserRequest"; -export { UpdateUserRequest } from "./UpdateUserRequest"; -export { GetClassroomsRequest } from "./GetClassroomsRequest"; -export { GetHeroRequest } from "./GetHeroRequest"; -export { SetAceConfig } from "./SetAceConfig"; -export { AddOAuthIdentityRequest } from "./AddOAuthIdentityRequest"; -export { UpdateSubscriptionRequest } from "./UpdateSubscriptionRequest"; -export { ShortenSubscriptionRequest } from "./ShortenSubscriptionRequest"; -export { GrantLicenseRequest } from "./GrantLicenseRequest"; -export { ShortenLicenseRequest } from "./ShortenLicenseRequest"; +export { UsersCreateRequest } from "./UsersCreateRequest"; +export { UsersGetRequest } from "./UsersGetRequest"; +export { UsersUpdateRequest } from "./UsersUpdateRequest"; +export { UsersGetClassroomsRequest } from "./UsersGetClassroomsRequest"; +export { UsersSetHeroRequest } from "./UsersSetHeroRequest"; +export { UsersSetAceConfigRequest } from "./UsersSetAceConfigRequest"; +export { UsersGrantPremiumSubscriptionRequest } from "./UsersGrantPremiumSubscriptionRequest"; +export { UsersShortenSubscriptionRequest } from "./UsersShortenSubscriptionRequest"; +export { UsersGrantLicenseRequest } from "./UsersGrantLicenseRequest"; +export { UsersShortenLicenseRequest } from "./UsersShortenLicenseRequest"; diff --git a/src/api/resources/users/index.ts b/src/api/resources/users/index.ts index c9240f8..5ec7692 100644 --- a/src/api/resources/users/index.ts +++ b/src/api/resources/users/index.ts @@ -1,2 +1 @@ -export * from "./types"; export * from "./client"; diff --git a/src/api/resources/users/types/UserRole.ts b/src/api/resources/users/types/UserRole.ts deleted file mode 100644 index 4db29ea..0000000 --- a/src/api/resources/users/types/UserRole.ts +++ /dev/null @@ -1,13 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -/** - * A `"student"` or `"teacher"`. If unset, a home user will be created, unable to join classrooms. - */ -export type UserRole = "student" | "teacher"; - -export const UserRole = { - Student: "student", - Teacher: "teacher", -} as const; diff --git a/src/api/resources/users/types/index.ts b/src/api/resources/users/types/index.ts deleted file mode 100644 index 50d31f4..0000000 --- a/src/api/resources/users/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./UserRole"; -export * from "./HeroConfig"; diff --git a/src/api/resources/clans/types/ClanResponse.ts b/src/api/types/ClanResponse.ts similarity index 89% rename from src/api/resources/clans/types/ClanResponse.ts rename to src/api/types/ClanResponse.ts index 9ededd1..ce21ee2 100644 --- a/src/api/resources/clans/types/ClanResponse.ts +++ b/src/api/types/ClanResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from ".."; /** * Subset of properties listed here diff --git a/src/api/resources/commons/types/ClassroomResponse.ts b/src/api/types/ClassroomResponse.ts similarity index 56% rename from src/api/resources/commons/types/ClassroomResponse.ts rename to src/api/types/ClassroomResponse.ts index a8a3872..8fc2205 100644 --- a/src/api/resources/commons/types/ClassroomResponse.ts +++ b/src/api/types/ClassroomResponse.ts @@ -2,19 +2,16 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from ".."; /** * Subset of properties listed here */ export interface ClassroomResponse { id?: CodeCombat.ObjectIdString; - /** The name of the classroom */ name?: string; - /** List of _ids of the student members of the classroom */ members?: CodeCombat.ObjectIdString[]; - /** The _id of the teacher owner of the classroom. */ ownerId?: CodeCombat.ObjectIdString; description?: string; - courses?: CodeCombat.Course[]; + courses?: CodeCombat.ClassroomResponseCoursesItem[]; } diff --git a/src/api/resources/commons/types/Course.ts b/src/api/types/ClassroomResponseCoursesItem.ts similarity index 74% rename from src/api/resources/commons/types/Course.ts rename to src/api/types/ClassroomResponseCoursesItem.ts index a93c1cf..3dd919b 100644 --- a/src/api/resources/commons/types/Course.ts +++ b/src/api/types/ClassroomResponseCoursesItem.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from ".."; -export interface Course { +export interface ClassroomResponseCoursesItem { id?: CodeCombat.ObjectIdString; levels?: Record[]; enrolled?: CodeCombat.ObjectIdString[]; diff --git a/src/api/resources/commons/types/ClassroomResponseWithCode.ts b/src/api/types/ClassroomResponseWithCode.ts similarity index 80% rename from src/api/resources/commons/types/ClassroomResponseWithCode.ts rename to src/api/types/ClassroomResponseWithCode.ts index b103fc5..7f7c83d 100644 --- a/src/api/resources/commons/types/ClassroomResponseWithCode.ts +++ b/src/api/types/ClassroomResponseWithCode.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from ".."; /** * Subset of properties listed here @@ -15,6 +15,6 @@ export interface ClassroomResponseWithCode { description?: string; code?: string; codeCamel?: string; - courses?: CodeCombat.Course[]; + courses?: CodeCombat.ClassroomResponseWithCodeCoursesItem[]; clanId?: CodeCombat.ObjectIdString; } diff --git a/src/api/types/ClassroomResponseWithCodeCoursesItem.ts b/src/api/types/ClassroomResponseWithCodeCoursesItem.ts new file mode 100644 index 0000000..4bf511b --- /dev/null +++ b/src/api/types/ClassroomResponseWithCodeCoursesItem.ts @@ -0,0 +1,12 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as CodeCombat from ".."; + +export interface ClassroomResponseWithCodeCoursesItem { + id?: CodeCombat.ObjectIdString; + levels?: Record[]; + enrolled?: CodeCombat.ObjectIdString[]; + instanceId?: CodeCombat.ObjectIdString; +} diff --git a/src/api/resources/classrooms/types/AceConfig.ts b/src/api/types/ClassroomsCreateRequestAceConfig.ts similarity index 74% rename from src/api/resources/classrooms/types/AceConfig.ts rename to src/api/types/ClassroomsCreateRequestAceConfig.ts index 129d6ad..630a17a 100644 --- a/src/api/resources/classrooms/types/AceConfig.ts +++ b/src/api/types/ClassroomsCreateRequestAceConfig.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface AceConfig { +export interface ClassroomsCreateRequestAceConfig { /** Programming language for the classroom */ language?: string; } diff --git a/src/api/types/ClassroomsGetMembersStatsResponseItem.ts b/src/api/types/ClassroomsGetMembersStatsResponseItem.ts new file mode 100644 index 0000000..09e7f09 --- /dev/null +++ b/src/api/types/ClassroomsGetMembersStatsResponseItem.ts @@ -0,0 +1,10 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as CodeCombat from ".."; + +export interface ClassroomsGetMembersStatsResponseItem { + id?: CodeCombat.ObjectIdString; + stats?: CodeCombat.ClassroomsGetMembersStatsResponseItemStats; +} diff --git a/src/api/resources/classrooms/types/PlayStats.ts b/src/api/types/ClassroomsGetMembersStatsResponseItemStats.ts similarity index 72% rename from src/api/resources/classrooms/types/PlayStats.ts rename to src/api/types/ClassroomsGetMembersStatsResponseItemStats.ts index 4f81617..37a60aa 100644 --- a/src/api/resources/classrooms/types/PlayStats.ts +++ b/src/api/types/ClassroomsGetMembersStatsResponseItemStats.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface PlayStats { +export interface ClassroomsGetMembersStatsResponseItemStats { gamesCompleted?: number; /** Total play time in seconds */ playtime?: number; diff --git a/src/api/resources/commons/types/DatetimeString.ts b/src/api/types/DatetimeString.ts similarity index 100% rename from src/api/resources/commons/types/DatetimeString.ts rename to src/api/types/DatetimeString.ts diff --git a/src/api/resources/classrooms/types/LevelSessionResponse.ts b/src/api/types/LevelSessionResponse.ts similarity index 82% rename from src/api/resources/classrooms/types/LevelSessionResponse.ts rename to src/api/types/LevelSessionResponse.ts index c79d174..8797289 100644 --- a/src/api/resources/classrooms/types/LevelSessionResponse.ts +++ b/src/api/types/LevelSessionResponse.ts @@ -2,11 +2,11 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from ".."; export interface LevelSessionResponse { - state?: CodeCombat.State; - level?: CodeCombat.Level; + state?: CodeCombat.LevelSessionResponseState; + level?: CodeCombat.LevelSessionResponseLevel; /** Level slug like `wakka-maul` */ levelId?: string; creator?: CodeCombat.ObjectIdString; diff --git a/src/api/resources/classrooms/types/Level.ts b/src/api/types/LevelSessionResponseLevel.ts similarity index 74% rename from src/api/resources/classrooms/types/Level.ts rename to src/api/types/LevelSessionResponseLevel.ts index 9394944..a00be95 100644 --- a/src/api/resources/classrooms/types/Level.ts +++ b/src/api/types/LevelSessionResponseLevel.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface Level { +export interface LevelSessionResponseLevel { /** The id for the level. */ original?: string; } diff --git a/src/api/resources/classrooms/types/State.ts b/src/api/types/LevelSessionResponseState.ts similarity index 68% rename from src/api/resources/classrooms/types/State.ts rename to src/api/types/LevelSessionResponseState.ts index d1b9272..a5fa9e0 100644 --- a/src/api/resources/classrooms/types/State.ts +++ b/src/api/types/LevelSessionResponseState.ts @@ -2,6 +2,6 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface State { +export interface LevelSessionResponseState { complete?: boolean; } diff --git a/src/api/resources/stats/types/LicenseStatsResponse.ts b/src/api/types/LicenseStatsResponse.ts similarity index 100% rename from src/api/resources/stats/types/LicenseStatsResponse.ts rename to src/api/types/LicenseStatsResponse.ts diff --git a/src/api/resources/commons/types/ObjectIdString.ts b/src/api/types/ObjectIdString.ts similarity index 100% rename from src/api/resources/commons/types/ObjectIdString.ts rename to src/api/types/ObjectIdString.ts diff --git a/src/api/resources/stats/types/PlaytimeStatsResponse.ts b/src/api/types/PlaytimeStatsResponse.ts similarity index 100% rename from src/api/resources/stats/types/PlaytimeStatsResponse.ts rename to src/api/types/PlaytimeStatsResponse.ts diff --git a/src/api/resources/commons/types/RoleString.ts b/src/api/types/RoleString.ts similarity index 100% rename from src/api/resources/commons/types/RoleString.ts rename to src/api/types/RoleString.ts diff --git a/src/api/resources/commons/types/UserResponse.ts b/src/api/types/UserResponse.ts similarity index 53% rename from src/api/resources/commons/types/UserResponse.ts rename to src/api/types/UserResponse.ts index 1a34280..70810df 100644 --- a/src/api/resources/commons/types/UserResponse.ts +++ b/src/api/types/UserResponse.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from ".."; /** * Subset of properties listed here @@ -13,8 +13,8 @@ export interface UserResponse { name?: string; slug?: string; role?: CodeCombat.RoleString; - stats?: CodeCombat.UserStats; - oAuthIdentities?: CodeCombat.AuthIdentity[]; - subscription?: CodeCombat.Subscription; - license?: CodeCombat.License; + stats?: CodeCombat.UserResponseStats; + oAuthIdentities?: CodeCombat.UserResponseOAuthIdentitiesItem[]; + subscription?: CodeCombat.UserResponseSubscription; + license?: CodeCombat.UserResponseLicense; } diff --git a/src/api/resources/commons/types/License.ts b/src/api/types/UserResponseLicense.ts similarity index 63% rename from src/api/resources/commons/types/License.ts rename to src/api/types/UserResponseLicense.ts index 7b29fe4..7bd146a 100644 --- a/src/api/resources/commons/types/License.ts +++ b/src/api/types/UserResponseLicense.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from ".."; -export interface License { +export interface UserResponseLicense { ends?: CodeCombat.DatetimeString; active?: boolean; } diff --git a/src/api/resources/commons/types/AuthIdentity.ts b/src/api/types/UserResponseOAuthIdentitiesItem.ts similarity index 69% rename from src/api/resources/commons/types/AuthIdentity.ts rename to src/api/types/UserResponseOAuthIdentitiesItem.ts index 8d2d940..7aa970a 100644 --- a/src/api/resources/commons/types/AuthIdentity.ts +++ b/src/api/types/UserResponseOAuthIdentitiesItem.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface AuthIdentity { +export interface UserResponseOAuthIdentitiesItem { provider?: string; id?: string; } diff --git a/src/api/resources/commons/types/UserStats.ts b/src/api/types/UserResponseStats.ts similarity index 86% rename from src/api/resources/commons/types/UserStats.ts rename to src/api/types/UserResponseStats.ts index 1b816e8..d4cda72 100644 --- a/src/api/resources/commons/types/UserStats.ts +++ b/src/api/types/UserResponseStats.ts @@ -2,7 +2,7 @@ * This file was auto-generated by Fern from our API Definition. */ -export interface UserStats { +export interface UserResponseStats { gamesCompleted?: number; concepts?: Record; /** Included only when specifically requested on the endpoint */ diff --git a/src/api/resources/commons/types/Subscription.ts b/src/api/types/UserResponseSubscription.ts similarity index 62% rename from src/api/resources/commons/types/Subscription.ts rename to src/api/types/UserResponseSubscription.ts index 0581621..91ecc6f 100644 --- a/src/api/resources/commons/types/Subscription.ts +++ b/src/api/types/UserResponseSubscription.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from ".."; -export interface Subscription { +export interface UserResponseSubscription { ends?: CodeCombat.DatetimeString; active?: boolean; } diff --git a/src/api/resources/users/client/requests/GetHeroRequest.ts b/src/api/types/UsersCreateRequestHeroConfig.ts similarity index 58% rename from src/api/resources/users/client/requests/GetHeroRequest.ts rename to src/api/types/UsersCreateRequestHeroConfig.ts index c734c3e..cf29a12 100644 --- a/src/api/resources/users/client/requests/GetHeroRequest.ts +++ b/src/api/types/UsersCreateRequestHeroConfig.ts @@ -2,8 +2,8 @@ * This file was auto-generated by Fern from our API Definition. */ -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from ".."; -export interface GetHeroRequest { +export interface UsersCreateRequestHeroConfig { thangType?: CodeCombat.ObjectIdString; } diff --git a/src/api/types/UsersCreateRequestRole.ts b/src/api/types/UsersCreateRequestRole.ts new file mode 100644 index 0000000..bdc6670 --- /dev/null +++ b/src/api/types/UsersCreateRequestRole.ts @@ -0,0 +1,14 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +/** + * `"student"` or `"teacher"`. If unset, a home user will be created, unable to join classrooms. + * + */ +export type UsersCreateRequestRole = "student" | "teacher"; + +export const UsersCreateRequestRole = { + Student: "student", + Teacher: "teacher", +} as const; diff --git a/src/api/types/index.ts b/src/api/types/index.ts new file mode 100644 index 0000000..cac14d4 --- /dev/null +++ b/src/api/types/index.ts @@ -0,0 +1,23 @@ +export * from "./UsersCreateRequestRole"; +export * from "./UsersCreateRequestHeroConfig"; +export * from "./ClassroomsCreateRequestAceConfig"; +export * from "./ClassroomsGetMembersStatsResponseItem"; +export * from "./ClassroomsGetMembersStatsResponseItemStats"; +export * from "./RoleString"; +export * from "./DatetimeString"; +export * from "./ObjectIdString"; +export * from "./UserResponse"; +export * from "./UserResponseStats"; +export * from "./UserResponseOAuthIdentitiesItem"; +export * from "./UserResponseSubscription"; +export * from "./UserResponseLicense"; +export * from "./ClassroomResponse"; +export * from "./ClassroomResponseCoursesItem"; +export * from "./ClassroomResponseWithCode"; +export * from "./ClassroomResponseWithCodeCoursesItem"; +export * from "./PlaytimeStatsResponse"; +export * from "./LicenseStatsResponse"; +export * from "./LevelSessionResponse"; +export * from "./LevelSessionResponseState"; +export * from "./LevelSessionResponseLevel"; +export * from "./ClanResponse"; diff --git a/src/core/fetcher/Fetcher.ts b/src/core/fetcher/Fetcher.ts index e19d35e..6af0fb1 100644 --- a/src/core/fetcher/Fetcher.ts +++ b/src/core/fetcher/Fetcher.ts @@ -1,8 +1,8 @@ -import URLSearchParams from "@ungap/url-search-params"; +import { default as URLSearchParams } from "@ungap/url-search-params"; import axios, { AxiosAdapter, AxiosError } from "axios"; import { APIResponse } from "./APIResponse"; -export type FetchFunction = (args: Fetcher.Args) => Promise>; +export type FetchFunction = (args: Fetcher.Args) => Promise>; export declare namespace Fetcher { export interface Args { @@ -14,7 +14,9 @@ export declare namespace Fetcher { body?: unknown; timeoutMs?: number; withCredentials?: boolean; + responseType?: "json" | "blob"; adapter?: AxiosAdapter; + onUploadProgress?: (event: ProgressEvent) => void; } export type Error = FailedStatusCodeError | NonJsonError | TimeoutError | UnknownError; @@ -41,11 +43,12 @@ export declare namespace Fetcher { } } -export const fetcher: FetchFunction = async (args) => { +async function fetcherImpl(args: Fetcher.Args): Promise> { const headers: Record = {}; if (args.body !== undefined && args.contentType != null) { headers["Content-Type"] = args.contentType; } + if (args.headers != null) { for (const [key, value] of Object.entries(args.headers)) { if (value != null) { @@ -63,16 +66,22 @@ export const fetcher: FetchFunction = async (args) => { data: args.body, validateStatus: () => true, transformResponse: (response) => response, - timeout: args.timeoutMs ?? 60_000, + timeout: args.timeoutMs, transitional: { clarifyTimeoutError: true, }, withCredentials: args.withCredentials, adapter: args.adapter, + onUploadProgress: args.onUploadProgress, + maxBodyLength: Infinity, + maxContentLength: Infinity, + responseType: args.responseType ?? "json", }); let body: unknown; - if (response.data != null && response.data.length > 0) { + if (args.responseType === "blob") { + body = response.data; + } else if (response.data != null && response.data.length > 0) { try { body = JSON.parse(response.data) ?? undefined; } catch { @@ -87,10 +96,10 @@ export const fetcher: FetchFunction = async (args) => { } } - if (response.status >= 200 && response.status < 300) { + if (response.status >= 200 && response.status < 400) { return { ok: true, - body, + body: body as R, }; } else { return { @@ -120,4 +129,6 @@ export const fetcher: FetchFunction = async (args) => { }, }; } -}; +} + +export const fetcher: FetchFunction = fetcherImpl; diff --git a/src/core/fetcher/index.ts b/src/core/fetcher/index.ts index 052af9c..6becab2 100644 --- a/src/core/fetcher/index.ts +++ b/src/core/fetcher/index.ts @@ -1,3 +1,4 @@ -export { type APIResponse } from "./APIResponse"; -export { fetcher, type Fetcher, type FetchFunction } from "./Fetcher"; +export type { APIResponse } from "./APIResponse"; +export { fetcher } from "./Fetcher"; +export type { Fetcher, FetchFunction } from "./Fetcher"; export { Supplier } from "./Supplier"; diff --git a/src/core/index.ts b/src/core/index.ts index 31aa898..e2eb66e 100644 --- a/src/core/index.ts +++ b/src/core/index.ts @@ -1,3 +1,3 @@ -export * as serialization from "./schemas"; -export * from "./auth"; export * from "./fetcher"; +export * from "./auth"; +export * as serialization from "./schemas"; diff --git a/src/core/schemas/Schema.ts b/src/core/schemas/Schema.ts index 31c4927..3211fa4 100644 --- a/src/core/schemas/Schema.ts +++ b/src/core/schemas/Schema.ts @@ -70,4 +70,24 @@ export interface SchemaOptions { * @default false */ allowUnrecognizedEnumValues?: boolean; + + /** + * whether to allow data that doesn't conform to the schema. + * invalid data is passed through without transformation. + * + * when this is enabled, .parse() and .json() will always + * return `ok: true`. `.parseOrThrow()` and `.jsonOrThrow()` + * will never fail. + * + * @default false + */ + skipValidation?: boolean; + + /** + * each validation failure contains a "path" property, which is + * the breadcrumbs to the offending node in the JSON. you can supply + * a prefix that is prepended to all the errors' paths. this can be + * helpful for zurg's internal debug logging. + */ + breadcrumbsPrefix?: string[]; } diff --git a/src/core/schemas/builders/date/date.ts b/src/core/schemas/builders/date/date.ts index 1c7d30c..b70f24b 100644 --- a/src/core/schemas/builders/date/date.ts +++ b/src/core/schemas/builders/date/date.ts @@ -1,4 +1,6 @@ import { BaseSchema, Schema, SchemaType } from "../../Schema"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; import { getSchemaUtils } from "../schema-utils"; // https://stackoverflow.com/questions/12756159/regex-and-iso8601-formatted-datetime @@ -7,25 +9,35 @@ const ISO_8601_REGEX = export function date(): Schema { const baseSchema: BaseSchema = { - parse: (raw) => { - if (typeof raw === "string" && ISO_8601_REGEX.test(raw)) { + parse: (raw, { breadcrumbsPrefix = [] } = {}) => { + if (typeof raw !== "string") { return { - ok: true, - value: new Date(raw), + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(raw, "string"), + }, + ], }; - } else { + } + if (!ISO_8601_REGEX.test(raw)) { return { ok: false, errors: [ { - path: [], - message: "Not an ISO 8601 date string", + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(raw, "ISO 8601 date string"), }, ], }; } + return { + ok: true, + value: new Date(raw), + }; }, - json: (date) => { + json: (date, { breadcrumbsPrefix = [] } = {}) => { if (date instanceof Date) { return { ok: true, @@ -36,8 +48,8 @@ export function date(): Schema { ok: false, errors: [ { - path: [], - message: "Not a Date object", + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(date, "Date object"), }, ], }; @@ -47,7 +59,7 @@ export function date(): Schema { }; return { - ...baseSchema, + ...maybeSkipValidation(baseSchema), ...getSchemaUtils(baseSchema), }; } diff --git a/src/core/schemas/builders/enum/enum.ts b/src/core/schemas/builders/enum/enum.ts index b7ac0f2..c1e24d6 100644 --- a/src/core/schemas/builders/enum/enum.ts +++ b/src/core/schemas/builders/enum/enum.ts @@ -1,28 +1,41 @@ import { Schema, SchemaType } from "../../Schema"; import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; export function enum_(values: E): Schema { const validValues = new Set(values); const schemaCreator = createIdentitySchemaCreator( SchemaType.ENUM, - (value, { allowUnrecognizedEnumValues } = {}) => { - if (typeof value === "string" && (validValues.has(value) || allowUnrecognizedEnumValues)) { + (value, { allowUnrecognizedEnumValues, breadcrumbsPrefix = [] } = {}) => { + if (typeof value !== "string") { return { - ok: true, - value: value as U, + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "string"), + }, + ], }; - } else { + } + + if (!validValues.has(value) && !allowUnrecognizedEnumValues) { return { ok: false, errors: [ { - path: [], - message: "Not one of the allowed values", + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "enum"), }, ], }; } + + return { + ok: true, + value: value as U, + }; } ); diff --git a/src/core/schemas/builders/lazy/index.ts b/src/core/schemas/builders/lazy/index.ts index ad14bf0..77420fb 100644 --- a/src/core/schemas/builders/lazy/index.ts +++ b/src/core/schemas/builders/lazy/index.ts @@ -1,2 +1,3 @@ -export { lazy, type SchemaGetter } from "./lazy"; +export { lazy } from "./lazy"; +export type { SchemaGetter } from "./lazy"; export { lazyObject } from "./lazyObject"; diff --git a/src/core/schemas/builders/list/list.ts b/src/core/schemas/builders/list/list.ts index 4d7facc..b333321 100644 --- a/src/core/schemas/builders/list/list.ts +++ b/src/core/schemas/builders/list/list.ts @@ -1,40 +1,54 @@ import { BaseSchema, MaybeValid, Schema, SchemaType, ValidationError } from "../../Schema"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; import { MaybePromise } from "../../utils/MaybePromise"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; import { getSchemaUtils } from "../schema-utils"; export function list(schema: Schema): Schema { const baseSchema: BaseSchema = { - parse: async (raw, opts) => validateAndTransformArray(raw, (item) => schema.parse(item, opts)), - json: (parsed, opts) => validateAndTransformArray(parsed, (item) => schema.json(item, opts)), + parse: async (raw, opts) => + validateAndTransformArray(raw, (item, index) => + schema.parse(item, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `[${index}]`], + }) + ), + json: (parsed, opts) => + validateAndTransformArray(parsed, (item, index) => + schema.json(item, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `[${index}]`], + }) + ), getType: () => SchemaType.LIST, }; return { - ...baseSchema, + ...maybeSkipValidation(baseSchema), ...getSchemaUtils(baseSchema), }; } async function validateAndTransformArray( value: unknown, - transformItem: (item: Raw) => MaybePromise> + transformItem: (item: Raw, index: number) => MaybePromise> ): Promise> { if (!Array.isArray(value)) { return { ok: false, errors: [ { - message: "Not a list", + message: getErrorMessageForIncorrectType(value, "list"), path: [], }, ], }; } - const maybeValidItems = await Promise.all(value.map((item) => transformItem(item))); + const maybeValidItems = await Promise.all(value.map((item, index) => transformItem(item, index))); return maybeValidItems.reduce>( - (acc, item, index) => { + (acc, item) => { if (acc.ok && item.ok) { return { ok: true, @@ -47,12 +61,7 @@ async function validateAndTransformArray( errors.push(...acc.errors); } if (!item.ok) { - errors.push( - ...item.errors.map((error) => ({ - path: [`[${index}]`, ...error.path], - message: error.message, - })) - ); + errors.push(...item.errors); } return { diff --git a/src/core/schemas/builders/literals/stringLiteral.ts b/src/core/schemas/builders/literals/stringLiteral.ts index 18a5504..3939b76 100644 --- a/src/core/schemas/builders/literals/stringLiteral.ts +++ b/src/core/schemas/builders/literals/stringLiteral.ts @@ -1,25 +1,29 @@ import { Schema, SchemaType } from "../../Schema"; import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; export function stringLiteral(literal: V): Schema { - const schemaCreator = createIdentitySchemaCreator(SchemaType.STRING_LITERAL, (value) => { - if (value === literal) { - return { - ok: true, - value: literal, - }; - } else { - return { - ok: false, - errors: [ - { - path: [], - message: `Not equal to "${literal}"`, - }, - ], - }; + const schemaCreator = createIdentitySchemaCreator( + SchemaType.STRING_LITERAL, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (value === literal) { + return { + ok: true, + value: literal, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, `"${literal}"`), + }, + ], + }; + } } - }); + ); return schemaCreator(); } diff --git a/src/core/schemas/builders/object-like/getObjectLikeUtils.ts b/src/core/schemas/builders/object-like/getObjectLikeUtils.ts index 3290ef5..270ea17 100644 --- a/src/core/schemas/builders/object-like/getObjectLikeUtils.ts +++ b/src/core/schemas/builders/object-like/getObjectLikeUtils.ts @@ -1,6 +1,7 @@ import { BaseSchema } from "../../Schema"; import { filterObject } from "../../utils/filterObject"; -import { isPlainObject, NOT_AN_OBJECT_ERROR_MESSAGE } from "../../utils/isPlainObject"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { isPlainObject } from "../../utils/isPlainObject"; import { getSchemaUtils } from "../schema-utils"; import { ObjectLikeSchema, ObjectLikeUtils } from "./types"; @@ -50,8 +51,8 @@ export function withParsedProperties property.valueSchema.parse(propertyValue, opts), + transform: (propertyValue) => + property.valueSchema.parse(propertyValue, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), rawKey], + }), }; }, unrecognizedObjectKeys: opts?.unrecognizedObjectKeys, + skipValidation: opts?.skipValidation, + breadcrumbsPrefix: opts?.breadcrumbsPrefix, }); }, @@ -111,16 +119,26 @@ export function object property.valueSchema.json(propertyValue, opts), + transform: (propertyValue) => + property.valueSchema.json(propertyValue, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), parsedKey], + }), }; } else { return { transformedKey: parsedKey, - transform: (propertyValue) => property.json(propertyValue, opts), + transform: (propertyValue) => + property.json(propertyValue, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), parsedKey], + }), }; } }, unrecognizedObjectKeys: opts?.unrecognizedObjectKeys, + skipValidation: opts?.skipValidation, + breadcrumbsPrefix: opts?.breadcrumbsPrefix, }); }, @@ -128,7 +146,7 @@ export function object({ requiredKeys, getProperty, unrecognizedObjectKeys = "fail", + skipValidation = false, + breadcrumbsPrefix = [], }: { value: unknown; requiredKeys: string[]; @@ -147,14 +167,16 @@ async function validateAndTransformObject({ preTransformedKey: string ) => { transformedKey: string; transform: (propertyValue: unknown) => MaybePromise> } | undefined; unrecognizedObjectKeys: "fail" | "passthrough" | "strip" | undefined; + skipValidation: boolean | undefined; + breadcrumbsPrefix: string[] | undefined; }): Promise> { if (!isPlainObject(value)) { return { ok: false, errors: [ { - path: [], - message: NOT_AN_OBJECT_ERROR_MESSAGE, + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "object"), }, ], }; @@ -174,19 +196,15 @@ async function validateAndTransformObject({ if (value.ok) { transformed[property.transformedKey] = value.value; } else { - errors.push( - ...value.errors.map((error) => ({ - path: [preTransformedKey, ...error.path], - message: error.message, - })) - ); + transformed[preTransformedKey] = preTransformedItemValue; + errors.push(...value.errors); } } else { switch (unrecognizedObjectKeys) { case "fail": errors.push({ - path: [preTransformedKey], - message: `Unrecognized key "${preTransformedKey}"`, + path: [...breadcrumbsPrefix, preTransformedKey], + message: `Unexpected key "${preTransformedKey}"`, }); break; case "strip": @@ -202,12 +220,12 @@ async function validateAndTransformObject({ ...requiredKeys .filter((key) => missingRequiredKeys.has(key)) .map((key) => ({ - path: [], + path: breadcrumbsPrefix, message: `Missing required key "${key}"`, })) ); - if (errors.length === 0) { + if (errors.length === 0 || skipValidation) { return { ok: true, value: transformed as Transformed, diff --git a/src/core/schemas/builders/primitives/boolean.ts b/src/core/schemas/builders/primitives/boolean.ts index 08177f8..fad6056 100644 --- a/src/core/schemas/builders/primitives/boolean.ts +++ b/src/core/schemas/builders/primitives/boolean.ts @@ -1,21 +1,25 @@ import { SchemaType } from "../../Schema"; import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; -export const boolean = createIdentitySchemaCreator(SchemaType.BOOLEAN, (value) => { - if (typeof value === "boolean") { - return { - ok: true, - value, - }; - } else { - return { - ok: false, - errors: [ - { - path: [], - message: "Not a boolean", - }, - ], - }; +export const boolean = createIdentitySchemaCreator( + SchemaType.BOOLEAN, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (typeof value === "boolean") { + return { + ok: true, + value, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "boolean"), + }, + ], + }; + } } -}); +); diff --git a/src/core/schemas/builders/primitives/number.ts b/src/core/schemas/builders/primitives/number.ts index 5b6f926..c268945 100644 --- a/src/core/schemas/builders/primitives/number.ts +++ b/src/core/schemas/builders/primitives/number.ts @@ -1,21 +1,25 @@ import { SchemaType } from "../../Schema"; import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; -export const number = createIdentitySchemaCreator(SchemaType.NUMBER, (value) => { - if (typeof value === "number") { - return { - ok: true, - value, - }; - } else { - return { - ok: false, - errors: [ - { - path: [], - message: "Not a number", - }, - ], - }; +export const number = createIdentitySchemaCreator( + SchemaType.NUMBER, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (typeof value === "number") { + return { + ok: true, + value, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "number"), + }, + ], + }; + } } -}); +); diff --git a/src/core/schemas/builders/primitives/string.ts b/src/core/schemas/builders/primitives/string.ts index b4b1e02..949f1f2 100644 --- a/src/core/schemas/builders/primitives/string.ts +++ b/src/core/schemas/builders/primitives/string.ts @@ -1,21 +1,25 @@ import { SchemaType } from "../../Schema"; import { createIdentitySchemaCreator } from "../../utils/createIdentitySchemaCreator"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; -export const string = createIdentitySchemaCreator(SchemaType.STRING, (value) => { - if (typeof value === "string") { - return { - ok: true, - value, - }; - } else { - return { - ok: false, - errors: [ - { - path: [], - message: "Not a string", - }, - ], - }; +export const string = createIdentitySchemaCreator( + SchemaType.STRING, + (value, { breadcrumbsPrefix = [] } = {}) => { + if (typeof value === "string") { + return { + ok: true, + value, + }; + } else { + return { + ok: false, + errors: [ + { + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "string"), + }, + ], + }; + } } -}); +); diff --git a/src/core/schemas/builders/record/index.ts b/src/core/schemas/builders/record/index.ts index 18a3253..82e25c5 100644 --- a/src/core/schemas/builders/record/index.ts +++ b/src/core/schemas/builders/record/index.ts @@ -1,2 +1,2 @@ export { record } from "./record"; -export { type BaseRecordSchema, type RecordSchema } from "./types"; +export type { BaseRecordSchema, RecordSchema } from "./types"; diff --git a/src/core/schemas/builders/record/record.ts b/src/core/schemas/builders/record/record.ts index 600853c..ac1cd22 100644 --- a/src/core/schemas/builders/record/record.ts +++ b/src/core/schemas/builders/record/record.ts @@ -1,7 +1,9 @@ import { MaybeValid, Schema, SchemaType, ValidationError } from "../../Schema"; import { entries } from "../../utils/entries"; -import { isPlainObject, NOT_AN_OBJECT_ERROR_MESSAGE } from "../../utils/isPlainObject"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { isPlainObject } from "../../utils/isPlainObject"; import { MaybePromise } from "../../utils/MaybePromise"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; import { getSchemaUtils } from "../schema-utils"; import { BaseRecordSchema, RecordSchema } from "./types"; @@ -14,23 +16,41 @@ export function record keySchema.parse(key, opts), - transformValue: (value) => valueSchema.parse(value, opts), + transformKey: (key) => + keySchema.parse(key, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key} (key)`], + }), + transformValue: (value, key) => + valueSchema.parse(value, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key}`], + }), + breadcrumbsPrefix: opts?.breadcrumbsPrefix, }); }, json: async (parsed, opts) => { return validateAndTransformRecord({ value: parsed, isKeyNumeric: (await keySchema.getType()) === SchemaType.NUMBER, - transformKey: (key) => keySchema.json(key, opts), - transformValue: (value) => valueSchema.json(value, opts), + transformKey: (key) => + keySchema.json(key, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key} (key)`], + }), + transformValue: (value, key) => + valueSchema.json(value, { + ...opts, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), `${key}`], + }), + breadcrumbsPrefix: opts?.breadcrumbsPrefix, }); }, getType: () => SchemaType.RECORD, }; return { - ...baseSchema, + ...maybeSkipValidation(baseSchema), ...getSchemaUtils(baseSchema), }; } @@ -40,19 +60,21 @@ async function validateAndTransformRecord MaybePromise>; - transformValue: (value: unknown) => MaybePromise>; + transformValue: (value: unknown, key: string | number) => MaybePromise>; + breadcrumbsPrefix: string[] | undefined; }): Promise>> { if (!isPlainObject(value)) { return { ok: false, errors: [ { - path: [], - message: NOT_AN_OBJECT_ERROR_MESSAGE, + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "object"), }, ], }; @@ -76,7 +98,7 @@ async function validateAndTransformRecord ({ - path: [`${key} (key)`, ...error.path], - message: error.message, - })) - ); + errors.push(...transformedKey.errors); } if (!transformedValue.ok) { - errors.push( - ...transformedValue.errors.map((error) => ({ - path: [stringKey, ...error.path], - message: error.message, - })) - ); + errors.push(...transformedValue.errors); } return { diff --git a/src/core/schemas/builders/schema-utils/index.ts b/src/core/schemas/builders/schema-utils/index.ts index d499652..aa04e05 100644 --- a/src/core/schemas/builders/schema-utils/index.ts +++ b/src/core/schemas/builders/schema-utils/index.ts @@ -1,3 +1,4 @@ -export { getSchemaUtils, optional, transform, type SchemaUtils } from "./getSchemaUtils"; +export { getSchemaUtils, optional, transform } from "./getSchemaUtils"; +export type { SchemaUtils } from "./getSchemaUtils"; export { JsonError } from "./JsonError"; export { ParseError } from "./ParseError"; diff --git a/src/core/schemas/builders/set/set.ts b/src/core/schemas/builders/set/set.ts index ffc32f6..3113bcb 100644 --- a/src/core/schemas/builders/set/set.ts +++ b/src/core/schemas/builders/set/set.ts @@ -1,4 +1,6 @@ import { BaseSchema, Schema, SchemaType } from "../../Schema"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; import { list } from "../list"; import { getSchemaUtils } from "../schema-utils"; @@ -22,8 +24,8 @@ export function set(schema: Schema): Schema(schema: Schema): Schema, ...Schem > = { parse: async (raw, opts) => { return validateAndTransformUndiscriminatedUnion>( - (schema) => schema.parse(raw, opts), - schemas + (schema, opts) => schema.parse(raw, opts), + schemas, + opts ); }, json: async (parsed, opts) => { return validateAndTransformUndiscriminatedUnion>( - (schema) => schema.json(parsed, opts), - schemas + (schema, opts) => schema.json(parsed, opts), + schemas, + opts ); }, getType: () => SchemaType.UNDISCRIMINATED_UNION, }; return { - ...baseSchema, + ...maybeSkipValidation(baseSchema), ...getSchemaUtils(baseSchema), }; } async function validateAndTransformUndiscriminatedUnion( - transform: (schema: Schema) => MaybePromise>, - schemas: Schema[] + transform: (schema: Schema, opts: SchemaOptions) => MaybePromise>, + schemas: Schema[], + opts: SchemaOptions | undefined ): Promise> { const errors: ValidationError[] = []; - for (const schema of schemas) { - const transformed = await transform(schema); + for (const [index, schema] of schemas.entries()) { + const transformed = await transform(schema, { ...opts, skipValidation: false }); if (transformed.ok) { return transformed; - } else if (errors.length === 0) { - errors.push(...transformed.errors); + } else { + for (const error of transformed.errors) { + errors.push({ + path: error.path, + message: `[Variant ${index}] ${error.message}`, + }); + } } } diff --git a/src/core/schemas/builders/union/index.ts b/src/core/schemas/builders/union/index.ts index 9f52942..85fc008 100644 --- a/src/core/schemas/builders/union/index.ts +++ b/src/core/schemas/builders/union/index.ts @@ -1,9 +1,10 @@ -export { discriminant, type Discriminant } from "./discriminant"; -export { - type inferParsedDiscriminant, - type inferParsedUnion, - type inferRawDiscriminant, - type inferRawUnion, - type UnionSubtypes, +export { discriminant } from "./discriminant"; +export type { Discriminant } from "./discriminant"; +export type { + inferParsedDiscriminant, + inferParsedUnion, + inferRawDiscriminant, + inferRawUnion, + UnionSubtypes, } from "./types"; export { union } from "./union"; diff --git a/src/core/schemas/builders/union/union.ts b/src/core/schemas/builders/union/union.ts index f4032c6..ed659be 100644 --- a/src/core/schemas/builders/union/union.ts +++ b/src/core/schemas/builders/union/union.ts @@ -1,7 +1,9 @@ import { BaseSchema, MaybeValid, SchemaType } from "../../Schema"; -import { isPlainObject, NOT_AN_OBJECT_ERROR_MESSAGE } from "../../utils/isPlainObject"; +import { getErrorMessageForIncorrectType } from "../../utils/getErrorMessageForIncorrectType"; +import { isPlainObject } from "../../utils/isPlainObject"; import { keys } from "../../utils/keys"; import { MaybePromise } from "../../utils/MaybePromise"; +import { maybeSkipValidation } from "../../utils/maybeSkipValidation"; import { enum_ } from "../enum"; import { ObjectSchema } from "../object"; import { getObjectLikeUtils, ObjectLikeSchema } from "../object-like"; @@ -31,11 +33,13 @@ export function union, U extends Union transformDiscriminantValue: (discriminantValue) => discriminantValueSchema.parse(discriminantValue, { allowUnrecognizedEnumValues: opts?.allowUnrecognizedUnionMembers, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), rawDiscriminant], }), getAdditionalPropertiesSchema: (discriminantValue) => union[discriminantValue], allowUnrecognizedUnionMembers: opts?.allowUnrecognizedUnionMembers, transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.parse(additionalProperties, opts), + breadcrumbsPrefix: opts?.breadcrumbsPrefix, }); }, json: async (parsed, opts) => { @@ -46,18 +50,20 @@ export function union, U extends Union transformDiscriminantValue: (discriminantValue) => discriminantValueSchema.json(discriminantValue, { allowUnrecognizedEnumValues: opts?.allowUnrecognizedUnionMembers, + breadcrumbsPrefix: [...(opts?.breadcrumbsPrefix ?? []), parsedDiscriminant], }), getAdditionalPropertiesSchema: (discriminantValue) => union[discriminantValue], allowUnrecognizedUnionMembers: opts?.allowUnrecognizedUnionMembers, transformAdditionalProperties: (additionalProperties, additionalPropertiesSchema) => additionalPropertiesSchema.json(additionalProperties, opts), + breadcrumbsPrefix: opts?.breadcrumbsPrefix, }); }, getType: () => SchemaType.UNION, }; return { - ...baseSchema, + ...maybeSkipValidation(baseSchema), ...getSchemaUtils(baseSchema), ...getObjectLikeUtils(baseSchema), }; @@ -75,6 +81,7 @@ async function transformAndValidateUnion< getAdditionalPropertiesSchema, allowUnrecognizedUnionMembers = false, transformAdditionalProperties, + breadcrumbsPrefix = [], }: { value: unknown; discriminant: string; @@ -86,6 +93,7 @@ async function transformAndValidateUnion< additionalProperties: unknown, additionalPropertiesSchema: ObjectSchema ) => MaybePromise>; + breadcrumbsPrefix: string[] | undefined; }): Promise< MaybeValid & TransformedAdditionalProperties> > { @@ -94,8 +102,8 @@ async function transformAndValidateUnion< ok: false, errors: [ { - path: [], - message: NOT_AN_OBJECT_ERROR_MESSAGE, + path: breadcrumbsPrefix, + message: getErrorMessageForIncorrectType(value, "object"), }, ], }; @@ -108,7 +116,7 @@ async function transformAndValidateUnion< ok: false, errors: [ { - path: [], + path: breadcrumbsPrefix, message: `Missing discriminant ("${discriminant}")`, }, ], @@ -119,10 +127,7 @@ async function transformAndValidateUnion< if (!transformedDiscriminantValue.ok) { return { ok: false, - errors: transformedDiscriminantValue.errors.map((error) => ({ - path: [discriminant, ...error.path], - message: error.message, - })), + errors: transformedDiscriminantValue.errors, }; } @@ -142,8 +147,8 @@ async function transformAndValidateUnion< ok: false, errors: [ { - path: [discriminant], - message: "Unrecognized discriminant value", + path: [...breadcrumbsPrefix, discriminant], + message: "Unexpected discriminant value", }, ], }; diff --git a/src/core/schemas/index.ts b/src/core/schemas/index.ts index 562d151..5429d8b 100644 --- a/src/core/schemas/index.ts +++ b/src/core/schemas/index.ts @@ -1,2 +1,2 @@ export * from "./builders"; -export { type inferParsed, type inferRaw, type Schema, type SchemaOptions } from "./Schema"; +export type { inferParsed, inferRaw, Schema, SchemaOptions } from "./Schema"; diff --git a/src/core/schemas/utils/createIdentitySchemaCreator.ts b/src/core/schemas/utils/createIdentitySchemaCreator.ts index d702b43..de107cf 100644 --- a/src/core/schemas/utils/createIdentitySchemaCreator.ts +++ b/src/core/schemas/utils/createIdentitySchemaCreator.ts @@ -1,5 +1,6 @@ import { getSchemaUtils } from "../builders/schema-utils"; import { BaseSchema, MaybeValid, Schema, SchemaOptions, SchemaType } from "../Schema"; +import { maybeSkipValidation } from "./maybeSkipValidation"; export function createIdentitySchemaCreator( schemaType: SchemaType, @@ -13,7 +14,7 @@ export function createIdentitySchemaCreator( }; return { - ...baseSchema, + ...maybeSkipValidation(baseSchema), ...getSchemaUtils(baseSchema), }; }; diff --git a/src/core/schemas/utils/getErrorMessageForIncorrectType.ts b/src/core/schemas/utils/getErrorMessageForIncorrectType.ts new file mode 100644 index 0000000..438012d --- /dev/null +++ b/src/core/schemas/utils/getErrorMessageForIncorrectType.ts @@ -0,0 +1,21 @@ +export function getErrorMessageForIncorrectType(value: unknown, expectedType: string): string { + return `Expected ${expectedType}. Received ${getTypeAsString(value)}.`; +} + +function getTypeAsString(value: unknown): string { + if (Array.isArray(value)) { + return "list"; + } + if (value === null) { + return "null"; + } + switch (typeof value) { + case "string": + return `"${value}"`; + case "number": + case "boolean": + case "undefined": + return `${value}`; + } + return typeof value; +} diff --git a/src/core/schemas/utils/isPlainObject.ts b/src/core/schemas/utils/isPlainObject.ts index ecd35a4..db82a72 100644 --- a/src/core/schemas/utils/isPlainObject.ts +++ b/src/core/schemas/utils/isPlainObject.ts @@ -1,5 +1,3 @@ -export const NOT_AN_OBJECT_ERROR_MESSAGE = "Not an object"; - // borrowed from https://github.com/lodash/lodash/blob/master/isPlainObject.js export function isPlainObject(value: unknown): value is Record { if (typeof value !== "object" || value === null) { diff --git a/src/core/schemas/utils/maybeSkipValidation.ts b/src/core/schemas/utils/maybeSkipValidation.ts new file mode 100644 index 0000000..99c02c3 --- /dev/null +++ b/src/core/schemas/utils/maybeSkipValidation.ts @@ -0,0 +1,39 @@ +import { BaseSchema, MaybeValid, SchemaOptions } from "../Schema"; +import { MaybePromise } from "./MaybePromise"; + +export function maybeSkipValidation, Raw, Parsed>(schema: S): S { + return { + ...schema, + json: transformAndMaybeSkipValidation(schema.json), + parse: transformAndMaybeSkipValidation(schema.parse), + }; +} + +function transformAndMaybeSkipValidation( + transform: (value: unknown, opts?: SchemaOptions) => MaybePromise> +): (value: unknown, opts?: SchemaOptions) => MaybePromise> { + return async (value, opts): Promise> => { + const transformed = await transform(value, opts); + const { skipValidation = false } = opts ?? {}; + if (!transformed.ok && skipValidation) { + // eslint-disable-next-line no-console + console.warn( + [ + "Failed to validate.", + ...transformed.errors.map( + (error) => + " - " + + (error.path.length > 0 ? `${error.path.join(".")}: ${error.message}` : error.message) + ), + ].join("\n") + ); + + return { + ok: true, + value: value as T, + }; + } else { + return transformed; + } + }; +} diff --git a/src/environments.ts b/src/environments.ts index 057a819..661d754 100644 --- a/src/environments.ts +++ b/src/environments.ts @@ -3,7 +3,7 @@ */ export const CodeCombatEnvironment = { - Production: "https://codecombat.com/api", + Default: "https://codecombat.com/api", } as const; -export type CodeCombatEnvironment = typeof CodeCombatEnvironment.Production; +export type CodeCombatEnvironment = typeof CodeCombatEnvironment.Default; diff --git a/src/errors/CodeCombatError.ts b/src/errors/CodeCombatError.ts index c31ff73..8037fc8 100644 --- a/src/errors/CodeCombatError.ts +++ b/src/errors/CodeCombatError.ts @@ -7,7 +7,7 @@ export class CodeCombatError extends Error { readonly body?: unknown; constructor({ message, statusCode, body }: { message?: string; statusCode?: number; body?: unknown }) { - super(message); + super(buildMessage({ message, statusCode, body })); Object.setPrototypeOf(this, CodeCombatError.prototype); if (statusCode != null) { this.statusCode = statusCode; @@ -18,3 +18,28 @@ export class CodeCombatError extends Error { } } } + +function buildMessage({ + message, + statusCode, + body, +}: { + message: string | undefined; + statusCode: number | undefined; + body: unknown | undefined; +}): string { + let lines: string[] = []; + if (message != null) { + lines.push(message); + } + + if (statusCode != null) { + lines.push(`Status code: ${statusCode.toString()}`); + } + + if (body != null) { + lines.push(`Body: ${JSON.stringify(body, undefined, 2)}`); + } + + return lines.join("\n"); +} diff --git a/src/serialization/client/index.ts b/src/serialization/client/index.ts new file mode 100644 index 0000000..415726b --- /dev/null +++ b/src/serialization/client/index.ts @@ -0,0 +1 @@ +export * from "./requests"; diff --git a/src/serialization/resources/users/client/requests/AddOAuthIdentityRequest.ts b/src/serialization/client/requests/PostUsersHandleOAuthIdentitiesRequest.ts similarity index 50% rename from src/serialization/resources/users/client/requests/AddOAuthIdentityRequest.ts rename to src/serialization/client/requests/PostUsersHandleOAuthIdentitiesRequest.ts index 7e4d8c6..ae21486 100644 --- a/src/serialization/resources/users/client/requests/AddOAuthIdentityRequest.ts +++ b/src/serialization/client/requests/PostUsersHandleOAuthIdentitiesRequest.ts @@ -2,20 +2,20 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../../core"; +import * as serializers from "../.."; +import * as CodeCombat from "../../../api"; +import * as core from "../../../core"; -export const AddOAuthIdentityRequest: core.serialization.Schema< - serializers.AddOAuthIdentityRequest.Raw, - CodeCombat.AddOAuthIdentityRequest +export const PostUsersHandleOAuthIdentitiesRequest: core.serialization.Schema< + serializers.PostUsersHandleOAuthIdentitiesRequest.Raw, + CodeCombat.PostUsersHandleOAuthIdentitiesRequest > = core.serialization.object({ provider: core.serialization.string(), accessToken: core.serialization.string().optional(), code: core.serialization.string().optional(), }); -export declare namespace AddOAuthIdentityRequest { +export declare namespace PostUsersHandleOAuthIdentitiesRequest { interface Raw { provider: string; accessToken?: string | null; diff --git a/src/serialization/client/requests/index.ts b/src/serialization/client/requests/index.ts new file mode 100644 index 0000000..69715ca --- /dev/null +++ b/src/serialization/client/requests/index.ts @@ -0,0 +1 @@ +export { PostUsersHandleOAuthIdentitiesRequest } from "./PostUsersHandleOAuthIdentitiesRequest"; diff --git a/src/serialization/index.ts b/src/serialization/index.ts index 3e5335f..a931b36 100644 --- a/src/serialization/index.ts +++ b/src/serialization/index.ts @@ -1 +1,3 @@ +export * from "./types"; export * from "./resources"; +export * from "./client"; diff --git a/src/serialization/resources/clans/client/requests/UpsertClanRequest.ts b/src/serialization/resources/clans/client/requests/ClansUpsertMemberRequest.ts similarity index 53% rename from src/serialization/resources/clans/client/requests/UpsertClanRequest.ts rename to src/serialization/resources/clans/client/requests/ClansUpsertMemberRequest.ts index 4c9fb51..70ca1af 100644 --- a/src/serialization/resources/clans/client/requests/UpsertClanRequest.ts +++ b/src/serialization/resources/clans/client/requests/ClansUpsertMemberRequest.ts @@ -3,17 +3,17 @@ */ import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../../api"; import * as core from "../../../../../core"; -export const UpsertClanRequest: core.serialization.Schema< - serializers.UpsertClanRequest.Raw, - CodeCombat.UpsertClanRequest +export const ClansUpsertMemberRequest: core.serialization.Schema< + serializers.ClansUpsertMemberRequest.Raw, + CodeCombat.ClansUpsertMemberRequest > = core.serialization.object({ userId: core.serialization.string(), }); -export declare namespace UpsertClanRequest { +export declare namespace ClansUpsertMemberRequest { interface Raw { userId: string; } diff --git a/src/serialization/resources/clans/client/requests/index.ts b/src/serialization/resources/clans/client/requests/index.ts index 5bbb7a7..173b4df 100644 --- a/src/serialization/resources/clans/client/requests/index.ts +++ b/src/serialization/resources/clans/client/requests/index.ts @@ -1 +1 @@ -export { UpsertClanRequest } from "./UpsertClanRequest"; +export { ClansUpsertMemberRequest } from "./ClansUpsertMemberRequest"; diff --git a/src/serialization/resources/clans/index.ts b/src/serialization/resources/clans/index.ts index c9240f8..5ec7692 100644 --- a/src/serialization/resources/clans/index.ts +++ b/src/serialization/resources/clans/index.ts @@ -1,2 +1 @@ -export * from "./types"; export * from "./client"; diff --git a/src/serialization/resources/clans/types/index.ts b/src/serialization/resources/clans/types/index.ts deleted file mode 100644 index 77565d4..0000000 --- a/src/serialization/resources/clans/types/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./ClanResponse"; diff --git a/src/serialization/resources/classrooms/client/getLevelSession.ts b/src/serialization/resources/classrooms/client/getLevelsPlayed.ts similarity index 81% rename from src/serialization/resources/classrooms/client/getLevelSession.ts rename to src/serialization/resources/classrooms/client/getLevelsPlayed.ts index 85b0727..e86fd0a 100644 --- a/src/serialization/resources/classrooms/client/getLevelSession.ts +++ b/src/serialization/resources/classrooms/client/getLevelsPlayed.ts @@ -3,11 +3,11 @@ */ import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../api"; import * as core from "../../../../core"; export const Response: core.serialization.Schema< - serializers.classrooms.getLevelSession.Response.Raw, + serializers.classrooms.getLevelsPlayed.Response.Raw, CodeCombat.LevelSessionResponse[] > = core.serialization.list(core.serialization.lazyObject(async () => (await import("../../..")).LevelSessionResponse)); diff --git a/src/serialization/resources/classrooms/client/getMembersStats.ts b/src/serialization/resources/classrooms/client/getMembersStats.ts index ef8142e..4c9c98c 100644 --- a/src/serialization/resources/classrooms/client/getMembersStats.ts +++ b/src/serialization/resources/classrooms/client/getMembersStats.ts @@ -3,14 +3,16 @@ */ import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../api"; import * as core from "../../../../core"; export const Response: core.serialization.Schema< serializers.classrooms.getMembersStats.Response.Raw, - CodeCombat.MemberStat[] -> = core.serialization.list(core.serialization.lazyObject(async () => (await import("../../..")).MemberStat)); + CodeCombat.ClassroomsGetMembersStatsResponseItem[] +> = core.serialization.list( + core.serialization.lazyObject(async () => (await import("../../..")).ClassroomsGetMembersStatsResponseItem) +); export declare namespace Response { - type Raw = serializers.MemberStat.Raw[]; + type Raw = serializers.ClassroomsGetMembersStatsResponseItem.Raw[]; } diff --git a/src/serialization/resources/classrooms/client/index.ts b/src/serialization/resources/classrooms/client/index.ts index f9cf304..a5ad942 100644 --- a/src/serialization/resources/classrooms/client/index.ts +++ b/src/serialization/resources/classrooms/client/index.ts @@ -1,3 +1,3 @@ export * as getMembersStats from "./getMembersStats"; -export * as getLevelSession from "./getLevelSession"; +export * as getLevelsPlayed from "./getLevelsPlayed"; export * from "./requests"; diff --git a/src/serialization/resources/classrooms/client/requests/CreateClassroomRequest.ts b/src/serialization/resources/classrooms/client/requests/ClassroomsCreateRequest.ts similarity index 52% rename from src/serialization/resources/classrooms/client/requests/CreateClassroomRequest.ts rename to src/serialization/resources/classrooms/client/requests/ClassroomsCreateRequest.ts index 8fd58ea..b29dcbf 100644 --- a/src/serialization/resources/classrooms/client/requests/CreateClassroomRequest.ts +++ b/src/serialization/resources/classrooms/client/requests/ClassroomsCreateRequest.ts @@ -3,25 +3,27 @@ */ import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../../api"; import * as core from "../../../../../core"; -export const CreateClassroomRequest: core.serialization.Schema< - serializers.CreateClassroomRequest.Raw, - CodeCombat.CreateClassroomRequest +export const ClassroomsCreateRequest: core.serialization.Schema< + serializers.ClassroomsCreateRequest.Raw, + CodeCombat.ClassroomsCreateRequest > = core.serialization.object({ name: core.serialization.string(), ownerId: core.serialization.property( "ownerID", core.serialization.lazy(async () => (await import("../../../..")).ObjectIdString) ), - aceConfig: core.serialization.lazyObject(async () => (await import("../../../..")).AceConfig), + aceConfig: core.serialization.lazyObject( + async () => (await import("../../../..")).ClassroomsCreateRequestAceConfig + ), }); -export declare namespace CreateClassroomRequest { +export declare namespace ClassroomsCreateRequest { interface Raw { name: string; ownerID: serializers.ObjectIdString.Raw; - aceConfig: serializers.AceConfig.Raw; + aceConfig: serializers.ClassroomsCreateRequestAceConfig.Raw; } } diff --git a/src/serialization/resources/classrooms/client/requests/EnrollUserInCourseRequest.ts b/src/serialization/resources/classrooms/client/requests/ClassroomsEnrollUserInCourseRequest.ts similarity index 53% rename from src/serialization/resources/classrooms/client/requests/EnrollUserInCourseRequest.ts rename to src/serialization/resources/classrooms/client/requests/ClassroomsEnrollUserInCourseRequest.ts index 6f78ca8..126d75f 100644 --- a/src/serialization/resources/classrooms/client/requests/EnrollUserInCourseRequest.ts +++ b/src/serialization/resources/classrooms/client/requests/ClassroomsEnrollUserInCourseRequest.ts @@ -3,17 +3,17 @@ */ import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../../api"; import * as core from "../../../../../core"; -export const EnrollUserInCourseRequest: core.serialization.Schema< - serializers.EnrollUserInCourseRequest.Raw, - Omit +export const ClassroomsEnrollUserInCourseRequest: core.serialization.Schema< + serializers.ClassroomsEnrollUserInCourseRequest.Raw, + Omit > = core.serialization.object({ userId: core.serialization.lazy(async () => (await import("../../../..")).ObjectIdString), }); -export declare namespace EnrollUserInCourseRequest { +export declare namespace ClassroomsEnrollUserInCourseRequest { interface Raw { userId: serializers.ObjectIdString.Raw; } diff --git a/src/serialization/resources/classrooms/client/requests/RemoveUserFromClassroomRequest.ts b/src/serialization/resources/classrooms/client/requests/ClassroomsRemoveEnrolledUserRequest.ts similarity index 53% rename from src/serialization/resources/classrooms/client/requests/RemoveUserFromClassroomRequest.ts rename to src/serialization/resources/classrooms/client/requests/ClassroomsRemoveEnrolledUserRequest.ts index f4c55a6..ce75212 100644 --- a/src/serialization/resources/classrooms/client/requests/RemoveUserFromClassroomRequest.ts +++ b/src/serialization/resources/classrooms/client/requests/ClassroomsRemoveEnrolledUserRequest.ts @@ -3,17 +3,17 @@ */ import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../../api"; import * as core from "../../../../../core"; -export const RemoveUserFromClassroomRequest: core.serialization.Schema< - serializers.RemoveUserFromClassroomRequest.Raw, - Omit +export const ClassroomsRemoveEnrolledUserRequest: core.serialization.Schema< + serializers.ClassroomsRemoveEnrolledUserRequest.Raw, + Omit > = core.serialization.object({ userId: core.serialization.lazy(async () => (await import("../../../..")).ObjectIdString), }); -export declare namespace RemoveUserFromClassroomRequest { +export declare namespace ClassroomsRemoveEnrolledUserRequest { interface Raw { userId: serializers.ObjectIdString.Raw; } diff --git a/src/serialization/resources/classrooms/client/requests/DeleteUserFromClassroomRequest.ts b/src/serialization/resources/classrooms/client/requests/ClassroomsRemoveMemberRequest.ts similarity index 58% rename from src/serialization/resources/classrooms/client/requests/DeleteUserFromClassroomRequest.ts rename to src/serialization/resources/classrooms/client/requests/ClassroomsRemoveMemberRequest.ts index feeb413..7af5f9c 100644 --- a/src/serialization/resources/classrooms/client/requests/DeleteUserFromClassroomRequest.ts +++ b/src/serialization/resources/classrooms/client/requests/ClassroomsRemoveMemberRequest.ts @@ -3,18 +3,18 @@ */ import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../../api"; import * as core from "../../../../../core"; -export const DeleteUserFromClassroomRequest: core.serialization.Schema< - serializers.DeleteUserFromClassroomRequest.Raw, - CodeCombat.DeleteUserFromClassroomRequest +export const ClassroomsRemoveMemberRequest: core.serialization.Schema< + serializers.ClassroomsRemoveMemberRequest.Raw, + CodeCombat.ClassroomsRemoveMemberRequest > = core.serialization.object({ userId: core.serialization.string(), retMemberLimit: core.serialization.number().optional(), }); -export declare namespace DeleteUserFromClassroomRequest { +export declare namespace ClassroomsRemoveMemberRequest { interface Raw { userId: string; retMemberLimit?: number | null; diff --git a/src/serialization/resources/classrooms/client/requests/UpsertClassroomRequest.ts b/src/serialization/resources/classrooms/client/requests/ClassroomsUpsertMemberRequest.ts similarity index 62% rename from src/serialization/resources/classrooms/client/requests/UpsertClassroomRequest.ts rename to src/serialization/resources/classrooms/client/requests/ClassroomsUpsertMemberRequest.ts index 0dee604..9858e3a 100644 --- a/src/serialization/resources/classrooms/client/requests/UpsertClassroomRequest.ts +++ b/src/serialization/resources/classrooms/client/requests/ClassroomsUpsertMemberRequest.ts @@ -3,19 +3,19 @@ */ import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../../api"; import * as core from "../../../../../core"; -export const UpsertClassroomRequest: core.serialization.Schema< - serializers.UpsertClassroomRequest.Raw, - CodeCombat.UpsertClassroomRequest +export const ClassroomsUpsertMemberRequest: core.serialization.Schema< + serializers.ClassroomsUpsertMemberRequest.Raw, + CodeCombat.ClassroomsUpsertMemberRequest > = core.serialization.object({ code: core.serialization.string(), userId: core.serialization.string(), retMemberLimit: core.serialization.number().optional(), }); -export declare namespace UpsertClassroomRequest { +export declare namespace ClassroomsUpsertMemberRequest { interface Raw { code: string; userId: string; diff --git a/src/serialization/resources/classrooms/client/requests/index.ts b/src/serialization/resources/classrooms/client/requests/index.ts index 60bf42a..885518b 100644 --- a/src/serialization/resources/classrooms/client/requests/index.ts +++ b/src/serialization/resources/classrooms/client/requests/index.ts @@ -1,5 +1,5 @@ -export { CreateClassroomRequest } from "./CreateClassroomRequest"; -export { UpsertClassroomRequest } from "./UpsertClassroomRequest"; -export { DeleteUserFromClassroomRequest } from "./DeleteUserFromClassroomRequest"; -export { EnrollUserInCourseRequest } from "./EnrollUserInCourseRequest"; -export { RemoveUserFromClassroomRequest } from "./RemoveUserFromClassroomRequest"; +export { ClassroomsCreateRequest } from "./ClassroomsCreateRequest"; +export { ClassroomsUpsertMemberRequest } from "./ClassroomsUpsertMemberRequest"; +export { ClassroomsRemoveMemberRequest } from "./ClassroomsRemoveMemberRequest"; +export { ClassroomsEnrollUserInCourseRequest } from "./ClassroomsEnrollUserInCourseRequest"; +export { ClassroomsRemoveEnrolledUserRequest } from "./ClassroomsRemoveEnrolledUserRequest"; diff --git a/src/serialization/resources/classrooms/index.ts b/src/serialization/resources/classrooms/index.ts index c9240f8..5ec7692 100644 --- a/src/serialization/resources/classrooms/index.ts +++ b/src/serialization/resources/classrooms/index.ts @@ -1,2 +1 @@ -export * from "./types"; export * from "./client"; diff --git a/src/serialization/resources/classrooms/types/AceConfig.ts b/src/serialization/resources/classrooms/types/AceConfig.ts deleted file mode 100644 index 4790160..0000000 --- a/src/serialization/resources/classrooms/types/AceConfig.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const AceConfig: core.serialization.ObjectSchema = - core.serialization.object({ - language: core.serialization.string().optional(), - }); - -export declare namespace AceConfig { - interface Raw { - language?: string | null; - } -} diff --git a/src/serialization/resources/classrooms/types/Level.ts b/src/serialization/resources/classrooms/types/Level.ts deleted file mode 100644 index 44f5d03..0000000 --- a/src/serialization/resources/classrooms/types/Level.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const Level: core.serialization.ObjectSchema = - core.serialization.object({ - original: core.serialization.string().optional(), - }); - -export declare namespace Level { - interface Raw { - original?: string | null; - } -} diff --git a/src/serialization/resources/classrooms/types/MemberStat.ts b/src/serialization/resources/classrooms/types/MemberStat.ts deleted file mode 100644 index 661ef31..0000000 --- a/src/serialization/resources/classrooms/types/MemberStat.ts +++ /dev/null @@ -1,23 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const MemberStat: core.serialization.ObjectSchema = - core.serialization.object({ - id: core.serialization.property( - "_id", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() - ), - stats: core.serialization.lazyObject(async () => (await import("../../..")).PlayStats).optional(), - }); - -export declare namespace MemberStat { - interface Raw { - _id?: serializers.ObjectIdString.Raw | null; - stats?: serializers.PlayStats.Raw | null; - } -} diff --git a/src/serialization/resources/classrooms/types/PlayStats.ts b/src/serialization/resources/classrooms/types/PlayStats.ts deleted file mode 100644 index 36f7863..0000000 --- a/src/serialization/resources/classrooms/types/PlayStats.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const PlayStats: core.serialization.ObjectSchema = - core.serialization.object({ - gamesCompleted: core.serialization.number().optional(), - playtime: core.serialization.number().optional(), - }); - -export declare namespace PlayStats { - interface Raw { - gamesCompleted?: number | null; - playtime?: number | null; - } -} diff --git a/src/serialization/resources/classrooms/types/State.ts b/src/serialization/resources/classrooms/types/State.ts deleted file mode 100644 index 7794a4d..0000000 --- a/src/serialization/resources/classrooms/types/State.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const State: core.serialization.ObjectSchema = - core.serialization.object({ - complete: core.serialization.boolean().optional(), - }); - -export declare namespace State { - interface Raw { - complete?: boolean | null; - } -} diff --git a/src/serialization/resources/classrooms/types/index.ts b/src/serialization/resources/classrooms/types/index.ts deleted file mode 100644 index a217cb9..0000000 --- a/src/serialization/resources/classrooms/types/index.ts +++ /dev/null @@ -1,6 +0,0 @@ -export * from "./LevelSessionResponse"; -export * from "./State"; -export * from "./Level"; -export * from "./AceConfig"; -export * from "./PlayStats"; -export * from "./MemberStat"; diff --git a/src/serialization/resources/commons/index.ts b/src/serialization/resources/commons/index.ts deleted file mode 100644 index eea524d..0000000 --- a/src/serialization/resources/commons/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types"; diff --git a/src/serialization/resources/commons/types/AuthIdentity.ts b/src/serialization/resources/commons/types/AuthIdentity.ts deleted file mode 100644 index 94d1c77..0000000 --- a/src/serialization/resources/commons/types/AuthIdentity.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const AuthIdentity: core.serialization.ObjectSchema = - core.serialization.object({ - provider: core.serialization.string().optional(), - id: core.serialization.string().optional(), - }); - -export declare namespace AuthIdentity { - interface Raw { - provider?: string | null; - id?: string | null; - } -} diff --git a/src/serialization/resources/commons/types/Course.ts b/src/serialization/resources/commons/types/Course.ts deleted file mode 100644 index 549e837..0000000 --- a/src/serialization/resources/commons/types/Course.ts +++ /dev/null @@ -1,34 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const Course: core.serialization.ObjectSchema = - core.serialization.object({ - id: core.serialization.property( - "_id", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() - ), - levels: core.serialization - .list(core.serialization.record(core.serialization.string(), core.serialization.unknown())) - .optional(), - enrolled: core.serialization - .list(core.serialization.lazy(async () => (await import("../../..")).ObjectIdString)) - .optional(), - instanceId: core.serialization.property( - "instance_id", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() - ), - }); - -export declare namespace Course { - interface Raw { - _id?: serializers.ObjectIdString.Raw | null; - levels?: Record[] | null; - enrolled?: serializers.ObjectIdString.Raw[] | null; - instance_id?: serializers.ObjectIdString.Raw | null; - } -} diff --git a/src/serialization/resources/commons/types/License.ts b/src/serialization/resources/commons/types/License.ts deleted file mode 100644 index 983ad6e..0000000 --- a/src/serialization/resources/commons/types/License.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const License: core.serialization.ObjectSchema = - core.serialization.object({ - ends: core.serialization.lazy(async () => (await import("../../..")).DatetimeString).optional(), - active: core.serialization.boolean().optional(), - }); - -export declare namespace License { - interface Raw { - ends?: serializers.DatetimeString.Raw | null; - active?: boolean | null; - } -} diff --git a/src/serialization/resources/commons/types/Subscription.ts b/src/serialization/resources/commons/types/Subscription.ts deleted file mode 100644 index 78dd842..0000000 --- a/src/serialization/resources/commons/types/Subscription.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const Subscription: core.serialization.ObjectSchema = - core.serialization.object({ - ends: core.serialization.lazy(async () => (await import("../../..")).DatetimeString).optional(), - active: core.serialization.boolean().optional(), - }); - -export declare namespace Subscription { - interface Raw { - ends?: serializers.DatetimeString.Raw | null; - active?: boolean | null; - } -} diff --git a/src/serialization/resources/commons/types/UserStats.ts b/src/serialization/resources/commons/types/UserStats.ts deleted file mode 100644 index cd07308..0000000 --- a/src/serialization/resources/commons/types/UserStats.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const UserStats: core.serialization.ObjectSchema = - core.serialization.object({ - gamesCompleted: core.serialization.number().optional(), - concepts: core.serialization.record(core.serialization.string(), core.serialization.number()).optional(), - playTime: core.serialization.number().optional(), - }); - -export declare namespace UserStats { - interface Raw { - gamesCompleted?: number | null; - concepts?: Record | null; - playTime?: number | null; - } -} diff --git a/src/serialization/resources/commons/types/index.ts b/src/serialization/resources/commons/types/index.ts deleted file mode 100644 index 374d90d..0000000 --- a/src/serialization/resources/commons/types/index.ts +++ /dev/null @@ -1,11 +0,0 @@ -export * from "./UserResponse"; -export * from "./UserStats"; -export * from "./AuthIdentity"; -export * from "./Subscription"; -export * from "./License"; -export * from "./ObjectIdString"; -export * from "./RoleString"; -export * from "./DatetimeString"; -export * from "./ClassroomResponseWithCode"; -export * from "./Course"; -export * from "./ClassroomResponse"; diff --git a/src/serialization/resources/index.ts b/src/serialization/resources/index.ts index edc161c..0876ca9 100644 --- a/src/serialization/resources/index.ts +++ b/src/serialization/resources/index.ts @@ -1,13 +1,6 @@ -export * as clans from "./clans"; -export * from "./clans/types"; export * as classrooms from "./classrooms"; -export * from "./classrooms/types"; -export * as commons from "./commons"; -export * from "./commons/types"; -export * as stats from "./stats"; -export * from "./stats/types"; export * as users from "./users"; -export * from "./users/types"; +export * as clans from "./clans"; export * from "./clans/client/requests"; export * from "./classrooms/client/requests"; export * from "./users/client/requests"; diff --git a/src/serialization/resources/stats/index.ts b/src/serialization/resources/stats/index.ts deleted file mode 100644 index eea524d..0000000 --- a/src/serialization/resources/stats/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from "./types"; diff --git a/src/serialization/resources/stats/types/index.ts b/src/serialization/resources/stats/types/index.ts deleted file mode 100644 index aa26a9e..0000000 --- a/src/serialization/resources/stats/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./PlaytimeStatsResponse"; -export * from "./LicenseStatsResponse"; diff --git a/src/serialization/resources/users/client/getClassrooms.ts b/src/serialization/resources/users/client/getClassrooms.ts index 64fe07c..1cf4148 100644 --- a/src/serialization/resources/users/client/getClassrooms.ts +++ b/src/serialization/resources/users/client/getClassrooms.ts @@ -3,7 +3,7 @@ */ import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../api"; import * as core from "../../../../core"; export const Response: core.serialization.Schema< diff --git a/src/serialization/resources/users/client/requests/GetHeroRequest.ts b/src/serialization/resources/users/client/requests/GetHeroRequest.ts deleted file mode 100644 index 75dd978..0000000 --- a/src/serialization/resources/users/client/requests/GetHeroRequest.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../../core"; - -export const GetHeroRequest: core.serialization.Schema = - core.serialization.object({ - thangType: core.serialization.lazy(async () => (await import("../../../..")).ObjectIdString).optional(), - }); - -export declare namespace GetHeroRequest { - interface Raw { - thangType?: serializers.ObjectIdString.Raw | null; - } -} diff --git a/src/serialization/resources/users/client/requests/GrantLicenseRequest.ts b/src/serialization/resources/users/client/requests/GrantLicenseRequest.ts deleted file mode 100644 index dfc4736..0000000 --- a/src/serialization/resources/users/client/requests/GrantLicenseRequest.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../../core"; - -export const GrantLicenseRequest: core.serialization.Schema< - serializers.GrantLicenseRequest.Raw, - CodeCombat.GrantLicenseRequest -> = core.serialization.object({ - ends: core.serialization.date(), -}); - -export declare namespace GrantLicenseRequest { - interface Raw { - ends: string; - } -} diff --git a/src/serialization/resources/users/client/requests/SetAceConfig.ts b/src/serialization/resources/users/client/requests/SetAceConfig.ts deleted file mode 100644 index 7e64bbb..0000000 --- a/src/serialization/resources/users/client/requests/SetAceConfig.ts +++ /dev/null @@ -1,22 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../../core"; - -export const SetAceConfig: core.serialization.Schema = - core.serialization.object({ - liveCompletion: core.serialization.boolean().optional(), - behaviors: core.serialization.boolean().optional(), - language: core.serialization.string().optional(), - }); - -export declare namespace SetAceConfig { - interface Raw { - liveCompletion?: boolean | null; - behaviors?: boolean | null; - language?: string | null; - } -} diff --git a/src/serialization/resources/users/client/requests/ShortenLicenseRequest.ts b/src/serialization/resources/users/client/requests/ShortenLicenseRequest.ts deleted file mode 100644 index ea793b5..0000000 --- a/src/serialization/resources/users/client/requests/ShortenLicenseRequest.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../../core"; - -export const ShortenLicenseRequest: core.serialization.Schema< - serializers.ShortenLicenseRequest.Raw, - CodeCombat.ShortenLicenseRequest -> = core.serialization.object({ - ends: core.serialization.date(), -}); - -export declare namespace ShortenLicenseRequest { - interface Raw { - ends: string; - } -} diff --git a/src/serialization/resources/users/client/requests/ShortenSubscriptionRequest.ts b/src/serialization/resources/users/client/requests/ShortenSubscriptionRequest.ts deleted file mode 100644 index 7f0773a..0000000 --- a/src/serialization/resources/users/client/requests/ShortenSubscriptionRequest.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../../core"; - -export const ShortenSubscriptionRequest: core.serialization.Schema< - serializers.ShortenSubscriptionRequest.Raw, - CodeCombat.ShortenSubscriptionRequest -> = core.serialization.object({ - ends: core.serialization.date(), -}); - -export declare namespace ShortenSubscriptionRequest { - interface Raw { - ends: string; - } -} diff --git a/src/serialization/resources/users/client/requests/UpdateSubscriptionRequest.ts b/src/serialization/resources/users/client/requests/UpdateSubscriptionRequest.ts deleted file mode 100644 index 93bd60f..0000000 --- a/src/serialization/resources/users/client/requests/UpdateSubscriptionRequest.ts +++ /dev/null @@ -1,20 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../../core"; - -export const UpdateSubscriptionRequest: core.serialization.Schema< - serializers.UpdateSubscriptionRequest.Raw, - CodeCombat.UpdateSubscriptionRequest -> = core.serialization.object({ - ends: core.serialization.date(), -}); - -export declare namespace UpdateSubscriptionRequest { - interface Raw { - ends: string; - } -} diff --git a/src/serialization/resources/users/client/requests/CreateUserRequest.ts b/src/serialization/resources/users/client/requests/UsersCreateRequest.ts similarity index 52% rename from src/serialization/resources/users/client/requests/CreateUserRequest.ts rename to src/serialization/resources/users/client/requests/UsersCreateRequest.ts index 9a6cfd4..271bbf5 100644 --- a/src/serialization/resources/users/client/requests/CreateUserRequest.ts +++ b/src/serialization/resources/users/client/requests/UsersCreateRequest.ts @@ -3,28 +3,30 @@ */ import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../../api"; import * as core from "../../../../../core"; -export const CreateUserRequest: core.serialization.Schema< - serializers.CreateUserRequest.Raw, - CodeCombat.CreateUserRequest +export const UsersCreateRequest: core.serialization.Schema< + serializers.UsersCreateRequest.Raw, + CodeCombat.UsersCreateRequest > = core.serialization.object({ name: core.serialization.string(), email: core.serialization.string(), - role: core.serialization.lazy(async () => (await import("../../../..")).UserRole).optional(), + role: core.serialization.lazy(async () => (await import("../../../..")).UsersCreateRequestRole).optional(), preferredLanguage: core.serialization.string().optional(), - heroConfig: core.serialization.lazyObject(async () => (await import("../../../..")).HeroConfig).optional(), + heroConfig: core.serialization + .lazyObject(async () => (await import("../../../..")).UsersCreateRequestHeroConfig) + .optional(), birthday: core.serialization.string().optional(), }); -export declare namespace CreateUserRequest { +export declare namespace UsersCreateRequest { interface Raw { name: string; email: string; - role?: serializers.UserRole.Raw | null; + role?: serializers.UsersCreateRequestRole.Raw | null; preferredLanguage?: string | null; - heroConfig?: serializers.HeroConfig.Raw | null; + heroConfig?: serializers.UsersCreateRequestHeroConfig.Raw | null; birthday?: string | null; } } diff --git a/src/serialization/resources/users/client/requests/UsersGrantLicenseRequest.ts b/src/serialization/resources/users/client/requests/UsersGrantLicenseRequest.ts new file mode 100644 index 0000000..5a5104c --- /dev/null +++ b/src/serialization/resources/users/client/requests/UsersGrantLicenseRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as CodeCombat from "../../../../../api"; +import * as core from "../../../../../core"; + +export const UsersGrantLicenseRequest: core.serialization.Schema< + serializers.UsersGrantLicenseRequest.Raw, + CodeCombat.UsersGrantLicenseRequest +> = core.serialization.object({ + ends: core.serialization.lazy(async () => (await import("../../../..")).DatetimeString), +}); + +export declare namespace UsersGrantLicenseRequest { + interface Raw { + ends: serializers.DatetimeString.Raw; + } +} diff --git a/src/serialization/resources/users/client/requests/UsersGrantPremiumSubscriptionRequest.ts b/src/serialization/resources/users/client/requests/UsersGrantPremiumSubscriptionRequest.ts new file mode 100644 index 0000000..de7723d --- /dev/null +++ b/src/serialization/resources/users/client/requests/UsersGrantPremiumSubscriptionRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as CodeCombat from "../../../../../api"; +import * as core from "../../../../../core"; + +export const UsersGrantPremiumSubscriptionRequest: core.serialization.Schema< + serializers.UsersGrantPremiumSubscriptionRequest.Raw, + CodeCombat.UsersGrantPremiumSubscriptionRequest +> = core.serialization.object({ + ends: core.serialization.lazy(async () => (await import("../../../..")).DatetimeString), +}); + +export declare namespace UsersGrantPremiumSubscriptionRequest { + interface Raw { + ends: serializers.DatetimeString.Raw; + } +} diff --git a/src/serialization/resources/users/client/requests/UsersSetAceConfigRequest.ts b/src/serialization/resources/users/client/requests/UsersSetAceConfigRequest.ts new file mode 100644 index 0000000..0089b3b --- /dev/null +++ b/src/serialization/resources/users/client/requests/UsersSetAceConfigRequest.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as CodeCombat from "../../../../../api"; +import * as core from "../../../../../core"; + +export const UsersSetAceConfigRequest: core.serialization.Schema< + serializers.UsersSetAceConfigRequest.Raw, + CodeCombat.UsersSetAceConfigRequest +> = core.serialization.object({ + liveCompletion: core.serialization.boolean().optional(), + behaviors: core.serialization.boolean().optional(), + language: core.serialization.string().optional(), +}); + +export declare namespace UsersSetAceConfigRequest { + interface Raw { + liveCompletion?: boolean | null; + behaviors?: boolean | null; + language?: string | null; + } +} diff --git a/src/serialization/resources/users/client/requests/UsersSetHeroRequest.ts b/src/serialization/resources/users/client/requests/UsersSetHeroRequest.ts new file mode 100644 index 0000000..27dfaf3 --- /dev/null +++ b/src/serialization/resources/users/client/requests/UsersSetHeroRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as CodeCombat from "../../../../../api"; +import * as core from "../../../../../core"; + +export const UsersSetHeroRequest: core.serialization.Schema< + serializers.UsersSetHeroRequest.Raw, + CodeCombat.UsersSetHeroRequest +> = core.serialization.object({ + thangType: core.serialization.lazy(async () => (await import("../../../..")).ObjectIdString).optional(), +}); + +export declare namespace UsersSetHeroRequest { + interface Raw { + thangType?: serializers.ObjectIdString.Raw | null; + } +} diff --git a/src/serialization/resources/users/client/requests/UsersShortenLicenseRequest.ts b/src/serialization/resources/users/client/requests/UsersShortenLicenseRequest.ts new file mode 100644 index 0000000..1c05c03 --- /dev/null +++ b/src/serialization/resources/users/client/requests/UsersShortenLicenseRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as CodeCombat from "../../../../../api"; +import * as core from "../../../../../core"; + +export const UsersShortenLicenseRequest: core.serialization.Schema< + serializers.UsersShortenLicenseRequest.Raw, + CodeCombat.UsersShortenLicenseRequest +> = core.serialization.object({ + ends: core.serialization.lazy(async () => (await import("../../../..")).DatetimeString), +}); + +export declare namespace UsersShortenLicenseRequest { + interface Raw { + ends: serializers.DatetimeString.Raw; + } +} diff --git a/src/serialization/resources/users/client/requests/UsersShortenSubscriptionRequest.ts b/src/serialization/resources/users/client/requests/UsersShortenSubscriptionRequest.ts new file mode 100644 index 0000000..bf38d9f --- /dev/null +++ b/src/serialization/resources/users/client/requests/UsersShortenSubscriptionRequest.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from "../../../.."; +import * as CodeCombat from "../../../../../api"; +import * as core from "../../../../../core"; + +export const UsersShortenSubscriptionRequest: core.serialization.Schema< + serializers.UsersShortenSubscriptionRequest.Raw, + CodeCombat.UsersShortenSubscriptionRequest +> = core.serialization.object({ + ends: core.serialization.lazy(async () => (await import("../../../..")).DatetimeString), +}); + +export declare namespace UsersShortenSubscriptionRequest { + interface Raw { + ends: serializers.DatetimeString.Raw; + } +} diff --git a/src/serialization/resources/users/client/requests/UpdateUserRequest.ts b/src/serialization/resources/users/client/requests/UsersUpdateRequest.ts similarity index 62% rename from src/serialization/resources/users/client/requests/UpdateUserRequest.ts rename to src/serialization/resources/users/client/requests/UsersUpdateRequest.ts index 289a679..09cf265 100644 --- a/src/serialization/resources/users/client/requests/UpdateUserRequest.ts +++ b/src/serialization/resources/users/client/requests/UsersUpdateRequest.ts @@ -3,18 +3,18 @@ */ import * as serializers from "../../../.."; -import { CodeCombat } from "@fern-api/codecombat"; +import * as CodeCombat from "../../../../../api"; import * as core from "../../../../../core"; -export const UpdateUserRequest: core.serialization.Schema< - serializers.UpdateUserRequest.Raw, - CodeCombat.UpdateUserRequest +export const UsersUpdateRequest: core.serialization.Schema< + serializers.UsersUpdateRequest.Raw, + CodeCombat.UsersUpdateRequest > = core.serialization.object({ name: core.serialization.string(), birthday: core.serialization.string().optional(), }); -export declare namespace UpdateUserRequest { +export declare namespace UsersUpdateRequest { interface Raw { name: string; birthday?: string | null; diff --git a/src/serialization/resources/users/client/requests/index.ts b/src/serialization/resources/users/client/requests/index.ts index d0ae960..93826fe 100644 --- a/src/serialization/resources/users/client/requests/index.ts +++ b/src/serialization/resources/users/client/requests/index.ts @@ -1,9 +1,8 @@ -export { CreateUserRequest } from "./CreateUserRequest"; -export { UpdateUserRequest } from "./UpdateUserRequest"; -export { GetHeroRequest } from "./GetHeroRequest"; -export { SetAceConfig } from "./SetAceConfig"; -export { AddOAuthIdentityRequest } from "./AddOAuthIdentityRequest"; -export { UpdateSubscriptionRequest } from "./UpdateSubscriptionRequest"; -export { ShortenSubscriptionRequest } from "./ShortenSubscriptionRequest"; -export { GrantLicenseRequest } from "./GrantLicenseRequest"; -export { ShortenLicenseRequest } from "./ShortenLicenseRequest"; +export { UsersCreateRequest } from "./UsersCreateRequest"; +export { UsersUpdateRequest } from "./UsersUpdateRequest"; +export { UsersSetHeroRequest } from "./UsersSetHeroRequest"; +export { UsersSetAceConfigRequest } from "./UsersSetAceConfigRequest"; +export { UsersGrantPremiumSubscriptionRequest } from "./UsersGrantPremiumSubscriptionRequest"; +export { UsersShortenSubscriptionRequest } from "./UsersShortenSubscriptionRequest"; +export { UsersGrantLicenseRequest } from "./UsersGrantLicenseRequest"; +export { UsersShortenLicenseRequest } from "./UsersShortenLicenseRequest"; diff --git a/src/serialization/resources/users/index.ts b/src/serialization/resources/users/index.ts index c9240f8..5ec7692 100644 --- a/src/serialization/resources/users/index.ts +++ b/src/serialization/resources/users/index.ts @@ -1,2 +1 @@ -export * from "./types"; export * from "./client"; diff --git a/src/serialization/resources/users/types/HeroConfig.ts b/src/serialization/resources/users/types/HeroConfig.ts deleted file mode 100644 index 86ee290..0000000 --- a/src/serialization/resources/users/types/HeroConfig.ts +++ /dev/null @@ -1,18 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const HeroConfig: core.serialization.ObjectSchema = - core.serialization.object({ - thangType: core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional(), - }); - -export declare namespace HeroConfig { - interface Raw { - thangType?: serializers.ObjectIdString.Raw | null; - } -} diff --git a/src/serialization/resources/users/types/UserRole.ts b/src/serialization/resources/users/types/UserRole.ts deleted file mode 100644 index 981084b..0000000 --- a/src/serialization/resources/users/types/UserRole.ts +++ /dev/null @@ -1,14 +0,0 @@ -/** - * This file was auto-generated by Fern from our API Definition. - */ - -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; - -export const UserRole: core.serialization.Schema = - core.serialization.enum_(["student", "teacher"]); - -export declare namespace UserRole { - type Raw = "student" | "teacher"; -} diff --git a/src/serialization/resources/users/types/index.ts b/src/serialization/resources/users/types/index.ts deleted file mode 100644 index 50d31f4..0000000 --- a/src/serialization/resources/users/types/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from "./UserRole"; -export * from "./HeroConfig"; diff --git a/src/serialization/resources/clans/types/ClanResponse.ts b/src/serialization/types/ClanResponse.ts similarity index 85% rename from src/serialization/resources/clans/types/ClanResponse.ts rename to src/serialization/types/ClanResponse.ts index 91da74b..cea4f4c 100644 --- a/src/serialization/resources/clans/types/ClanResponse.ts +++ b/src/serialization/types/ClanResponse.ts @@ -2,24 +2,24 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const ClanResponse: core.serialization.ObjectSchema = core.serialization.object({ id: core.serialization.property( "_id", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() ), name: core.serialization.string().optional(), displayName: core.serialization.string().optional(), members: core.serialization - .list(core.serialization.lazy(async () => (await import("../../..")).ObjectIdString)) + .list(core.serialization.lazy(async () => (await import("..")).ObjectIdString)) .optional(), ownerId: core.serialization.property( "ownerID", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() ), description: core.serialization.string().optional(), type: core.serialization.string().optional(), diff --git a/src/serialization/resources/commons/types/ClassroomResponse.ts b/src/serialization/types/ClassroomResponse.ts similarity index 70% rename from src/serialization/resources/commons/types/ClassroomResponse.ts rename to src/serialization/types/ClassroomResponse.ts index 650bae2..9a736cc 100644 --- a/src/serialization/resources/commons/types/ClassroomResponse.ts +++ b/src/serialization/types/ClassroomResponse.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const ClassroomResponse: core.serialization.ObjectSchema< serializers.ClassroomResponse.Raw, @@ -12,19 +12,19 @@ export const ClassroomResponse: core.serialization.ObjectSchema< > = core.serialization.object({ id: core.serialization.property( "_id", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() ), name: core.serialization.string().optional(), members: core.serialization - .list(core.serialization.lazy(async () => (await import("../../..")).ObjectIdString)) + .list(core.serialization.lazy(async () => (await import("..")).ObjectIdString)) .optional(), ownerId: core.serialization.property( "ownerID", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() ), description: core.serialization.string().optional(), courses: core.serialization - .list(core.serialization.lazyObject(async () => (await import("../../..")).Course)) + .list(core.serialization.lazyObject(async () => (await import("..")).ClassroomResponseCoursesItem)) .optional(), }); @@ -35,6 +35,6 @@ export declare namespace ClassroomResponse { members?: serializers.ObjectIdString.Raw[] | null; ownerID?: serializers.ObjectIdString.Raw | null; description?: string | null; - courses?: serializers.Course.Raw[] | null; + courses?: serializers.ClassroomResponseCoursesItem.Raw[] | null; } } diff --git a/src/serialization/types/ClassroomResponseCoursesItem.ts b/src/serialization/types/ClassroomResponseCoursesItem.ts new file mode 100644 index 0000000..4c8566e --- /dev/null +++ b/src/serialization/types/ClassroomResponseCoursesItem.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const ClassroomResponseCoursesItem: core.serialization.ObjectSchema< + serializers.ClassroomResponseCoursesItem.Raw, + CodeCombat.ClassroomResponseCoursesItem +> = core.serialization.object({ + id: core.serialization.property( + "_id", + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() + ), + levels: core.serialization + .list(core.serialization.record(core.serialization.string(), core.serialization.unknown())) + .optional(), + enrolled: core.serialization + .list(core.serialization.lazy(async () => (await import("..")).ObjectIdString)) + .optional(), + instanceId: core.serialization.property( + "instance_id", + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() + ), +}); + +export declare namespace ClassroomResponseCoursesItem { + interface Raw { + _id?: serializers.ObjectIdString.Raw | null; + levels?: Record[] | null; + enrolled?: serializers.ObjectIdString.Raw[] | null; + instance_id?: serializers.ObjectIdString.Raw | null; + } +} diff --git a/src/serialization/resources/commons/types/ClassroomResponseWithCode.ts b/src/serialization/types/ClassroomResponseWithCode.ts similarity index 73% rename from src/serialization/resources/commons/types/ClassroomResponseWithCode.ts rename to src/serialization/types/ClassroomResponseWithCode.ts index 9846073..e394935 100644 --- a/src/serialization/resources/commons/types/ClassroomResponseWithCode.ts +++ b/src/serialization/types/ClassroomResponseWithCode.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const ClassroomResponseWithCode: core.serialization.ObjectSchema< serializers.ClassroomResponseWithCode.Raw, @@ -12,23 +12,23 @@ export const ClassroomResponseWithCode: core.serialization.ObjectSchema< > = core.serialization.object({ id: core.serialization.property( "_id", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() ), name: core.serialization.string().optional(), members: core.serialization - .list(core.serialization.lazy(async () => (await import("../../..")).ObjectIdString)) + .list(core.serialization.lazy(async () => (await import("..")).ObjectIdString)) .optional(), ownerId: core.serialization.property( "ownerID", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() ), description: core.serialization.string().optional(), code: core.serialization.string().optional(), codeCamel: core.serialization.string().optional(), courses: core.serialization - .list(core.serialization.lazyObject(async () => (await import("../../..")).Course)) + .list(core.serialization.lazyObject(async () => (await import("..")).ClassroomResponseWithCodeCoursesItem)) .optional(), - clanId: core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional(), + clanId: core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional(), }); export declare namespace ClassroomResponseWithCode { @@ -40,7 +40,7 @@ export declare namespace ClassroomResponseWithCode { description?: string | null; code?: string | null; codeCamel?: string | null; - courses?: serializers.Course.Raw[] | null; + courses?: serializers.ClassroomResponseWithCodeCoursesItem.Raw[] | null; clanId?: serializers.ObjectIdString.Raw | null; } } diff --git a/src/serialization/types/ClassroomResponseWithCodeCoursesItem.ts b/src/serialization/types/ClassroomResponseWithCodeCoursesItem.ts new file mode 100644 index 0000000..35b96c0 --- /dev/null +++ b/src/serialization/types/ClassroomResponseWithCodeCoursesItem.ts @@ -0,0 +1,36 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const ClassroomResponseWithCodeCoursesItem: core.serialization.ObjectSchema< + serializers.ClassroomResponseWithCodeCoursesItem.Raw, + CodeCombat.ClassroomResponseWithCodeCoursesItem +> = core.serialization.object({ + id: core.serialization.property( + "_id", + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() + ), + levels: core.serialization + .list(core.serialization.record(core.serialization.string(), core.serialization.unknown())) + .optional(), + enrolled: core.serialization + .list(core.serialization.lazy(async () => (await import("..")).ObjectIdString)) + .optional(), + instanceId: core.serialization.property( + "instance_id", + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() + ), +}); + +export declare namespace ClassroomResponseWithCodeCoursesItem { + interface Raw { + _id?: serializers.ObjectIdString.Raw | null; + levels?: Record[] | null; + enrolled?: serializers.ObjectIdString.Raw[] | null; + instance_id?: serializers.ObjectIdString.Raw | null; + } +} diff --git a/src/serialization/types/ClassroomsCreateRequestAceConfig.ts b/src/serialization/types/ClassroomsCreateRequestAceConfig.ts new file mode 100644 index 0000000..0a755c0 --- /dev/null +++ b/src/serialization/types/ClassroomsCreateRequestAceConfig.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const ClassroomsCreateRequestAceConfig: core.serialization.ObjectSchema< + serializers.ClassroomsCreateRequestAceConfig.Raw, + CodeCombat.ClassroomsCreateRequestAceConfig +> = core.serialization.object({ + language: core.serialization.string().optional(), +}); + +export declare namespace ClassroomsCreateRequestAceConfig { + interface Raw { + language?: string | null; + } +} diff --git a/src/serialization/types/ClassroomsGetMembersStatsResponseItem.ts b/src/serialization/types/ClassroomsGetMembersStatsResponseItem.ts new file mode 100644 index 0000000..84398d2 --- /dev/null +++ b/src/serialization/types/ClassroomsGetMembersStatsResponseItem.ts @@ -0,0 +1,27 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const ClassroomsGetMembersStatsResponseItem: core.serialization.ObjectSchema< + serializers.ClassroomsGetMembersStatsResponseItem.Raw, + CodeCombat.ClassroomsGetMembersStatsResponseItem +> = core.serialization.object({ + id: core.serialization.property( + "_id", + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() + ), + stats: core.serialization + .lazyObject(async () => (await import("..")).ClassroomsGetMembersStatsResponseItemStats) + .optional(), +}); + +export declare namespace ClassroomsGetMembersStatsResponseItem { + interface Raw { + _id?: serializers.ObjectIdString.Raw | null; + stats?: serializers.ClassroomsGetMembersStatsResponseItemStats.Raw | null; + } +} diff --git a/src/serialization/types/ClassroomsGetMembersStatsResponseItemStats.ts b/src/serialization/types/ClassroomsGetMembersStatsResponseItemStats.ts new file mode 100644 index 0000000..041a920 --- /dev/null +++ b/src/serialization/types/ClassroomsGetMembersStatsResponseItemStats.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const ClassroomsGetMembersStatsResponseItemStats: core.serialization.ObjectSchema< + serializers.ClassroomsGetMembersStatsResponseItemStats.Raw, + CodeCombat.ClassroomsGetMembersStatsResponseItemStats +> = core.serialization.object({ + gamesCompleted: core.serialization.number().optional(), + playtime: core.serialization.number().optional(), +}); + +export declare namespace ClassroomsGetMembersStatsResponseItemStats { + interface Raw { + gamesCompleted?: number | null; + playtime?: number | null; + } +} diff --git a/src/serialization/resources/commons/types/DatetimeString.ts b/src/serialization/types/DatetimeString.ts similarity index 68% rename from src/serialization/resources/commons/types/DatetimeString.ts rename to src/serialization/types/DatetimeString.ts index fec4bff..5bc6789 100644 --- a/src/serialization/resources/commons/types/DatetimeString.ts +++ b/src/serialization/types/DatetimeString.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const DatetimeString: core.serialization.Schema = core.serialization.string(); diff --git a/src/serialization/resources/classrooms/types/LevelSessionResponse.ts b/src/serialization/types/LevelSessionResponse.ts similarity index 73% rename from src/serialization/resources/classrooms/types/LevelSessionResponse.ts rename to src/serialization/types/LevelSessionResponse.ts index d9d0998..52e4188 100644 --- a/src/serialization/resources/classrooms/types/LevelSessionResponse.ts +++ b/src/serialization/types/LevelSessionResponse.ts @@ -2,30 +2,30 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const LevelSessionResponse: core.serialization.ObjectSchema< serializers.LevelSessionResponse.Raw, CodeCombat.LevelSessionResponse > = core.serialization.object({ - state: core.serialization.lazyObject(async () => (await import("../../..")).State).optional(), - level: core.serialization.lazyObject(async () => (await import("../../..")).Level).optional(), + state: core.serialization.lazyObject(async () => (await import("..")).LevelSessionResponseState).optional(), + level: core.serialization.lazyObject(async () => (await import("..")).LevelSessionResponseLevel).optional(), levelId: core.serialization.property("levelID", core.serialization.string().optional()), - creator: core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional(), + creator: core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional(), playtime: core.serialization.number().optional(), - changed: core.serialization.lazy(async () => (await import("../../..")).DatetimeString).optional(), - created: core.serialization.lazy(async () => (await import("../../..")).DatetimeString).optional(), - dateFirstCompleted: core.serialization.lazy(async () => (await import("../../..")).DatetimeString).optional(), + changed: core.serialization.lazy(async () => (await import("..")).DatetimeString).optional(), + created: core.serialization.lazy(async () => (await import("..")).DatetimeString).optional(), + dateFirstCompleted: core.serialization.lazy(async () => (await import("..")).DatetimeString).optional(), submitted: core.serialization.boolean().optional(), published: core.serialization.boolean().optional(), }); export declare namespace LevelSessionResponse { interface Raw { - state?: serializers.State.Raw | null; - level?: serializers.Level.Raw | null; + state?: serializers.LevelSessionResponseState.Raw | null; + level?: serializers.LevelSessionResponseLevel.Raw | null; levelID?: string | null; creator?: serializers.ObjectIdString.Raw | null; playtime?: number | null; diff --git a/src/serialization/types/LevelSessionResponseLevel.ts b/src/serialization/types/LevelSessionResponseLevel.ts new file mode 100644 index 0000000..ef6f2b7 --- /dev/null +++ b/src/serialization/types/LevelSessionResponseLevel.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const LevelSessionResponseLevel: core.serialization.ObjectSchema< + serializers.LevelSessionResponseLevel.Raw, + CodeCombat.LevelSessionResponseLevel +> = core.serialization.object({ + original: core.serialization.string().optional(), +}); + +export declare namespace LevelSessionResponseLevel { + interface Raw { + original?: string | null; + } +} diff --git a/src/serialization/types/LevelSessionResponseState.ts b/src/serialization/types/LevelSessionResponseState.ts new file mode 100644 index 0000000..ec3be8f --- /dev/null +++ b/src/serialization/types/LevelSessionResponseState.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const LevelSessionResponseState: core.serialization.ObjectSchema< + serializers.LevelSessionResponseState.Raw, + CodeCombat.LevelSessionResponseState +> = core.serialization.object({ + complete: core.serialization.boolean().optional(), +}); + +export declare namespace LevelSessionResponseState { + interface Raw { + complete?: boolean | null; + } +} diff --git a/src/serialization/resources/stats/types/LicenseStatsResponse.ts b/src/serialization/types/LicenseStatsResponse.ts similarity index 84% rename from src/serialization/resources/stats/types/LicenseStatsResponse.ts rename to src/serialization/types/LicenseStatsResponse.ts index f93975c..f9b2bfc 100644 --- a/src/serialization/resources/stats/types/LicenseStatsResponse.ts +++ b/src/serialization/types/LicenseStatsResponse.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const LicenseStatsResponse: core.serialization.ObjectSchema< serializers.LicenseStatsResponse.Raw, diff --git a/src/serialization/resources/commons/types/ObjectIdString.ts b/src/serialization/types/ObjectIdString.ts similarity index 68% rename from src/serialization/resources/commons/types/ObjectIdString.ts rename to src/serialization/types/ObjectIdString.ts index c9a3dc4..8e34319 100644 --- a/src/serialization/resources/commons/types/ObjectIdString.ts +++ b/src/serialization/types/ObjectIdString.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const ObjectIdString: core.serialization.Schema = core.serialization.string(); diff --git a/src/serialization/resources/stats/types/PlaytimeStatsResponse.ts b/src/serialization/types/PlaytimeStatsResponse.ts similarity index 79% rename from src/serialization/resources/stats/types/PlaytimeStatsResponse.ts rename to src/serialization/types/PlaytimeStatsResponse.ts index c60eef2..72dc2c7 100644 --- a/src/serialization/resources/stats/types/PlaytimeStatsResponse.ts +++ b/src/serialization/types/PlaytimeStatsResponse.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const PlaytimeStatsResponse: core.serialization.ObjectSchema< serializers.PlaytimeStatsResponse.Raw, diff --git a/src/serialization/resources/commons/types/RoleString.ts b/src/serialization/types/RoleString.ts similarity index 67% rename from src/serialization/resources/commons/types/RoleString.ts rename to src/serialization/types/RoleString.ts index c77d85a..b4c3c4e 100644 --- a/src/serialization/resources/commons/types/RoleString.ts +++ b/src/serialization/types/RoleString.ts @@ -2,9 +2,9 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const RoleString: core.serialization.Schema = core.serialization.string(); diff --git a/src/serialization/resources/commons/types/UserResponse.ts b/src/serialization/types/UserResponse.ts similarity index 59% rename from src/serialization/resources/commons/types/UserResponse.ts rename to src/serialization/types/UserResponse.ts index 0318e06..be84c96 100644 --- a/src/serialization/resources/commons/types/UserResponse.ts +++ b/src/serialization/types/UserResponse.ts @@ -2,26 +2,28 @@ * This file was auto-generated by Fern from our API Definition. */ -import * as serializers from "../../.."; -import { CodeCombat } from "@fern-api/codecombat"; -import * as core from "../../../../core"; +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; export const UserResponse: core.serialization.ObjectSchema = core.serialization.object({ id: core.serialization.property( "_id", - core.serialization.lazy(async () => (await import("../../..")).ObjectIdString).optional() + core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional() ), email: core.serialization.string().optional(), name: core.serialization.string().optional(), slug: core.serialization.string().optional(), - role: core.serialization.lazy(async () => (await import("../../..")).RoleString).optional(), - stats: core.serialization.lazyObject(async () => (await import("../../..")).UserStats).optional(), + role: core.serialization.lazy(async () => (await import("..")).RoleString).optional(), + stats: core.serialization.lazyObject(async () => (await import("..")).UserResponseStats).optional(), oAuthIdentities: core.serialization - .list(core.serialization.lazyObject(async () => (await import("../../..")).AuthIdentity)) + .list(core.serialization.lazyObject(async () => (await import("..")).UserResponseOAuthIdentitiesItem)) .optional(), - subscription: core.serialization.lazyObject(async () => (await import("../../..")).Subscription).optional(), - license: core.serialization.lazyObject(async () => (await import("../../..")).License).optional(), + subscription: core.serialization + .lazyObject(async () => (await import("..")).UserResponseSubscription) + .optional(), + license: core.serialization.lazyObject(async () => (await import("..")).UserResponseLicense).optional(), }); export declare namespace UserResponse { @@ -31,9 +33,9 @@ export declare namespace UserResponse { name?: string | null; slug?: string | null; role?: serializers.RoleString.Raw | null; - stats?: serializers.UserStats.Raw | null; - oAuthIdentities?: serializers.AuthIdentity.Raw[] | null; - subscription?: serializers.Subscription.Raw | null; - license?: serializers.License.Raw | null; + stats?: serializers.UserResponseStats.Raw | null; + oAuthIdentities?: serializers.UserResponseOAuthIdentitiesItem.Raw[] | null; + subscription?: serializers.UserResponseSubscription.Raw | null; + license?: serializers.UserResponseLicense.Raw | null; } } diff --git a/src/serialization/types/UserResponseLicense.ts b/src/serialization/types/UserResponseLicense.ts new file mode 100644 index 0000000..1eea7a1 --- /dev/null +++ b/src/serialization/types/UserResponseLicense.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const UserResponseLicense: core.serialization.ObjectSchema< + serializers.UserResponseLicense.Raw, + CodeCombat.UserResponseLicense +> = core.serialization.object({ + ends: core.serialization.lazy(async () => (await import("..")).DatetimeString).optional(), + active: core.serialization.boolean().optional(), +}); + +export declare namespace UserResponseLicense { + interface Raw { + ends?: serializers.DatetimeString.Raw | null; + active?: boolean | null; + } +} diff --git a/src/serialization/types/UserResponseOAuthIdentitiesItem.ts b/src/serialization/types/UserResponseOAuthIdentitiesItem.ts new file mode 100644 index 0000000..26bcafe --- /dev/null +++ b/src/serialization/types/UserResponseOAuthIdentitiesItem.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const UserResponseOAuthIdentitiesItem: core.serialization.ObjectSchema< + serializers.UserResponseOAuthIdentitiesItem.Raw, + CodeCombat.UserResponseOAuthIdentitiesItem +> = core.serialization.object({ + provider: core.serialization.string().optional(), + id: core.serialization.string().optional(), +}); + +export declare namespace UserResponseOAuthIdentitiesItem { + interface Raw { + provider?: string | null; + id?: string | null; + } +} diff --git a/src/serialization/types/UserResponseStats.ts b/src/serialization/types/UserResponseStats.ts new file mode 100644 index 0000000..ed465dd --- /dev/null +++ b/src/serialization/types/UserResponseStats.ts @@ -0,0 +1,24 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const UserResponseStats: core.serialization.ObjectSchema< + serializers.UserResponseStats.Raw, + CodeCombat.UserResponseStats +> = core.serialization.object({ + gamesCompleted: core.serialization.number().optional(), + concepts: core.serialization.record(core.serialization.string(), core.serialization.number()).optional(), + playTime: core.serialization.number().optional(), +}); + +export declare namespace UserResponseStats { + interface Raw { + gamesCompleted?: number | null; + concepts?: Record | null; + playTime?: number | null; + } +} diff --git a/src/serialization/types/UserResponseSubscription.ts b/src/serialization/types/UserResponseSubscription.ts new file mode 100644 index 0000000..92cde2f --- /dev/null +++ b/src/serialization/types/UserResponseSubscription.ts @@ -0,0 +1,22 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const UserResponseSubscription: core.serialization.ObjectSchema< + serializers.UserResponseSubscription.Raw, + CodeCombat.UserResponseSubscription +> = core.serialization.object({ + ends: core.serialization.lazy(async () => (await import("..")).DatetimeString).optional(), + active: core.serialization.boolean().optional(), +}); + +export declare namespace UserResponseSubscription { + interface Raw { + ends?: serializers.DatetimeString.Raw | null; + active?: boolean | null; + } +} diff --git a/src/serialization/types/UsersCreateRequestHeroConfig.ts b/src/serialization/types/UsersCreateRequestHeroConfig.ts new file mode 100644 index 0000000..bc7c444 --- /dev/null +++ b/src/serialization/types/UsersCreateRequestHeroConfig.ts @@ -0,0 +1,20 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const UsersCreateRequestHeroConfig: core.serialization.ObjectSchema< + serializers.UsersCreateRequestHeroConfig.Raw, + CodeCombat.UsersCreateRequestHeroConfig +> = core.serialization.object({ + thangType: core.serialization.lazy(async () => (await import("..")).ObjectIdString).optional(), +}); + +export declare namespace UsersCreateRequestHeroConfig { + interface Raw { + thangType?: serializers.ObjectIdString.Raw | null; + } +} diff --git a/src/serialization/types/UsersCreateRequestRole.ts b/src/serialization/types/UsersCreateRequestRole.ts new file mode 100644 index 0000000..75db603 --- /dev/null +++ b/src/serialization/types/UsersCreateRequestRole.ts @@ -0,0 +1,16 @@ +/** + * This file was auto-generated by Fern from our API Definition. + */ + +import * as serializers from ".."; +import * as CodeCombat from "../../api"; +import * as core from "../../core"; + +export const UsersCreateRequestRole: core.serialization.Schema< + serializers.UsersCreateRequestRole.Raw, + CodeCombat.UsersCreateRequestRole +> = core.serialization.enum_(["student", "teacher"]); + +export declare namespace UsersCreateRequestRole { + type Raw = "student" | "teacher"; +} diff --git a/src/serialization/types/index.ts b/src/serialization/types/index.ts new file mode 100644 index 0000000..cac14d4 --- /dev/null +++ b/src/serialization/types/index.ts @@ -0,0 +1,23 @@ +export * from "./UsersCreateRequestRole"; +export * from "./UsersCreateRequestHeroConfig"; +export * from "./ClassroomsCreateRequestAceConfig"; +export * from "./ClassroomsGetMembersStatsResponseItem"; +export * from "./ClassroomsGetMembersStatsResponseItemStats"; +export * from "./RoleString"; +export * from "./DatetimeString"; +export * from "./ObjectIdString"; +export * from "./UserResponse"; +export * from "./UserResponseStats"; +export * from "./UserResponseOAuthIdentitiesItem"; +export * from "./UserResponseSubscription"; +export * from "./UserResponseLicense"; +export * from "./ClassroomResponse"; +export * from "./ClassroomResponseCoursesItem"; +export * from "./ClassroomResponseWithCode"; +export * from "./ClassroomResponseWithCodeCoursesItem"; +export * from "./PlaytimeStatsResponse"; +export * from "./LicenseStatsResponse"; +export * from "./LevelSessionResponse"; +export * from "./LevelSessionResponseState"; +export * from "./LevelSessionResponseLevel"; +export * from "./ClanResponse"; diff --git a/tsconfig.json b/tsconfig.json index b49fa5f..e65fa53 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,7 +2,7 @@ "compilerOptions": { "extendedDiagnostics": true, "strict": true, - "target": "esnext", + "target": "ES6", "module": "CommonJS", "moduleResolution": "node", "esModuleInterop": true, @@ -11,12 +11,7 @@ "noUnusedParameters": true, "outDir": "dist", "rootDir": "src", - "baseUrl": "src", - "paths": { - "@fern-api/codecombat": [ - "." - ] - } + "baseUrl": "src" }, "include": [ "src" diff --git a/yarn.lock b/yarn.lock index 79f1e4f..cf98630 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2,27 +2,6 @@ # yarn lockfile v1 -"@nodelib/fs.scandir@2.1.5": - version "2.1.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.scandir/-/fs.scandir-2.1.5.tgz#7619c2eb21b25483f6d167548b4cfd5a7488c3d5" - integrity sha512-vq24Bq3ym5HEQm2NKCr3yXDwjc7vTsEThRDnkp2DK9p1uqLR+DHurm/NOTo0KG7HYHU7eppKZj3MyqYuMBf62g== - dependencies: - "@nodelib/fs.stat" "2.0.5" - run-parallel "^1.1.9" - -"@nodelib/fs.stat@2.0.5", "@nodelib/fs.stat@^2.0.2": - version "2.0.5" - resolved "https://registry.yarnpkg.com/@nodelib/fs.stat/-/fs.stat-2.0.5.tgz#5bd262af94e9d25bd1e71b05deed44876a222e8b" - integrity sha512-RkhPPp2zrqDAQA/2jNhnztcPAlv64XdhIp7a7454A5ovI7Bukxgt7MX7udwAu3zg1DcpPU0rz3VV1SeaqvY4+A== - -"@nodelib/fs.walk@^1.2.3": - version "1.2.8" - resolved "https://registry.yarnpkg.com/@nodelib/fs.walk/-/fs.walk-1.2.8.tgz#e95737e8bb6746ddedf69c556953494f196fe69a" - integrity sha512-oGB+UxlgWcgQkgwo8GcEGwemoTFt3FIO9ababBmaGwXIoBKZ+GTy0pP185beGg7Llih/NSHSV2XAs1lnznocSg== - dependencies: - "@nodelib/fs.scandir" "2.1.5" - fastq "^1.6.0" - "@types/node@17.0.33": version "17.0.33" resolved "https://registry.yarnpkg.com/@types/node/-/node-17.0.33.tgz#3c1879b276dc63e73030bb91165e62a4509cd506" @@ -38,19 +17,6 @@ resolved "https://registry.yarnpkg.com/@ungap/url-search-params/-/url-search-params-0.2.2.tgz#2de3bdec21476a9b70ef11fd7b794752f9afa04c" integrity sha512-qQsguKXZVKdCixOHX9jqnX/K/1HekPDpGKyEcXHT+zR6EjGA7S4boSuelL4uuPv6YfhN0n8c4UxW+v/Z3gM2iw== -anymatch@~3.1.2: - version "3.1.3" - resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e" - integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw== - dependencies: - normalize-path "^3.0.0" - picomatch "^2.0.4" - -array-union@^2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/array-union/-/array-union-2.1.0.tgz#b798420adbeb1de828d84acd8a2e23d3efe85e8d" - integrity sha512-HGyxoOTYUyCM6stUe6EJgnd4EoewAI7zMdfqO+kGjnlZmBDz/cR5pf8r/cR4Wq60sL/p0IkcjUEEPwS3GFrIyw== - asynckit@^0.4.0: version "0.4.0" resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79" @@ -64,33 +30,6 @@ axios@0.27.2: follow-redirects "^1.14.9" form-data "^4.0.0" -binary-extensions@^2.0.0: - version "2.2.0" - resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d" - integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA== - -braces@^3.0.2, braces@~3.0.2: - version "3.0.2" - resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107" - integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A== - dependencies: - fill-range "^7.0.1" - -chokidar@^3.5.3: - version "3.5.3" - resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd" - integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw== - dependencies: - anymatch "~3.1.2" - braces "~3.0.2" - glob-parent "~5.1.2" - is-binary-path "~2.1.0" - is-glob "~4.0.1" - normalize-path "~3.0.0" - readdirp "~3.6.0" - optionalDependencies: - fsevents "~2.3.2" - combined-stream@^1.0.8: version "1.0.8" resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f" @@ -98,48 +37,11 @@ combined-stream@^1.0.8: dependencies: delayed-stream "~1.0.0" -commander@^9.0.0: - version "9.5.0" - resolved "https://registry.yarnpkg.com/commander/-/commander-9.5.0.tgz#bc08d1eb5cedf7ccb797a96199d41c7bc3e60d30" - integrity sha512-KRs7WVDKg86PWiuAqhDrAQnTXZKraVcCc6vFdL14qrZ/DcWwuRo7VoiYXalXO7S5GKpqYiVEwCbgFDfxNHKJBQ== - delayed-stream@~1.0.0: version "1.0.0" resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619" integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ== -dir-glob@^3.0.1: - version "3.0.1" - resolved "https://registry.yarnpkg.com/dir-glob/-/dir-glob-3.0.1.tgz#56dbf73d992a4a93ba1584f4534063fd2e41717f" - integrity sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA== - dependencies: - path-type "^4.0.0" - -fast-glob@^3.2.9: - version "3.2.12" - resolved "https://registry.yarnpkg.com/fast-glob/-/fast-glob-3.2.12.tgz#7f39ec99c2e6ab030337142da9e0c18f37afae80" - integrity sha512-DVj4CQIYYow0BlaelwK1pHl5n5cRSJfM60UA0zK891sVInoPri2Ekj7+e1CT3/3qxXenpI+nBBmQAcJPJgaj4w== - dependencies: - "@nodelib/fs.stat" "^2.0.2" - "@nodelib/fs.walk" "^1.2.3" - glob-parent "^5.1.2" - merge2 "^1.3.0" - micromatch "^4.0.4" - -fastq@^1.6.0: - version "1.15.0" - resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.15.0.tgz#d04d07c6a2a68fe4599fea8d2e103a937fae6b3a" - integrity sha512-wBrocU2LCXXa+lWBt8RoIRD89Fi8OdABODa/kEnyeyjS5aZO5/GNvI5sEINADqP/h8M29UHTHUb53sUu5Ihqdw== - dependencies: - reusify "^1.0.4" - -fill-range@^7.0.1: - version "7.0.1" - resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40" - integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ== - dependencies: - to-regex-range "^5.0.1" - follow-redirects@^1.14.9: version "1.15.2" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.2.tgz#b460864144ba63f2681096f274c4e57026da2c13" @@ -154,77 +56,11 @@ form-data@^4.0.0: combined-stream "^1.0.8" mime-types "^2.1.12" -fsevents@~2.3.2: - version "2.3.2" - resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a" - integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA== - -glob-parent@^5.1.2, glob-parent@~5.1.2: - version "5.1.2" - resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4" - integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow== - dependencies: - is-glob "^4.0.1" - -globby@^11.0.4: - version "11.1.0" - resolved "https://registry.yarnpkg.com/globby/-/globby-11.1.0.tgz#bd4be98bb042f83d796f7e3811991fbe82a0d34b" - integrity sha512-jhIXaOzy1sb8IyocaruWSn1TjmnBVs8Ayhcy83rmxNJ8q2uWKCAj3CnJY+KpGSXCueAPc0i05kVvVKtP1t9S3g== - dependencies: - array-union "^2.1.0" - dir-glob "^3.0.1" - fast-glob "^3.2.9" - ignore "^5.2.0" - merge2 "^1.4.1" - slash "^3.0.0" - -ignore@^5.2.0: - version "5.2.4" - resolved "https://registry.yarnpkg.com/ignore/-/ignore-5.2.4.tgz#a291c0c6178ff1b960befe47fcdec301674a6324" - integrity sha512-MAb38BcSbH0eHNBxn7ql2NH/kX33OkB3lZ1BNdh7ENeRChHTYsTvWrMubiIAMNS2llXEEgZ1MUOBtXChP3kaFQ== - -is-binary-path@~2.1.0: - version "2.1.0" - resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09" - integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw== - dependencies: - binary-extensions "^2.0.0" - -is-extglob@^2.1.1: - version "2.1.1" - resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2" - integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ== - -is-glob@^4.0.1, is-glob@~4.0.1: - version "4.0.3" - resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084" - integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg== - dependencies: - is-extglob "^2.1.1" - -is-number@^7.0.0: - version "7.0.0" - resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b" - integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng== - js-base64@3.7.2: version "3.7.2" resolved "https://registry.yarnpkg.com/js-base64/-/js-base64-3.7.2.tgz#816d11d81a8aff241603d19ce5761e13e41d7745" integrity sha512-NnRs6dsyqUXejqk/yv2aiXlAvOs56sLkX6nUdeaNezI5LFFLlsZjOThmwnrcwh5ZZRwZlCMnVAY3CvhIhoVEKQ== -merge2@^1.3.0, merge2@^1.4.1: - version "1.4.1" - resolved "https://registry.yarnpkg.com/merge2/-/merge2-1.4.1.tgz#4368892f885e907455a6fd7dc55c0c9d404990ae" - integrity sha512-8q7VEgMJW4J8tcfVPy8g09NcQwZdbwFEqhe/WZkoIzjn/3TGDwtOCYtXGxA3O8tPzpczCCDgv+P2P5y00ZJOOg== - -micromatch@^4.0.4: - version "4.0.5" - resolved "https://registry.yarnpkg.com/micromatch/-/micromatch-4.0.5.tgz#bc8999a7cbbf77cdc89f132f6e467051b49090c6" - integrity sha512-DMy+ERcEW2q8Z2Po+WNXuw3c5YaUSFjAO5GsJqfEl7UjvtIuFKO6ZrKvcItdy98dwFI2N1tg3zNIdKaQT+aNdA== - dependencies: - braces "^3.0.2" - picomatch "^2.3.1" - mime-db@1.52.0: version "1.52.0" resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70" @@ -237,91 +73,11 @@ mime-types@^2.1.12: dependencies: mime-db "1.52.0" -mylas@^2.1.9: - version "2.1.13" - resolved "https://registry.yarnpkg.com/mylas/-/mylas-2.1.13.tgz#1e23b37d58fdcc76e15d8a5ed23f9ae9fc0cbdf4" - integrity sha512-+MrqnJRtxdF+xngFfUUkIMQrUUL0KsxbADUkn23Z/4ibGg192Q+z+CQyiYwvWTsYjJygmMR8+w3ZDa98Zh6ESg== - -normalize-path@^3.0.0, normalize-path@~3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65" - integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA== - -path-type@^4.0.0: - version "4.0.0" - resolved "https://registry.yarnpkg.com/path-type/-/path-type-4.0.0.tgz#84ed01c0a7ba380afe09d90a8c180dcd9d03043b" - integrity sha512-gDKb8aZMDeD/tZWs9P6+q0J9Mwkdl6xMV8TjnGP3qJVJ06bdMgkbBlLU8IdfOsIsFz2BW1rNVT3XuNEl8zPAvw== - -picomatch@^2.0.4, picomatch@^2.2.1, picomatch@^2.3.1: - version "2.3.1" - resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42" - integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA== - -plimit-lit@^1.2.6: - version "1.5.0" - resolved "https://registry.yarnpkg.com/plimit-lit/-/plimit-lit-1.5.0.tgz#f66df8a7041de1e965c4f1c0697ab486968a92a5" - integrity sha512-Eb/MqCb1Iv/ok4m1FqIXqvUKPISufcjZ605hl3KM/n8GaX8zfhtgdLwZU3vKjuHGh2O9Rjog/bHTq8ofIShdng== - dependencies: - queue-lit "^1.5.0" - prettier@2.7.1: version "2.7.1" resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.7.1.tgz#e235806850d057f97bb08368a4f7d899f7760c64" integrity sha512-ujppO+MkdPqoVINuDFDRLClm7D78qbDt0/NR+wp5FqEZOoTNAjPHWj17QRhu7geIHJfcNhRk1XVQmF8Bp3ye+g== -queue-lit@^1.5.0: - version "1.5.0" - resolved "https://registry.yarnpkg.com/queue-lit/-/queue-lit-1.5.0.tgz#8197fdafda1edd615c8a0fc14c48353626e5160a" - integrity sha512-IslToJ4eiCEE9xwMzq3viOO5nH8sUWUCwoElrhNMozzr9IIt2qqvB4I+uHu/zJTQVqc9R5DFwok4ijNK1pU3fA== - -queue-microtask@^1.2.2: - version "1.2.3" - resolved "https://registry.yarnpkg.com/queue-microtask/-/queue-microtask-1.2.3.tgz#4929228bbc724dfac43e0efb058caf7b6cfb6243" - integrity sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A== - -readdirp@~3.6.0: - version "3.6.0" - resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7" - integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA== - dependencies: - picomatch "^2.2.1" - -reusify@^1.0.4: - version "1.0.4" - resolved "https://registry.yarnpkg.com/reusify/-/reusify-1.0.4.tgz#90da382b1e126efc02146e90845a88db12925d76" - integrity sha512-U9nH88a3fc/ekCF1l0/UP1IosiuIjyTh7hBvXVMHYgVcfGvt897Xguj2UOLDeI5BG2m7/uwyaLVT6fbtCwTyzw== - -run-parallel@^1.1.9: - version "1.2.0" - resolved "https://registry.yarnpkg.com/run-parallel/-/run-parallel-1.2.0.tgz#66d1368da7bdf921eb9d95bd1a9229e7f21a43ee" - integrity sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA== - dependencies: - queue-microtask "^1.2.2" - -slash@^3.0.0: - version "3.0.0" - resolved "https://registry.yarnpkg.com/slash/-/slash-3.0.0.tgz#6539be870c165adbd5240220dbe361f1bc4d4634" - integrity sha512-g9Q1haeby36OSStwb4ntCGGGaKsaVSjQ68fBxoQcutl5fS1vuY18H3wSt3jFyFtrkx+Kz0V1G85A4MyAdDMi2Q== - -to-regex-range@^5.0.1: - version "5.0.1" - resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4" - integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ== - dependencies: - is-number "^7.0.0" - -tsc-alias@1.7.1: - version "1.7.1" - resolved "https://registry.yarnpkg.com/tsc-alias/-/tsc-alias-1.7.1.tgz#24e846788c53761a7d96135d1cf0e6566ae6ae5b" - integrity sha512-P4+0i+OB0hX17Ca+U6EJ4WZZ+OSupqW32VJ34N7g7+Ch+bwSx1AqYOvDdIVYEKymBh3dfG0t1qxbxPlBbtB1lQ== - dependencies: - chokidar "^3.5.3" - commander "^9.0.0" - globby "^11.0.4" - mylas "^2.1.9" - normalize-path "^3.0.0" - plimit-lit "^1.2.6" - typescript@4.6.4: version "4.6.4" resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.6.4.tgz#caa78bbc3a59e6a5c510d35703f6a09877ce45e9"